From nobody Wed Apr 8 04:34:30 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 CD443C00140 for ; Wed, 24 Aug 2022 08:20:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235823AbiHXIU5 (ORCPT ); Wed, 24 Aug 2022 04:20:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58146 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235766AbiHXIUe (ORCPT ); Wed, 24 Aug 2022 04:20:34 -0400 Received: from mail-pl1-x634.google.com (mail-pl1-x634.google.com [IPv6:2607:f8b0:4864:20::634]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 051FA85FCD for ; Wed, 24 Aug 2022 01:20:27 -0700 (PDT) Received: by mail-pl1-x634.google.com with SMTP id p13so3662555pld.6 for ; Wed, 24 Aug 2022 01:20:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance-com.20210112.gappssmtp.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc; bh=6sL83Ah5J4Txh12rTADuAWsNxWsApjv5n3GbxKgC1I4=; b=YyTOMGVC+f89/pninVXkLZTBAdHTuaIb2YEzmTpr0YhcBAB/Fl4riv1XmMp9t7/IgX DZN8LVI7gNWRHy74o7YokuVqq1F2V9MeAgwS+n2bGk0A5lEZLVj/5H1yAyJLv1nZ8aHb cCgN54uvzD7TG8tNlDqC5/pFIp+TBxvWFiBMy39oBNOjwMY5v011r/CuvA2HDHuNeRMR RMjTW6HpfO2VHwkeuJ8BM5zgJ2mhEUyAvpwMZQXQ/dsOyRhz8klkfhkJCODvAkjs80Oz FcTC5cO5EP1KDIEJwLV+Y1QMPimq9b3+58Ho3Sp/QIX1vYUTP0i7a6U/bkzjV9Z3KsR7 oLHg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc; bh=6sL83Ah5J4Txh12rTADuAWsNxWsApjv5n3GbxKgC1I4=; b=nJDnhyWah+Yyd66MoQTbfp7myCQpnl7e0wu+dj50LoqpgoMxAAtv3HUiQ4xYJ5MieV zNJ52X7tYDyrcFGcmO0uVYVVUwYAsb/EkARPo6+AAsvNQzO9RtaheFKspH1y9TetMIRX Xnf6bFzLvYGLV9U7T/BISR3/nazuEmnt169AV58TgvzNMQXZ/oT/Ap/np2PCvVCRGSRA xPV5NNvBpFECu4pWG4s9P9B9dwYkU2NZIP5YyfnSNHTNeDal5x6by7UTigoRRb3HLjw+ vi/9dDye1MGo0wl682NpQctisAI3RknPFeJKoYDugIrXbRTxJFzVsQgbu5f6RPAq11nH MN/g== X-Gm-Message-State: ACgBeo1VbjNEgjE61a8paTO7LjtpSqDAcO9IY0X2EsOIyvRaw/72dXxW t9i2U41LkOIR6/aBIQamQGqsug== X-Google-Smtp-Source: AA6agR4WRBQ7a2V97gttdVqlEdAiRRGcv0hJ0GPlAD/yUyckgX7Do4diSR5lQ71J0urZXuz/wb5sxA== X-Received: by 2002:a17:90b:1a8d:b0:1fb:3ab0:a470 with SMTP id ng13-20020a17090b1a8d00b001fb3ab0a470mr7323838pjb.154.1661329226958; Wed, 24 Aug 2022 01:20:26 -0700 (PDT) Received: from C02CV1DAMD6P.bytedance.net ([139.177.225.244]) by smtp.gmail.com with ESMTPSA id q31-20020a635c1f000000b00421841943dfsm10486587pgb.12.2022.08.24.01.20.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 24 Aug 2022 01:20:26 -0700 (PDT) From: Chengming Zhou To: tj@kernel.org, hannes@cmpxchg.org, mkoutny@suse.com, surenb@google.com Cc: gregkh@linuxfoundation.org, corbet@lwn.net, mingo@redhat.com, peterz@infradead.org, songmuchun@bytedance.com, cgroups@vger.kernel.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, Chengming Zhou Subject: [PATCH v3 08/10] sched/psi: consolidate cgroup_psi() Date: Wed, 24 Aug 2022 16:18:27 +0800 Message-Id: <20220824081829.33748-9-zhouchengming@bytedance.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220824081829.33748-1-zhouchengming@bytedance.com> References: <20220824081829.33748-1-zhouchengming@bytedance.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" cgroup_psi() can't return psi_group for root cgroup, so we have many open code "psi =3D cgroup_ino(cgrp) =3D=3D 1 ? &psi_system : cgrp->psi". This patch move cgroup_psi() definition to , in which we can return psi_system for root cgroup, so can handle all cgroups. Signed-off-by: Chengming Zhou Acked-by: Johannes Weiner --- include/linux/cgroup.h | 5 ----- include/linux/psi.h | 6 ++++++ kernel/cgroup/cgroup.c | 10 +++++----- 3 files changed, 11 insertions(+), 10 deletions(-) diff --git a/include/linux/cgroup.h b/include/linux/cgroup.h index 7ed1fa7a6fc8..3c48753f2949 100644 --- a/include/linux/cgroup.h +++ b/include/linux/cgroup.h @@ -682,11 +682,6 @@ static inline void pr_cont_cgroup_path(struct cgroup *= cgrp) pr_cont_kernfs_path(cgrp->kn); } =20 -static inline struct psi_group *cgroup_psi(struct cgroup *cgrp) -{ - return cgrp->psi; -} - bool cgroup_psi_enabled(void); =20 static inline void cgroup_init_kthreadd(void) diff --git a/include/linux/psi.h b/include/linux/psi.h index fffd229fbf19..362a74ca1d3b 100644 --- a/include/linux/psi.h +++ b/include/linux/psi.h @@ -7,6 +7,7 @@ #include #include #include +#include =20 struct seq_file; struct css_set; @@ -30,6 +31,11 @@ __poll_t psi_trigger_poll(void **trigger_ptr, struct fil= e *file, poll_table *wait); =20 #ifdef CONFIG_CGROUPS +static inline struct psi_group *cgroup_psi(struct cgroup *cgrp) +{ + return cgroup_ino(cgrp) =3D=3D 1 ? &psi_system : cgrp->psi; +} + int psi_cgroup_alloc(struct cgroup *cgrp); void psi_cgroup_free(struct cgroup *cgrp); void cgroup_move_task(struct task_struct *p, struct css_set *to); diff --git a/kernel/cgroup/cgroup.c b/kernel/cgroup/cgroup.c index 8540878469e6..cc228235ce38 100644 --- a/kernel/cgroup/cgroup.c +++ b/kernel/cgroup/cgroup.c @@ -3657,21 +3657,21 @@ static int cpu_stat_show(struct seq_file *seq, void= *v) static int cgroup_io_pressure_show(struct seq_file *seq, void *v) { struct cgroup *cgrp =3D seq_css(seq)->cgroup; - struct psi_group *psi =3D cgroup_ino(cgrp) =3D=3D 1 ? &psi_system : cgrp-= >psi; + struct psi_group *psi =3D cgroup_psi(cgrp); =20 return psi_show(seq, psi, PSI_IO); } static int cgroup_memory_pressure_show(struct seq_file *seq, void *v) { struct cgroup *cgrp =3D seq_css(seq)->cgroup; - struct psi_group *psi =3D cgroup_ino(cgrp) =3D=3D 1 ? &psi_system : cgrp-= >psi; + struct psi_group *psi =3D cgroup_psi(cgrp); =20 return psi_show(seq, psi, PSI_MEM); } static int cgroup_cpu_pressure_show(struct seq_file *seq, void *v) { struct cgroup *cgrp =3D seq_css(seq)->cgroup; - struct psi_group *psi =3D cgroup_ino(cgrp) =3D=3D 1 ? &psi_system : cgrp-= >psi; + struct psi_group *psi =3D cgroup_psi(cgrp); =20 return psi_show(seq, psi, PSI_CPU); } @@ -3697,7 +3697,7 @@ static ssize_t cgroup_pressure_write(struct kernfs_op= en_file *of, char *buf, return -EBUSY; } =20 - psi =3D cgroup_ino(cgrp) =3D=3D 1 ? &psi_system : cgrp->psi; + psi =3D cgroup_psi(cgrp); new =3D psi_trigger_create(psi, buf, res); if (IS_ERR(new)) { cgroup_put(cgrp); @@ -3735,7 +3735,7 @@ static ssize_t cgroup_cpu_pressure_write(struct kernf= s_open_file *of, static int cgroup_irq_pressure_show(struct seq_file *seq, void *v) { struct cgroup *cgrp =3D seq_css(seq)->cgroup; - struct psi_group *psi =3D cgroup_ino(cgrp) =3D=3D 1 ? &psi_system : cgrp-= >psi; + struct psi_group *psi =3D cgroup_psi(cgrp); =20 return psi_show(seq, psi, PSI_IRQ); } --=20 2.37.2