forked from torvalds/linux
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
powerpc, membarrier: Skip memory barrier in switch_mm()
Allow PowerPC to skip the full memory barrier in switch_mm(), and only issue the barrier when scheduling into a task belonging to a process that has registered to use expedited private. Threads targeting the same VM but which belong to different thread groups is a tricky case. It has a few consequences: It turns out that we cannot rely on get_nr_threads(p) to count the number of threads using a VM. We can use (atomic_read(&mm->mm_users) == 1 && get_nr_threads(p) == 1) instead to skip the synchronize_sched() for cases where the VM only has a single user, and that user only has a single thread. It also turns out that we cannot use for_each_thread() to set thread flags in all threads using a VM, as it only iterates on the thread group. Therefore, test the membarrier state variable directly rather than relying on thread flags. This means membarrier_register_private_expedited() needs to set the MEMBARRIER_STATE_PRIVATE_EXPEDITED flag, issue synchronize_sched(), and only then set MEMBARRIER_STATE_PRIVATE_EXPEDITED_READY which allows private expedited membarrier commands to succeed. membarrier_arch_switch_mm() now tests for the MEMBARRIER_STATE_PRIVATE_EXPEDITED flag. Signed-off-by: Mathieu Desnoyers <[email protected]> Acked-by: Thomas Gleixner <[email protected]> Acked-by: Peter Zijlstra (Intel) <[email protected]> Cc: Alan Stern <[email protected]> Cc: Alexander Viro <[email protected]> Cc: Andrea Parri <[email protected]> Cc: Andrew Hunter <[email protected]> Cc: Andy Lutomirski <[email protected]> Cc: Avi Kivity <[email protected]> Cc: Benjamin Herrenschmidt <[email protected]> Cc: Boqun Feng <[email protected]> Cc: Dave Watson <[email protected]> Cc: David Sehr <[email protected]> Cc: Greg Hackmann <[email protected]> Cc: Linus Torvalds <[email protected]> Cc: Maged Michael <[email protected]> Cc: Michael Ellerman <[email protected]> Cc: Nicholas Piggin <[email protected]> Cc: Paul E. McKenney <[email protected]> Cc: Paul Mackerras <[email protected]> Cc: Russell King <[email protected]> Cc: Will Deacon <[email protected]> Cc: [email protected] Cc: [email protected] Cc: [email protected] Link: http://lkml.kernel.org/r/[email protected] Signed-off-by: Ingo Molnar <[email protected]>
- Loading branch information
Showing
8 changed files
with
58 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8944,6 +8944,7 @@ L: [email protected] | |
S: Supported | ||
F: kernel/sched/membarrier.c | ||
F: include/uapi/linux/membarrier.h | ||
F: arch/powerpc/include/asm/membarrier.h | ||
|
||
MEMORY MANAGEMENT | ||
L: [email protected] | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
#ifndef _ASM_POWERPC_MEMBARRIER_H | ||
#define _ASM_POWERPC_MEMBARRIER_H | ||
|
||
static inline void membarrier_arch_switch_mm(struct mm_struct *prev, | ||
struct mm_struct *next, | ||
struct task_struct *tsk) | ||
{ | ||
/* | ||
* Only need the full barrier when switching between processes. | ||
* Barrier when switching from kernel to userspace is not | ||
* required here, given that it is implied by mmdrop(). Barrier | ||
* when switching from userspace to kernel is not needed after | ||
* store to rq->curr. | ||
*/ | ||
if (likely(!(atomic_read(&next->membarrier_state) & | ||
MEMBARRIER_STATE_PRIVATE_EXPEDITED) || !prev)) | ||
return; | ||
|
||
/* | ||
* The membarrier system call requires a full memory barrier | ||
* after storing to rq->curr, before going back to user-space. | ||
*/ | ||
smp_mb(); | ||
} | ||
|
||
#endif /* _ASM_POWERPC_MEMBARRIER_H */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters