Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp868013pxf; Wed, 7 Apr 2021 13:42:59 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyhrs21MHJheJCB+xBaRadl9XnfQw7HhggaJeuG3qNHfRPO5o4KXN7aCSqxUHul7tl68T+m X-Received: by 2002:a05:6638:528:: with SMTP id j8mr5598885jar.108.1617828178889; Wed, 07 Apr 2021 13:42:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1617828178; cv=none; d=google.com; s=arc-20160816; b=PdEQned2kuCQtn2fopE5FtAJqJqu6Im6W/nJ7ELMy+5O5V9wEm+XtThJ4sBS27HGvU XHjw9+gjhUGH/4H3xiyNDkSK6MfHdRsF7glu8dl71Fthh9V/1z3L5eLAQXoNmqM7fUs0 FN5A7KmSFRA/UgVspj/Yufhqff6z1H5rqcNUxQfqzpTG8zAbt/Lu2nHOAigWq9cs0IrN faslKddXcsSCrpYOOEKPDcgbtkV2J+HMvZDWkRwKABS79QqDJNvpPoapretdeysnvpr+ IG+s71mi4tUvQs2Fl2M8SNQlgeLxsYSZA5e0cyVAOlLu9gJ8fWHY3AvTXdVb06HIV/iH 0ynA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date; bh=ES8eiTeTT+8CUGOoAa4b8INQwstrwPZ4edrDO2nToSY=; b=IcfJJhWvzzutaaraRzKoPimW0NkY7Exn8UXKceuc/ruGAJ6McRiBbpxyZYxgm74810 DUo8WCPPegSbf0etfi+YDZxB6BIOuGUCuBziVjNZDHJtgCLvV3U5RhDTeaitfHIgaZ3v VATXzYGjbfGpoL1V5akmV4lHtp4l0QDkNcJbHzd81Db++VYFa7ABziVLi1kASGqTohIO CNbNmYgrY25ExUmf2ymIdfE1Vd4jd2PqpStOBcFVR1fIlRhsQaYTZGLBwM0a7/ysri1g a1CJaYT92PPGT5sDV8DDdU/bLbe/GsrG+xQyjYDmLLY9K3pmlFBGsVhb9RTFPLN3b09t 6+hA== 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id p12si10504939ios.6.2021.04.07.13.42.47; Wed, 07 Apr 2021 13:42:58 -0700 (PDT) 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234594AbhDGJlT (ORCPT + 99 others); Wed, 7 Apr 2021 05:41:19 -0400 Received: from outbound-smtp21.blacknight.com ([81.17.249.41]:56139 "EHLO outbound-smtp21.blacknight.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234442AbhDGJlS (ORCPT ); Wed, 7 Apr 2021 05:41:18 -0400 Received: from mail.blacknight.com (pemlinmail04.blacknight.ie [81.17.254.17]) by outbound-smtp21.blacknight.com (Postfix) with ESMTPS id C911218E007 for ; Wed, 7 Apr 2021 10:41:08 +0100 (IST) Received: (qmail 15390 invoked from network); 7 Apr 2021 09:41:08 -0000 Received: from unknown (HELO techsingularity.net) (mgorman@techsingularity.net@[84.203.22.4]) by 81.17.254.9 with ESMTPSA (AES256-SHA encrypted, authenticated); 7 Apr 2021 09:41:08 -0000 Date: Wed, 7 Apr 2021 10:41:06 +0100 From: Mel Gorman To: Peter Zijlstra Cc: Rik van Riel , Vincent Guittot , linux-kernel , Kernel Team , Ingo Molnar , Valentin Schneider Subject: Re: [PATCH v3] sched/fair: bring back select_idle_smt, but differently Message-ID: <20210407094106.GC3697@techsingularity.net> References: <20210321150358.71ef52b1@imladris.surriel.com> <20210322110306.GE3697@techsingularity.net> <20210326151932.2c187840@imladris.surriel.com> <1e21aa6ea7de3eae32b29559926d4f0ba5fea130.camel@surriel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-15 Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.10.1 (2018-07-13) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Apr 07, 2021 at 09:17:18AM +0200, Peter Zijlstra wrote: > Subject: sched/fair: Bring back select_idle_smt(), but differently > From: Rik van Riel > Date: Fri, 26 Mar 2021 15:19:32 -0400 > > From: Rik van Riel > > Mel Gorman did some nice work in 9fe1f127b913 ("sched/fair: Merge > select_idle_core/cpu()"), resulting in the kernel being more efficient > at finding an idle CPU, and in tasks spending less time waiting to be > run, both according to the schedstats run_delay numbers, and according > to measured application latencies. Yay. > > The flip side of this is that we see more task migrations (about 30% > more), higher cache misses, higher memory bandwidth utilization, and > higher CPU use, for the same number of requests/second. > > This is most pronounced on a memcache type workload, which saw a > consistent 1-3% increase in total CPU use on the system, due to those > increased task migrations leading to higher L2 cache miss numbers, and > higher memory utilization. The exclusive L3 cache on Skylake does us > no favors there. > > On our web serving workload, that effect is usually negligible. > > It appears that the increased number of CPU migrations is generally a > good thing, since it leads to lower cpu_delay numbers, reflecting the > fact that tasks get to run faster. However, the reduced locality and > the corresponding increase in L2 cache misses hurts a little. > > The patch below appears to fix the regression, while keeping the > benefit of the lower cpu_delay numbers, by reintroducing > select_idle_smt with a twist: when a socket has no idle cores, check > to see if the sibling of "prev" is idle, before searching all the > other CPUs. > > This fixes both the occasional 9% regression on the web serving > workload, and the continuous 2% CPU use regression on the memcache > type workload. > > With Mel's patches and this patch together, task migrations are still > high, but L2 cache misses, memory bandwidth, and CPU time used are > back down to what they were before. The p95 and p99 response times for > the memcache type application improve by about 10% over what they were > before Mel's patches got merged. > > Signed-off-by: Rik van Riel > Signed-off-by: Peter Zijlstra (Intel) > Link: https://lkml.kernel.org/r/20210326151932.2c187840@imladris.surriel.com I think this is still ok and should not invalidate the previous tests on v3. While test_idle_cores() was checked on target, as long as target/prev share cache, the test should be equivalent other than there is a minor race so Reviewed-by: Mel Gorman One minor question below though which previously confused me. > --- a/kernel/sched/fair.c > +++ b/kernel/sched/fair.c > @@ -6112,6 +6112,27 @@ static int select_idle_core(struct task_ > return -1; > } > > +/* > + * Scan the local SMT mask for idle CPUs. > + */ > +static int select_idle_smt(struct task_struct *p, struct sched_domain *sd, int target) > +{ > + int cpu; > + > + if (!static_branch_likely(&sched_smt_present)) > + return -1; > + > + for_each_cpu(cpu, cpu_smt_mask(target)) { > + if (!cpumask_test_cpu(cpu, p->cpus_ptr) || > + !cpumask_test_cpu(cpu, sched_domain_span(sd))) > + continue; While I know that !cpumask_test_cpu(cpu, sched_domain_span(sd)) was done previously, I found it hard to believe that the test matters. If target/prev share a the LLC domain, why would the SMT siblings *not* share a LLC? -- Mel Gorman SUSE Labs