From 296946442c062be28262e4c769fb5e486c965717 Mon Sep 17 00:00:00 2001 From: Bruno Faccini Date: Wed, 3 Sep 2014 11:09:34 +0200 Subject: [PATCH] LU-5349 include: use __vmalloc() to avoid __GFP_FS default When possible, try to Direct use of __vmalloc() which allows for protection flag specification, and particularly to not set __GFP_FS, which can cause some deadlock situations in our code. This patch is the b2_5 back-port of : Lustre-commit: 635421641bfa8a412edebd4ffbbdf05fd0c47410 Lustre-change: http://review.whamcloud.com/11190/ Also corrects a typo in __OBD_VMALLOC_VERBOSE name. Signed-off-by: Bruno Faccini Change-Id: I588ebf27d1ff7538745b732d174696c379107ea3 Reviewed-on: http://review.whamcloud.com/11739 Tested-by: Jenkins Tested-by: Maloo Reviewed-by: Oleg Drokin --- libcfs/libcfs/linux/linux-mem.c | 8 ++++++++ lustre/include/obd_support.h | 12 ++++++++---- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/libcfs/libcfs/linux/linux-mem.c b/libcfs/libcfs/linux/linux-mem.c index cc18de2..44f6c4e 100644 --- a/libcfs/libcfs/linux/linux-mem.c +++ b/libcfs/libcfs/linux/linux-mem.c @@ -59,6 +59,14 @@ EXPORT_SYMBOL(cfs_cpt_malloc); void * cfs_cpt_vmalloc(struct cfs_cpt_table *cptab, int cpt, size_t nr_bytes) { + /* vmalloc_node() sets __GFP_FS by default but no current Kernel + * exported entry-point allows for both a NUMA node specification + * and a custom allocation flags mask. This may be an issue since + * __GFP_FS usage can cause some deadlock situations in our code, + * like when memory reclaim started, within the same context of a + * thread doing FS operations, that can also attempt conflicting FS + * operations, ... + */ return vmalloc_node(nr_bytes, cfs_cpt_spread_node(cptab, cpt)); } EXPORT_SYMBOL(cfs_cpt_vmalloc); diff --git a/lustre/include/obd_support.h b/lustre/include/obd_support.h index 95e8d95..08bb414 100644 --- a/lustre/include/obd_support.h +++ b/lustre/include/obd_support.h @@ -667,10 +667,14 @@ do { \ #define OBD_CPT_ALLOC_PTR(ptr, cptab, cpt) \ OBD_CPT_ALLOC(ptr, cptab, cpt, sizeof *(ptr)) -# define __OBD_VMALLOC_VEROBSE(ptr, cptab, cpt, size) \ +/* Direct use of __vmalloc() allows for protection flag specification + * (and particularly to not set __GFP_FS, which is likely to cause some + * deadlock situations in our code). + */ +# define __OBD_VMALLOC_VERBOSE(ptr, cptab, cpt, size) \ do { \ (ptr) = cptab == NULL ? \ - vmalloc(size) : \ + __vmalloc(size, GFP_NOFS | __GFP_HIGHMEM, PAGE_KERNEL) : \ cfs_cpt_vmalloc(cptab, cpt, size); \ if (unlikely((ptr) == NULL)) { \ CERROR("vmalloc of '" #ptr "' (%d bytes) failed\n", \ @@ -684,9 +688,9 @@ do { \ } while(0) # define OBD_VMALLOC(ptr, size) \ - __OBD_VMALLOC_VEROBSE(ptr, NULL, 0, size) + __OBD_VMALLOC_VERBOSE(ptr, NULL, 0, size) # define OBD_CPT_VMALLOC(ptr, cptab, cpt, size) \ - __OBD_VMALLOC_VEROBSE(ptr, cptab, cpt, size) + __OBD_VMALLOC_VERBOSE(ptr, cptab, cpt, size) #ifdef __KERNEL__ -- 1.8.3.1