From 1ca7f6329833d551f69fd8aec29b66845bedb0c9 Mon Sep 17 00:00:00 2001 From: Andreas Dilger Date: Tue, 24 Jul 2018 23:36:18 -0600 Subject: [PATCH] LU-11163 libcfs: fix CPT NUMA memory failures 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 Change-Id: Ib0ab84bef8ff10c43bafb48a8082b62fc544ca29 Reviewed-on: https://review.whamcloud.com/32848 Tested-by: Jenkins Tested-by: Maloo Reviewed-by: Patrick Farrell Reviewed-by: John L. Hammond Reviewed-by: Oleg Drokin --- lustre/include/obd_support.h | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/lustre/include/obd_support.h b/lustre/include/obd_support.h index e9dd33e..f84c3a5 100644 --- a/lustre/include/obd_support.h +++ b/lustre/include/obd_support.h @@ -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) \ -- 1.8.3.1