From: I Hsin Cheng <richard120310@gmail.com>
To: jstultz@google.com
Cc: tglx@linutronix.de, sboyd@kernel.org,
linux-kernel@vger.kernel.org, jserv@ccns.ncku.edu.tw,
skhan@linuxfoundation.org, linux-kernel-mentees@lists.linux.dev,
I Hsin Cheng <richard120310@gmail.com>
Subject: [PATCH] clocksource: Utilize cpumask_next_wrap() to shrink code size
Date: Wed, 11 Jun 2025 18:45:06 +0800 [thread overview]
Message-ID: <20250611104506.2270561-1-richard120310@gmail.com> (raw)
Simplify the procedure of CPU random selection under
"clocksource_verify_choose_cpus()" with "cpumask_next_wrap()". The
logic is still the same but with this change it can shrink the code size
by 18 bytes and increase readability.
$ ./scripts/bloat-o-meter vmlinux_old vmlinux_new
add/remove: 0/0 grow/shrink: 0/1 up/down: 0/-18 (-18)
Function old new delta
clocksource_verify_percpu 1064 1046 -18
Signed-off-by: I Hsin Cheng <richard120310@gmail.com>
---
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..ab580873408b 100644
--- a/kernel/time/clocksource.c
+++ b/kernel/time/clocksource.c
@@ -343,9 +343,7 @@ static void clocksource_verify_choose_cpus(void)
*/
for (i = 1; i < n; i++) {
cpu = get_random_u32_below(nr_cpu_ids);
- cpu = cpumask_next(cpu - 1, cpu_online_mask);
- if (cpu >= nr_cpu_ids)
- cpu = cpumask_first(cpu_online_mask);
+ cpu = cpumask_next_wrap(cpu - 1, cpu_online_mask);
if (!WARN_ON_ONCE(cpu >= nr_cpu_ids))
cpumask_set_cpu(cpu, &cpus_chosen);
}
--
2.43.0
next reply other threads:[~2025-06-11 10:45 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-06-11 10:45 I Hsin Cheng [this message]
2025-06-11 18:35 ` [PATCH] clocksource: Utilize cpumask_next_wrap() to shrink code size John Stultz
2025-06-11 19:04 ` Yury Norov
2025-06-12 7:45 ` I Hsin Cheng
2025-06-12 15:33 ` Yury Norov
2025-06-13 5:13 ` Yury Norov
2025-06-13 5:25 ` I Hsin Cheng
2025-06-13 5:29 ` I Hsin Cheng
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=20250611104506.2270561-1-richard120310@gmail.com \
--to=richard120310@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=sboyd@kernel.org \
--cc=skhan@linuxfoundation.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