From nobody Wed Apr 8 12:59:53 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0CEEFECAAD3 for ; Fri, 9 Sep 2022 14:01:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232073AbiIIOBI (ORCPT ); Fri, 9 Sep 2022 10:01:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58658 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231903AbiIIOAX (ORCPT ); Fri, 9 Sep 2022 10:00:23 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F0E607696A; Fri, 9 Sep 2022 07:00:21 -0700 (PDT) Date: Fri, 09 Sep 2022 14:00:19 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1662732020; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=vZiCFPj/s8c2noQK7Uibq8m0gp+0ROK/FKslf4sXX7M=; b=pYK/skg7xqhpd6NAn/ORFPlbZpJHZWFSGwXk64SO0ISMRctUhqBefBrJXqpq6PnqfTJL5M 2OX+7x6KgRugqlCOWOJmmRN0SQ4nJAYqBpYa2oHPXiIQqVad5Xhsg+acqPnEA1rusfvTzH e9evNa7LQtZuNws0lMfnInXOxQtz8HdYoDpVZuEca5N3GflcfabCrTspBkRdn3ObgINE+l hseF4UaoMl5JGhaP4MRcfwjtecJjHfLn+m3ooUs6jA/YqWwIIXKma7J2eClhfIVqn/QaOm Qq9umXwYoTUrkMANsH2THOQXapIm89Xqmy+aXGHvajnmCEiS9RW8MkpnpYw6Ow== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1662732020; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=vZiCFPj/s8c2noQK7Uibq8m0gp+0ROK/FKslf4sXX7M=; b=S5zC6Cv8a8OlXIYkumh1tD7BjLoOAf4G++QQVc8wl/3B4KxJUd87xn/9carqwzb+tCQAQo Awlw3SDhgGXuG0Cw== From: "tip-bot2 for Chengming Zhou" Sender: tip-bot2@linutronix.de Reply-to: linux-kernel@vger.kernel.org To: linux-tip-commits@vger.kernel.org Subject: [tip: sched/psi] sched/psi: Fix periodic aggregation shut off Cc: Chengming Zhou , "Peter Zijlstra (Intel)" , Johannes Weiner , x86@kernel.org, linux-kernel@vger.kernel.org In-Reply-To: <20220825164111.29534-2-zhouchengming@bytedance.com> References: <20220825164111.29534-2-zhouchengming@bytedance.com> MIME-Version: 1.0 Message-ID: <166273201939.401.5670565753865792420.tip-bot2@tip-bot2> Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The following commit has been merged into the sched/psi branch of tip: Commit-ID: c530a3c716b963625e43aa915e0de6b4d1ce8ad9 Gitweb: https://git.kernel.org/tip/c530a3c716b963625e43aa915e0de6b4d= 1ce8ad9 Author: Chengming Zhou AuthorDate: Fri, 26 Aug 2022 00:41:02 +08:00 Committer: Peter Zijlstra CommitterDate: Fri, 09 Sep 2022 11:08:30 +02:00 sched/psi: Fix periodic aggregation shut off We don't want to wake periodic aggregation work back up if the task change is the aggregation worker itself going to sleep, or we'll ping-pong forever. Previously, we would use psi_task_change() in psi_dequeue() when task going to sleep, so this check was put in psi_task_change(). But commit 4117cebf1a9f ("psi: Optimize task switch inside shared cgroups") defer task sleep handling to psi_task_switch(), won't go through psi_task_change() anymore. So this patch move this check to psi_task_switch(). Fixes: 4117cebf1a9f ("psi: Optimize task switch inside shared cgroups") Signed-off-by: Chengming Zhou Signed-off-by: Peter Zijlstra (Intel) Acked-by: Johannes Weiner Link: https://lore.kernel.org/r/20220825164111.29534-2-zhouchengming@byteda= nce.com --- kernel/sched/psi.c | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/kernel/sched/psi.c b/kernel/sched/psi.c index ecb4b4f..39463dc 100644 --- a/kernel/sched/psi.c +++ b/kernel/sched/psi.c @@ -796,7 +796,6 @@ void psi_task_change(struct task_struct *task, int clea= r, int set) { int cpu =3D task_cpu(task); struct psi_group *group; - bool wake_clock =3D true; void *iter =3D NULL; u64 now; =20 @@ -806,19 +805,9 @@ void psi_task_change(struct task_struct *task, int cle= ar, int set) psi_flags_change(task, clear, set); =20 now =3D cpu_clock(cpu); - /* - * Periodic aggregation shuts off if there is a period of no - * task changes, so we wake it back up if necessary. However, - * don't do this if the task change is the aggregation worker - * itself going to sleep, or we'll ping-pong forever. - */ - if (unlikely((clear & TSK_RUNNING) && - (task->flags & PF_WQ_WORKER) && - wq_worker_last_func(task) =3D=3D psi_avgs_work)) - wake_clock =3D false; =20 while ((group =3D iterate_groups(task, &iter))) - psi_group_change(group, cpu, clear, set, now, wake_clock); + psi_group_change(group, cpu, clear, set, now, true); } =20 void psi_task_switch(struct task_struct *prev, struct task_struct *next, @@ -854,6 +843,7 @@ void psi_task_switch(struct task_struct *prev, struct t= ask_struct *next, =20 if (prev->pid) { int clear =3D TSK_ONCPU, set =3D 0; + bool wake_clock =3D true; =20 /* * When we're going to sleep, psi_dequeue() lets us @@ -867,13 +857,23 @@ void psi_task_switch(struct task_struct *prev, struct= task_struct *next, clear |=3D TSK_MEMSTALL_RUNNING; if (prev->in_iowait) set |=3D TSK_IOWAIT; + + /* + * Periodic aggregation shuts off if there is a period of no + * task changes, so we wake it back up if necessary. However, + * don't do this if the task change is the aggregation worker + * itself going to sleep, or we'll ping-pong forever. + */ + if (unlikely((prev->flags & PF_WQ_WORKER) && + wq_worker_last_func(prev) =3D=3D psi_avgs_work)) + wake_clock =3D false; } =20 psi_flags_change(prev, clear, set); =20 iter =3D NULL; while ((group =3D iterate_groups(prev, &iter)) && group !=3D common) - psi_group_change(group, cpu, clear, set, now, true); + psi_group_change(group, cpu, clear, set, now, wake_clock); =20 /* * TSK_ONCPU is handled up to the common ancestor. If we're tasked @@ -882,7 +882,7 @@ void psi_task_switch(struct task_struct *prev, struct t= ask_struct *next, if (sleep) { clear &=3D ~TSK_ONCPU; for (; group; group =3D iterate_groups(prev, &iter)) - psi_group_change(group, cpu, clear, set, now, true); + psi_group_change(group, cpu, clear, set, now, wake_clock); } } }