Whamcloud - gitweb
LU-5349 include: use __vmalloc() to avoid __GFP_FS default 90/11190/4 dne2
authorBruno Faccini <bruno.faccini@intel.com>
Wed, 23 Jul 2014 09:03:54 +0000 (11:03 +0200)
committerOleg Drokin <oleg.drokin@intel.com>
Tue, 29 Jul 2014 19:21:06 +0000 (19:21 +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.

Signed-off-by: Bruno Faccini <bruno.faccini@intel.com>
Change-Id: I25fc4a55374c09c12156b2a2f8d8b2434b4cd689
Reviewed-on: http://review.whamcloud.com/11190
Reviewed-by: Andreas Dilger <andreas.dilger@intel.com>
Tested-by: Jenkins
Tested-by: Maloo <hpdd-maloo@intel.com>
Reviewed-by: James Simmons <uja.ornl@gmail.com>
Reviewed-by: Oleg Drokin <oleg.drokin@intel.com>
libcfs/libcfs/linux/linux-mem.c
lustre/include/obd_support.h

index 8cdf07d..0887a31 100644 (file)
@@ -53,6 +53,14 @@ EXPORT_SYMBOL(cfs_cpt_malloc);
 void *
 cfs_cpt_vzalloc(struct cfs_cpt_table *cptab, int cpt, size_t nr_bytes)
 {
 void *
 cfs_cpt_vzalloc(struct cfs_cpt_table *cptab, int cpt, size_t nr_bytes)
 {
+       /* vzalloc_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 vzalloc_node(nr_bytes, cfs_cpt_spread_node(cptab, cpt));
 }
 EXPORT_SYMBOL(cfs_cpt_vzalloc);
        return vzalloc_node(nr_bytes, cfs_cpt_spread_node(cptab, cpt));
 }
 EXPORT_SYMBOL(cfs_cpt_vzalloc);
index cc3e2c4..7801966 100644 (file)
@@ -703,10 +703,15 @@ do {                                                                            \
 #define OBD_CPT_ALLOC_PTR(ptr, cptab, cpt)                                   \
        OBD_CPT_ALLOC(ptr, cptab, cpt, sizeof *(ptr))
 
 #define OBD_CPT_ALLOC_PTR(ptr, cptab, cpt)                                   \
        OBD_CPT_ALLOC(ptr, cptab, cpt, sizeof *(ptr))
 
+/* 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 ?                                               \
 # define __OBD_VMALLOC_VERBOSE(ptr, cptab, cpt, size)                        \
 do {                                                                         \
        (ptr) = cptab == NULL ?                                               \
-               vzalloc(size) :                                       \
+               __vmalloc(size, GFP_NOFS | __GFP_HIGHMEM | __GFP_ZERO,        \
+                         PAGE_KERNEL) :                                      \
                cfs_cpt_vzalloc(cptab, cpt, size);                            \
        if (unlikely((ptr) == NULL)) {                                        \
                CERROR("vmalloc of '" #ptr "' (%d bytes) failed\n",           \
                cfs_cpt_vzalloc(cptab, cpt, size);                            \
        if (unlikely((ptr) == NULL)) {                                        \
                CERROR("vmalloc of '" #ptr "' (%d bytes) failed\n",           \