Received: by 2002:a05:6a10:6744:0:0:0:0 with SMTP id w4csp1374791pxu; Fri, 16 Oct 2020 10:20:10 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxa1QARLyylW4PnzUIsab2DMvsvAdWcNNhNIMT560Oaq4fmOxldrIRwdA/iIrOLR0gsKtoS X-Received: by 2002:aa7:c7c2:: with SMTP id o2mr5344233eds.366.1602868810568; Fri, 16 Oct 2020 10:20:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1602868810; cv=none; d=google.com; s=arc-20160816; b=fRz4WYn8njuQXKrEXxfdtUGPCjO/U47ZrXveorK3h/XXnImR35LwuQKbL1xOvmto7Q 6WY0iWwknXvXubZ/FHz7LhrQ02h7VIDfm0vRUMg3vwMRT2GgT/oHEFedDgWxvuA3ruYz rQI7d9KAtEJEh7CUEfKUOPJ59PijjDssYHWGtMsX/fcX0DDTAMAFeF7HIZveLDZdCkaW gDVRVyYvlLEdqbYCxpm4XlUf7nC1B847wen1WM1yPJoai1afMEtsduTTt6bkeuoYIPNC 1pj8vZ0zT86jdHDXPYoicxmMXqoiQdZqLkaTidWOaal3oipE4T0tRbKEG08WCNgo+c0L ZtEQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=n94Aye7p3JfVB9OWEVZfTsET/k6kwBnbW1NyhTebgm0=; b=e7ytT5i/ooePssZZb0PkCSDUUEqzwYD4FdmJRWCep80tjEnmtLUgO5I+9p9513ijJM T3H3A3PFDbijI8YjVjgw2Ibce0BV1MxGFWJiirJivKuj/myJgkcFEswJVhkLvEb/RTzK cLFq46nVfRk1MjtHyqueH8eMxGazk6mg7C9E81kDEhSQvsVuknzoPipvSWNk3YPvq8Np Vi5iyBcMbUtIn99rmHxby2g+tgIuKVTyCVCchWm8E4mgbtPXbjNWqtz7UKAi4+b1GMnx 0ruUQySeJKOgAZ49Bw3OdsbPRFN85eXdXIIevEC23y/VA1f4V7ogC0Kn42ueSd74Yyfq c54A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b="MXe/RlNt"; 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=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 u2si2190715edq.230.2020.10.16.10.19.48; Fri, 16 Oct 2020 10:20:10 -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; dkim=pass header.i=@google.com header.s=20161025 header.b="MXe/RlNt"; 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=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2390212AbgJPRSI (ORCPT + 99 others); Fri, 16 Oct 2020 13:18:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52342 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732580AbgJPRSI (ORCPT ); Fri, 16 Oct 2020 13:18:08 -0400 Received: from mail-ej1-x642.google.com (mail-ej1-x642.google.com [IPv6:2a00:1450:4864:20::642]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3A595C0613D3 for ; Fri, 16 Oct 2020 10:18:08 -0700 (PDT) Received: by mail-ej1-x642.google.com with SMTP id h24so4255396ejg.9 for ; Fri, 16 Oct 2020 10:18:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=n94Aye7p3JfVB9OWEVZfTsET/k6kwBnbW1NyhTebgm0=; b=MXe/RlNtDcm7WmVWFKDrU32h37x7JqsxCQ0bYdYnCA8PwEMLhCFZDac8it5CjMwsj0 YRwzHriIDngcRdS6/ZMdt+d2U/KNGvr4TWgPvzTEWqLCeo1tQUGkKWGwkcINPz6JqX6n elXBSN0v7qKAvTya4tu7H1T3//dv1GZFkj395XpcREj7uOSgac/8PWLmfm7qKEx1ZZhU 5Oxr52FoRFm0XrZcjXCqFh4vRriDbE18XLwtVXMAFMLXAPxW0O8GxZKpd/zozWK16nZ1 G3eBKVQ9uYhacdk23r4cxLPqrTN2iAqOm+zXa053vR2pxTe1jBi34ejoXIKpqTVH7kh/ cqkw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=n94Aye7p3JfVB9OWEVZfTsET/k6kwBnbW1NyhTebgm0=; b=XPpzfNu1RGEOgZBs9ZoJYVsX5xl8Ip/VeWCySUA3HGjVwxghDlpnwylZ6NSrNh9G5m E1l3F7RE3r05TBG+YZY4qE8g2n6LsbGtAv0jlc5MT830rGi2mcT2S9d7o5WM/0qrPDrR 8j21pJPoqG+hMFA+22j81e5H+Wy7zhr/1EBHr4EagLF/VBvTFcGia2qnQsg4jndBiPiB +hrWxjOlyJ6N4uKIQqkxBl+BsH2fwJ7B5OH5hW70lpOFjdtDSCL9b/Pakypq/JFD2HIj DEnGcvYXFkqskdUx4QM2Nop0m+u+IBIr33ZutTxb99BQ8YLx+YCt3rmX5/5qSdyIT//A DtLw== X-Gm-Message-State: AOAM530QdiFlMI7YYNKnnNPiK6XIt9hKmqhQjUJsfus/0fUkMo+QBBE9 5ojLEjVukII+GwDa0MWRB6/hy6SgEOTGD0YFVpuINQ== X-Received: by 2002:a17:906:364f:: with SMTP id r15mr4775896ejb.388.1602868685981; Fri, 16 Oct 2020 10:18:05 -0700 (PDT) MIME-Version: 1.0 References: <20201016163634.857573-1-wvw@google.com> In-Reply-To: From: Wei Wang Date: Fri, 16 Oct 2020 10:17:54 -0700 Message-ID: Subject: Re: [PATCH] sched: cpufreq_schedutil: maintain raw cache when next_f is not changed To: "Rafael J. Wysocki" Cc: Wei Wang , Viresh Kumar , Quentin Perret , "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 , Linux Kernel Mailing List Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Oct 16, 2020 at 10:01 AM Rafael J. Wysocki wrote: > > On Fri, Oct 16, 2020 at 6:36 PM Wei Wang wrote: > > > > 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. > > IMV you need to be more specific about why this helps. > I think the idea of cached_raw_freq is to reduce the chance of calling cpufreq drivers (in some arch those may be costly) but sometimes the cache will be wiped for correctness. The purpose of this patch is to still keep the cached value instead of wiping them. thx wvw > > > 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(-) > > > > 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); > > -- > > 2.29.0.rc1.297.gfa9743e501-goog > >