diff mbox series

[3/6] cma: Warn about callers requesting unsupported flags

Message ID 20190218210715.1066-4-krisman@collabora.com (mailing list archive)
State New, archived
Headers show
Series Improve handling of GFP flags in the CMA allocator | expand

Commit Message

Gabriel Krisman Bertazi Feb. 18, 2019, 9:07 p.m. UTC
The CMA allocator does not support every standard GFP flag.  Instead of
silently ignoring, we should be noisy about it, to catch wrong code
paths early.

Signed-off-by: Gabriel Krisman Bertazi <krisman@collabora.com>
---
 mm/cma.c | 4 ++++
 1 file changed, 4 insertions(+)
diff mbox series

Patch

diff --git a/mm/cma.c b/mm/cma.c
index fdad7ad0d9c4..5789e3545faf 100644
--- a/mm/cma.c
+++ b/mm/cma.c
@@ -411,6 +411,10 @@  struct page *cma_alloc(struct cma *cma, size_t count, unsigned int align,
 	struct page *page = NULL;
 	int ret = -ENOMEM;
 
+	/* Be noisy about caller asking for unsupported flags. */
+	WARN_ON(unlikely(!(gfp_mask & __GFP_DIRECT_RECLAIM) ||
+			 (gfp_mask & (__GFP_ZERO|__GFP_NOFAIL))));
+
 	if (!cma || !cma->count)
 		return NULL;