From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-qv1-f47.google.com (mail-qv1-f47.google.com [209.85.219.47]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 362233B8D42 for ; Tue, 3 Feb 2026 16:46:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.47 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770137195; cv=none; b=BjBVDjUKldgWPi1wiUip/0Gi1SJ/Jr9PC7SHV92gv7afhMTffyfRjeMtRJQe/rYt+Y8FP5rA453FqMKHqw+w/pYduIk723w7Wkjnw/qgKhyEYVYBi3yxRgoGP5WmtDe3kpJ/3P7BqjmeOIbQzdj80LgjQqMPOr8tX6qrhvXJFxY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770137195; c=relaxed/simple; bh=E2zJrof1IXDsYUYeAK4ER0PhGpZ3piLUa27e9d7jcY4=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=Ek+0YU3RP0/bZT/ci4VqSb5EA2uyPxjLD6tzDlovffQZD6zHAY1k9PPEp3As/83IiXgQpeMDwXeBx5qm0OYaTEQNX2J7g1VSxWp622L0ZOPv/0s3aPIfqupTSWKBtKJkL607TDdBP6YxaacONIUDxoqVw0N8LKmu0mr68jox8Mo= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=cmpxchg.org; spf=pass smtp.mailfrom=cmpxchg.org; dkim=pass (2048-bit key) header.d=cmpxchg.org header.i=@cmpxchg.org header.b=EQOFWs7F; arc=none smtp.client-ip=209.85.219.47 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=cmpxchg.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=cmpxchg.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=cmpxchg.org header.i=@cmpxchg.org header.b="EQOFWs7F" Received: by mail-qv1-f47.google.com with SMTP id 6a1803df08f44-88a2e3bd3cdso238566d6.0 for ; Tue, 03 Feb 2026 08:46:31 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cmpxchg.org; s=google; t=1770137191; x=1770741991; darn=vger.kernel.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=RjI0mbv0/R8vhQ7pdO5K6iq+O8h1z0X5g7nycLimXf4=; b=EQOFWs7FjsofjacVQ8o3oyRl4qauhiptThYaxlNT/6kE1Njvfgt84bIyjNn8QCyfuj BH0TJAn/FUCMIhMxWwUIe+tcJIeMsAd45Yrr+yLjWXEjSmdqXOS+Lb6e3ahQAm61Ifl2 /liLxTtzivFvl5Rzx5GiN4QEczqqPmUmMDxzh/focnOk4OF9zy4Pw8nhnDKN+CW/79np VGxO4K7hREMLIS0pCwvTHgcIgcoqGZLJJqMpGU0GTPtE31cb1tRiSNy6N6uC19Apoj+F 39K4/02ciYqLfDHCux6p2XkY0N67OFaOC1geWA1pLutlZA5vi5TNJ5GU60Pe54DEzX7w IXqA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1770137191; x=1770741991; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-gg:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=RjI0mbv0/R8vhQ7pdO5K6iq+O8h1z0X5g7nycLimXf4=; b=W9HAwN4bIzmypTUIjJPZsXwAKpxY6cZi5UmMq0hJ1HDebMVmSOUatmRJ++oO375MMW EMmJGuXgRSch/3AEsSK69UMhlUVWCIdlPiogYKd53KO562VbLS0+ezryzXp0qdNzg0nG Tli/AfY5qHKwXPfjrYb7GPl91ewRebdaOBQLuGwC8ZyUD1TE2vf2ot2Ll0IfOR3fpK1U vD1VNiZvWXklJBKXwZfuu0XvwjcyigW5BS37J5m1yMQaKXz3NT0hUFNI26Y4nA+W20EU /9IKPu0TKHg1d3r/JlLnuzEaaoCfyJHhZ60BGIa18WK4LooyxzbFPHF7W5rSDS+CwUGW c7rA== X-Gm-Message-State: AOJu0Yzwkn2avJBj6EMx7ZsJGWxUGE6QD+zMgLI1HI23cEzT5h/9Nqbi p9o9UMRdSaAiMzlp9HO1fqKabB5HC5mnppYjMY3zCuIKVc9N46Mc3FrXq5p+wQUvsr8= X-Gm-Gg: AZuq6aIv0q6PVY2Uwi0Je/FWTYQMg0H55Zguaqc0Upn6JN5jhvROMB5SRukR305O+Qd 9EKOcoDjP4utEoCWlrRa2og0GPV8YykKmZrcqg6Mit5vLz3z9FkNindwUyVSxECyBnTSOi3xxHb H2gS8tOa6VWvMgGV7++wN3wycSL/PMYcD13Z0ncJqN33I4fsA+68WstKFepgwfNpSZzdOGjsV4n VWrxGLRMb+pQFMKAb5PFICJJVb3ibApjz0KAyuybgcY+9tqCsdpEQzTRp1yVil1Jx/XYcnROSr/ klZGFTzB41ZA8YrWiy+Sl47bDFZ5JJYeTDwWUEV4LvYu7op+s+S3BUx1B1uZKGpKUi6oiHcfXeH mSol2oJfbkPnsy5ikiPKXc+uGdR1bleTmfr3MqG0IcOTYshEBNWGPSKds2ABErK/shfsvr8OUa9 xm3i5zdYkONg== X-Received: by 2002:a05:6214:4009:b0:894:7ddf:d4af with SMTP id 6a1803df08f44-895220f5bb4mr790066d6.6.1770137190882; Tue, 03 Feb 2026 08:46:30 -0800 (PST) Received: from localhost ([2603:7000:c00:1d00:365a:60ff:fe62:ff29]) by smtp.gmail.com with ESMTPSA id 6a1803df08f44-89521d3c513sm1136806d6.54.2026.02.03.08.46.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Feb 2026 08:46:30 -0800 (PST) Date: Tue, 3 Feb 2026 11:46:26 -0500 From: Johannes Weiner To: Zhan Xusheng Cc: linux-kernel@vger.kernel.org, linux-sched@vger.kernel.org, Zhan Xusheng Subject: Re: [PATCH] sched/psi: Skip CPUs with zero non-idle jiffies in per-cpu aggregation Message-ID: References: <20260203100007.22044-1-zhanxusheng@xiaomi.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20260203100007.22044-1-zhanxusheng@xiaomi.com> On Tue, Feb 03, 2026 at 06:00:07PM +0800, Zhan Xusheng wrote: > PSI per-cpu aggregation weights each CPU's contribution by its > non-idle time converted to jiffies. CPUs with zero non-idle jiffies > do not contribute to the weighted result, but are still processed in > the current implementation. > > Skip CPUs with zero non-idle jiffies early to avoid unnecessary > per-cpu arithmetic during aggregation. > > No functional change intended. > > Signed-off-by: Zhan Xusheng Makes sense. > --- > kernel/sched/psi.c | 7 +++++++ > 1 file changed, 7 insertions(+) > > diff --git a/kernel/sched/psi.c b/kernel/sched/psi.c > index 59fdb7ebbf22..ce2321793a67 100644 > --- a/kernel/sched/psi.c > +++ b/kernel/sched/psi.c > @@ -387,6 +387,13 @@ static void collect_percpu_times(struct psi_group *group, > changed_states |= cpu_changed_states; > > nonidle = nsecs_to_jiffies(times[PSI_NONIDLE]); > + /* > + * A CPU with zero non-idle jiffies does not contribute to the > + * weighted per-CPU aggregation. There is no need to include it > + * in deltas or total accumulation. > + */ > + if (!nonidle) > + continue; You could save the nsecs_to_jiffies() dance as well by doing: if (!(cpu_changed_states & (1 << PSI_NONIDLE))) coninue;