Whamcloud - gitweb
LU-16387 lustre: switch OBD_ALLOC_LARGE to vmalloc faster 80/49380/3
authorAlexander Zarochentsev <alexander.zarochentsev@hpe.com>
Tue, 6 Dec 2022 17:10:41 +0000 (20:10 +0300)
committerOleg Drokin <green@whamcloud.com>
Sat, 7 Jan 2023 07:57:27 +0000 (07:57 +0000)
No need to waste time trying hard to kmalloc large memory
chunk in OBD_ALLOC_LARGE. Reduce memory allocation attempts
by specifiying __GFP_NORETRY for all allocations > PAGE_SIZE
(as in kvmalloc in linux-4.18 kernel),
so the kmalloc part fails easily.

HPE-bug-id: LUS-11409
Signed-off-by: Alexander Zarochentsev <alexander.zarochentsev@hpe.com>
Change-Id: I7ff8acfb6b467a4f5a7e61b2b8ec631bea89f8a5
Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/49380
Reviewed-by: Andrew Perepechko <andrew.perepechko@hpe.com>
Reviewed-by: Alex Zhuravlev <bzzz@whamcloud.com>
Reviewed-by: Nikitas Angelinas <nikitas.angelinas@hpe.com>
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
Tested-by: jenkins <devops@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
lustre/include/obd_support.h

index bf26027..3ef800b 100644 (file)
@@ -882,10 +882,11 @@ do {                                                                            \
 #define OBD_ALLOC_LARGE(ptr, size)                                            \
 do {                                                                          \
        /* LU-8196 - force large allocations to use vmalloc, not kmalloc */   \
-       if ((size) > KMALLOC_MAX_SIZE)                                          \
+       if ((size) > KMALLOC_MAX_SIZE)                                        \
                ptr = NULL;                                                   \
-       else                                                                  \
-               OBD_ALLOC_GFP(ptr, size, GFP_NOFS | __GFP_NOWARN);            \
+       else                                                                  \
+               OBD_ALLOC_GFP(ptr, size, GFP_NOFS | __GFP_NOWARN |            \
+                             (((size) > PAGE_SIZE) ? __GFP_NORETRY : 0));    \
        if (ptr == NULL)                                                      \
                 OBD_VMALLOC(ptr, size);                                       \
 } while (0)