Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp1759165pxj; Wed, 19 May 2021 13:15:13 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyXgSPulV9UlTY2+2JlPPHc1C5rh9rBjja9ye+p8laVPG2lKgEiFp9cbc24FCq9YwyvZ+mT X-Received: by 2002:a17:906:1dc2:: with SMTP id v2mr984816ejh.8.1621455313575; Wed, 19 May 2021 13:15:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621455313; cv=none; d=google.com; s=arc-20160816; b=hSqVrR+9/7VGFoCffIKzwvsGx6vkzLo8lrGIpoXcSLNyo4PZgRKZZS7RRM3/afeMQU VKaK+b2oc4tmPfsIwScZzgF4+61oz4Fu9fbtjTT0AbHkykqOtSmfFN7OUU7ri7qPfBxu IwRBXMyew2iWUbLR2LKNkZCFlV9GvaZ2bgp9y16iG9kEuJdFLRHT8UifD+EVKpot6LoS b2c4VuJDGJy6ThVjI8oygA1O7iqRID07h77B2wvEHiz5mxgaTGjLeSCrr7dRyQUGYEWl sRqotWrFgdIKPuEJjbHPdOgd/+lfgPtfVXjYeboQZh/1ykaMEHj66zq+x/SgztkIKURI s7Bg== 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=XvrNvdeGKY2osrq3uT3hfC0ofRtv729XHe6JbaQjhHo=; b=bgiW0KvJ0MjKQ4IROLe6lIYBuGqrDWUB77Xt6ldkAU31ugjtWUCU9ZPBRYj+2DIG7b GmjgNaydOwlWICOQKhPxrgXBQDWLCEsfw7Vm3IuPA0qIxccmEL+ST/dZx6tQerXClgxT AXjmQkHyL/VGWh6JLDsxtvzTW9xO1otegi6Aa7SdHvx3P5W3FJvBLsy5T9tdEZqYbNwT 56dDe6bqa2uPnsYmAju39NLdcD9DHS9zrH56ZKkC+EHZ4KowtX7hn5YIy+pnGJWY30Ga GBCOG7/z+oeso4xZiGkdh8a5GhBk5jygVMn2DmN/1zGGY4zK/UUAVVSgtnCTP8vdUMt6 MniQ== 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 a1si175057edy.232.2021.05.19.13.14.49; Wed, 19 May 2021 13:15:13 -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 S1355091AbhESQIB (ORCPT + 99 others); Wed, 19 May 2021 12:08:01 -0400 Received: from foss.arm.com ([217.140.110.172]:46862 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1354270AbhESQIA (ORCPT ); Wed, 19 May 2021 12:08:00 -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 E2B9F1480; Wed, 19 May 2021 09:06:40 -0700 (PDT) Received: from e120877-lin.cambridge.arm.com (usa-sjc-imap-foss1.foss.arm.com [10.121.207.14]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 9096D3F73D; Wed, 19 May 2021 09:06:39 -0700 (PDT) Date: Wed, 19 May 2021 17:06:34 +0100 From: Vincent Donnefort To: Dietmar Eggemann Cc: Ingo Molnar , Peter Zijlstra , Xuewen Yan , Juri Lelli , Vincent Guittot , Steven Rostedt , Patrick Bellasi , Quentin Perret , linux-kernel@vger.kernel.org Subject: Re: [PATCH] sched/fair: Fix util_est UTIL_AVG_UNCHANGED handling Message-ID: <20210519160633.GA230499@e120877-lin.cambridge.arm.com> References: <20210514103748.737809-1-dietmar.eggemann@arm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210514103748.737809-1-dietmar.eggemann@arm.com> User-Agent: Mutt/1.5.24 (2015-08-30) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, May 14, 2021 at 12:37:48PM +0200, Dietmar Eggemann wrote: > The util_est internal UTIL_AVG_UNCHANGED flag which is used to prevent > unnecessary util_est updates uses the LSB of util_est.enqueued. It is > exposed via _task_util_est() (and task_util_est()). > > Commit 92a801e5d5b7 ("sched/fair: Mask UTIL_AVG_UNCHANGED usages") > mentions that the LSB is lost for util_est resolution but > find_energy_efficient_cpu() checks if task_util_est() returns 0 to > return prev_cpu early. > > _task_util_est() returns the max value of util_est.ewma and > util_est.enqueued or'ed w/ UTIL_AVG_UNCHANGED. > So task_util_est() returning the max of task_util() and > _task_util_est() will never return 0 under the default > SCHED_FEAT(UTIL_EST, true). > > To fix this use the MSB of util_est.enqueued instead and keep the flag > util_est internal, i.e. don't export it via _task_util_est(). > > The maximal possible util_avg value for a task is 1024 so the MSB of > 'unsigned int util_est.enqueued' isn't used to store a util value. > > As a caveat the code behind the util_est_se trace point has to filter > UTIL_AVG_UNCHANGED to see the real util_est.enqueued value which should > be easy to do. > > This also fixes an issue report by Xuewen Yan that util_est_update() > only used UTIL_AVG_UNCHANGED for the subtrahend of the equation: > > last_enqueued_diff = ue.enqueued - (task_util() | UTIL_AVG_UNCHANGED) > > Fixes: b89997aa88f0b sched/pelt: Fix task util_est update filtering > Signed-off-by: Dietmar Eggemann I don't believe this made it through our integration branch testing, so I gave a try manually on my Hikey with LISA's UtilConvergence test. 20 iterations of that test passed without any problem. > --- > kernel/sched/fair.c | 5 +++-- > kernel/sched/pelt.h | 13 +++++++------ > 2 files changed, 10 insertions(+), 8 deletions(-) > > diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c > index 161b92aa1c79..0150d440b0a2 100644 > --- a/kernel/sched/fair.c > +++ b/kernel/sched/fair.c > @@ -3856,7 +3856,7 @@ static inline unsigned long _task_util_est(struct task_struct *p) > { > struct util_est ue = READ_ONCE(p->se.avg.util_est); > > - return (max(ue.ewma, ue.enqueued) | UTIL_AVG_UNCHANGED); > + return max(ue.ewma, (ue.enqueued & ~UTIL_AVG_UNCHANGED)); > } Shall we also update proc_sched_show_task() to avoid reading this flag there? -- Vincent