Received: by 2002:a05:6a10:6744:0:0:0:0 with SMTP id w4csp1474155pxu; Fri, 16 Oct 2020 12:57:19 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwe4HQciAhUc0K0ZT4KHVD0HLOGuWk6PzBi7lzsjEZZeGh7eaoXXgOvz7+ueoK7ED9Faz8k X-Received: by 2002:aa7:c586:: with SMTP id g6mr5896098edq.343.1602878239052; Fri, 16 Oct 2020 12:57:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1602878239; cv=none; d=google.com; s=arc-20160816; b=odC7muFX8oGNziM/aOdvXPUxlvzjvXR1zA5wIf+T8OXS1azbMYRh179K6h31khJlQL r7ky3jzvP2UaUDa1b/ozrZYfgzuLvWDVRiLJGb6Rh4RWdegnpipz28p42W0b1ArCvAtj NzM6ErVw3PAPzAUQT4BM8PbDw6ttyEpm8DSijSIwYgyMeXslfFzM4lNnkP1ZPFnFDZ/K nxgBtEX16LU5xJMUYZKcC5ip0OJkthOTE/bd/IoFq+YCMiN4Ht3FFxhuujldy3Lr6a0g BtSCXIog2vMVqWjszW84hWtiWC1qe24wbvc7j+GMkq9zzQ0frA2UBu6tPP5x6iScCnct pAWA== 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; bh=2Himune9w6PJjlJKnqlQ8/CdxmtO3vE0wktnjw8cHEI=; b=PK3qE5vy+AXHnzPUPngEz5atObF3tNJUoRipgLe/KtBqa9WdnqDPw4Mxp0ZDzrc31/ fIl3JSXd0jiVJZiIN1dhrx3VUiyGfD2yohPPU+LxoysqboObu9VblEgCJf7Eym/xM8ox +FSX/HVaR/aKGgR7wd6kvAj0luUc3I9+8i3+wwACcyqteiOyTf7q2EVGfwUVZT4rETX5 xUkBzEyxuio9SRTzcyHGnOQU/JR5Rqi0mmD9eSKWf7VBGFyGFSiVpnnCd0sNGcx97TUR W6dPcvoQ0ySwxyF7Cc3KerH8TnsR4EYEend4HNftflz7rknlonFW3D1KRROmHiyqe5By kozw== 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=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id l2si2396683ejb.423.2020.10.16.12.56.56; Fri, 16 Oct 2020 12:57:19 -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=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2410447AbgJPRBy (ORCPT + 99 others); Fri, 16 Oct 2020 13:01:54 -0400 Received: from mail-ot1-f68.google.com ([209.85.210.68]:35440 "EHLO mail-ot1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2408925AbgJPRBy (ORCPT ); Fri, 16 Oct 2020 13:01:54 -0400 Received: by mail-ot1-f68.google.com with SMTP id f22so439146ots.2; Fri, 16 Oct 2020 10:01:53 -0700 (PDT) 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=2Himune9w6PJjlJKnqlQ8/CdxmtO3vE0wktnjw8cHEI=; b=DwF0RNFFQBbt+KIaH8w/5Z0LWk3GG/c/JcCtX/+bTDgWI0v1Cy4s9aC0AdstydWMZS fK9ngfOxcswwQpNw84qVaTdyDIGuRYF4X34LSiUj3uAIyi4hTjBUM+XCsrbX6lWGggFi sUEeqwbdoFtAhFXnFjwda9kaH5xTD48vlKVdHtXcHC3+JAE0Dh7LWjrYmAxzpzEzBntR EbUO1H1TXwmZ+9rNdUafa5WR+l+wh4JgMEQIJNsNhndsKbeQU+RSrGJHevXjFHCQnfvh 8iU4MjsyVzxrIIaiLRybmGWLtJRbxOsjpmkaaD5X5lqqpMKTXoiScYPViAQivlg1YiNw tayw== X-Gm-Message-State: AOAM533Qwd6KRxB/ghgOYtRa3oAaYC1G+D3QeJPxab/Sw8qY2VKFyXyr KFZLSJ4rNrrz30ysajsYBygtPYs9YuTCIwSUxMI= X-Received: by 2002:a05:6830:30ae:: with SMTP id g14mr3471060ots.206.1602867713251; Fri, 16 Oct 2020 10:01:53 -0700 (PDT) MIME-Version: 1.0 References: <20201016163634.857573-1-wvw@google.com> In-Reply-To: <20201016163634.857573-1-wvw@google.com> From: "Rafael J. Wysocki" Date: Fri, 16 Oct 2020 19:01:42 +0200 Message-ID: Subject: Re: [PATCH] sched: cpufreq_schedutil: maintain raw cache when next_f is not changed To: Wei Wang Cc: wei.vince.wang@gmail.com, 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 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. > 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 >