sched/membarrier: Skip IPIs when mm->mm_users == 1

If there is only a single mm_user for the mm, the private expedited
membarrier command can skip the IPIs, because only a single thread
is using the mm.

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Cc: Chris Metcalf <cmetcalf@ezchip.com>
Cc: Christoph Lameter <cl@linux.com>
Cc: Eric W. Biederman <ebiederm@xmission.com>
Cc: Kirill Tkhai <tkhai@yandex.ru>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Mike Galbraith <efault@gmx.de>
Cc: Oleg Nesterov <oleg@redhat.com>
Cc: Paul E. McKenney <paulmck@linux.ibm.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Russell King - ARM Linux admin <linux@armlinux.org.uk>
Cc: Thomas Gleixner <tglx@linutronix.de>
Link: https://lkml.kernel.org/r/20190919173705.2181-7-mathieu.desnoyers@efficios.com
Signed-off-by: Ingo Molnar <mingo@kernel.org>
This commit is contained in:
Mathieu Desnoyers 2019-09-19 13:37:04 -04:00 коммит произвёл Ingo Molnar
Родитель 19a4ff534b
Коммит c6d68c1c4a
1 изменённых файлов: 5 добавлений и 4 удалений

Просмотреть файл

@ -145,20 +145,21 @@ static int membarrier_private_expedited(int flags)
int cpu; int cpu;
bool fallback = false; bool fallback = false;
cpumask_var_t tmpmask; cpumask_var_t tmpmask;
struct mm_struct *mm = current->mm;
if (flags & MEMBARRIER_FLAG_SYNC_CORE) { if (flags & MEMBARRIER_FLAG_SYNC_CORE) {
if (!IS_ENABLED(CONFIG_ARCH_HAS_MEMBARRIER_SYNC_CORE)) if (!IS_ENABLED(CONFIG_ARCH_HAS_MEMBARRIER_SYNC_CORE))
return -EINVAL; return -EINVAL;
if (!(atomic_read(&current->mm->membarrier_state) & if (!(atomic_read(&mm->membarrier_state) &
MEMBARRIER_STATE_PRIVATE_EXPEDITED_SYNC_CORE_READY)) MEMBARRIER_STATE_PRIVATE_EXPEDITED_SYNC_CORE_READY))
return -EPERM; return -EPERM;
} else { } else {
if (!(atomic_read(&current->mm->membarrier_state) & if (!(atomic_read(&mm->membarrier_state) &
MEMBARRIER_STATE_PRIVATE_EXPEDITED_READY)) MEMBARRIER_STATE_PRIVATE_EXPEDITED_READY))
return -EPERM; return -EPERM;
} }
if (num_online_cpus() == 1) if (atomic_read(&mm->mm_users) == 1 || num_online_cpus() == 1)
return 0; return 0;
/* /*
@ -194,7 +195,7 @@ static int membarrier_private_expedited(int flags)
continue; continue;
rcu_read_lock(); rcu_read_lock();
p = rcu_dereference(cpu_rq(cpu)->curr); p = rcu_dereference(cpu_rq(cpu)->curr);
if (p && p->mm == current->mm) { if (p && p->mm == mm) {
if (!fallback) if (!fallback)
__cpumask_set_cpu(cpu, tmpmask); __cpumask_set_cpu(cpu, tmpmask);
else else