Received: by 2002:a05:6358:489b:b0:bb:da1:e618 with SMTP id x27csp2012611rwn; Fri, 9 Sep 2022 07:23:01 -0700 (PDT) X-Google-Smtp-Source: AA6agR4fMtz4FAN6q1XSn6ecMQr2jvF1Ro2GOMqRX/GRD+YFMl3m+WBuFk9UG67WclJg0rOOA0sW X-Received: by 2002:a63:201c:0:b0:434:8bd6:87e1 with SMTP id g28-20020a63201c000000b004348bd687e1mr12673521pgg.394.1662733381070; Fri, 09 Sep 2022 07:23:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1662733381; cv=none; d=google.com; s=arc-20160816; b=QKXoSTVd9TtR2Eseqx1ZH9Z08QiAUEZJTxazbtOr2qspaQC6JmBPaUPwfJ+kFlcXsJ eeqCzhVVzcR6sU4W4IX1idpCdT+j8jBynExDpgBqQoMIFqnadVF20AoTWPmvOjsi1pQe c0zsIcuePaywQlHzKWXwbcAIRacol88aaBq4C30oRe1suY+r+/6j65978usHxUei5mqt gBetIBWW2mqWRLLVWrayNjJf27G8yp7wBrazizyaQNZsufa1t0BeG9EFb1gZ9ymsImgz I49x+oLTPzrKefMPuryoBppQXH+2AsZUc6Kc5d+MEZGjLdCvKGlcnjly4+m2W9i/v0fq NOJA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:robot-unsubscribe :robot-id:message-id:mime-version:references:in-reply-to:cc:subject :to:reply-to:sender:from:dkim-signature:dkim-signature:date; bh=ztIrvO7wvHDRKyT/Q36jHpGmiAxD4bEGWdq/LvPxpq4=; b=QOsvaoK0ym5S5FS5c7nbIve7Zu0fSIOuqXRuYsgDu4NugQCBKLVf+5n7Hh+e21bjtW Z+0I4g5qn/dOCzsB/7ViFGVly1NqrZDxhO6TfSpRkZEHpJU4rr7aJR4T8xfRjolC258o 1v3fhmJ3bUM+6l7V42k4nqBAwUtovJ/qBT3o+hoINBrKsCO+jlbJvhhOLIbpI8QEJPdi xiK65d5GFmS69BDkIBblr2z2Lo4/Nc05jcxhxmwy5GQbgudYxz/bUhDo6oSS1u4BnOkj d1z7omdLPOUg10iOyZBPXkJk5ULMQMSLva7m/udDKfXO/smnPyATsvkJsY8HBq7SMrEc GBDQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=Ki1offbB; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=UWTihh55; 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=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id j3-20020a170903028300b00176a87603dbsi700118plr.156.2022.09.09.07.22.49; Fri, 09 Sep 2022 07:23:01 -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=@linutronix.de header.s=2020 header.b=Ki1offbB; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=UWTihh55; 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=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231730AbiIIOA3 (ORCPT + 99 others); Fri, 9 Sep 2022 10:00:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58018 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231538AbiIIOAP (ORCPT ); Fri, 9 Sep 2022 10:00:15 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 184F659250; Fri, 9 Sep 2022 07:00:14 -0700 (PDT) Date: Fri, 09 Sep 2022 14:00:11 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1662732012; 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=ztIrvO7wvHDRKyT/Q36jHpGmiAxD4bEGWdq/LvPxpq4=; b=Ki1offbBWtu+FjzGd4p4UKKzFeDJ6Z8OI2TCsqCnEXaREheZp6CwSbDjTUBy/moIz1Bi/h V3+JbKP52uhgMqOlIs5/eAzpXCbRVjkObw9i650AfPO09Alt4Kx9sBx1hq3D4TpFqblkE8 AlmFOruQou45hSLoOdDZYlAbQjHSoyduc9GWmdwSHIn9uXYxDFevZqLO47XCA0timDGWg4 BPLFhjIuWE7HY3Sy76NRHQ/gu9OaIA0OgeG07k+lCHVKHc074aqMhdhKp7xeXwzS+j7aL6 IEX26ZnPHurUXWT+lrLk61krbWxuPPr95QDnsNACKwn/v86+tpfpAmHAbu3eTg== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1662732012; 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=ztIrvO7wvHDRKyT/Q36jHpGmiAxD4bEGWdq/LvPxpq4=; b=UWTihh551aDRVuKbfTkciXCHWHEb0u3B6gQXF8CqGNfI4rRBcagQsanAfamLwGJjudJ/a4 deNFVMXT8W8dubBw== 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: Consolidate cgroup_psi() Cc: Chengming Zhou , "Peter Zijlstra (Intel)" , Johannes Weiner , x86@kernel.org, linux-kernel@vger.kernel.org In-Reply-To: <20220825164111.29534-9-zhouchengming@bytedance.com> References: <20220825164111.29534-9-zhouchengming@bytedance.com> MIME-Version: 1.0 Message-ID: <166273201151.401.3919626881356716563.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: 7bit X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham 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 The following commit has been merged into the sched/psi branch of tip: Commit-ID: 57899a6610e67ba26fa3251ebbef4a5ed21efc5d Gitweb: https://git.kernel.org/tip/57899a6610e67ba26fa3251ebbef4a5ed21efc5d Author: Chengming Zhou AuthorDate: Fri, 26 Aug 2022 00:41:09 +08:00 Committer: Peter Zijlstra CommitterDate: Fri, 09 Sep 2022 11:08:33 +02:00 sched/psi: Consolidate cgroup_psi() 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 Signed-off-by: Peter Zijlstra (Intel) Acked-by: Johannes Weiner Link: https://lore.kernel.org/r/20220825164111.29534-9-zhouchengming@bytedance.com --- 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 b0914aa..80cb970 100644 --- a/include/linux/cgroup.h +++ b/include/linux/cgroup.h @@ -673,11 +673,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 fffd229..362a74c 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 b46d39b..772b35d 100644 --- a/kernel/cgroup/cgroup.c +++ b/kernel/cgroup/cgroup.c @@ -3689,21 +3689,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); } @@ -3729,7 +3729,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); @@ -3767,7 +3767,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); }