* [PATCH] clocksource: Utilize cpumask_next_wrap() to shrink code size @ 2025-06-11 10:45 I Hsin Cheng 2025-06-11 18:35 ` John Stultz 0 siblings, 1 reply; 8+ messages in thread From: I Hsin Cheng @ 2025-06-11 10:45 UTC (permalink / raw) To: jstultz Cc: tglx, sboyd, linux-kernel, jserv, skhan, linux-kernel-mentees, I Hsin Cheng 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 ^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [PATCH] clocksource: Utilize cpumask_next_wrap() to shrink code size 2025-06-11 10:45 [PATCH] clocksource: Utilize cpumask_next_wrap() to shrink code size I Hsin Cheng @ 2025-06-11 18:35 ` John Stultz 2025-06-11 19:04 ` Yury Norov 0 siblings, 1 reply; 8+ messages in thread From: John Stultz @ 2025-06-11 18:35 UTC (permalink / raw) To: I Hsin Cheng, Yury Norov Cc: tglx, sboyd, linux-kernel, jserv, skhan, linux-kernel-mentees On Wed, Jun 11, 2025 at 3:45 AM I Hsin Cheng <richard120310@gmail.com> wrote: > > 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); > } I think Yury submitted the same change here recently: https://lore.kernel.org/lkml/20250607141106.563924-3-yury.norov@gmail.com/ Though, I think he has another iteration needed as Thomas had feedback on the subject line. The bloat-o-meter data is a nice inclusion here! Yury: Would you be open to adapting I Hsin Cheng's commit message into yours and adding them as co-author via the Co-developed-by: tag? (Assuming I Hsin Cheng agrees - See Documentation/process/submitting-patches.rst for how to do this properly). thanks -john ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] clocksource: Utilize cpumask_next_wrap() to shrink code size 2025-06-11 18:35 ` John Stultz @ 2025-06-11 19:04 ` Yury Norov 2025-06-12 7:45 ` I Hsin Cheng 0 siblings, 1 reply; 8+ messages in thread From: Yury Norov @ 2025-06-11 19:04 UTC (permalink / raw) To: John Stultz Cc: I Hsin Cheng, tglx, sboyd, linux-kernel, jserv, skhan, linux-kernel-mentees On Wed, Jun 11, 2025 at 11:35:13AM -0700, John Stultz wrote: > On Wed, Jun 11, 2025 at 3:45 AM I Hsin Cheng <richard120310@gmail.com> wrote: > > > > 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); > > } > > I think Yury submitted the same change here recently: > https://lore.kernel.org/lkml/20250607141106.563924-3-yury.norov@gmail.com/ > > Though, I think he has another iteration needed as Thomas had feedback > on the subject line. > > The bloat-o-meter data is a nice inclusion here! > > Yury: Would you be open to adapting I Hsin Cheng's commit message into > yours and adding them as co-author via the Co-developed-by: tag? > (Assuming I Hsin Cheng agrees - See > Documentation/process/submitting-patches.rst for how to do this > properly). Yeah, bloat-o-meter report is good enough to add co-developed-by tag. I Hsin, do you agree? ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] clocksource: Utilize cpumask_next_wrap() to shrink code size 2025-06-11 19:04 ` Yury Norov @ 2025-06-12 7:45 ` I Hsin Cheng 2025-06-12 15:33 ` Yury Norov 0 siblings, 1 reply; 8+ messages in thread From: I Hsin Cheng @ 2025-06-12 7:45 UTC (permalink / raw) To: Yury Norov Cc: John Stultz, tglx, sboyd, linux-kernel, jserv, skhan, linux-kernel-mentees On Wed, Jun 11, 2025 at 03:04:42PM -0400, Yury Norov wrote: > On Wed, Jun 11, 2025 at 11:35:13AM -0700, John Stultz wrote: > > On Wed, Jun 11, 2025 at 3:45 AM I Hsin Cheng <richard120310@gmail.com> wrote: > > > > > > 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); > > > } > > > > I think Yury submitted the same change here recently: > > https://lore.kernel.org/lkml/20250607141106.563924-3-yury.norov@gmail.com/ > > > > Though, I think he has another iteration needed as Thomas had feedback > > on the subject line. > > > > The bloat-o-meter data is a nice inclusion here! > > > > Yury: Would you be open to adapting I Hsin Cheng's commit message into > > yours and adding them as co-author via the Co-developed-by: tag? > > (Assuming I Hsin Cheng agrees - See > > Documentation/process/submitting-patches.rst for how to do this > > properly). > > Yeah, bloat-o-meter report is good enough to add co-developed-by tag. > I Hsin, do you agree? Sure thing, so do I need to apply the tag myself or we'll follow Yury's patch work? Best regards, I Hsin Cheng ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] clocksource: Utilize cpumask_next_wrap() to shrink code size 2025-06-12 7:45 ` I Hsin Cheng @ 2025-06-12 15:33 ` Yury Norov 2025-06-13 5:13 ` Yury Norov 0 siblings, 1 reply; 8+ messages in thread From: Yury Norov @ 2025-06-12 15:33 UTC (permalink / raw) To: I Hsin Cheng Cc: John Stultz, tglx, sboyd, linux-kernel, jserv, skhan, linux-kernel-mentees On Thu, Jun 12, 2025 at 03:45:36PM +0800, I Hsin Cheng wrote: > On Wed, Jun 11, 2025 at 03:04:42PM -0400, Yury Norov wrote: > > On Wed, Jun 11, 2025 at 11:35:13AM -0700, John Stultz wrote: > > > On Wed, Jun 11, 2025 at 3:45 AM I Hsin Cheng <richard120310@gmail.com> wrote: > > > > > > > > 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); > > > > } > > > > > > I think Yury submitted the same change here recently: > > > https://lore.kernel.org/lkml/20250607141106.563924-3-yury.norov@gmail.com/ > > > > > > Though, I think he has another iteration needed as Thomas had feedback > > > on the subject line. > > > > > > The bloat-o-meter data is a nice inclusion here! > > > > > > Yury: Would you be open to adapting I Hsin Cheng's commit message into > > > yours and adding them as co-author via the Co-developed-by: tag? > > > (Assuming I Hsin Cheng agrees - See > > > Documentation/process/submitting-patches.rst for how to do this > > > properly). > > > > Yeah, bloat-o-meter report is good enough to add co-developed-by tag. > > I Hsin, do you agree? > > Sure thing, so do I need to apply the tag myself or we'll follow Yury's > patch work? I'll send v2 and include your results. ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] clocksource: Utilize cpumask_next_wrap() to shrink code size 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 0 siblings, 2 replies; 8+ messages in thread From: Yury Norov @ 2025-06-13 5:13 UTC (permalink / raw) To: I Hsin Cheng Cc: John Stultz, tglx, sboyd, linux-kernel, jserv, skhan, linux-kernel-mentees > > > > I think Yury submitted the same change here recently: > > > > https://lore.kernel.org/lkml/20250607141106.563924-3-yury.norov@gmail.com/ > > > > > > > > Though, I think he has another iteration needed as Thomas had feedback > > > > on the subject line. > > > > > > > > The bloat-o-meter data is a nice inclusion here! > > > > > > > > Yury: Would you be open to adapting I Hsin Cheng's commit message into > > > > yours and adding them as co-author via the Co-developed-by: tag? > > > > (Assuming I Hsin Cheng agrees - See > > > > Documentation/process/submitting-patches.rst for how to do this > > > > properly). > > > > > > Yeah, bloat-o-meter report is good enough to add co-developed-by tag. > > > I Hsin, do you agree? > > > > Sure thing, so do I need to apply the tag myself or we'll follow Yury's > > patch work? > > I'll send v2 and include your results. John, FYI. I Hsing submitted another patch that duplicates this series. You're in CC, but just in case: https://lore.kernel.org/all/20250613033447.3531709-1-richard120310@gmail.com/ I think it's pretty disgusting. I will not make him co-author, and will not give any credit for this work. Thanks, Yury ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] clocksource: Utilize cpumask_next_wrap() to shrink code size 2025-06-13 5:13 ` Yury Norov @ 2025-06-13 5:25 ` I Hsin Cheng 2025-06-13 5:29 ` I Hsin Cheng 1 sibling, 0 replies; 8+ messages in thread From: I Hsin Cheng @ 2025-06-13 5:25 UTC (permalink / raw) To: Yury Norov Cc: John Stultz, tglx, sboyd, linux-kernel, jserv, skhan, linux-kernel-mentees On Fri, Jun 13, 2025 at 01:13:38AM -0400, Yury Norov wrote: > > > > > I think Yury submitted the same change here recently: > > > > > https://lore.kernel.org/lkml/20250607141106.563924-3-yury.norov@gmail.com/ > > > > > > > > > > Though, I think he has another iteration needed as Thomas had feedback > > > > > on the subject line. > > > > > > > > > > The bloat-o-meter data is a nice inclusion here! > > > > > > > > > > Yury: Would you be open to adapting I Hsin Cheng's commit message into > > > > > yours and adding them as co-author via the Co-developed-by: tag? > > > > > (Assuming I Hsin Cheng agrees - See > > > > > Documentation/process/submitting-patches.rst for how to do this > > > > > properly). > > > > > > > > Yeah, bloat-o-meter report is good enough to add co-developed-by tag. > > > > I Hsin, do you agree? > > > > > > Sure thing, so do I need to apply the tag myself or we'll follow Yury's > > > patch work? > > > > I'll send v2 and include your results. > > John, FYI. > > I Hsing submitted another patch that duplicates this series. You're in > CC, but just in case: > > https://lore.kernel.org/all/20250613033447.3531709-1-richard120310@gmail.com/ > > I think it's pretty disgusting. I will not make him co-author, and > will not give any credit for this work. > > Thanks, > Yury I'm really sorry for this, I really didn't notice others have already send the patches. I didn't mean to copy others work on purpose, I am very sorry. Thanks, I Hsin Cheng. ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] clocksource: Utilize cpumask_next_wrap() to shrink code size 2025-06-13 5:13 ` Yury Norov 2025-06-13 5:25 ` I Hsin Cheng @ 2025-06-13 5:29 ` I Hsin Cheng 1 sibling, 0 replies; 8+ messages in thread From: I Hsin Cheng @ 2025-06-13 5:29 UTC (permalink / raw) To: Yury Norov Cc: John Stultz, tglx, sboyd, linux-kernel, jserv, skhan, linux-kernel-mentees On Fri, Jun 13, 2025 at 01:13:38AM -0400, Yury Norov wrote: > > > > > I think Yury submitted the same change here recently: > > > > > https://lore.kernel.org/lkml/20250607141106.563924-3-yury.norov@gmail.com/ > > > > > > > > > > Though, I think he has another iteration needed as Thomas had feedback > > > > > on the subject line. > > > > > > > > > > The bloat-o-meter data is a nice inclusion here! > > > > > > > > > > Yury: Would you be open to adapting I Hsin Cheng's commit message into > > > > > yours and adding them as co-author via the Co-developed-by: tag? > > > > > (Assuming I Hsin Cheng agrees - See > > > > > Documentation/process/submitting-patches.rst for how to do this > > > > > properly). > > > > > > > > Yeah, bloat-o-meter report is good enough to add co-developed-by tag. > > > > I Hsin, do you agree? > > > > > > Sure thing, so do I need to apply the tag myself or we'll follow Yury's > > > patch work? > > > > I'll send v2 and include your results. > > John, FYI. > > I Hsing submitted another patch that duplicates this series. You're in > CC, but just in case: > > https://lore.kernel.org/all/20250613033447.3531709-1-richard120310@gmail.com/ > > I think it's pretty disgusting. I will not make him co-author, and > will not give any credit for this work. > > Thanks, > Yury I just realized your patch series already does that, I didn't check on other patches, I'm sorry, I should've been more careful on that, not just looking at the only patch in the link. Hope you can forgive me, I really have no offense on that and didn't mean to do it. Best regards, I Hsin Cheng ^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2025-06-13 5:30 UTC | newest] Thread overview: 8+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2025-06-11 10:45 [PATCH] clocksource: Utilize cpumask_next_wrap() to shrink code size I Hsin Cheng 2025-06-11 18:35 ` 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
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox