[308/622] lnet: libcfs: crashes with certain cpu part numbers
diff mbox series

Message ID 1582838290-17243-309-git-send-email-jsimmons@infradead.org
State New
Headers show
Series
  • lustre: sync closely to 2.13.52
Related show

Commit Message

James Simmons Feb. 27, 2020, 9:12 p.m. UTC
From: Andrew Perepechko <c17827@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@cray.com>
Reviewed-by: Alexander Boyko <c17825@cray.com>
Reviewed-by: Alexander Zarochentsev <c17826@cray.com>
Cray-bug-id: LUS-6455
Reviewed-on: https://review.whamcloud.com/34991
Reviewed-by: Gu Zheng <gzheng@ddn.com>
Reviewed-by: Alexandr Boyko <c17825@cray.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
Signed-off-by: James Simmons <jsimmons@infradead.org>
---
 net/lnet/libcfs/libcfs_cpu.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Patch
diff mbox series

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;