public inbox for stable@vger.kernel.org
 help / color / mirror / Atom feed
From: "Ionut Nechita (Wind River)" <ionut.nechita@windriver.com>
To: stable@vger.kernel.org
Cc: frederic@kernel.org, tglx@linutronix.de,
	linux-kernel@vger.kernel.org, rdunlap@infradead.org,
	ptesarik@suse.com, Ionut Nechita <ionut.nechita@windriver.com>
Subject: [PATCH v2 6.12.y 6/7] timers/migration: Remove locking on group connection
Date: Sat, 21 Mar 2026 12:24:39 +0200	[thread overview]
Message-ID: <20260321102440.27782-7-ionut.nechita@windriver.com> (raw)
In-Reply-To: <20260321102440.27782-1-ionut.nechita@windriver.com>

From: Ionut Nechita <ionut.nechita@windriver.com>

From: Frederic Weisbecker <frederic@kernel.org>

commit fa9620355d4192200f15cb3d97c6eb9c02442249 upstream.

Initializing the tmc's group, the group's number of children and the
group's parent can all be done without locking because:

  1) Reading the group's parent and its group mask is done locklessly.

  2) The connections prepared for a given CPU hierarchy are visible to the
     target CPU once online, thanks to the CPU hotplug enforced memory
     ordering.

  3) In case of a newly created upper level, the new root and its
     connections and initialization are made visible by the CPU which made
     the connections. When that CPUs goes idle in the future, the new link
     is published by tmigr_inactive_up() through the atomic RmW on
     ->migr_state.

  4) If CPUs were still walking up the active hierarchy, they could observe
     the new root earlier. In this case the ordering is enforced by an
     early initialization of the group mask and by barriers that maintain
     address dependency as explained in:

     b729cc1ec21a ("timers/migration: Fix another race between hotplug and idle entry/exit")
     de3ced72a792 ("timers/migration: Enforce group initialization visibility to tree walkers")

  5) Timers are propagated by a chain of group locking from the bottom to
     the top. And while doing so, the tree also propagates groups links
     and initialization. Therefore remote expiration, which also relies
     on group locking, will observe those links and initialization while
     holding the root lock before walking the tree remotely and update
     remote timers. This is especially important for migrators in the
     active hierarchy that may observe the new root early.

Therefore the locking is unnecessary at initialization. If anything, it
just brings confusion. Remove it.

Signed-off-by: Frederic Weisbecker <frederic@kernel.org>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Link: https://patch.msgid.link/20251024132536.39841-3-frederic@kernel.org
---
 kernel/time/timer_migration.c | 10 ----------
 1 file changed, 10 deletions(-)

diff --git a/kernel/time/timer_migration.c b/kernel/time/timer_migration.c
index 1e371f1fdc86c..5f8aef94ca0f7 100644
--- a/kernel/time/timer_migration.c
+++ b/kernel/time/timer_migration.c
@@ -1573,9 +1573,6 @@ static void tmigr_connect_child_parent(struct tmigr_group *child,
 {
 	struct tmigr_walk data;
 
-	raw_spin_lock_irq(&child->lock);
-	raw_spin_lock_nested(&parent->lock, SINGLE_DEPTH_NESTING);
-
 	if (activate) {
 		/*
 		 * @child is the old top and @parent the new one. In this
@@ -1596,9 +1593,6 @@ static void tmigr_connect_child_parent(struct tmigr_group *child,
 	 */
 	smp_store_release(&child->parent, parent);
 
-	raw_spin_unlock(&parent->lock);
-	raw_spin_unlock_irq(&child->lock);
-
 	trace_tmigr_connect_child_parent(child);
 
 	if (!activate)
@@ -1695,13 +1689,9 @@ static int tmigr_setup_groups(unsigned int cpu, unsigned int node)
 		if (i == 0) {
 			struct tmigr_cpu *tmc = per_cpu_ptr(&tmigr_cpu, cpu);
 
-			raw_spin_lock_irq(&group->lock);
-
 			tmc->tmgroup = group;
 			tmc->groupmask = BIT(group->num_children++);
 
-			raw_spin_unlock_irq(&group->lock);
-
 			trace_tmigr_connect_cpu_parent(tmc);
 
 			/* There are no children that need to be connected */
-- 
2.53.0


  parent reply	other threads:[~2026-03-21 10:25 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-03-21 10:24 [PATCH v2 6.12.y 0/7] timers/migration: Backport fixes and cleanups from mainline Ionut Nechita (Wind River)
2026-03-21 10:24 ` [PATCH v2 6.12.y 1/7] timer/migration: Fix kernel-doc warnings for union tmigr_state Ionut Nechita (Wind River)
2026-03-21 10:24 ` [PATCH v2 6.12.y 2/7] timers/migration: Annotate accesses to ignore flag Ionut Nechita (Wind River)
2026-03-21 11:03   ` Greg KH
2026-03-24  7:40     ` Ionut Nechita (Sunlight Linux)
2026-03-21 10:24 ` [PATCH v2 6.12.y 3/7] timers/migration: Simplify top level detection on group setup Ionut Nechita (Wind River)
2026-03-21 10:24 ` [PATCH v2 6.12.y 4/7] timers/migration: Clean up the loop in tmigr_quick_check() Ionut Nechita (Wind River)
2026-03-21 10:24 ` [PATCH v2 6.12.y 5/7] timers/migration: Convert "while" loops to use "for" Ionut Nechita (Wind River)
2026-03-21 10:24 ` Ionut Nechita (Wind River) [this message]
2026-03-21 10:24 ` [PATCH v2 6.12.y 7/7] timers/migration: Fix imbalanced NUMA trees Ionut Nechita (Wind River)

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=20260321102440.27782-7-ionut.nechita@windriver.com \
    --to=ionut.nechita@windriver.com \
    --cc=frederic@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=ptesarik@suse.com \
    --cc=rdunlap@infradead.org \
    --cc=stable@vger.kernel.org \
    --cc=tglx@linutronix.de \
    /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