From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from out-179.mta0.migadu.com (out-179.mta0.migadu.com [91.218.175.179]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 95474431487 for ; Wed, 15 Jul 2026 10:47:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=91.218.175.179 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784112467; cv=none; b=baubXBN0XOlH3SRGB+V77LADki94hIMENnnC/cDm+frvuaQfzTO6cROFjjbMgu+8GyDqsyxW3t5a0lBHyGkxr1j3vZ2x1k29u6TanWoqKaZs1Qyezh+Hb2U3FFmFvItOT7mc3nJ+mOcGIuZ+8WI99sqaIWiyWc8Q8CMK0rdy8es= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784112467; c=relaxed/simple; bh=cBZLapoGSR/Ha/mk//e5pmPMVogmgB8xFaY3mmjgr9Q=; h=Message-ID:Date:MIME-Version:Subject:To:References:From: In-Reply-To:Content-Type; b=Nz1FsE4vyftiqeJFV3gxjqm4PBo2TU1mReEgCSGx8fURdH0WwyzJJdZIAearL1cdSvfdGesIKpiN7G9kd7gx0/lJMrgOQ12R11KyjfVpst/LoKZJ1np0JwwGqK4Tz1DYL+iUCHeRqZj0438XbLckV/QDq2nTzR0UP2phRr0lSQw= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b=iGCXxBs9; arc=none smtp.client-ip=91.218.175.179 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b="iGCXxBs9" Message-ID: <55f46ada-094d-410d-9d75-49c14ec612e8@linux.dev> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1784112460; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Koz6uWyEJHNfPpCepmJlgo8DPLftwsf5snbHEsvip8U=; b=iGCXxBs9+Mhq/O3p5Wx9EfjlyO6nsMVsFXf/LsrJQfH/RbboJF9RrPNNgQMs63RtNluz1+ 7oEPIsiqQ4vAvBrbLyHadF0anBfoccqhYapdSv4SQMH3oXNspInLjvZ8NXiI+O9kL25txx lJ+fiXiJPievRXhykO8ZgIsa5XXaTuM= Date: Wed, 15 Jul 2026 11:47:37 +0100 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Subject: Re: [PATCH] sched/psi: use for_each_set_bit() in psi_group_change() task-count walk To: K Prateek Nayak , 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 References: <20260714142057.181135-1-usama.arif@linux.dev> Content-Language: en-US X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Usama Arif In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Migadu-Flow: FLOW_OUT 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 > 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) { >