From: I Hsin Cheng <richard120310@gmail.com>
To: yury.norov@gmail.com
Cc: linux@rasmusvillemoes.dk, jstultz@google.com, tglx@linutronix.de,
sboyd@kernel.org, linux-kernel@vger.kernel.org,
eleanor15x@gmail.com, visitorckw@gmail.com,
jserv@ccns.ncku.edu.tw, skhan@linuxfoundation.org,
linux-kernel-mentees@lists.linux.dev,
I Hsin Cheng <richard120310@gmail.com>
Subject: [RFC PATCH 2/2] clocksource: Use cpumask_first_but() in clocksource_verify_choose_cpus()
Date: Fri, 13 Jun 2025 11:34:47 +0800 [thread overview]
Message-ID: <20250613033447.3531709-3-richard120310@gmail.com> (raw)
In-Reply-To: <20250613033447.3531709-1-richard120310@gmail.com>
Utilize cpumask_first_but() helper instead of first using
cpumask_first() and then cpumask_next(). The logic is the same here,
using the new helper will make it more conscious.
Use bloat-o-meter to check the impact on code size, the result is the
same, does not have positive impact nor negative impact.
$ ./scripts/bloat-o-meter vmlinux_old vmlinux_new
add/remove: 0/0 grow/shrink: 0/0 up/down: 0/0 (0)
Function old new delta
Total: Before=22590709, After=22590709, chg +0.00%
Signed-off-by: I Hsin Cheng <richard120310@gmail.com>
---
Generally speaking, I think this is just a small tweak on the code,
making it more readable. However, no benefit in code size or performance
as the implementation behind the helper is in fact the same as the one
used here.
Maybe more tests should be done to ensure the change is solid, I hope to
seek some suggestions from everyone who has any ideas, or this is enough
then it's good.
Best regards,
I Hsin Cheng
---
kernel/time/clocksource.c | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)
diff --git a/kernel/time/clocksource.c b/kernel/time/clocksource.c
index bb48498ebb5a..12ff0c048570 100644
--- a/kernel/time/clocksource.c
+++ b/kernel/time/clocksource.c
@@ -323,9 +323,7 @@ static void clocksource_verify_choose_cpus(void)
return;
/* Make sure to select at least one CPU other than the current CPU. */
- cpu = cpumask_first(cpu_online_mask);
- if (cpu == smp_processor_id())
- cpu = cpumask_next(cpu, cpu_online_mask);
+ cpu = cpumask_first_but(cpu_online_mask, smp_processor_id());
if (WARN_ON_ONCE(cpu >= nr_cpu_ids))
return;
cpumask_set_cpu(cpu, &cpus_chosen);
--
2.43.0
next prev parent reply other threads:[~2025-06-13 3:35 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-06-13 3:34 [RFC PATCH 0/2] Introduce cpumask_first_but() and use cases I Hsin Cheng
2025-06-13 3:34 ` [RFC PATCH 1/2] cpumask: Introduce cpumask_first_but() I Hsin Cheng
2025-06-13 5:55 ` Kuan-Wei Chiu
2025-06-13 3:34 ` I Hsin Cheng [this message]
2025-06-13 5:02 ` [RFC PATCH 2/2] clocksource: Use cpumask_first_but() in clocksource_verify_choose_cpus() Yury Norov
2025-06-13 5:22 ` I Hsin Cheng
2025-06-16 14:34 ` Shuah Khan
2025-06-13 5:41 ` I Hsin Cheng
2025-06-13 6:00 ` I Hsin Cheng
2025-06-13 10:48 ` Thomas Gleixner
2025-06-13 11:37 ` I Hsin Cheng
2025-06-13 16:29 ` Yury Norov
2025-06-13 16:56 ` Thomas Gleixner
2025-06-16 14:38 ` Shuah Khan
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=20250613033447.3531709-3-richard120310@gmail.com \
--to=richard120310@gmail.com \
--cc=eleanor15x@gmail.com \
--cc=jserv@ccns.ncku.edu.tw \
--cc=jstultz@google.com \
--cc=linux-kernel-mentees@lists.linux.dev \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@rasmusvillemoes.dk \
--cc=sboyd@kernel.org \
--cc=skhan@linuxfoundation.org \
--cc=tglx@linutronix.de \
--cc=visitorckw@gmail.com \
--cc=yury.norov@gmail.com \
/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