Skip to contentSkip to conversation

Fix: membarrier: add missing preempt off around smp_call_function_many

PATCH In review Mathieu Desnoyers 3 participants 5 messages Dec 15, 2017 – Jan 10, 2018

Subsystems (3)
lore
Share & tools
lore

Mathieu Desnoyers

author maintainer
#0 lore raw

PATCH 1/1 Fix: membarrier: add missing preempt off around smp_call_function_many

smp_call_function_many requires disabling preemption around the call.

CC Linus Torvalds <[email protected]>
CC Peter Zijlstra <[email protected]>
CC Paul E. McKenney <[email protected]>
CC Boqun Feng <[email protected]>
CC Andrew Hunter <[email protected]>
CC Maged Michael <[email protected]>
CC Avi Kivity <[email protected]>
CC Benjamin Herrenschmidt <[email protected]>
CC Paul Mackerras <[email protected]>
CC Michael Ellerman <[email protected]>
CC Dave Watson <[email protected]>
CC Thomas Gleixner <[email protected]>
CC Ingo Molnar <[email protected]>
CC "H. Peter Anvin" <[email protected]>
CC Andrea Parri <[email protected]>
CC <[email protected]> # v4.14
---
 kernel/sched/membarrier.c | 2 ++
 1 file changed, 2 insertions(+)
kernel/sched/membarrier.c +2 -0
index dd7908743dab..9bcbacba82a8 100644
@@ -89,7 +89,9 @@ static int membarrier_private_expedited(void)
 		rcu_read_unlock();
 	}
 	if (!fallback) {
+		preempt_disable();
 		smp_call_function_many(tmpmask, ipi_mb, NULL, 1);
+		preempt_enable();
 		free_cpumask_var(tmpmask);
 	}
 	cpus_read_unlock();
Signature · 1 line
2.11.0
author maintainer
#1 lore raw

Hi Linus, Peter, Ingo,

Now that membarrier.c has been moved from kernel/ to kernel/sched/, should I route this membarrier fix through the scheduler maintainers, or is it OK to send it to you directly ?

Thanks,

Mathieu

Quoted 39 lines · ----- On Dec 15, 2017, at 2:23 PM, Mathieu Desnoyers…

smp_call_function_many requires disabling preemption around the call.

CC Linus Torvalds <[email protected]>
CC Peter Zijlstra <[email protected]>
CC Paul E. McKenney <[email protected]>
CC Boqun Feng <[email protected]>
CC Andrew Hunter <[email protected]>
CC Maged Michael <[email protected]>
CC Avi Kivity <[email protected]>
CC Benjamin Herrenschmidt <[email protected]>
CC Paul Mackerras <[email protected]>
CC Michael Ellerman <[email protected]>
CC Dave Watson <[email protected]>
CC Thomas Gleixner <[email protected]>
CC Ingo Molnar <[email protected]>
CC "H. Peter Anvin" <[email protected]>
CC Andrea Parri <[email protected]>
CC <[email protected]> # v4.14

---
kernel/sched/membarrier.c | 2 ++

1 file changed, 2 insertions(+)
kernel/sched/membarrier.c +2 -1
index dd7908743dab..9bcbacba82a8 100644
@@ -89,7 +89,9 @@ static int membarrier_private_expedited(void)
 		rcu_read_unlock();
 	}
 	if (!fallback) {
+		preempt_disable();
 		smp_call_function_many(tmpmask, ipi_mb, NULL, 1);
+		preempt_enable();
 		free_cpumask_var(tmpmask);
 	}
 	cpus_read_unlock();
--

2.11.0

Signature · 3 lines
Mathieu Desnoyers
EfficiOS Inc.
http://www.efficios.com
author maintainer
#2 lore raw

Hi Linus,

Can you pick up this straightforward fix please ? Let me know whether I need to re-send the patch if for some reason the original post is too far back in your inbox.

Thanks,

Mathieu

Quoted 57 lines · ----- On Dec 20, 2017, at 10:02 AM, Mathieu Desnoyers…

Hi Linus, Peter, Ingo,

Now that membarrier.c has been moved from kernel/ to kernel/sched/, should I route this membarrier fix through the scheduler maintainers, or is it OK to send it to you directly ?

