linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "tip-bot2 for Mathieu Desnoyers" <tip-bot2@linutronix.de>
To: linux-tip-commits@vger.kernel.org
Cc: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>,
	"Peter Zijlstra (Intel)" <peterz@infradead.org>,
	Chris Metcalf <cmetcalf@ezchip.com>,
	Christoph Lameter <cl@linux.com>,
	"Eric W. Biederman" <ebiederm@xmission.com>,
	Kirill Tkhai <tkhai@yandex.ru>,
	Linus Torvalds <torvalds@linux-foundation.org>,
	Mike Galbraith <efault@gmx.de>, Oleg Nesterov <oleg@redhat.com>,
	"Paul E. McKenney" <paulmck@linux.ibm.com>,
	"Russell King - ARM Linux admin" <linux@armlinux.org.uk>,
	Thomas Gleixner <tglx@linutronix.de>,
	Ingo Molnar <mingo@kernel.org>, Borislav Petkov <bp@alien8.de>,
	linux-kernel@vger.kernel.org
Subject: [tip: sched/urgent] sched/membarrier: Skip IPIs when mm->mm_users == 1
Date: Fri, 27 Sep 2019 08:10:42 -0000	[thread overview]
Message-ID: <156957184275.9866.9051290983348883537.tip-bot2@tip-bot2> (raw)
In-Reply-To: <20190919173705.2181-7-mathieu.desnoyers@efficios.com>

The following commit has been merged into the sched/urgent branch of tip:

Commit-ID:     c6d68c1c4a4d6611fc0f8145d764226571d737ca
Gitweb:        https://git.kernel.org/tip/c6d68c1c4a4d6611fc0f8145d764226571d737ca
Author:        Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
AuthorDate:    Thu, 19 Sep 2019 13:37:04 -04:00
Committer:     Ingo Molnar <mingo@kernel.org>
CommitterDate: Wed, 25 Sep 2019 17:42:31 +02:00

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>
---
 kernel/sched/membarrier.c |  9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

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

  reply	other threads:[~2019-09-27  8:11 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-09-19 17:36 [RFC PATCH for 5.4 0/7] Membarrier fixes and cleanups Mathieu Desnoyers
2019-09-19 17:36 ` [RFC PATCH for 5.4 1/7] Fix: sched/membarrier: Private expedited registration check Mathieu Desnoyers
2019-09-27  8:10   ` [tip: sched/urgent] sched/membarrier: Fix private " tip-bot2 for Mathieu Desnoyers
2019-09-19 17:37 ` [RFC PATCH for 5.4 2/7] Cleanup: sched/membarrier: Remove redundant check Mathieu Desnoyers
2019-09-27  8:10   ` [tip: sched/urgent] " tip-bot2 for Mathieu Desnoyers
2019-09-19 17:37 ` [RFC PATCH for 5.4 3/7] Cleanup: sched/membarrier: Only sync_core before usermode for same mm Mathieu Desnoyers
2019-09-27  8:10   ` [tip: sched/urgent] sched/membarrier: Call sync_core only " tip-bot2 for Mathieu Desnoyers
2019-09-19 17:37 ` [RFC PATCH for 5.4 4/7] Fix: sched/membarrier: p->mm->membarrier_state racy load (v4) Mathieu Desnoyers
2019-09-27  8:10   ` [tip: sched/urgent] sched/membarrier: Fix p->mm->membarrier_state racy load tip-bot2 for Mathieu Desnoyers
2019-10-01  8:44     ` Ingo Molnar
2019-10-01  8:50       ` Peter Zijlstra
2019-10-01 19:34         ` [tip: sched/urgent] membarrier: Fix RCU locking bug caused by faulty merge tip-bot2 for Peter Zijlstra
2019-09-19 17:37 ` [RFC PATCH for 5.4 5/7] selftests: sched/membarrier: Add multi-threaded test Mathieu Desnoyers
2019-09-27  8:10   ` [tip: sched/urgent] selftests, " tip-bot2 for Mathieu Desnoyers
2019-09-19 17:37 ` [RFC PATCH for 5.4 6/7] sched/membarrier: Skip IPIs when mm->mm_users == 1 Mathieu Desnoyers
2019-09-27  8:10   ` tip-bot2 for Mathieu Desnoyers [this message]
2019-09-19 17:37 ` [RFC PATCH for 5.4 7/7] sched/membarrier: Return -ENOMEM to userspace on memory allocation failure Mathieu Desnoyers
2019-09-27  8:10   ` [tip: sched/urgent] " tip-bot2 for Mathieu Desnoyers
2019-09-23  9:06 ` [RFC PATCH for 5.4 0/7] Membarrier fixes and cleanups Peter Zijlstra
2019-09-23 14:55   ` Mathieu Desnoyers
2019-09-25  8:07     ` Peter Zijlstra
2019-09-25 15:50       ` Mathieu Desnoyers

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=156957184275.9866.9051290983348883537.tip-bot2@tip-bot2 \
    --to=tip-bot2@linutronix.de \
    --cc=bp@alien8.de \
    --cc=cl@linux.com \
    --cc=cmetcalf@ezchip.com \
    --cc=ebiederm@xmission.com \
    --cc=efault@gmx.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-tip-commits@vger.kernel.org \
    --cc=linux@armlinux.org.uk \
    --cc=mathieu.desnoyers@efficios.com \
    --cc=mingo@kernel.org \
    --cc=oleg@redhat.com \
    --cc=paulmck@linux.ibm.com \
    --cc=peterz@infradead.org \
    --cc=tglx@linutronix.de \
    --cc=tkhai@yandex.ru \
    --cc=torvalds@linux-foundation.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).