Skip to content

Commit 9075653

Browse files
compudjpaulmck
authored andcommitted
Fix: Disable sys_membarrier when nohz_full is enabled
Userspace applications should be allowed to expect the membarrier system call with MEMBARRIER_CMD_SHARED command to issue memory barriers on nohz_full CPUs, but synchronize_sched() does not take those into account. Given that we do not want unrelated processes to be able to affect real-time sensitive nohz_full CPUs, simply return ENOSYS when membarrier is invoked on a kernel with enabled nohz_full CPUs. Signed-off-by: Mathieu Desnoyers <[email protected]> CC: Josh Triplett <[email protected]> CC: Steven Rostedt <[email protected]> CC: <[email protected]> [3.10+] Signed-off-by: Paul E. McKenney <[email protected]> Cc: Frederic Weisbecker <[email protected]> Cc: Chris Metcalf <[email protected]> Cc: Rik van Riel <[email protected]> Acked-by: Lai Jiangshan <[email protected]> Reviewed-by: Josh Triplett <[email protected]>
1 parent 4d4f88f commit 9075653

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

kernel/membarrier.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616

1717
#include <linux/syscalls.h>
1818
#include <linux/membarrier.h>
19+
#include <linux/tick.h>
1920

2021
/*
2122
* Bitmask made from a "or" of all commands within enum membarrier_cmd,
@@ -51,6 +52,9 @@
5152
*/
5253
SYSCALL_DEFINE2(membarrier, int, cmd, int, flags)
5354
{
55+
/* MEMBARRIER_CMD_SHARED is not compatible with nohz_full. */
56+
if (tick_nohz_full_enabled())
57+
return -ENOSYS;
5458
if (unlikely(flags))
5559
return -EINVAL;
5660
switch (cmd) {

0 commit comments

Comments
 (0)