mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "tip-bot2 for Frederic Weisbecker" <tip-bot2@linutronix.de>
To: linux-tip-commits@vger.kernel.org
Cc: Frederic Weisbecker <frederic@kernel.org>,
	Thomas Gleixner <tglx@linutronix.de>,
	x86@kernel.org, linux-kernel@vger.kernel.org
Subject: [tip: timers/core] timers/migration: Convert "while" loops to use "for"
Date: Sat, 01 Nov 2025 19:41:27 -0000	[thread overview]
Message-ID: <176202608781.2601451.1432013530667416309.tip-bot2@tip-bot2> (raw)
In-Reply-To: <20251024132536.39841-2-frederic@kernel.org>

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

Commit-ID:     6c181b5667eea3e6564d334443536a5974190e15
Gitweb:        https://git.kernel.org/tip/6c181b5667eea3e6564d334443536a5974190e15
Author:        Frederic Weisbecker <frederic@kernel.org>
AuthorDate:    Fri, 24 Oct 2025 15:25:31 +02:00
Committer:     Thomas Gleixner <tglx@linutronix.de>
CommitterDate: Sat, 01 Nov 2025 20:38:24 +01:00

timers/migration: Convert "while" loops to use "for"

Both the "do while" and "while" loops in tmigr_setup_groups() eventually
mimic the behaviour of "for" loops.

Simplify accordingly.

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

diff --git a/kernel/time/timer_migration.c b/kernel/time/timer_migration.c
index c0c54dc..1e371f1 100644
--- a/kernel/time/timer_migration.c
+++ b/kernel/time/timer_migration.c
@@ -1642,22 +1642,23 @@ static void tmigr_connect_child_parent(struct tmigr_group *child,
 static int tmigr_setup_groups(unsigned int cpu, unsigned int node)
 {
 	struct tmigr_group *group, *child, **stack;
-	int top = 0, err = 0, i = 0;
+	int i, top = 0, err = 0;
 	struct list_head *lvllist;
 
 	stack = kcalloc(tmigr_hierarchy_levels, sizeof(*stack), GFP_KERNEL);
 	if (!stack)
 		return -ENOMEM;
 
-	do {
+	for (i = 0; i < tmigr_hierarchy_levels; i++) {
 		group = tmigr_get_group(cpu, node, i);
 		if (IS_ERR(group)) {
 			err = PTR_ERR(group);
+			i--;
 			break;
 		}
 
 		top = i;
-		stack[i++] = group;
+		stack[i] = group;
 
 		/*
 		 * When booting only less CPUs of a system than CPUs are
@@ -1667,16 +1668,18 @@ static int tmigr_setup_groups(unsigned int cpu, unsigned int node)
 		 * be different from tmigr_hierarchy_levels, contains only a
 		 * single group.
 		 */
-		if (group->parent || list_is_singular(&tmigr_level_list[i - 1]))
+		if (group->parent || list_is_singular(&tmigr_level_list[i]))
 			break;
+	}
 
-	} while (i < tmigr_hierarchy_levels);
-
-	/* Assert single root */
-	WARN_ON_ONCE(!err && !group->parent && !list_is_singular(&tmigr_level_list[top]));
+	/* Assert single root without parent */
+	if (WARN_ON_ONCE(i >= tmigr_hierarchy_levels))
+		return -EINVAL;
+	if (WARN_ON_ONCE(!err && !group->parent && !list_is_singular(&tmigr_level_list[top])))
+		return -EINVAL;
 
-	while (i > 0) {
-		group = stack[--i];
+	for (; i >= 0; i--) {
+		group = stack[i];
 
 		if (err < 0) {
 			list_del(&group->list);

  reply	other threads:[~2025-11-01 19:41 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-10-24 13:25 [PATCH 0/6] timers/migration: Fix NUMA trees + cleanups Frederic Weisbecker
2025-10-24 13:25 ` [PATCH 1/6] timers/migration: Convert "while" loops to use "for" Frederic Weisbecker
2025-11-01 19:41   ` tip-bot2 for Frederic Weisbecker [this message]
2025-10-24 13:25 ` [PATCH 2/6] timers/migration: Remove locking on group connection Frederic Weisbecker
2025-11-01 19:41   ` [tip: timers/core] " tip-bot2 for Frederic Weisbecker
2025-10-24 13:25 ` [PATCH 3/6] timers/migration: Fix imbalanced NUMA trees Frederic Weisbecker
2025-11-01 19:41   ` [tip: timers/core] " tip-bot2 for Frederic Weisbecker
2025-10-24 13:25 ` [PATCH 4/6] timers/migration: Assert that hotplug preparing CPU is part of stable active hierarchy Frederic Weisbecker
2025-11-01 19:41   ` [tip: timers/core] " tip-bot2 for Frederic Weisbecker
2025-10-24 13:25 ` [PATCH 5/6] timers/migration: Remove unused "cpu" parameter from tmigr_get_group() Frederic Weisbecker
2025-11-01 19:41   ` [tip: timers/core] " tip-bot2 for Frederic Weisbecker
2025-10-24 13:25 ` [PATCH 6/6] timers/migration: Remove dead code handling idle CPU checking for remote timers Frederic Weisbecker
2025-11-01 19:41   ` [tip: timers/core] " tip-bot2 for Frederic Weisbecker

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=176202608781.2601451.1432013530667416309.tip-bot2@tip-bot2 \
    --to=tip-bot2@linutronix.de \
    --cc=frederic@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-tip-commits@vger.kernel.org \
    --cc=tglx@linutronix.de \
    --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®