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

Commit 511c3be5 authored by qctecmdr Service's avatar qctecmdr Service Committed by Gerrit - the friendly Code Review server
Browse files

Merge "mm: cma: sleep between retries in cma_alloc"

parents 3ed9e964 231b2404
Loading
Loading
Loading
Loading
+20 −2
Original line number Diff line number Diff line
@@ -35,6 +35,7 @@
#include <linux/cma.h>
#include <linux/highmem.h>
#include <linux/io.h>
#include <linux/delay.h>
#include <trace/events/cma.h>

#include "cma.h"
@@ -407,6 +408,7 @@ struct page *cma_alloc(struct cma *cma, size_t count, unsigned int align,
	unsigned long bitmap_maxno, bitmap_no, bitmap_count;
	struct page *page = NULL;
	int ret = -ENOMEM;
	int retry_after_sleep = 0;

	if (!cma || !cma->count)
		return NULL;
@@ -431,9 +433,25 @@ struct page *cma_alloc(struct cma *cma, size_t count, unsigned int align,
				bitmap_maxno, start, bitmap_count, mask,
				offset);
		if (bitmap_no >= bitmap_maxno) {
			if (retry_after_sleep < 2) {
				start = 0;
				/*
				 * Page may be momentarily pinned by some other
				 * process which has been scheduled out, eg.
				 * in exit path, during unmap call, or process
				 * fork and so cannot be freed there. Sleep
				 * for 100ms and retry twice to see if it has
				 * been freed later.
				 */
				mutex_unlock(&cma->lock);
				msleep(100);
				retry_after_sleep++;
				continue;
			} else {
				mutex_unlock(&cma->lock);
				break;
			}
		}
		bitmap_set(cma->bitmap, bitmap_no, bitmap_count);
		/*
		 * It's safe to drop the lock here. We've marked this region for