Whamcloud - gitweb
LU-12352 libcfs: crashes with certain cpu part numbers 91/34991/6
authorAndrew Perepechko <c17827@cray.com>
Thu, 17 Jan 2019 21:58:10 +0000 (00:58 +0300)
committerOleg Drokin <green@whamcloud.com>
Tue, 4 Jun 2019 05:27:17 +0000 (05:27 +0000)
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 <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
Tested-by: Jenkins
Reviewed-by: Gu Zheng <gzheng@ddn.com>
Reviewed-by: Alexandr Boyko <c17825@cray.com>
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
libcfs/libcfs/libcfs_cpu.c

index e183986..127b63a 100644 (file)
@@ -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,
                        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;
                        if (rc < 0) {
                                rc = -EINVAL;
                                goto failed_mask;