From patchwork Fri Oct 16 16:36:33 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wei Wang X-Patchwork-Id: 317817 Delivered-To: patch@linaro.org Received: by 2002:a92:d603:0:0:0:0:0 with SMTP id w3csp1613311ilm; Fri, 16 Oct 2020 09:36:42 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyqzNnbcHAJJazC1ntUD5MphgtpZ96lMU1/ZtSZadgIpjcGJe9R95J8BTZNC7OIngGkADSx X-Received: by 2002:a17:907:94cb:: with SMTP id dn11mr4714504ejc.326.1602866202606; Fri, 16 Oct 2020 09:36:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1602866202; cv=none; d=google.com; s=arc-20160816; b=ZLuvNKdaSJyEBzLArDu6m4GsEr/EY9Erwcb3w9IOUUAV9AhiN1SgrcqiJlPJ9RULWb fbPqIJ8WTH+3wXpm8af4dqkzJw7J681Xcd7ArpJzr4w5MPpCVst0+dOiWwbQ0ZVMRANM C8JQ3iR2XSjDn2IaOVtfAz50XYJHZx1OE/ZfWOVP17fgfPhVP4Xeo9NNM1thHWUbe9AN uZmcv0R4S9/7oaLs4dWUe7XKR7TSaBVbcViiNkNFv8XCWwJwVvvAHGWUsDW7bs8ByWlF XBgv1oeGLuhz1TRvYxbyEn2lrzpBrQ+mtydbMsnBtqRxg56BSuCNAeeox5bhMuBQvhoW 1qdA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:to:cc:from:subject:mime-version:message-id:date :sender:dkim-signature; bh=ESK7AGq3xcY8c9Kxha7AtdakH67WdRXIQfnsDd+BhXg=; b=MJeyGyn5kFpFZJnuCUdP8d9kwY8im8mlTvtnQRFta8KbmrxX5sZm5b/RYsliRvwNw0 Vl69T/7OmCTeDN1nZAGn5MW0DApDirezVxRpA2KdZofp+HCBW/ojSHLXOyM7KM0j8bg7 pzigJm8MufIR3DcQfwQfgLmJE5UNwIOjWxrFhihP4tGcdxVBcKXl8GTkIYd8lh19flAL WtDDP2+ri7so9kMODUfkBWXf0DQjyjfmn+LaI1XKdnzc58yLsNGU1Wady/qUiY3UJ82E FFp7idlTszdiI+dSQ7NKuyp7Q+i71aKK/zhtMZgu+0WvyZd1YoltW/SXfMFZQAB+emtH ViBg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=dofkqMiA; spf=pass (google.com: domain of linux-pm-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-pm-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id h16si1867265ejj.688.2020.10.16.09.36.41; Fri, 16 Oct 2020 09:36:42 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-pm-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=dofkqMiA; spf=pass (google.com: domain of linux-pm-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-pm-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2406328AbgJPQgj (ORCPT + 9 others); Fri, 16 Oct 2020 12:36:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45952 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2410846AbgJPQgh (ORCPT ); Fri, 16 Oct 2020 12:36:37 -0400 Received: from mail-pf1-x44a.google.com (mail-pf1-x44a.google.com [IPv6:2607:f8b0:4864:20::44a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 124EBC061755 for ; Fri, 16 Oct 2020 09:36:38 -0700 (PDT) Received: by mail-pf1-x44a.google.com with SMTP id w78so1744792pfc.15 for ; Fri, 16 Oct 2020 09:36:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=sender:date:message-id:mime-version:subject:from:cc; bh=ESK7AGq3xcY8c9Kxha7AtdakH67WdRXIQfnsDd+BhXg=; b=dofkqMiAcYaTZ/EU/5BiqncgO4c4vvmzEbKqHqFSlvIscLiIgRE/bTb1TustzDyW5+ 1d+MDxzUeGcty3tPvWgNBr8re5d1r05uCLQVUyvDWo12ygO68kqBUaC/YvvrQOBXKx6C lDzvruetF0BhW2g9fEHlRdHlShRQBxUvfcBGy8xB8BE0KZm0AhYakD993Plztl0nmxu3 7W2ffDpO0liBBnb7GDO5SbSR2mrFTmtKJxjCIoQwys77J/qZgidVxMhgN6EqoA4KNTk8 wX+qKyK6iRoT+AGjl7M1ZrIyJhBDRT/klURxjkDudaL3DgoJBj3dfx2KzoXfZyfAjs/H DAPw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:date:message-id:mime-version:subject:from :cc; bh=ESK7AGq3xcY8c9Kxha7AtdakH67WdRXIQfnsDd+BhXg=; b=MuMnzxF1zkR3cQJJa9rlWH0pxgDh9Kbk91G2KFMGzWNReHbg43qzx3hQtDWJMlL+J9 6KoVwKqZ7I52Ny+haAJSfr/5qLKP9gWw+BRRbjCu+koTWW/P8yDh6EWHQR0xARWi2pbA qN5RY3BA1OeLjJuO7mtZTA7jZTOFGoEfnqZkLOhoqWuUU9v5JkJ4k/GxiwKUayNDJY83 7aqTeK//Vc81SUq+yOYdSQPXENY6tdcmyHqGlc32EOzATvrdfG16EUW4i86IwSWdSAet Q1Y6Od12yaD4ESiVdeOEe+hz1Zr30ZGGLSo22ZsxKTJo6jn0E3tQ9GoMuhIV84qPJ+NO GXDA== X-Gm-Message-State: AOAM530CcFYQXpDGxUkSLjIyAKby+bL7Nk4zwmOfnmbi+tWzaJODxZYr CsK8M8Mjfq2571DqP31lUfQ0N5U= Sender: "wvw via sendgmr" X-Received: from wvw-pc.mtv.corp.google.com ([2620:15c:211:1:f693:9fff:fef4:4f9b]) (user=wvw job=sendgmr) by 2002:a17:902:402:b029:d5:ac47:c33f with SMTP id 2-20020a1709020402b02900d5ac47c33fmr4582746ple.60.1602866197061; Fri, 16 Oct 2020 09:36:37 -0700 (PDT) Date: Fri, 16 Oct 2020 09:36:33 -0700 Message-Id: <20201016163634.857573-1-wvw@google.com> Mime-Version: 1.0 X-Mailer: git-send-email 2.29.0.rc1.297.gfa9743e501-goog Subject: [PATCH] sched: cpufreq_schedutil: maintain raw cache when next_f is not changed From: Wei Wang Cc: wei.vince.wang@gmail.com, viresh.kumar@linaro.org, qperret@google.com, Wei Wang , "Rafael J. Wysocki" , Ingo Molnar , Peter Zijlstra , Juri Lelli , Vincent Guittot , Dietmar Eggemann , Steven Rostedt , Ben Segall , Mel Gorman , Daniel Bristot de Oliveira , linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org To: unlisted-recipients:; (no To-header on input) Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org Currently, raw cache will be reset when next_f is changed after get_next_freq for correctness. However, it may introduce more cycles. This patch changes it to maintain the cached value instead of dropping it. This is adapted from https://android-review.googlesource.com/1352810/ Signed-off-by: Wei Wang --- kernel/sched/cpufreq_schedutil.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) -- 2.29.0.rc1.297.gfa9743e501-goog diff --git a/kernel/sched/cpufreq_schedutil.c b/kernel/sched/cpufreq_schedutil.c index 5ae7b4e6e8d6..ae3ae7fcd027 100644 --- a/kernel/sched/cpufreq_schedutil.c +++ b/kernel/sched/cpufreq_schedutil.c @@ -31,6 +31,7 @@ struct sugov_policy { s64 freq_update_delay_ns; unsigned int next_freq; unsigned int cached_raw_freq; + unsigned int prev_cached_raw_freq; /* The next fields are only needed if fast switch cannot be used: */ struct irq_work irq_work; @@ -165,6 +166,7 @@ static unsigned int get_next_freq(struct sugov_policy *sg_policy, return sg_policy->next_freq; sg_policy->need_freq_update = false; + sg_policy->prev_cached_raw_freq = sg_policy->cached_raw_freq; sg_policy->cached_raw_freq = freq; return cpufreq_driver_resolve_freq(policy, freq); } @@ -464,8 +466,8 @@ static void sugov_update_single(struct update_util_data *hook, u64 time, if (busy && next_f < sg_policy->next_freq) { next_f = sg_policy->next_freq; - /* Reset cached freq as next_freq has changed */ - sg_policy->cached_raw_freq = 0; + /* Restore cached freq as next_freq has changed */ + sg_policy->cached_raw_freq = sg_policy->prev_cached_raw_freq; } /* @@ -828,6 +830,7 @@ static int sugov_start(struct cpufreq_policy *policy) sg_policy->limits_changed = false; sg_policy->need_freq_update = false; sg_policy->cached_raw_freq = 0; + sg_policy->prev_cached_raw_freq = 0; for_each_cpu(cpu, policy->cpus) { struct sugov_cpu *sg_cpu = &per_cpu(sugov_cpu, cpu);