Received: by 2002:ac0:a594:0:0:0:0:0 with SMTP id m20-v6csp53953imm; Mon, 21 May 2018 02:04:14 -0700 (PDT) X-Google-Smtp-Source: AB8JxZoFQcdV8QUa3E6PWlACm+E3ePX/8QL2DAu4KHsuLBewiRJTJhJVT+V8J2RfBl/Yt2fVsQjG X-Received: by 2002:a63:b907:: with SMTP id z7-v6mr15339587pge.9.1526893454626; Mon, 21 May 2018 02:04:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1526893454; cv=none; d=google.com; s=arc-20160816; b=RWqAfIXvmWwwj7H2mDOh7DOcELy0/wv0HuENcYNhThmQoAihAn9k57uycULnE7cmRQ j3pD5ywC7kMq7wqmTEwvQIzObG2Qec06Q96voUC9ct3f/vzA8BIjyjMUH5t810e/2DBz 3gkX6iQbQx+jQXGVflwFjHtIe1/Q1rJFIG86adQqhugPV3T7P5MFXr9/5fyTQDOTriuy rsvsofR9Qi4mMSx/UqaUwpiEievirurfoz8Zye3SUw3R2Dj0V7z3hSQSZvaq0iIq44UY 54BhdqjUR5NPqRsWRv8px8QV9Rgv6WcvDHJRyH0Bihlf7WcRAXFwTjEfxoz+vJon3kHp fhpw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature:arc-authentication-results; bh=rKXDAAXDv8pyN1BFxlwH1fUU1SwAw/uXooCEA6W6DKU=; b=o8mvqm5ytmUVo6Wf1ZS0p70/lwpemOW56RQ3tUuv/0IYlHc4wKjGxarSDZsFJxcU8I tkYhERFf9hK/Wbbc13SPX2ZN6vCKiOlIhpMTv0RAq7kS4qmb+eHUPyVmRiAIcobFN33+ 4AJESqVZj7peSIE38Mdr09TFYdh4dKElqnMY6XfIXC7EM5ymL8zjT8LDbJjUEQLvvVmV vxJmW5830RiSZ/aeBX5XrQkLjCY4lL1+NpXgWMmRnZY6NjGp98jSONdEssbWo7YhiP5z Nta7HDj8A1FtXnLVzvN6zUGxubRkudIVuJiRw6sqW1I56rikMNYlwzyoODTO/bFyQ3pN LRMg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=LAHmhFu0; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id r9-v6si13804118pfg.247.2018.05.21.02.03.59; Mon, 21 May 2018 02:04:14 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=LAHmhFu0; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751143AbeEUJDn (ORCPT + 99 others); Mon, 21 May 2018 05:03:43 -0400 Received: from mail-pg0-f68.google.com ([74.125.83.68]:41352 "EHLO mail-pg0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750970AbeEUJDl (ORCPT ); Mon, 21 May 2018 05:03:41 -0400 Received: by mail-pg0-f68.google.com with SMTP id d14-v6so2498190pgv.8 for ; Mon, 21 May 2018 02:03:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=rKXDAAXDv8pyN1BFxlwH1fUU1SwAw/uXooCEA6W6DKU=; b=LAHmhFu012XgoAwnS2cwdR89jTeoch15ftSb+o5cTaWI3Twh/zRt5gWhIUFMezkeET w0AGL1s4WW/H7RDJpmO+gv5NLiCLftPTIMFgnMtBYRfZSIRVv6a46A83PMkgNwyGsemx bxCLvOOichHw+nwYpsUd+gH+RoUqGCqNbFRCQ= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=rKXDAAXDv8pyN1BFxlwH1fUU1SwAw/uXooCEA6W6DKU=; b=Lb5To3wSWk2nVN410kJ0jrDJo0wRya+04EXBC/hQe4EpE/khsyBRkoy+VxStlRcYFY SaLKgD3BT+JQMpFNCbkVv53vtoPvtCl5XN91Pd/pr/IHmogDhWChw87piO4RFi/mmGFG wyGF6KoTpTC89/xG4zxc/NBEhqoj3CJ8B2+TKn63oqbckkmp2NUDk+C5mwDPgOj4t+8O qubSNSxJDAVnkU8QPCK9DflwZ/ouq91QmUnvv7Rw0JgrgKi8uyzsMH8h6aiVeDckaf1C WjhUi/FKXbyXUv6Nmfa71jZpdki+0SVyrhtxqI8ngSWCLhVD6C8z2kgelAE46FhcnEIe knpg== X-Gm-Message-State: ALKqPweYksSFkjzqgOpvSv+D3Hc+pIlz9M5NTiVt93s98U3nyJxBWctL fs4c+EYeneZkEwXSCeohjIuagg== X-Received: by 2002:a62:5050:: with SMTP id e77-v6mr19488665pfb.16.1526893421194; Mon, 21 May 2018 02:03:41 -0700 (PDT) Received: from localhost ([122.167.163.112]) by smtp.gmail.com with ESMTPSA id 68-v6sm23666027pfk.46.2018.05.21.02.03.40 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 21 May 2018 02:03:40 -0700 (PDT) Date: Mon, 21 May 2018 14:33:38 +0530 From: Viresh Kumar To: Patrick Bellasi Cc: linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org, Ingo Molnar , Peter Zijlstra , "Rafael J . Wysocki" , Vincent Guittot , Dietmar Eggemann , Juri Lelli , Joel Fernandes Subject: Re: [PATCH v3 1/2] cpufreq: schedutil: Fix iowait boost reset Message-ID: <20180521090338.7z6n7ydy3rx3jnoa@vireshk-i7> References: <20180521085120.7902-1-patrick.bellasi@arm.com> <20180521085120.7902-2-patrick.bellasi@arm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20180521085120.7902-2-patrick.bellasi@arm.com> User-Agent: NeoMutt/20180323-120-3dd1ac Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 21-05-18, 09:51, Patrick Bellasi wrote: > A more energy efficient update of the IO wait boosting mechanism has > been introduced in: > > commit a5a0809bc58e ("cpufreq: schedutil: Make iowait boost more energy efficient") > > where the boost value is expected to be: > > - doubled at each successive wakeup from IO > staring from the minimum frequency supported by a CPU > > - reset when a CPU is not updated for more then one tick > by either disabling the IO wait boost or resetting its value to the > minimum frequency if this new update requires an IO boost. > > This approach is supposed to "ignore" boosting for sporadic wakeups from > IO, while still getting the frequency boosted to the maximum to benefit > long sequence of wakeup from IO operations. > > However, these assumptions are not always satisfied. > For example, when an IO boosted CPU enters idle for more the one tick > and then wakes up after an IO wait, since in sugov_set_iowait_boost() we > first check the IOWAIT flag, we keep doubling the iowait boost instead > of restarting from the minimum frequency value. > > This misbehavior could happen mainly on non-shared frequency domains, > thus defeating the energy efficiency optimization, but it can also > happen on shared frequency domain systems. > > Let fix this issue in sugov_set_iowait_boost() by: > - first check the IO wait boost reset conditions > to eventually reset the boost value > - then applying the correct IO boost value > if required by the caller > > Reported-by: Viresh Kumar > Signed-off-by: Patrick Bellasi > Cc: Ingo Molnar > Cc: Peter Zijlstra > Cc: Rafael J. Wysocki > Cc: Viresh Kumar > Cc: Joel Fernandes > Cc: Juri Lelli > Cc: Dietmar Eggemann > Cc: linux-kernel@vger.kernel.org > Cc: linux-pm@vger.kernel.org > Fixes: a5a0809bc58e ("cpufreq: schedutil: Make iowait boost more energy efficient") > > --- > Changes in v3: > - split the fix into a separated patch (this one) > - added "Fixes" tag (Viresh) > --- > kernel/sched/cpufreq_schedutil.c | 18 ++++++++++-------- > 1 file changed, 10 insertions(+), 8 deletions(-) > > diff --git a/kernel/sched/cpufreq_schedutil.c b/kernel/sched/cpufreq_schedutil.c > index e13df951aca7..c4063e578e4d 100644 > --- a/kernel/sched/cpufreq_schedutil.c > +++ b/kernel/sched/cpufreq_schedutil.c > @@ -203,6 +203,16 @@ static unsigned long sugov_aggregate_util(struct sugov_cpu *sg_cpu) > > static void sugov_set_iowait_boost(struct sugov_cpu *sg_cpu, u64 time, unsigned int flags) > { > + /* Clear iowait_boost if the CPU apprears to have been idle. */ > + if (sg_cpu->iowait_boost) { > + s64 delta_ns = time - sg_cpu->last_update; > + > + if (delta_ns > TICK_NSEC) { > + sg_cpu->iowait_boost = 0; > + sg_cpu->iowait_boost_pending = false; > + } > + } > + > if (flags & SCHED_CPUFREQ_IOWAIT) { > if (sg_cpu->iowait_boost_pending) > return; > @@ -216,14 +226,6 @@ static void sugov_set_iowait_boost(struct sugov_cpu *sg_cpu, u64 time, unsigned > } else { > sg_cpu->iowait_boost = sg_cpu->sg_policy->policy->min; > } > - } else if (sg_cpu->iowait_boost) { > - s64 delta_ns = time - sg_cpu->last_update; > - > - /* Clear iowait_boost if the CPU apprears to have been idle. */ > - if (delta_ns > TICK_NSEC) { > - sg_cpu->iowait_boost = 0; > - sg_cpu->iowait_boost_pending = false; > - } > } > } > Acked-by: Viresh Kumar -- viresh