Whamcloud - gitweb
LU-11163 libcfs: fix CPT NUMA memory failures 48/32848/6
authorAndreas Dilger <adilger@whamcloud.com>
Wed, 25 Jul 2018 05:36:18 +0000 (23:36 -0600)
committerOleg Drokin <green@whamcloud.com>
Fri, 2 Nov 2018 07:17:41 +0000 (07:17 +0000)
In some (mis-)configurations, NUMA nodes may not have any local RAM,
or the memory allocations are non-uniform between NUMA nodes.

In the unlikely case that a CPT-bound allocation fails, retry the
allocation without the CPT-binding.  Having some remote memory usage
is better than an allocation failure.

Signed-off-by: Andreas Dilger <adilger@whamcloud.com>
Change-Id: Ib0ab84bef8ff10c43bafb48a8082b62fc544ca29
Reviewed-on: https://review.whamcloud.com/32848
Tested-by: Jenkins
Tested-by: Maloo <hpdd-maloo@intel.com>
Reviewed-by: Patrick Farrell <paf@cray.com>
Reviewed-by: John L. Hammond <jhammond@whamcloud.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
lustre/include/obd_support.h

index e9dd33e..f84c3a5 100644 (file)
@@ -752,11 +752,13 @@ static inline void obd_memory_sub(long size)
 
 #define __OBD_MALLOC_VERBOSE(ptr, cptab, cpt, size, flags)                   \
 do {                                                                         \
-       (ptr) = (cptab) == NULL ?                                             \
-               kmalloc(size, (flags) | __GFP_ZERO) :                         \
-               cfs_cpt_malloc(cptab, cpt, size, (flags) | __GFP_ZERO);       \
-       if (likely((ptr) != NULL))                                            \
-               OBD_ALLOC_POST(ptr, size, "kmalloced");                       \
+       if (cptab)                                                            \
+               ptr = cfs_cpt_malloc((cptab), (cpt), (size),                  \
+                                    (flags) | __GFP_ZERO | __GFP_NOWARN);    \
+       if (!(cptab) || unlikely(!(ptr))) /* retry without CPT if failure */  \
+               ptr = kmalloc(size, (flags) | __GFP_ZERO);                    \
+       if (likely((ptr) != NULL))                                            \
+               OBD_ALLOC_POST((ptr), (size), "kmalloced");                   \
 } while (0)
 
 #define OBD_ALLOC_GFP(ptr, size, gfp_mask)                                   \