Received: by 2002:a05:6602:18e:0:0:0:0 with SMTP id m14csp6294537ioo; Thu, 2 Jun 2022 03:25:41 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxZ3o/4/OmZ4DXhGbbUiVXryEg73yMcWUogVYkHm4bPpSYHLBlhYd2UASZl2UjVbVV5P725 X-Received: by 2002:a17:907:d27:b0:6ff:d8b:9564 with SMTP id gn39-20020a1709070d2700b006ff0d8b9564mr3554566ejc.364.1654165540872; Thu, 02 Jun 2022 03:25:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654165540; cv=none; d=google.com; s=arc-20160816; b=MXNDAq9c72pds2XCQmx/Sv6VM1dARqZAaO40SttD1fQE2xUDMbZUmsyniEJCi12qky BE1psU/hHGBivt2B/Q+rdfQRyBfF4fSOWykAL6fdlxHp4+D5siE8t011SN4043jqeiLV yCuv+kMThSnKkwcCoH7GbLvqb822MfB/ceI7a2gZchvrqpU3y8yzETW5NBQ1Otk/KYXR 46zUeLfwMn8D8pyCBpPEYZ4ZpKVusGSFVOdrhxJQIfhYhsUiYfIcTSxA6wDgEh1af494 gWlX7xp8AbJxF3ivKNitTWglzzBJJKoVrpPQBdzqbFCZbvB9BbndJqpfYl64ZdaktP7f Tc4w== 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 :message-id:date:subject:cc:to:from; bh=oNkrgrIx0Mgz0g0efVyNwNiwctZA6bHws9EKClt7L6M=; b=azcOkwra6/Vq03JNIWPf+zwImjcAwjFMqHtC3vSd3i9D/p58PEQXJMpnNXobbi9xNH nAi48gWAQJCoDEsId2qFrcwZ5Jz68Gg342eiHJuPIIAmzBQtUOe0MUBuJCnIILFCO+4c 5GiI6O6ZF0oAs0CaVcOeEwfk4TyIqEyJ3V+0G31qzV8p2BE4XMBH742bSxExQvw1LcKi DiDrn+Fe6uwJfosn1SrnzyJu05pWDbVBQk3Eru6pJjMn2w3EybO4jufnCoZraBOvKc1I qMXSxZpaoO5iO2xSM3f1UwQuL4qT/foZ37kgEa8HqfXGof5WKWscY7GXm054mcWHhibi 6z7A== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id m16-20020a1709060d9000b006ff46987deasi3689225eji.311.2022.06.02.03.25.14; Thu, 02 Jun 2022 03:25:40 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229898AbiFBEw6 (ORCPT + 99 others); Thu, 2 Jun 2022 00:52:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42252 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229867AbiFBEwm (ORCPT ); Thu, 2 Jun 2022 00:52:42 -0400 Received: from nksmu.kylinos.cn (mailgw.kylinos.cn [123.150.8.42]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 949B555B0 for ; Wed, 1 Jun 2022 21:52:40 -0700 (PDT) X-UUID: c5b39320cda94d40b717a0897b88f1fd-20220602 X-Spam-Fingerprint: 0 X-GW-Reason: 13103 X-Policy-Incident: 5pS25Lu25Lq66LaF6L+HMTDkurrpnIDopoHlrqHmoLg= X-Content-Feature: ica/max.line-size 100 audit/email.address 2 meta/cnt.alert 1 X-CPASD-INFO: cbbbc0d484424a0a9583bbd036ec801d@rLKcgpBikmRkVHZ-g6R7m1lmaGOSjoR _dXCFk2ZgXYSVhH5xTWJsXVKBfG5QZWNdYVN_eGpQYl9gZFB5i3-XblBgXoZgUZB3sqScgpRelA== X-CLOUD-ID: cbbbc0d484424a0a9583bbd036ec801d X-CPASD-SUMMARY: SIP:-1,APTIP:-2.0,KEY:0.0,FROMBLOCK:1,OB:0.0,URL:-5,TVAL:186. 0,ESV:0.0,ECOM:-5.0,ML:0.0,FD:0.0,CUTS:305.0,IP:-2.0,MAL:-5.0,PHF:-5.0,PHC:-5 .0,SPF:4.0,EDMS:-5,IPLABEL:4480.0,FROMTO:0,AD:0,FFOB:0.0,CFOB:1.0,SPC:0,SIG:- 5,AUF:12,DUF:42068,ACD:302,DCD:404,SL:0,EISP:0,AG:0,CFC:0.802,CFSR:0.031,UAT: 0,RAF:0,IMG:-5.0,DFA:0,DTA:0,IBL:-2.0,ADI:-5,SBL:0,REDM:0,REIP:0,ESB:0,ATTNUM :0,EAF:0,CID:-5.0,VERSION:2.3.17 X-CPASD-ID: c5b39320cda94d40b717a0897b88f1fd-20220602 X-CPASD-BLOCK: 1000 X-CPASD-STAGE: 1 X-UUID: c5b39320cda94d40b717a0897b88f1fd-20220602 X-User: huangbing@kylinos.cn Received: from localhost.localdomain [(116.128.244.169)] by nksmu.kylinos.cn (envelope-from ) (Generic MTA) with ESMTP id 2121234482; Thu, 02 Jun 2022 11:10:52 +0800 From: Bing Huang To: peterz@infradead.org, dietmar.eggemann@arm.com Cc: brauner@kernel.org, bristot@redhat.com, bsegall@google.com, juri.lelli@redhat.com, linux-kernel@vger.kernel.org, mgorman@suse.de, mingo@redhat.com, rostedt@goodmis.org, vincent.guittot@linaro.org Subject: [PATCH v3] sched/fair: static cpumasks for load balance Date: Thu, 2 Jun 2022 11:07:53 +0800 Message-Id: <20220602030753.399566-1-huangbing@kylinos.cn> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,KHOP_HELO_FCRDNS, SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE,T_SPF_PERMERROR,UNPARSEABLE_RELAY 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 both cpu mask load_balance_mask and select_idle_mask just only used in fair.c, but allocation in core.c in CONFIG_CPUMASK_OFFSTACK=y case, and global via declare per cpu variations. More or less, it looks wired. Co-developed-by: Dietmar Eggemann Signed-off-by: Bing Huang --- v1->v2: move load_balance_mask and select_idle_mask allocation from sched_init() to init_sched_fair_class() v2->v3: fixup by Dietmar Eggemann kernel/sched/core.c | 11 ----------- kernel/sched/fair.c | 13 +++++++++++-- 2 files changed, 11 insertions(+), 13 deletions(-) diff --git a/kernel/sched/core.c b/kernel/sched/core.c index 696c6490bd5b..707df2aeebf8 100644 --- a/kernel/sched/core.c +++ b/kernel/sched/core.c @@ -9503,9 +9503,6 @@ LIST_HEAD(task_groups); static struct kmem_cache *task_group_cache __read_mostly; #endif -DECLARE_PER_CPU(cpumask_var_t, load_balance_mask); -DECLARE_PER_CPU(cpumask_var_t, select_idle_mask); - void __init sched_init(void) { unsigned long ptr = 0; @@ -9549,14 +9546,6 @@ void __init sched_init(void) #endif /* CONFIG_RT_GROUP_SCHED */ } -#ifdef CONFIG_CPUMASK_OFFSTACK - for_each_possible_cpu(i) { - per_cpu(load_balance_mask, i) = (cpumask_var_t)kzalloc_node( - cpumask_size(), GFP_KERNEL, cpu_to_node(i)); - per_cpu(select_idle_mask, i) = (cpumask_var_t)kzalloc_node( - cpumask_size(), GFP_KERNEL, cpu_to_node(i)); - } -#endif /* CONFIG_CPUMASK_OFFSTACK */ init_rt_bandwidth(&def_rt_bandwidth, global_rt_period(), global_rt_runtime()); diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c index 8c5b74f66bd3..310b6f52a7df 100644 --- a/kernel/sched/fair.c +++ b/kernel/sched/fair.c @@ -5843,8 +5843,8 @@ static void dequeue_task_fair(struct rq *rq, struct task_struct *p, int flags) #ifdef CONFIG_SMP /* Working cpumask for: load_balance, load_balance_newidle. */ -DEFINE_PER_CPU(cpumask_var_t, load_balance_mask); -DEFINE_PER_CPU(cpumask_var_t, select_idle_mask); +static DEFINE_PER_CPU(cpumask_var_t, load_balance_mask); +static DEFINE_PER_CPU(cpumask_var_t, select_idle_mask); #ifdef CONFIG_NO_HZ_COMMON @@ -11841,6 +11841,15 @@ void show_numa_stats(struct task_struct *p, struct seq_file *m) __init void init_sched_fair_class(void) { #ifdef CONFIG_SMP + int i; + + for_each_possible_cpu(i) { + zalloc_cpumask_var_node(&per_cpu(load_balance_mask, i), + GFP_KERNEL, cpu_to_node(i)); + zalloc_cpumask_var_node(&per_cpu(select_idle_mask, i), + GFP_KERNEL, cpu_to_node(i)); + } + open_softirq(SCHED_SOFTIRQ, run_rebalance_domains); #ifdef CONFIG_NO_HZ_COMMON -- 2.25.1 No virus found Checked by Hillstone Network AntiVirus