Received: by 2002:ac0:a594:0:0:0:0:0 with SMTP id m20-v6csp1433892imm; Tue, 22 May 2018 04:08:48 -0700 (PDT) X-Google-Smtp-Source: AB8JxZrm5dg/2eOveE5QXcsaqNubrA1Z6TbbRj8sa65xQs7rdV0NgCiMLg1Jx3PdD+0yjdo8DhWr X-Received: by 2002:a63:7e13:: with SMTP id z19-v6mr7061281pgc.205.1526987328555; Tue, 22 May 2018 04:08:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1526987328; cv=none; d=google.com; s=arc-20160816; b=k3s7y1QqRGKtUL1Oz4tZYwXwns7jYgH+fNTJfycOInBLFDPMewooxk5VpgdPeWcxsK JPWrtpKw9RADR4arL8aNqYi/8Un3P76fQ0mNdp4gE4ZrmYsbuBM6nk802mrml/xdIHwR WF6AiOANbz/s8Cag138SadmInqzvhIq0LGUKS/snALE6WnGaxk0r2ujayo+geUKWtSEZ 8zeB7RJP0AFfuf3+J98jajDDjmfCa6k/dQbrowspd2SWW2gA0+mdElABOwrlSytlYKqz r7PSXzo54SLcTo20U+eFQO9Vh9VypfyhTgj8Kc+9W/5OJjFmVf4KaURHzP3j6umD5nYz smIg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:arc-authentication-results; bh=XMeSyr40II+EsggwtKpBTibjfLXiooCXpVqURUuiWTE=; b=dmGsuHwFxJP8TMXZ+axFOV/XxJnlLPdEde/G92Ek3XWCCIXdzy8vaVwPrYsiU9StsE 9LHxzHXHJWFehGtb7TS4ZEy1ijJGGYcf0E6PDza8nGhBTsq8mGWqeUt96KuWJV5d8+Ix Z/1laPcS5oiyXjUuHs1UmjWswEMO3WRW9qBSn0cbyJvwRia+LgyoKq+gKR3yK6t1Yq0S sUIv5ogsjunxd0pEQ6Yf7hDpUVupeMoiWkyuqJCoB7CkCS9hY4ZphH+TA/0h2r/owTrz UwxWOf3+eIBe5alZEJI7vqXF5hll7wmxJrIUq8VzUuE9UkMGaYrTJfTuoZSBwvBu/GHs f2qA== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id j191-v6si12849558pgd.440.2018.05.22.04.08.34; Tue, 22 May 2018 04:08:48 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751519AbeEVLIR (ORCPT + 99 others); Tue, 22 May 2018 07:08:17 -0400 Received: from foss.arm.com ([217.140.101.70]:35022 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750733AbeEVLIM (ORCPT ); Tue, 22 May 2018 07:08:12 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 1357D15AD; Tue, 22 May 2018 04:08:12 -0700 (PDT) Received: from e110439-lin.cambridge.arm.com (e110439-lin.cambridge.arm.com [10.1.210.68]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 123703F24A; Tue, 22 May 2018 04:08:09 -0700 (PDT) From: Patrick Bellasi To: linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org Cc: Ingo Molnar , Peter Zijlstra , "Rafael J . Wysocki" , Viresh Kumar , Vincent Guittot , Dietmar Eggemann , Juri Lelli , Joel Fernandes Subject: [PATCH v4 1/2] cpufreq: schedutil: Fix iowait boost reset Date: Tue, 22 May 2018 12:07:53 +0100 Message-Id: <20180522110754.20832-2-patrick.bellasi@arm.com> X-Mailer: git-send-email 2.15.1 In-Reply-To: <20180522110754.20832-1-patrick.bellasi@arm.com> References: <20180522110754.20832-1-patrick.bellasi@arm.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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") Reviewed-by: Joel Fernandes (Google) Acked-by: Viresh Kumar Acked-by: Peter Zijlstra (Intel) --- Changes in v4: - added Reviewed-by Joel Fernandes - added Acked-by Viresh and Peter 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; - } } } -- 2.15.1