Whamcloud - gitweb
LU-4423 libcfs: disable preempt while sampling processor id. 60/32360/3
authorNeilBrown <neilb@suse.com>
Sat, 12 May 2018 17:52:58 +0000 (13:52 -0400)
committerOleg Drokin <oleg.drokin@intel.com>
Mon, 21 May 2018 16:54:28 +0000 (16:54 +0000)
Calling smp_processor_id() without disabling preemption
triggers a warning (if CONFIG_DEBUG_PREEMPT).
I think the result of cfs_cpt_current() is only used as a hint for
load balancing, rather than as a precise and stable indicator of
the current CPU.  So it doesn't need to be called with
preemption disabled.

So disable preemption inside cfs_cpt_current() to silence the warning.

Linux-commit : dbeccabf5294e80f7cc9ee566746c42211bed736

Change-Id: Iaa930acc7a2633c0e40bcabbe6bd309a3d767325
Signed-off-by: NeilBrown <neilb@suse.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: James Simmons <uja.ornl@yahoo.com>
Reviewed-on: https://review.whamcloud.com/32360
Tested-by: Jenkins
Tested-by: Maloo <hpdd-maloo@intel.com>
Reviewed-by: Dmitry Eremin <dmitry.eremin@intel.com>
Reviewed-by: Andreas Dilger <andreas.dilger@intel.com>
Reviewed-by: Oleg Drokin <oleg.drokin@intel.com>
libcfs/libcfs/libcfs_cpu.c

index 18c4839..c80f9d4 100644 (file)
@@ -678,19 +678,20 @@ EXPORT_SYMBOL(cfs_cpt_spread_node);
 
 int cfs_cpt_current(struct cfs_cpt_table *cptab, int remap)
 {
-       int cpu = smp_processor_id();
-       int cpt = cptab->ctb_cpu2cpt[cpu];
+       int cpu;
+       int cpt;
 
-       if (cpt < 0) {
-               if (!remap)
-                       return cpt;
+       preempt_disable();
+       cpu = smp_processor_id();
+       cpt = cptab->ctb_cpu2cpt[cpu];
 
+       if (cpt < 0 && remap) {
                /* don't return negative value for safety of upper layer,
                 * instead we shadow the unknown cpu to a valid partition ID
                 */
                cpt = cpu % cptab->ctb_nparts;
        }
-
+       preempt_enable();
        return cpt;
 }
 EXPORT_SYMBOL(cfs_cpt_current);