Received: by 2002:a05:6358:45e:b0:b5:b6eb:e1f9 with SMTP id 30csp323950rwe; Wed, 24 Aug 2022 01:22:47 -0700 (PDT) X-Google-Smtp-Source: AA6agR5c825rh2SevMxu6IHsmQWSgaxOWvvOqM8/igy1ynDQFfPKqvaqRjTb/bleuSp8ev0kWMZ+ X-Received: by 2002:a05:6402:10cc:b0:446:491f:d6dd with SMTP id p12-20020a05640210cc00b00446491fd6ddmr6673174edu.360.1661329367292; Wed, 24 Aug 2022 01:22:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1661329367; cv=none; d=google.com; s=arc-20160816; b=ymPYX6mFPBiXrxA4cHWTCwuv1nVfS1rcVmBWS292RIJoL+XV2K4KPAPXIiGUMNswyu POERqkDeOJu6W1Ymrzu5H4Fm1hhRV9CY6ObAXCi6wOLyjIYYmPwxmBXDO5AMyUxWF0wm KTyxlmB/lVNepaS4V3k3s6X2/2cBYwmh5l44svzZobm1KDYUTOnNP18BxdFbhWwM0Pp+ n3ZohD3rprJfCtxqAHaqcup70djGAExPAn8wJdBdh37pp+4bVhfDEsWE9S/FmCDs3Q/b 7UwlSv/fI8VPGanCVxvH5Bniq3w/Qc/aep8o0NBpsMG5m8f8neD8CZJi+EwhXzbvFAD/ 2nVQ== 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=KFhoipy95bP113xci+lGCwwditMpaEg770tCZfK2FCQ=; b=wDzFTxo+QgsvYwxXRIzc8j70tmBkfe0dy2p9oDQWPX3idQzyy8kt5fUJbM3kJHDg9/ 02os09XhvAN/xg2aUoT5LLel/sQW0FBcDy2zMIUl0TBAkTIFNWR/bCDTir9KgunIvCT0 lYWTzoOySA4x4z1/klMHjd+ooflP9s1i4iXnL45pOwpW7r8tgLIYbMipyT3d1XZcdD3r 8XKXwX35YK2/GPgqsYfF7PAgrhaifg/n25P4scDca1BVWwk+90UKFZntYV7BnMJRDwEV 4vUsyYU6ipoMKOo69jT6uIempZD1c5WI5Nh5zxw0uMKJbOIMDBb3//aEJiOehA+f04+v eTEg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bytedance-com.20210112.gappssmtp.com header.s=20210112 header.b=GlH6POhM; 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 hp25-20020a1709073e1900b0073dbc331a40si800826ejc.188.2022.08.24.01.22.21; Wed, 24 Aug 2022 01:22:47 -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=GlH6POhM; 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 S235652AbiHXIUE (ORCPT + 99 others); Wed, 24 Aug 2022 04:20:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57730 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235637AbiHXIT7 (ORCPT ); Wed, 24 Aug 2022 04:19:59 -0400 Received: from mail-pl1-x632.google.com (mail-pl1-x632.google.com [IPv6:2607:f8b0:4864:20::632]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0AAE17FF93 for ; Wed, 24 Aug 2022 01:19:58 -0700 (PDT) Received: by mail-pl1-x632.google.com with SMTP id p18so15025736plr.8 for ; Wed, 24 Aug 2022 01:19:58 -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=KFhoipy95bP113xci+lGCwwditMpaEg770tCZfK2FCQ=; b=GlH6POhMxkFS95xU5zJMGW8H+X23wvpWqnYzcrsJBfEAuqIfo0ZAdpRSi3bnpYan7d 41MJ816H6hy5iMnQ/1e99Mw7saohjTnOTAEuJIJtiEDxaE2lnFbrnalZB69bweIDitf3 bXCr4JlID95qEy+fYmofaooTzZTbvOjnAWs1ZFIxOO8j6YG8eLh05jjact9kwCs74AnV SUUAORriiSdHNb5QHf5HXw4BJFeZ7pURb40oFVrAtPJjp3EgPie6UivFIl80nlVjM7xs 8un5b5VtVGYsFbhLn5k1+U6Ycgrv63323+BtnkeAUMaLYZ9V6BBQ7BmYsxcnPgh3gSGY dv0g== 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=KFhoipy95bP113xci+lGCwwditMpaEg770tCZfK2FCQ=; b=n7Cqgf67/H1EQQTdtGvIY5ZTPBJ1qRfm1Ungasfm1mgDooLT9qcY40k0e7NdXkZhGz dvGxiN7o/LqrzhIeeaKqjo4G43iKm8WEUDpd+nVMZhDGVe+SyYN07gzZRw5XQ5BB8v1p rdzuma2mn8jMgMjirtASMNJDz8sTI4EiQOXhNpIXon0cWnuZsdu37VjJ/sAZauyahN7s lfZrzWVORLWXR3hOgdNPAwYVGXgIpdA2dWwqNam+Gk5Pchy5hCk0Qhj5IYMe+RKbloQZ 4DCQ/bDKKBXqRG2CGZLz/o0WOpx8rmEvFgDoBZpDUswa+Udf+etxLpsaB8mCKjYHfZSB K9Rw== X-Gm-Message-State: ACgBeo3jAzPPaSkxWI9NjjUlQY7bsGRbVkXIGU3M1YjyvJo4+OJt4JVt 0TTTirX1oRB3Widzyq16QjYwmg== X-Received: by 2002:a17:90b:1901:b0:1fa:e81b:fc0e with SMTP id mp1-20020a17090b190100b001fae81bfc0emr7231297pjb.115.1661329197580; Wed, 24 Aug 2022 01:19:57 -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.19.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 24 Aug 2022 01:19:57 -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 03/10] sched/psi: save percpu memory when !psi_cgroups_enabled Date: Wed, 24 Aug 2022 16:18:22 +0800 Message-Id: <20220824081829.33748-4-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 We won't use cgroup psi_group when !psi_cgroups_enabled, so don't bother to alloc percpu memory and init for it. Also don't need to migrate task PSI stats between cgroups in cgroup_move_task(). Signed-off-by: Chengming Zhou Acked-by: Johannes Weiner --- kernel/sched/psi.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/kernel/sched/psi.c b/kernel/sched/psi.c index 39463dcc16bb..77d53c03a76f 100644 --- a/kernel/sched/psi.c +++ b/kernel/sched/psi.c @@ -201,6 +201,7 @@ void __init psi_init(void) { if (!psi_enable) { static_branch_enable(&psi_disabled); + static_branch_disable(&psi_cgroups_enabled); return; } @@ -950,7 +951,7 @@ void psi_memstall_leave(unsigned long *flags) #ifdef CONFIG_CGROUPS int psi_cgroup_alloc(struct cgroup *cgroup) { - if (static_branch_likely(&psi_disabled)) + if (!static_branch_likely(&psi_cgroups_enabled)) return 0; cgroup->psi = kzalloc(sizeof(struct psi_group), GFP_KERNEL); @@ -968,7 +969,7 @@ int psi_cgroup_alloc(struct cgroup *cgroup) void psi_cgroup_free(struct cgroup *cgroup) { - if (static_branch_likely(&psi_disabled)) + if (!static_branch_likely(&psi_cgroups_enabled)) return; cancel_delayed_work_sync(&cgroup->psi->avgs_work); @@ -996,7 +997,7 @@ void cgroup_move_task(struct task_struct *task, struct css_set *to) struct rq_flags rf; struct rq *rq; - if (static_branch_likely(&psi_disabled)) { + if (!static_branch_likely(&psi_cgroups_enabled)) { /* * Lame to do this here, but the scheduler cannot be locked * from the outside, so we move cgroups from inside sched/. -- 2.37.2