Whamcloud - gitweb
LU-5349 include: use __vmalloc() to avoid __GFP_FS default 39/11739/2
authorBruno Faccini <bruno.faccini@intel.com>
Wed, 3 Sep 2014 09:09:34 +0000 (11:09 +0200)
committerOleg Drokin <oleg.drokin@intel.com>
Wed, 24 Sep 2014 02:31:09 +0000 (02:31 +0000)
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 <bruno.faccini@intel.com>
Change-Id: I588ebf27d1ff7538745b732d174696c379107ea3
Reviewed-on: http://review.whamcloud.com/11739
Tested-by: Jenkins
Tested-by: Maloo <hpdd-maloo@intel.com>
Reviewed-by: Oleg Drokin <oleg.drokin@intel.com>
libcfs/libcfs/linux/linux-mem.c
lustre/include/obd_support.h

index cc18de2..44f6c4e 100644 (file)
@@ -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);
index 95e8d95..08bb414 100644 (file)
@@ -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__