Received: by 2002:a05:6358:45e:b0:b5:b6eb:e1f9 with SMTP id 30csp332377rwe; Wed, 24 Aug 2022 01:34:34 -0700 (PDT) X-Google-Smtp-Source: AA6agR5NTc//y+rPHnE6zJ5cSHGvP5h933SJGXcZs5IscklyvehbVLK8nTwUSN8CCXWhACO5VSnZ X-Received: by 2002:a05:6a00:1943:b0:536:2bef:2f93 with SMTP id s3-20020a056a00194300b005362bef2f93mr21570182pfk.34.1661330074194; Wed, 24 Aug 2022 01:34:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1661330074; cv=none; d=google.com; s=arc-20160816; b=OeBUXEVEgpZFdrcgLz0e2h33g3H7Nx5ZEeTuDNv6268jlKgQWhf9zm9zHjhnGEkrcE xedWIydkg7gLsAqemFBEBzNOWvGcEnecUr3TwhSfDuP0ki73bN2oPl9vmkBvlf6reAlz XxIuEzG2ayjv3n8ve5afRQ3EpM0gWa/px1VPVIQjdm6IlgoZGH/Dqx+FSBIccKI9781n gKSf/x/VAzvC7sjwzEsA378JTOAmytI6CvitSMEhkSvbGXbqL92fhkI+Oz8cOXWlXnTr +xUXkxX9XnIySRI0e6yvJlWdyARLUUIJRLpcKqYFFCsQjut6VpPov3zH0B12D3FlMEcL 4Pag== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=6sL83Ah5J4Txh12rTADuAWsNxWsApjv5n3GbxKgC1I4=; b=fXWsx2dkYvKsGZ40OpNvuFWtCCS9eZzHJNwvIPxxYUv4yilzjOMeCwipo3rZ0FExYU fcKgxSV+WqE+segQrAGhMrVYLt83gqH/SPOKwINAtyj3f8Wa37y9MDxz1485hlEKZXPu baJCIXuFahNFezGzWTX6peb06DJfYetAZhto3eLZdKSvB7RYhAVQOF4anVegJJnrUwAl IC3mBtG2+sTMHEzTIT0G8Jc+K25zL31HRew4fnHAoBc+wSNUCabnRM4HYkzS4kSlISEv 20WM+flDWKsO+/ssCyJrg0dglx+ehU/5724hr1/dYeAF2HPiw0IZzT/MW3Jp8FX/dKN5 ExVg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bytedance-com.20210112.gappssmtp.com header.s=20210112 header.b=YyTOMGVC; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=bytedance.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id my11-20020a17090b4c8b00b001fb706e96adsi864489pjb.136.2022.08.24.01.34.23; Wed, 24 Aug 2022 01:34:34 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@bytedance-com.20210112.gappssmtp.com header.s=20210112 header.b=YyTOMGVC; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=bytedance.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235889AbiHXIU4 (ORCPT + 99 others); Wed, 24 Aug 2022 04:20:56 -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-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: 8bit X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org cgroup_psi() can't return psi_group for root cgroup, so we have many open code "psi = cgroup_ino(cgrp) == 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 --- 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); } -static inline struct psi_group *cgroup_psi(struct cgroup *cgrp) -{ - return cgrp->psi; -} - bool cgroup_psi_enabled(void); 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 struct seq_file; struct css_set; @@ -30,6 +31,11 @@ __poll_t psi_trigger_poll(void **trigger_ptr, struct file *file, poll_table *wait); #ifdef CONFIG_CGROUPS +static inline struct psi_group *cgroup_psi(struct cgroup *cgrp) +{ + return cgroup_ino(cgrp) == 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 = seq_css(seq)->cgroup; - struct psi_group *psi = cgroup_ino(cgrp) == 1 ? &psi_system : cgrp->psi; + struct psi_group *psi = cgroup_psi(cgrp); return psi_show(seq, psi, PSI_IO); } static int cgroup_memory_pressure_show(struct seq_file *seq, void *v) { struct cgroup *cgrp = seq_css(seq)->cgroup; - struct psi_group *psi = cgroup_ino(cgrp) == 1 ? &psi_system : cgrp->psi; + struct psi_group *psi = cgroup_psi(cgrp); return psi_show(seq, psi, PSI_MEM); } static int cgroup_cpu_pressure_show(struct seq_file *seq, void *v) { struct cgroup *cgrp = seq_css(seq)->cgroup; - struct psi_group *psi = cgroup_ino(cgrp) == 1 ? &psi_system : cgrp->psi; + struct psi_group *psi = cgroup_psi(cgrp); return psi_show(seq, psi, PSI_CPU); } @@ -3697,7 +3697,7 @@ static ssize_t cgroup_pressure_write(struct kernfs_open_file *of, char *buf, return -EBUSY; } - psi = cgroup_ino(cgrp) == 1 ? &psi_system : cgrp->psi; + psi = cgroup_psi(cgrp); new = 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 kernfs_open_file *of, static int cgroup_irq_pressure_show(struct seq_file *seq, void *v) { struct cgroup *cgrp = seq_css(seq)->cgroup; - struct psi_group *psi = cgroup_ino(cgrp) == 1 ? &psi_system : cgrp->psi; + struct psi_group *psi = cgroup_psi(cgrp); return psi_show(seq, psi, PSI_IRQ); } -- 2.37.2