[lustre-devel] [PATCH 308/622] lnet: libcfs: crashes with certain cpu part numbers

James Simmons jsimmons at infradead.org
Thu Feb 27 13:12:56 PST 2020


From: Andrew Perepechko <c17827 at cray.com>

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.

WC-bug-id: https://jira.whamcloud.com/browse/LU-12352
Lustre-commit: e33e3da58972 ("LU-12352 libcfs: crashes with certain cpu part numbers")
Signed-off-by: Andrew Perepechko <c17827 at cray.com>
Reviewed-by: Alexander Boyko <c17825 at cray.com>
Reviewed-by: Alexander Zarochentsev <c17826 at cray.com>
Cray-bug-id: LUS-6455
Reviewed-on: https://review.whamcloud.com/34991
Reviewed-by: Gu Zheng <gzheng at ddn.com>
Reviewed-by: Alexandr Boyko <c17825 at cray.com>
Reviewed-by: Oleg Drokin <green at whamcloud.com>
Signed-off-by: James Simmons <jsimmons at infradead.org>
---
 net/lnet/libcfs/libcfs_cpu.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/net/lnet/libcfs/libcfs_cpu.c b/net/lnet/libcfs/libcfs_cpu.c
index 80533c2..20ca15a 100644
--- a/net/lnet/libcfs/libcfs_cpu.c
+++ b/net/lnet/libcfs/libcfs_cpu.c
@@ -913,7 +913,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



More information about the lustre-devel mailing list