staging: lustre: lnet/selftest: fix compile error on UP build
authorNeilBrown <neilb@suse.com>
Tue, 23 Jan 2018 06:27:47 +0000 (17:27 +1100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 23 Jan 2018 10:42:03 +0000 (11:42 +0100)
When compiled without CONFIG_SMP, we get a compile error
as ->ctb_parts is not defined.

There is already a function, cfs_cpt_cpumask(), which will get the
cpumask we need, and which handles the UP case by returning a NULL pointer.
So use that and handle NULL.
Also avoid the #ifdef by allocating a cpumask_var and copying
into it, rather than sharing the mask.

Reported-by: kbuild test robot <fengguang.wu@intel.com>
Fixes: 6106c0f82481 ("staging: lustre: lnet: convert selftest to use workqueues")
Signed-off-by: NeilBrown <neilb@suse.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/staging/lustre/lnet/selftest/module.c

index 31a74b4..7359aa5 100644 (file)
@@ -110,7 +110,8 @@ lnet_selftest_init(void)
        lst_init_step = LST_INIT_WI_TEST;
        for (i = 0; i < nscheds; i++) {
                int nthrs = cfs_cpt_weight(lnet_cpt_table(), i);
-               struct workqueue_attrs attrs;
+               struct workqueue_attrs attrs = {0};
+               cpumask_var_t *mask = cfs_cpt_cpumask(lnet_cpt_table(), i);
 
                /* reserve at least one CPU for LND */
                nthrs = max(nthrs - 1, 1);
@@ -121,14 +122,12 @@ lnet_selftest_init(void)
                        rc = -ENOMEM;
                        goto error;
                }
-               attrs.nice = 0;
-               #ifdef CONFIG_CPUMASK_OFFSTACK
-               attrs.cpumask = lnet_cpt_table()->ctb_parts[i].cpt_cpumask;
-               #else
-               cpumask_copy(attrs.cpumask, lnet_cpt_table()->ctb_parts[i].cpt_cpumask);
-               #endif
-               attrs.no_numa = false;
-               apply_workqueue_attrs(lst_test_wq[i], &attrs);
+
+               if (mask && alloc_cpumask_var(&attrs.cpumask, GFP_KERNEL)) {
+                       cpumask_copy(attrs.cpumask, *mask);
+                       apply_workqueue_attrs(lst_test_wq[i], &attrs);
+                       free_cpumask_var(attrs.cpumask);
+               }
        }
 
        rc = srpc_startup();