mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "tip-bot2 for Aniket Gattani" <tip-bot2@linutronix.de>
To: linux-tip-commits@vger.kernel.org
Cc: Aniket Gattani <aniketgattani@google.com>,
	"Peter Zijlstra (Intel)" <peterz@infradead.org>,
	x86@kernel.org, linux-kernel@vger.kernel.org
Subject: [tip: locking/core] sched/membarrier: Modernize membarrier_global_expedited with cleanup guards
Date: Tue, 05 May 2026 10:55:36 -0000	[thread overview]
Message-ID: <177797853688.424702.1772606465208765988.tip-bot2@tip-bot2> (raw)
In-Reply-To: <20260503212205.3714217-3-aniketgattani@google.com>

The following commit has been merged into the locking/core branch of tip:

Commit-ID:     a5959728548caf0aa17879342ee6571a29d54574
Gitweb:        https://git.kernel.org/tip/a5959728548caf0aa17879342ee6571a29d54574
Author:        Aniket Gattani <aniketgattani@google.com>
AuthorDate:    Sun, 03 May 2026 21:22:04 
Committer:     Peter Zijlstra <peterz@infradead.org>
CommitterDate: Tue, 05 May 2026 12:50:48 +02:00

sched/membarrier: Modernize membarrier_global_expedited with cleanup guards

Replace explicit lock/unlock and free calls with scoped guards and
automatic cleanup constructs.

Signed-off-by: Aniket Gattani <aniketgattani@google.com>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Link: https://patch.msgid.link/20260503212205.3714217-3-aniketgattani@google.com
---
 kernel/sched/membarrier.c | 21 ++++-----------------
 1 file changed, 4 insertions(+), 17 deletions(-)

diff --git a/kernel/sched/membarrier.c b/kernel/sched/membarrier.c
index 3d88e90..12b68a7 100644
--- a/kernel/sched/membarrier.c
+++ b/kernel/sched/membarrier.c
@@ -267,23 +267,19 @@ void membarrier_update_current_mm(struct mm_struct *next_mm)
 
 static int membarrier_global_expedited(void)
 {
+	cpumask_var_t __free(free_cpumask_var) tmpmask = CPUMASK_VAR_NULL;
 	int cpu;
-	cpumask_var_t tmpmask;
 
 	if (num_online_cpus() == 1)
 		return 0;
 
-	/*
-	 * Matches memory barriers after rq->curr modification in
-	 * scheduler.
-	 */
-	smp_mb();	/* system call entry is not a mb. */
-
 	if (!zalloc_cpumask_var(&tmpmask, GFP_KERNEL))
 		return -ENOMEM;
 
+	guard(mb)();
 	SERIALIZE_IPI();
-	cpus_read_lock();
+	guard(cpus_read_lock)();
+
 	rcu_read_lock();
 	for_each_online_cpu(cpu) {
 		struct task_struct *p;
@@ -319,15 +315,6 @@ static int membarrier_global_expedited(void)
 	smp_call_function_many(tmpmask, ipi_mb, NULL, 1);
 	preempt_enable();
 
-	free_cpumask_var(tmpmask);
-	cpus_read_unlock();
-
-	/*
-	 * Memory barrier on the caller thread _after_ we finished
-	 * waiting for the last IPI. Matches memory barriers before
-	 * rq->curr modification in scheduler.
-	 */
-	smp_mb();	/* exit from system call is not a mb */
 	return 0;
 }
 

  reply	other threads:[~2026-05-05 10:55 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-05-03 21:22 [PATCH v3 0/3] sched/membarrier: Use per-CPU mutexes for targeted commands Aniket Gattani
2026-05-03 21:22 ` [PATCH v3 1/3] " Aniket Gattani
2026-05-05 10:55   ` [tip: locking/core] " tip-bot2 for Aniket Gattani
2026-05-03 21:22 ` [PATCH v3 2/3] sched/membarrier: Modernize membarrier_global_expedited with cleanup guards Aniket Gattani
2026-05-05 10:55   ` tip-bot2 for Aniket Gattani [this message]
2026-05-03 21:22 ` [PATCH v3 3/3] selftests/membarrier: Add rseq stress test for CFS throttle interactions Aniket Gattani
2026-05-05 10:55   ` [tip: locking/core] " tip-bot2 for Aniket Gattani

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=177797853688.424702.1772606465208765988.tip-bot2@tip-bot2 \
    --to=tip-bot2@linutronix.de \
    --cc=aniketgattani@google.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-tip-commits@vger.kernel.org \
    --cc=peterz@infradead.org \
    --cc=x86@kernel.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

all inboxes | Powered by JetHome®