[PATCH 4.15 062/168] staging: lustre: disable preempt while sampling processor id.

2018-04-10 Thread Greg Kroah-Hartman
4.15-stable review patch.  If anyone has any objections, please let me know.

--

From: NeilBrown 


[ Upstream commit dbeccabf5294e80f7cc9ee566746c42211bed736 ]

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.

Signed-off-by: NeilBrown 
Reviewed-by: Andreas Dilger 
Signed-off-by: Greg Kroah-Hartman 
Signed-off-by: Sasha Levin 
Signed-off-by: Greg Kroah-Hartman 
---
 drivers/staging/lustre/lnet/libcfs/linux/linux-cpu.c |   13 +++--
 1 file changed, 7 insertions(+), 6 deletions(-)

--- a/drivers/staging/lustre/lnet/libcfs/linux/linux-cpu.c
+++ b/drivers/staging/lustre/lnet/libcfs/linux/linux-cpu.c
@@ -529,19 +529,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);




[PATCH 4.15 062/168] staging: lustre: disable preempt while sampling processor id.

2018-04-10 Thread Greg Kroah-Hartman
4.15-stable review patch.  If anyone has any objections, please let me know.

--

From: NeilBrown 


[ Upstream commit dbeccabf5294e80f7cc9ee566746c42211bed736 ]

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.

Signed-off-by: NeilBrown 
Reviewed-by: Andreas Dilger 
Signed-off-by: Greg Kroah-Hartman 
Signed-off-by: Sasha Levin 
Signed-off-by: Greg Kroah-Hartman 
---
 drivers/staging/lustre/lnet/libcfs/linux/linux-cpu.c |   13 +++--
 1 file changed, 7 insertions(+), 6 deletions(-)

--- a/drivers/staging/lustre/lnet/libcfs/linux/linux-cpu.c
+++ b/drivers/staging/lustre/lnet/libcfs/linux/linux-cpu.c
@@ -529,19 +529,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);