Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit cdaab23e authored by Patrick Daly's avatar Patrick Daly
Browse files

ion: ion_page_pool: Check for fatal signals from OOM killer



The OOM killer sets tsk_is_oom_victim() which allows access to memory
reserves. These reserves are intended for use by processes which need to
allocate a small amount of memory for a short time, such that they can
free their caches/buffers/etc. Ion allocations are not used for this
usecase.

Exiting immediately allows handling the fatal signal to occur that much
sooner.

This patch does not attempt to fix a similar issue in handling of the
prefetch ioctl - Since prefetch is handled by a kernel thread, it will
never be killed by the OOM killer.

Change-Id: I9dca65920229026dfacd688cf10470504d1957ed
Signed-off-by: default avatarPatrick Daly <pdaly@codeaurora.org>
parent a93f3584
Loading
Loading
Loading
Loading
+4 −1
Original line number Diff line number Diff line
@@ -126,6 +126,9 @@ static struct ion_buffer *ion_buffer_create(struct ion_heap *heap,
		if (!(heap->flags & ION_HEAP_FLAG_DEFER_FREE))
			goto err2;

		if (ret == -EINTR)
			goto err2;

		ion_heap_freelist_drain(heap, 0);
		ret = heap->ops->allocate(heap, buffer, len, flags);
		if (ret)
@@ -1062,7 +1065,7 @@ struct dma_buf *ion_alloc_dmabuf(size_t len, unsigned int heap_id_mask,
		if (!((1 << heap->id) & heap_id_mask))
			continue;
		buffer = ion_buffer_create(heap, dev, len, flags);
		if (!IS_ERR(buffer))
		if (!IS_ERR(buffer) || PTR_ERR(buffer) == -EINTR)
			break;
	}
	up_read(&dev->lock);
+4 −0
Original line number Diff line number Diff line
@@ -22,6 +22,7 @@
#include <linux/init.h>
#include <linux/slab.h>
#include <linux/swap.h>
#include <linux/sched/signal.h>

#include "ion.h"

@@ -81,6 +82,9 @@ struct page *ion_page_pool_alloc(struct ion_page_pool *pool, bool *from_pool)

	BUG_ON(!pool);

	if (fatal_signal_pending(current))
		return ERR_PTR(-EINTR);

	if (*from_pool && mutex_trylock(&pool->mutex)) {
		if (pool->high_count)
			page = ion_page_pool_remove(pool, true);