Thanks,

Mathieu

----- On Dec 15, 2017, at 2:23 PM, Mathieu Desnoyers

Quoted 38 lines · [email protected] wrote:

smp_call_function_many requires disabling preemption around the call.

CC Linus Torvalds <[email protected]>
CC Peter Zijlstra <[email protected]>
CC Paul E. McKenney <[email protected]>
CC Boqun Feng <[email protected]>
CC Andrew Hunter <[email protected]>
CC Maged Michael <[email protected]>
CC Avi Kivity <[email protected]>
CC Benjamin Herrenschmidt <[email protected]>
CC Paul Mackerras <[email protected]>
CC Michael Ellerman <[email protected]>
CC Dave Watson <[email protected]>
CC Thomas Gleixner <[email protected]>
CC Ingo Molnar <[email protected]>
CC "H. Peter Anvin" <[email protected]>
CC Andrea Parri <[email protected]>
CC <[email protected]> # v4.14

---
kernel/sched/membarrier.c | 2 ++

1 file changed, 2 insertions(+)
kernel/sched/membarrier.c +2 -1
index dd7908743dab..9bcbacba82a8 100644
@@ -89,7 +89,9 @@ static int membarrier_private_expedited(void)
 		rcu_read_unlock();
 	}
 	if (!fallback) {
+		preempt_disable();
 		smp_call_function_many(tmpmask, ipi_mb, NULL, 1);
+		preempt_enable();
 		free_cpumask_var(tmpmask);
 	}
 	cpus_read_unlock();
--
Quoted 1 line

2.11.0

--
Mathieu Desnoyers
EfficiOS Inc.
http://www.efficios.com

Signature · 3 lines
Mathieu Desnoyers
EfficiOS Inc.
http://www.efficios.com
#3 lore raw
Quoted 5 lines · Mathieu Desnoyers

Hi Linus,

Can you pick up this straightforward fix please ? Let me know whether I need to re-send the patch if for some reason the original post is too far back in your inbox.

The fix looks much more reasonable than previous attempts: I'll pick it up into tip:sched/urgent and send it Linuswards.

Thanks,

Ingo

#4 lore raw

[tip:sched/urgent] membarrier: Disable preemption when calling smp_call_function_many()

In reply to Mathieu Desnoyers
membarrier: Disable preemption when calling smp_call_function_many()
Commit-ID:  541676078b52f365f53d46ee5517d305cd1b6350
Gitweb:     https://git.kernel.org/tip/541676078b52f365f53d46ee5517d305cd1b6350
Author:     Mathieu Desnoyers <[email protected]>
AuthorDate: Fri, 15 Dec 2017 14:23:10 -0500
Committer:  Ingo Molnar <[email protected]>
CommitDate: Wed, 10 Jan 2018 08:50:31 +0100

membarrier: Disable preemption when calling smp_call_function_many()

smp_call_function_many() requires disabling preemption around the call.

Cc <[email protected]> # v4.14+
Cc Andrea Parri <[email protected]>
Cc Andrew Hunter <[email protected]>
Cc Avi Kivity <[email protected]>
Cc Benjamin Herrenschmidt <[email protected]>
Cc Boqun Feng <[email protected]>
Cc Dave Watson <[email protected]>
Cc H. Peter Anvin <[email protected]>
Cc Linus Torvalds <[email protected]>
Cc Maged Michael <[email protected]>
Cc Michael Ellerman <[email protected]>
Cc Paul E . McKenney <[email protected]>
Cc Paul E. McKenney <[email protected]>
Cc Paul Mackerras <[email protected]>
Cc Peter Zijlstra <[email protected]>
Cc Thomas Gleixner <[email protected]>
---
 kernel/sched/membarrier.c | 2 ++
 1 file changed, 2 insertions(+)
kernel/sched/membarrier.c +2 -0
index dd79087..9bcbacb 100644
@@ -89,7 +89,9 @@ static int membarrier_private_expedited(void)
 		rcu_read_unlock();
 	}
 	if (!fallback) {
+		preempt_disable();
 		smp_call_function_many(tmpmask, ipi_mb, NULL, 1);
+		preempt_enable();
 		free_cpumask_var(tmpmask);
 	}
 	cpus_read_unlock();