Received: by 2002:a05:6602:18e:0:0:0:0 with SMTP id m14csp6200880ioo; Thu, 2 Jun 2022 00:49:58 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyUDhaYKmjrvhdeCDF3Y9PG2kuff31YkmkdDkgHCvzRjgxzlck0nwMGAbaoC0bBI+klVekB X-Received: by 2002:a17:90b:1298:b0:1e3:49cb:85be with SMTP id fw24-20020a17090b129800b001e349cb85bemr3890405pjb.159.1654156198215; Thu, 02 Jun 2022 00:49:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654156198; cv=none; d=google.com; s=arc-20160816; b=EXGRZopYm8m5KKuuOpVutpcGklktoSaT7rEsAH0XqAIObnHN2jaF+aT4/Lsd8OdWuT hMpoqeWVyOf/2cSaabIYYYapVuGxDYhIi9jJqMbew+/uKXwSZ2UFYFuoWGcWBPeV4o1u bADD7dRK4IibzBLZ8IBI0uIkt8abSYNM9i0z2QEmY2GQMef3sKbrO+/2W+c4tIwXIzL3 jHBoLRNEjTHpVXEhwmgm8sTNhQuUUQpayab3V2itz7oS7HT8cNSJ0B3WrtPtVtOdGKQq su/jGXecSHffw7+9Z/PMcQDF7KtHzhL6XOhICZuPz9dxwrOWIvXqXX3hHRNppc4yUutV aIuA== 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=1H5/QZ45mwhAJcb3yabhwkRgUl50fyzA2+Uufb/XsXA=; b=lMY2m3JMAbWp0Ps160ccOPDo1CRU0QdHzYBbMG/1aYCe7Cnd3BotePbeNMfLKVlqAT 4jozNwGECPA1qn/JvZyDAxN53fr4GFiWVudzEiOTIQwcwE21cJMOk857DSPCucHWQnE4 bguvLS2xQPENtUKi1kod2vCvgNx8y8NnlcPxLCR7dlKpboWPZsY3P/09xiehzc0OEFA0 S6TFdnYoiGIQLxVvp8OAKLdO+dqtU+l1bO7vzCw3bszDFs2z12UIB4ms3cVeyxOdgcdX s14oI/QV3VXWR1p3DGVTWH1AxRnvFlSfYPaVGar0O4w3398P/gjL9IayTYxm+3nqY3md oxpw== 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 z10-20020a63e54a000000b003fc5a49f76fsi5211780pgj.372.2022.06.02.00.49.46; Thu, 02 Jun 2022 00:49:58 -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 S229872AbiFBEwo (ORCPT + 99 others); Thu, 2 Jun 2022 00:52:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42194 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229621AbiFBEwl (ORCPT ); Thu, 2 Jun 2022 00:52:41 -0400 Received: from nksmu.kylinos.cn (mailgw.kylinos.cn [123.150.8.42]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2BCF71159 for ; Wed, 1 Jun 2022 21:52:38 -0700 (PDT) X-UUID: a828858c71ec40fdbd2877cbb1e1c59f-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 3 meta/cnt.alert 1 X-CPASD-INFO: 83a86b36504749499f45c750e0154d2d@gYObWGOUYWZhUHaDg3x_c1mXZGWTY1V _p2pRZWKUXoSVhH5xTWJsXVKBfG5QZWNdYVN_eGpQYl9gZFB5i3-XblBgXoZgUZB3h3WbWGaQYw== X-CLOUD-ID: 83a86b36504749499f45c750e0154d2d 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:304.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:0.0,SPC:0,SIG:- 5,AUF:11,DUF:42066,ACD:302,DCD:404,SL:0,EISP:0,AG:0,CFC:0.812,CFSR:0.029,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: a828858c71ec40fdbd2877cbb1e1c59f-20220602 X-CPASD-BLOCK: 1000 X-CPASD-STAGE: 1 X-UUID: a828858c71ec40fdbd2877cbb1e1c59f-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 1997259765; Thu, 02 Jun 2022 11:04:31 +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:01:35 +0800 Message-Id: <20220602030135.398697-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 Marco Elver 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