Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp1821508pxb; Mon, 18 Jan 2021 00:19:05 -0800 (PST) X-Google-Smtp-Source: ABdhPJwhovpwycPWssvkzicwtKExhS2moQ9dWKyIlXAehSYQrozpaFHBudYura/2OH9Aj0/jZpIf X-Received: by 2002:a50:eacd:: with SMTP id u13mr8802400edp.382.1610957945691; Mon, 18 Jan 2021 00:19:05 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1610957945; cv=none; d=google.com; s=arc-20160816; b=AVWSpVrfymhyhZ+rMTvbAzEra2C8BeBReZFoMLPyKkCqdJYrRa7GygvtYJHBJlesXt hb3ymYm3irrBqcGB9HGJkxnmZzb7FiRwt0ZS6UPVk6mekZi45a7pal0PgxY/wD7/cl40 zu2lnrX9KGsSUU6f7XBUpdC1WmuzTR5UBC+Op4tLgIRfZdKWM5PfzoC9F+hKVjM6glZ0 wNQWKtWyqfyVY2laqEvNHRbJBgD09OgWGyeU2JlQT0q1amf9ANFZSe5++r+S+0kIx8cY 0AbcIcDUUvdhxwOR0lFgoi+t0QxpsIk+be/+exmNgDDqibjjD28O+YAkRli3NaLgdVz5 j0Hg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject:ironport-sdr:ironport-sdr; bh=84IdAO0JqpRvwoSO6V4ZhvaicB8zOSU+7rlxSKFapS4=; b=anVjYC7413lla/oYOYN5B9pJHes1jJvK47+SGt0KS6fKeoZ9U9BLHKcycIum0Nobb3 tSG5iiUh5kW8C4xJn/47XJ9ajfuEpFDkR5A1upU348sOcuAqu4O4EcI7tmdT26hxp232 ZDBB2wv0gVDPZvpfyZyeUcm2h4Q0e8gCkwJHVeag+iM05UOPYjLk6jCWKdcTOOhsFCRm sm9IMu84bVD4hQRR/q+zZnHpnXf0z3jmCbqgNI6sKRLSlXqEB00Et+Z8T3lqKVvv6u2H 3W/uM2z7cm8Dr4jntDRjcOSwCycYzw1wELI2qKdix6kc3AkbbSRo8Xh0qe74WyLN7YsB 6jTA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id a42si8592553edf.469.2021.01.18.00.18.41; Mon, 18 Jan 2021 00:19:05 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387580AbhARIQg (ORCPT + 99 others); Mon, 18 Jan 2021 03:16:36 -0500 Received: from mga03.intel.com ([134.134.136.65]:4440 "EHLO mga03.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387519AbhARIQb (ORCPT ); Mon, 18 Jan 2021 03:16:31 -0500 IronPort-SDR: GphGWMlzH8kAydya9wJEiZxu1AsdefYRmDK3KwkMiJ+O3Qy9lrIRlpm11ft4deyFlXoB23MVFN pcgw62Ai1dFw== X-IronPort-AV: E=McAfee;i="6000,8403,9867"; a="178858764" X-IronPort-AV: E=Sophos;i="5.79,355,1602572400"; d="scan'208";a="178858764" Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by orsmga103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 Jan 2021 00:14:41 -0800 IronPort-SDR: XIDnbbshtYmYF2VwX7P7oQN9JVWobXBnovfjFlRsfyUKaVCXYqBI7skhFdp6fjRbyjZjFATABq bdJoxLQJ2EmQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.79,355,1602572400"; d="scan'208";a="406148235" Received: from cli6-desk1.ccr.corp.intel.com (HELO [10.239.161.125]) ([10.239.161.125]) by FMSMGA003.fm.intel.com with ESMTP; 18 Jan 2021 00:14:37 -0800 Subject: Re: [PATCH 3/5] sched/fair: Make select_idle_cpu() proportional to cores To: Mel Gorman , Peter Zijlstra , Ingo Molnar Cc: Vincent Guittot , Qais Yousef , LKML References: <20210115100855.23679-1-mgorman@techsingularity.net> <20210115100855.23679-4-mgorman@techsingularity.net> From: "Li, Aubrey" Message-ID: Date: Mon, 18 Jan 2021 16:14:36 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.6.0 MIME-Version: 1.0 In-Reply-To: <20210115100855.23679-4-mgorman@techsingularity.net> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2021/1/15 18:08, Mel Gorman wrote: > From: Peter Zijlstra (Intel) > > Instead of calculating how many (logical) CPUs to scan, compute how > many cores to scan. > > This changes behaviour for anything !SMT2. > > Signed-off-by: Peter Zijlstra (Intel) > Signed-off-by: Mel Gorman > --- > kernel/sched/core.c | 18 +++++++++++++----- > kernel/sched/fair.c | 12 ++++++++++-- > kernel/sched/sched.h | 2 ++ > 3 files changed, 25 insertions(+), 7 deletions(-) > > diff --git a/kernel/sched/core.c b/kernel/sched/core.c > index 15d2562118d1..ada8faac2e4d 100644 > --- a/kernel/sched/core.c > +++ b/kernel/sched/core.c > @@ -7444,11 +7444,19 @@ int sched_cpu_activate(unsigned int cpu) > balance_push_set(cpu, false); > > #ifdef CONFIG_SCHED_SMT > - /* > - * When going up, increment the number of cores with SMT present. > - */ > - if (cpumask_weight(cpu_smt_mask(cpu)) == 2) > - static_branch_inc_cpuslocked(&sched_smt_present); > + do { > + int weight = cpumask_weight(cpu_smt_mask(cpu)); > + > + if (weight > sched_smt_weight) > + sched_smt_weight = weight; > + > + /* > + * When going up, increment the number of cores with SMT present. > + */ > + if (weight == 2) > + static_branch_inc_cpuslocked(&sched_smt_present); > + > + } while (0); > #endif > set_cpu_active(cpu, true); > > diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c > index c8d8e185cf3b..0811e2fe4f19 100644 > --- a/kernel/sched/fair.c > +++ b/kernel/sched/fair.c > @@ -6010,6 +6010,8 @@ static inline int find_idlest_cpu(struct sched_domain *sd, struct task_struct *p > DEFINE_STATIC_KEY_FALSE(sched_smt_present); > EXPORT_SYMBOL_GPL(sched_smt_present); > > +int sched_smt_weight __read_mostly = 1; > + > static inline void set_idle_cores(int cpu, int val) > { > struct sched_domain_shared *sds; > @@ -6124,6 +6126,8 @@ static int select_idle_smt(struct task_struct *p, struct sched_domain *sd, int t > > #else /* CONFIG_SCHED_SMT */ > > +#define sched_smt_weight 1 > + > static inline int select_idle_core(struct task_struct *p, struct sched_domain *sd, int target) > { > return -1; > @@ -6136,6 +6140,8 @@ static inline int select_idle_smt(struct task_struct *p, struct sched_domain *sd > > #endif /* CONFIG_SCHED_SMT */ > > +#define sis_min_cores 2 > + > /* > * Scan the LLC domain for idle CPUs; this is dynamically regulated by > * comparing the average scan cost (tracked in sd->avg_scan_cost) against the > @@ -6166,10 +6172,12 @@ static int select_idle_cpu(struct task_struct *p, struct sched_domain *sd, int t > avg_cost = this_sd->avg_scan_cost + 1; > > span_avg = sd->span_weight * avg_idle; > - if (span_avg > 4*avg_cost) > + if (span_avg > sis_min_cores*avg_cost) > nr = div_u64(span_avg, avg_cost); > else > - nr = 4; > + nr = sis_min_cores; > + > + nr *= sched_smt_weight; Is it better to put this into an inline wrapper to hide sched_smt_weight if !CONFIG_SCHED_SMT? Thanks, -Aubrey