Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp2516119pxb; Fri, 29 Oct 2021 03:04:16 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzq+KxBQSPwlwvsthGS4IDaNt+2om/9uC7l9gxmKLvISgs9zpkMU1kptTpvBknukDZXqm1R X-Received: by 2002:a17:906:a4e:: with SMTP id x14mr12082899ejf.1.1635501856697; Fri, 29 Oct 2021 03:04:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1635501856; cv=none; d=google.com; s=arc-20160816; b=EpbxZtI7QDYbluPtJ72v+iorZR0acyu1JyU8IuzAbKekEy2hlDxwSnwH5tmCQqo+XP 4dm8crECxC8nO+AE+BVd2Q8jBDTH3vEtKGuFdJrWsy/xKYCfnKeLhIzWC1wNUrEzmjZ7 vN9+RKky4S1Pyrjap2W8qnTfpdMu4X8kkhOqQoIAA8UEVNF/TLNe8fGQTk6ll7lynQKx 3IcJU7Ea2Bm1NAtwcsJgSrK/mLXM0hCMx6+ogDAU607UGKEkDtAnZGU6xvfwUVnn1oul musIQWvB8aZZ8kBjbddr5VwM5gvknb/Ljjk7JAnnT6NmTngBeZf6yOIA+yPHzopl+BXv edtA== 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 :to:subject; bh=of+dXFzFLvK1zGxENHWdbTvD9wcgsdytbXaPbtnIqt0=; b=Nm3iA82cISawoiN+nPQWlytZ+PT2LRWjbxiWyeaXYpiSSdEWh0Ieo88UH2t+HO6I1H ZnQEummAFRXRgi0Lxn7pan+jLjWh1azxenE5iVhkbTVgb4rYTGODtqFGpF0ZIt2cG/Hk 7xfuPRSYsCO2yWWm2ONeNMaXQXVNY+q0NjpU/PEVJhRujLBfu8sZ9GmfJuErqqDzj6EH grRkA7zz+RXDKIg++JOPsrzIRhpRWARt6gIkKQbyVwPUiofgOP8A0//Szf2ERHD7iVEk 9Fbe+Sq0cdNV1HkrLDfx5Sir+mQUrEKXt4EnqFC5KxflsDH+xRDZUU0Tzxl1dPIutlcv 9mlg== 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=arm.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id f7si8598065edd.188.2021.10.29.03.03.52; Fri, 29 Oct 2021 03:04:16 -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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231691AbhJ2KDz (ORCPT + 99 others); Fri, 29 Oct 2021 06:03:55 -0400 Received: from foss.arm.com ([217.140.110.172]:36592 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231620AbhJ2KDx (ORCPT ); Fri, 29 Oct 2021 06:03:53 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id D8B461063; Fri, 29 Oct 2021 03:01:24 -0700 (PDT) Received: from [192.168.154.184] (unknown [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 013553F5A1; Fri, 29 Oct 2021 03:01:22 -0700 (PDT) Subject: Re: [PATCH 3/5] sched/fair: Wait before decaying max_newidle_lb_cost To: Vincent Guittot , mingo@redhat.com, peterz@infradead.org, juri.lelli@redhat.com, rostedt@goodmis.org, bsegall@google.com, mgorman@suse.de, bristot@redhat.com, linux-kernel@vger.kernel.org, tim.c.chen@linux.intel.com References: <20211019123537.17146-1-vincent.guittot@linaro.org> <20211019123537.17146-4-vincent.guittot@linaro.org> From: Dietmar Eggemann Message-ID: <67218e25-a472-baa0-19bf-71af26f5e767@arm.com> Date: Fri, 29 Oct 2021 12:01:21 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.13.0 MIME-Version: 1.0 In-Reply-To: <20211019123537.17146-4-vincent.guittot@linaro.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 19/10/2021 14:35, Vincent Guittot wrote: > Decay max_newidle_lb_cost only when it has not been updated for a while > and ensure to not decay a recently changed value. > > Signed-off-by: Vincent Guittot > --- > include/linux/sched/topology.h | 2 +- > kernel/sched/fair.c | 36 +++++++++++++++++++++++++--------- > kernel/sched/topology.c | 2 +- > 3 files changed, 29 insertions(+), 11 deletions(-) > > diff --git a/include/linux/sched/topology.h b/include/linux/sched/topology.h > index 2f9166f6dec8..c07bfa2d80f2 100644 > --- a/include/linux/sched/topology.h > +++ b/include/linux/sched/topology.h > @@ -105,7 +105,7 @@ struct sched_domain { > > /* idle_balance() stats */ > u64 max_newidle_lb_cost; > - unsigned long next_decay_max_lb_cost; > + unsigned long last_decay_max_lb_cost; > > u64 avg_scan_cost; /* select_idle_sibling */ > > diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c > index c4c36865321b..e50fd751e1df 100644 > --- a/kernel/sched/fair.c > +++ b/kernel/sched/fair.c > @@ -10239,6 +10239,30 @@ void update_max_interval(void) > max_load_balance_interval = HZ*num_online_cpus()/10; > } > > +static inline bool update_newidle_cost(struct sched_domain *sd, u64 cost) > +{ > + if (cost > sd->max_newidle_lb_cost) { > + /* > + * Track max cost of a domain to make sure to not delay the > + * next wakeup on the CPU. > + */ > + sd->max_newidle_lb_cost = cost; > + sd->last_decay_max_lb_cost = jiffies; That's the actual change of the patch: sd->last_decay_max_lb_cost being moved forward also when newidle cost is updated from newidle_balance() ? > + } else if (time_after(jiffies, sd->last_decay_max_lb_cost + HZ)) { > + /* > + * Decay the newidle max times by ~1% per second to ensure that > + * it is not outdated and the current max cost is actually > + * shorter. I assume that `max cost` refers here to a local variable of the only caller of update_newidle_cost(..., 0) - rebalance_domains()? "the current max cost" has to be shorter so that rq->max_idle_balance_cost also decays in this case. Is this what this comment tries to say here? [...]