From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail.linutronix.de (146.0.238.70:993) by crypto-ml.lab.linutronix.de with IMAP4-SSL for ; 11 Jun 2018 18:35:19 -0000 Received: from aserp2130.oracle.com ([141.146.126.79]) by Galois.linutronix.de with esmtps (TLS1.2:RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1fSRew-0001f3-9M for speck@linutronix.de; Mon, 11 Jun 2018 20:35:18 +0200 Received: from pps.filterd (aserp2130.oracle.com [127.0.0.1]) by aserp2130.oracle.com (8.16.0.22/8.16.0.22) with SMTP id w5BIPnjM027475 for ; Mon, 11 Jun 2018 18:35:11 GMT Received: from userv0022.oracle.com (userv0022.oracle.com [156.151.31.74]) by aserp2130.oracle.com with ESMTP id 2jg4dkxw6b-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Mon, 11 Jun 2018 18:35:11 +0000 Received: from aserv0121.oracle.com (aserv0121.oracle.com [141.146.126.235]) by userv0022.oracle.com (8.14.4/8.14.4) with ESMTP id w5BIZ91t024171 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Mon, 11 Jun 2018 18:35:10 GMT Received: from abhmp0019.oracle.com (abhmp0019.oracle.com [141.146.116.25]) by aserv0121.oracle.com (8.14.4/8.13.8) with ESMTP id w5BIZ939032530 for ; Mon, 11 Jun 2018 18:35:09 GMT Date: Mon, 11 Jun 2018 14:35:08 -0400 From: Konrad Rzeszutek Wilk Subject: [MODERATED] Re: [patch V2 01/12] sched/smt: Update sched_smt_present at runtime Message-ID: <20180611183508.GA25607@char.us.oracle.com> References: <20180606192714.754943543@linutronix.de> <20180606192807.014995293@linutronix.de> MIME-Version: 1.0 In-Reply-To: <20180606192807.014995293@linutronix.de> Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit To: speck@linutronix.de List-ID: On Wed, Jun 06, 2018 at 09:27:15PM +0200, speck for Thomas Gleixner wrote: > Subject: [patch V2 01/12] sched/smt: Update sched_smt_present at runtime > From: Peter Zijlstra > > The static key sched_smt_present is only updated at boot time when SMT > siblings have been deteced. Booting with maxcpus=1 and bringing the > siblings online after boot rebuilds the scheduling domains correctly but > does not update the static key, so the SMT code is not enabled. > > Let the key update in the scheduler CPU hotplug code to fix this. > > Signed-off-by: Peter Zijlstra > Signed-off-by: Thomas Gleixner Reviewed-by: Konrad Rzeszutek Wilk with one question below (not that matters much, but): > --- > kernel/sched/core.c | 32 ++++++++++++++------------------ > kernel/sched/fair.c | 1 + > 2 files changed, 15 insertions(+), 18 deletions(-) > > --- a/kernel/sched/core.c > +++ b/kernel/sched/core.c > @@ -5771,6 +5771,20 @@ int sched_cpu_activate(unsigned int cpu) > struct rq *rq = cpu_rq(cpu); > struct rq_flags rf; > > +#ifdef CONFIG_SCHED_SMT > + /* > + * We can't rely on the sched domains themselves to reliably inform us > + * of SMT, but if we ever see a CPU with siblings pass by, enable the > + * SMT code. > + * > + * The failure case for domains is when we boot with SMT disabled, then > + * create partitions that split all cores and then hotplug the Don't you nee to first hotplug the siblings, then create the partitions? Or did you mean 'hotplug' == smp_callin? > + * siblings. In that case we'll never build an SMT domain. > + */ > + if (cpumask_weight(cpu_smt_mask(cpu)) > 1) > + static_branch_enable_cpuslocked(&sched_smt_present); > +#endif > + > set_cpu_active(cpu, true); > > if (sched_smp_initialized) { > @@ -5868,22 +5882,6 @@ int sched_cpu_dying(unsigned int cpu) > } > #endif > > -#ifdef CONFIG_SCHED_SMT > -DEFINE_STATIC_KEY_FALSE(sched_smt_present); > - > -static void sched_init_smt(void) > -{ > - /* > - * We've enumerated all CPUs and will assume that if any CPU > - * has SMT siblings, CPU0 will too. > - */ > - if (cpumask_weight(cpu_smt_mask(0)) > 1) > - static_branch_enable(&sched_smt_present); > -} > -#else > -static inline void sched_init_smt(void) { } > -#endif > - > void __init sched_init_smp(void) > { > sched_init_numa(); > @@ -5905,8 +5903,6 @@ void __init sched_init_smp(void) > init_sched_rt_class(); > init_sched_dl_class(); > > - sched_init_smt(); > - > sched_smp_initialized = true; > } > > --- a/kernel/sched/fair.c > +++ b/kernel/sched/fair.c > @@ -6238,6 +6238,7 @@ static inline int find_idlest_cpu(struct > } > > #ifdef CONFIG_SCHED_SMT > +DEFINE_STATIC_KEY_FALSE(sched_smt_present); > > static inline void set_idle_cores(int cpu, int val) > { >