Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

sched/membarrier: reduce the ability to hammer on sys_membarrier

On some systems, sys_membarrier can be very expensive, causing overall
slowdowns for everything. So put a lock on the path in order to
serialize the accesses to prevent the ability for this to be called at
too high of a frequency and saturate the machine.

Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Reviewed-and-tested-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Acked-by: Borislav Petkov <bp@alien8.de>
Fixes: 22e4ebb97582 ("membarrier: Provide expedited private command")
Fixes: c5f58bd58f43 ("membarrier: Provide GLOBAL_EXPEDITED command")
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

authored by

Linus Torvalds and committed by
Linus Torvalds
944d5fe5 b401b621

+6
+6
kernel/sched/membarrier.c
··· 162 162 | MEMBARRIER_PRIVATE_EXPEDITED_RSEQ_BITMASK \ 163 163 | MEMBARRIER_CMD_GET_REGISTRATIONS) 164 164 165 + static DEFINE_MUTEX(membarrier_ipi_mutex); 166 + #define SERIALIZE_IPI() guard(mutex)(&membarrier_ipi_mutex) 167 + 165 168 static void ipi_mb(void *info) 166 169 { 167 170 smp_mb(); /* IPIs should be serializing but paranoid. */ ··· 262 259 if (!zalloc_cpumask_var(&tmpmask, GFP_KERNEL)) 263 260 return -ENOMEM; 264 261 262 + SERIALIZE_IPI(); 265 263 cpus_read_lock(); 266 264 rcu_read_lock(); 267 265 for_each_online_cpu(cpu) { ··· 351 347 if (cpu_id < 0 && !zalloc_cpumask_var(&tmpmask, GFP_KERNEL)) 352 348 return -ENOMEM; 353 349 350 + SERIALIZE_IPI(); 354 351 cpus_read_lock(); 355 352 356 353 if (cpu_id >= 0) { ··· 465 460 * between threads which are users of @mm has its membarrier state 466 461 * updated. 467 462 */ 463 + SERIALIZE_IPI(); 468 464 cpus_read_lock(); 469 465 rcu_read_lock(); 470 466 for_each_online_cpu(cpu) {