All of lore.kernel.org
 help / color / mirror / Atom feed
From: Usama Arif <usama.arif@linux.dev>
To: K Prateek Nayak <kprateek.nayak@amd.com>,
	bsegall@google.com, dietmar.eggemann@arm.com, hannes@cmpxchg.org,
	juri.lelli@redhat.com, linux-kernel@vger.kernel.org,
	mgorman@suse.de, mingo@redhat.com, peterz@infradead.org,
	rostedt@goodmis.org, surenb@google.com,
	vincent.guittot@linaro.org, vschneid@redhat.com,
	shakeel.butt@linux.dev, riel@surriel.com, kernel-team@meta.com
Subject: Re: [PATCH] sched/psi: use for_each_set_bit() in psi_group_change() task-count walk
Date: Wed, 15 Jul 2026 11:47:37 +0100	[thread overview]
Message-ID: <55f46ada-094d-410d-9d75-49c14ec612e8@linux.dev> (raw)
In-Reply-To: <abcc65d3-0c98-41e5-85c9-2abd5eaee308@amd.com>



On 15/07/2026 04:49, K Prateek Nayak wrote:
> Hello Usama,
> 
> On 7/14/2026 7:50 PM, Usama Arif wrote:
>> diff --git a/kernel/sched/psi.c b/kernel/sched/psi.c
>> index d9c9d9480a45..f5ae1ceb21a7 100644
>> --- a/kernel/sched/psi.c
>> +++ b/kernel/sched/psi.c
>> @@ -798,7 +798,8 @@ static void psi_group_change(struct psi_group *group, int cpu,
>>  			     u64 now, bool wake_clock)
>>  {
>>  	struct psi_group_cpu *groupc;
>> -	unsigned int t, m;
>> +	unsigned long clear_bits, set_bits;
>> +	unsigned int t;
>>  	u32 state_mask;
>>  
>>  	lockdep_assert_rq_held(cpu_rq(cpu));
>> @@ -824,9 +825,8 @@ static void psi_group_change(struct psi_group *group, int cpu,
>>  	 * The rest of the state mask is calculated based on the task
>>  	 * counts. Update those first, then construct the mask.
>>  	 */
>> -	for (t = 0, m = clear; m; m &= ~(1 << t), t++) {
>> -		if (!(m & (1 << t)))
>> -			continue;
>> +	clear_bits = clear;
> 
> nit.
> 
> Can't we convert the arguments to unsigned long instead of assigning
> them to these local variables?

I kind of prefer the explicit conversion. Also all the callers take int
instead of long. The printk would also change from %x to %lx.

The assignment itself should hopefully be free? The compiler hopefully
optimizes it away.

> 
> Apart form that, for_each_set_bit() is indeed much cleaner. Feel free
> to include:
> 
> Reviewed-by: K Prateek Nayak <kprateek.nayak@amd.com>
> 

Thanks for the review!

>> +	for_each_set_bit(t, &clear_bits, NR_PSI_TASK_COUNTS) {
>>  		if (groupc->tasks[t]) {
>>  			groupc->tasks[t]--;
>>  		} else if (!psi_bug) {
> 


  reply	other threads:[~2026-07-15 10:47 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-14 14:20 [PATCH] sched/psi: use for_each_set_bit() in psi_group_change() task-count walk Usama Arif
2026-07-15  3:49 ` K Prateek Nayak
2026-07-15 10:47   ` Usama Arif [this message]
2026-07-15 13:54 ` Johannes Weiner
2026-07-15 17:03   ` Usama Arif
2026-07-16 11:58     ` Johannes Weiner

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=55f46ada-094d-410d-9d75-49c14ec612e8@linux.dev \
    --to=usama.arif@linux.dev \
    --cc=bsegall@google.com \
    --cc=dietmar.eggemann@arm.com \
    --cc=hannes@cmpxchg.org \
    --cc=juri.lelli@redhat.com \
    --cc=kernel-team@meta.com \
    --cc=kprateek.nayak@amd.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mgorman@suse.de \
    --cc=mingo@redhat.com \
    --cc=peterz@infradead.org \
    --cc=riel@surriel.com \
    --cc=rostedt@goodmis.org \
    --cc=shakeel.butt@linux.dev \
    --cc=surenb@google.com \
    --cc=vincent.guittot@linaro.org \
    --cc=vschneid@redhat.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.