[Devel] [PATCH vz7] fs/ext4: Suppress false warnings in ext4_kv*alloc()

Oleg Babin obabin at virtuozzo.com
Wed Mar 21 14:53:05 MSK 2018


In the implementation of ext4_kvmalloc() and ext4_kvzalloc() functions
a first attempt to allocate memory with kmalloc() can legitimately fail
in which case we will try to allocate memory with __vmalloc() instead.
Given this we do not want kmalloc() to generate any warning to dmesg
on allocation failure and possibly on high order allocation, also we
do not want kmalloc() to retry the allocation (possibly invoking
out-of-memory killer). So we add __GFP_NORETRY and __GFP_NOWARN flags
to kmalloc() invocation.

Implementation of ext4_kv*alloc() is similar to kv*alloc() but we can't
just replace one with another as kv*alloc() requires GFP_KERNEL flag to
be passed (implementation generates a warning if the flag is not passed)
and the flag is not always used on ext4_kv*alloc() invocation.

https://jira.sw.ru/browse/PSBM-82549
Signed-off-by: Oleg Babin <obabin at virtuozzo.com>
---
 fs/ext4/super.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/fs/ext4/super.c b/fs/ext4/super.c
index c1e7ad7..fff95d3 100644
--- a/fs/ext4/super.c
+++ b/fs/ext4/super.c
@@ -161,7 +161,7 @@ void *ext4_kvmalloc(size_t size, gfp_t flags)
 {
 	void *ret;
 
-	ret = kmalloc(size, flags);
+	ret = kmalloc(size, flags | __GFP_NORETRY | __GFP_NOWARN);
 	if (!ret)
 		ret = __vmalloc(size, flags, PAGE_KERNEL);
 	return ret;
@@ -171,7 +171,7 @@ void *ext4_kvzalloc(size_t size, gfp_t flags)
 {
 	void *ret;
 
-	ret = kzalloc(size, flags);
+	ret = kzalloc(size, flags | __GFP_NORETRY | __GFP_NOWARN);
 	if (!ret)
 		ret = __vmalloc(size, flags | __GFP_ZERO, PAGE_KERNEL);
 	return ret;
-- 
1.8.3.1



More information about the Devel mailing list