From 6677b0ad0db9d4b826d77a768bf561bfe6533ffe Mon Sep 17 00:00:00 2001 From: Andrew Perepechko Date: Fri, 18 Jan 2019 00:58:10 +0300 Subject: [PATCH] LU-12352 libcfs: crashes with certain cpu part numbers Due to a bug in the code, libcfs will crash if the number of online cpus does not divide by the number of cpu partitions. Based on the checks in cfs_cpt_table_create(), it appears that the original intent was to push the remaining cpus into the initial partitions. So let's do that properly. Lustre-commit: e33e3da58972a811e6eafc479f95f6df2baf4b9b Lustre-change: https://review.whamcloud.com/34991 Change-Id: I3c5e2aa1fdfca4c07e7afce143c984973373f009 Cray-bug-id: LUS-6455 Signed-off-by: Andrew Perepechko Reviewed-by: Alexander Boyko Reviewed-by: Alexander Zarochentsev Reviewed-by: Gu Zheng Reviewed-by: Alexandr Boyko Reviewed-on: https://review.whamcloud.com/37994 Reviewed-by: Serguei Smirnov Tested-by: jenkins Tested-by: Maloo Reviewed-by: Oleg Drokin --- libcfs/libcfs/libcfs_cpu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libcfs/libcfs/libcfs_cpu.c b/libcfs/libcfs/libcfs_cpu.c index 58bda9c..8757ad1 100644 --- a/libcfs/libcfs/libcfs_cpu.c +++ b/libcfs/libcfs/libcfs_cpu.c @@ -904,7 +904,7 @@ static struct cfs_cpt_table *cfs_cpt_table_create(int ncpt) int ncpu = cpumask_weight(part->cpt_cpumask); rc = cfs_cpt_choose_ncpus(cptab, cpt, node_mask, - num - ncpu); + (rem > 0) + num - ncpu); if (rc < 0) { rc = -EINVAL; goto failed_mask; -- 1.8.3.1