Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp4642926pxu; Thu, 10 Dec 2020 01:36:07 -0800 (PST) X-Google-Smtp-Source: ABdhPJzvxY3R2nz+AqpIOpGkXgrl75rWlxciCC9nfF9IBeYIteZHav9YRgvzZlMJXf7HA1k5pmZk X-Received: by 2002:a17:907:20a6:: with SMTP id pw6mr5789288ejb.73.1607592967141; Thu, 10 Dec 2020 01:36:07 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1607592967; cv=none; d=google.com; s=arc-20160816; b=hkhxFm+I1uA0bEFT4kkfnvvofBEPyxKIp3xk0p/VFel0YHX5nuUnLND9ZEbc5lxrF2 HnOwJPDib02Dfg98DQD8tyF1SWSpM4UJ1edI+H84pBVYCY5qv0VBUQbz1CiW8fIML073 N28E0dgIWtrcWEXUIhE2PdjIpMjH63LE78l1ky4JxKfnZpLtSCE6vPF7nmT/IfUs29ND PkcQdQ3/O4Uw/yl6kOe45VbRriWye3IazjgwZ9uMmQ93VvW0pIetRlPj7Hl1qkPm+fcS bYBlf2RHSyJDAkenaj+oIrfsPC8odWprp4Lrjo3N+cj807bp+EQ1IHbYum0OgKwkSHS3 b4PA== 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=+a/b342AEee4esTrUh2NsulIjDT0w2C00VROJM+yWtQ=; b=fII/kVZ96q2MYrw5VcCNsXrdq5GHQgT4lrHCg2WuNzX4l6cUq7UplGjGL2Dmg4piDC 8JmMBi0NLYaPeaboD5OFCw2DkmhXgmSqEp/10hw3k/yBC07MtKfVKXmK3YdJlrLsrhex k7EVBfGzG8G3faZS+abd16ZEB/lu0zq8+t8elI6tRSgJHV2kl0fv9IgLyTZsaSjXq3v7 jRhRloAhSD8eLJubG9Z4JnzlF4FkKt/0K9oKIADyx+2gf1DJlouqURQ1FeygsIepF1eE uJNEkPjmYqIMxG2JhfU0cHwbeaT2qsPkb7bdqDQpWFvOdSwa7Ai/g+zbZADFrd4xsN5b tfDA== 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 g10si2429105edy.201.2020.12.10.01.35.44; Thu, 10 Dec 2020 01:36:07 -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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731916AbgLJJde (ORCPT + 99 others); Thu, 10 Dec 2020 04:33:34 -0500 Received: from outbound-smtp31.blacknight.com ([81.17.249.62]:53395 "EHLO outbound-smtp31.blacknight.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727461AbgLJJde (ORCPT ); Thu, 10 Dec 2020 04:33:34 -0500 Received: from mail.blacknight.com (pemlinmail03.blacknight.ie [81.17.254.16]) by outbound-smtp31.blacknight.com (Postfix) with ESMTPS id AFF24C0B17 for ; Thu, 10 Dec 2020 09:32:41 +0000 (GMT) Received: (qmail 30451 invoked from network); 10 Dec 2020 09:32:41 -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); 10 Dec 2020 09:32:41 -0000 Date: Thu, 10 Dec 2020 09:32:40 +0000 From: Mel Gorman To: "Li, Aubrey" Cc: Peter Ziljstra , Ingo Molnar , LKML , Barry Song , Juri Lelli , Vincent Guittot , Valentin Schneider , Linux-ARM Subject: Re: [PATCH 2/4] sched/fair: Move avg_scan_cost calculations under SIS_PROP Message-ID: <20201210093240.GQ3371@techsingularity.net> References: <20201208153501.1467-1-mgorman@techsingularity.net> <20201208153501.1467-3-mgorman@techsingularity.net> <1963d0ca-054c-19f9-94e0-d019a2e8e259@linux.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-15 Content-Disposition: inline In-Reply-To: <1963d0ca-054c-19f9-94e0-d019a2e8e259@linux.intel.com> User-Agent: Mutt/1.10.1 (2018-07-13) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Dec 10, 2020 at 01:18:05PM +0800, Li, Aubrey wrote: > > diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c > > index ac7b34e7372b..5c41875aec23 100644 > > --- a/kernel/sched/fair.c > > +++ b/kernel/sched/fair.c > > @@ -6153,6 +6153,8 @@ static int select_idle_cpu(struct task_struct *p, struct sched_domain *sd, int t > > if (!this_sd) > > return -1; > > > > + cpumask_and(cpus, sched_domain_span(sd), p->cpus_ptr); > > + > > if (sched_feat(SIS_PROP)) { > > u64 avg_cost, avg_idle, span_avg; > > > > @@ -6168,11 +6170,9 @@ static int select_idle_cpu(struct task_struct *p, struct sched_domain *sd, int t > > nr = div_u64(span_avg, avg_cost); > > else > > nr = 4; > > - } > > - > > - time = cpu_clock(this); > > > > - cpumask_and(cpus, sched_domain_span(sd), p->cpus_ptr); > > + time = cpu_clock(this); > > + } > > > > for_each_cpu_wrap(cpu, cpus, target) { > > if (!--nr) > > return -1; > > I thought about this again and here seems not to be consistent: > - even if nr reduces to 0, shouldn't avg_scan_cost be updated as well before return -1? You're right, but it's outside the scope of this patch. I noted that this was a problem in lore.kernel.org/r/lore.kernel.org/r/20201203141124.7391-8-mgorman@techsingularity.net It's neither a consistent win or loss to always account for it and so was dropped for this series to keep the number of controversial patches to a minimum. > - if avg_scan_cost is not updated because nr is throttled, the first > time = cpu_clock(this); > can be optimized. As nr is calculated and we already know which of the weight of cpumask and nr is greater. > That is also outside the scope of this patch. To do that, cpumask_weight() would have to be calculated but it's likely to be a net loss. Even under light load, nr will be smaller than the domain weight incurring both the cost of cpumask_weight and the clock read in the common case. -- Mel Gorman SUSE Labs