Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp3062240pxu; Mon, 14 Dec 2020 19:42:38 -0800 (PST) X-Google-Smtp-Source: ABdhPJxWpFlcJpDnAvEGKClKpuzMD85pSMPRZ4C+o9eIGQciazbBZjbvhYT3uIny81hjX0pWAYhK X-Received: by 2002:aa7:c2d8:: with SMTP id m24mr13071992edp.300.1608003758563; Mon, 14 Dec 2020 19:42:38 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1608003758; cv=none; d=google.com; s=arc-20160816; b=tdcGYQCtHeXds2H9VR74yVEWEcVAK8isZ3P9v+Ud9SsEaVl1zKtTg0LcieBy2sbBZe CopQw/RzvlUi00D1PoW/aY+FO7OhAc7q2vUevGkSFy3vyjNi6svuBYMzG/rMd568uXVy zZEGQGeZnp5CUozG+8dp9hfXBl7cfdGHFq6VAxWmh/jHOOTsltM41bt5e+d5nQe/1SWj sbNFybjPGdBNXflwIIsAeUg62+V94dsoR5A1sw6spHmF2iRsP6+UchhhOxR1knjdOeS+ DHpZxK3bYXxTYQPv4JZ7m3ueuXqcz9D1be3uKlJQt8WW5sf3w7cpHAHA4zYjLfDSdYVH 4rUA== 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=YpFnFOtyV+3qU/s3TJ/+cs2ywn+BkOtO0PX6kzZWXCY=; b=ysyapT8UbZsdPc8LGlmOhUwGSIqLPaQOnvaNQ84IjZpmPBjNWWVzAlumH65BfMlnY6 tAwQS5GHeRWpx9Zj7mxJ9nBIpkRGurhktz1c92pgh0aReUvVr1BtfUTeGyp1Gy2MNesy A4n0dD/IUJ+fn4wY/5HUhmw0x+WoQRLBZl2jcjIX81m95x1cpAPFLJ4bi//0vfdgECsm bws25CHLSqeAOwZZHW1aOoZ4+ul7y18w3rMLfZm3+djRsn103hZga7N0tqpL4KYsop4g xLW1WQ9G7Wd5qEieJ5RCYVw8b16vHeVO8g1xZr0+yq7stQrHG0aZU1Rl/EoJV6VTIi7z yKKg== 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 c3si221203eds.266.2020.12.14.19.42.15; Mon, 14 Dec 2020 19:42:38 -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 S1725968AbgLODie (ORCPT + 99 others); Mon, 14 Dec 2020 22:38:34 -0500 Received: from mga03.intel.com ([134.134.136.65]:20811 "EHLO mga03.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725821AbgLODiZ (ORCPT ); Mon, 14 Dec 2020 22:38:25 -0500 IronPort-SDR: zxaYf55MEynG2ESS5Cm1+u9Io0fRzn8GhxGcUiboorL7BMwKUkgWHwx357Yuk8dOEb4ZW/aqtb eV9JpubLPvuQ== X-IronPort-AV: E=McAfee;i="6000,8403,9835"; a="174929745" X-IronPort-AV: E=Sophos;i="5.78,420,1599548400"; d="scan'208";a="174929745" Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by orsmga103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 14 Dec 2020 19:36:39 -0800 IronPort-SDR: gA0/KtfqVgSUqvHYRUw0Hbv2zHiYM3zKDsZMvmi+fYGPoYKTBGH6ed4l0vLsnICWehndUpmNWI KgOrIlzwaqxQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.78,420,1599548400"; d="scan'208";a="383023280" Received: from cli6-desk1.ccr.corp.intel.com (HELO [10.239.161.125]) ([10.239.161.125]) by fmsmga004.fm.intel.com with ESMTP; 14 Dec 2020 19:36:36 -0800 Subject: Re: [RFC][PATCH 1/5] sched/fair: Fix select_idle_cpu()s cost accounting To: Peter Zijlstra , mgorman@techsingularity.net, vincent.guittot@linaro.org Cc: linux-kernel@vger.kernel.org, mingo@redhat.com, juri.lelli@redhat.com, valentin.schneider@arm.com, qais.yousef@arm.com, dietmar.eggemann@arm.com, rostedt@goodmis.org, bsegall@google.com, tim.c.chen@linux.intel.com, benbjiang@gmail.com References: <20201214164822.402812729@infradead.org> <20201214170017.877557652@infradead.org> From: "Li, Aubrey" Message-ID: Date: Tue, 15 Dec 2020 11:36:35 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:68.0) Gecko/20100101 Thunderbird/68.9.0 MIME-Version: 1.0 In-Reply-To: <20201214170017.877557652@infradead.org> 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 2020/12/15 0:48, Peter Zijlstra wrote: > We compute the average cost of the total scan, but then use it as a > per-cpu scan cost when computing the scan proportion. Fix this by > properly computing a per-cpu scan cost. > > This also fixes a bug where we would terminate early (!--nr, case) and > not account that cost at all. I'm a bit worried this may introduce a regression under heavy load. The overhead of adding another cpu_clock() and calculation becomes significant when sis_scan is throttled by nr. I'm not sure if it's a good idea to not account the scan cost at all when sis_scan is throttled, that is, remove the first cpu_clock() as well. The avg scan cost remains the value when the system is not very busy, and when the load comes down and span avg idle > span avg cost, we account the cost again. This should make select_idle_cpu() a bit faster when the load is very high. Thanks, -Aubrey > > Signed-off-by: Peter Zijlstra (Intel) > --- > kernel/sched/fair.c | 13 +++++++++---- > 1 file changed, 9 insertions(+), 4 deletions(-) > > --- a/kernel/sched/fair.c > +++ b/kernel/sched/fair.c > @@ -6144,10 +6144,10 @@ static inline int select_idle_smt(struct > static int select_idle_cpu(struct task_struct *p, struct sched_domain *sd, int target) > { > struct cpumask *cpus = this_cpu_cpumask_var_ptr(select_idle_mask); > + int cpu, loops = 1, nr = INT_MAX; > + int this = smp_processor_id(); > struct sched_domain *this_sd; > u64 time; > - int this = smp_processor_id(); > - int cpu, nr = INT_MAX; > > this_sd = rcu_dereference(*this_cpu_ptr(&sd_llc)); > if (!this_sd) > @@ -6175,14 +6175,19 @@ static int select_idle_cpu(struct task_s > } > > for_each_cpu_wrap(cpu, cpus, target) { > - if (!--nr) > - return -1; > if (available_idle_cpu(cpu) || sched_idle_cpu(cpu)) > break; > + > + if (loops >= nr) { > + cpu = -1; > + break; > + } > + loops++; > } > > if (sched_feat(SIS_PROP)) { > time = cpu_clock(this) - time; > + time = div_u64(time, loops); > update_avg(&this_sd->avg_scan_cost, time); > } > > >