From: Andrew Perepechko Date: Thu, 17 Jan 2019 21:58:10 +0000 (+0300) Subject: LU-12352 libcfs: crashes with certain cpu part numbers X-Git-Tag: 2.12.54~2 X-Git-Url: https://git.whamcloud.com/?a=commitdiff_plain;h=refs%2Fchanges%2F91%2F34991%2F6;p=fs%2Flustre-release.git 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. Change-Id: I3c5e2aa1fdfca4c07e7afce143c984973373f009 Signed-off-by: Andrew Perepechko Reviewed-by: Alexander Boyko Reviewed-by: Alexander Zarochentsev Cray-bug-id: LUS-6455 Reviewed-on: https://review.whamcloud.com/34991 Tested-by: Jenkins Reviewed-by: Gu Zheng Reviewed-by: Alexandr Boyko Tested-by: Maloo Reviewed-by: Oleg Drokin --- diff --git a/libcfs/libcfs/libcfs_cpu.c b/libcfs/libcfs/libcfs_cpu.c index e183986..127b63a 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;