Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp227573pxb; Tue, 23 Feb 2021 23:57:03 -0800 (PST) X-Google-Smtp-Source: ABdhPJzAzC9RhRx9f3l4sT2LnMjFAiaDRji34YiFXC6DzWULXlYwpMJMaLrAKsjo8cOCCJ0hogfm X-Received: by 2002:a05:6402:308c:: with SMTP id de12mr31612009edb.255.1614153423228; Tue, 23 Feb 2021 23:57:03 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1614153423; cv=none; d=google.com; s=arc-20160816; b=nbp4TtJriSrf80x7noOlGXyQf/c0i1yZQwXbxaDnypIwS/LYXG+1m/72S6EpcTM8kg lIzb0uhyxCEd7//J8ioNs87LEdXtWtHS+zNeD4eoAuiwwMftK55jNgVVC4mztq/SpXO8 w26zw/la0ezWEhl56ECwXBvqgKHEAWtXJu+O753+AFZbWN1NQJtFIDIuPWH+R+LPvvWu uAGWhlEuHppdwNaPywxzu9i08Md/FhjkCVo4YO1WpdvJsN46l9HHeFau7LuDHLcx2e7D azH+o2qqzO/Ma+g7MmVr1f+zb+vTYUmFVX1DA057mDokxoIt7emmxv9+//J4Ipw+JgMN Uhcg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=3LG0BhVnu4iz0iyFBpTqgUDFv1szlGALeoWhu9s88OI=; b=o+FV4hlOB8GmCRiBvRGxMwpKzniGW6nfz1P0X+9HYjcmz8mG4lUj+tc2J0ylORMJWk K6rREHYoXzddfRmyJ7W3xRWPHaVT6vPLYll4vBd57IMiYv189j//BkI4c1yrYMta7E6D 2HAePDA/gsj8syeBHf5EUmmw7WJ+D+Ld88gDKWkQEbk/7aZe3dMk5MJJ7ok9nGeE45S4 runCQnVlB9pLt2LZzdXsSenSlepeNK405bNSFgCssoWemaFh70TxrWUNO6zRrTE9n7n5 ABEwru6ANBaHq6nLG6VUzd7ATohqJFg0Jv4STHsMWZ8wkrGZYuYZy7AXkCLuv+2K/hLU XG5A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=pStPBhZl; 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=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id p24si717171edw.475.2021.02.23.23.56.39; Tue, 23 Feb 2021 23:57:03 -0800 (PST) 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=@linaro.org header.s=google header.b=pStPBhZl; 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=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234040AbhBXGDW (ORCPT + 99 others); Wed, 24 Feb 2021 01:03:22 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59944 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234031AbhBXGDU (ORCPT ); Wed, 24 Feb 2021 01:03:20 -0500 Received: from mail-pj1-x1029.google.com (mail-pj1-x1029.google.com [IPv6:2607:f8b0:4864:20::1029]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EECE4C061574 for ; Tue, 23 Feb 2021 22:02:39 -0800 (PST) Received: by mail-pj1-x1029.google.com with SMTP id l18so615243pji.3 for ; Tue, 23 Feb 2021 22:02:39 -0800 (PST) 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=3LG0BhVnu4iz0iyFBpTqgUDFv1szlGALeoWhu9s88OI=; b=pStPBhZlG3uqDu09IqRmrBX2CmAUWlU16dzzb3AoOtspcJdh9T+ltKLtdvcy5lx2Yc eNQxmycupFYTTrvnhtVYCy4DmMEGvOnMfyYLMKfItegvu+v2VEXI++GLAYY3pWPBBMUw ENY4UlETpfHyqe3CZYc/NsCJgFrRgZzxNb4h8aGs6HZ0qKFgwuZ2ExAvEjb7cdov/nbu 5G7CdN/ajv9/Qhn3S7G40woem9lmTT6K4BA2R+mfEOSpQTb1cY37/ZOZIn6h9IZ5zpg5 vb92j2IR6ITd0BGl43MZlPbiu9lyq+fghSvrvvm9Ka0YD52lI3RqdL6I1qWX6sHwmc+H qAEw== 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=3LG0BhVnu4iz0iyFBpTqgUDFv1szlGALeoWhu9s88OI=; b=UAYPJRjHaqJByeiQzo+0xWhiq2pAfMDLlxrZYG+9qSN7tRzDM8VTXfQYJ+vYMUjO9T 4P59LqEtN5V6LeaBjkWPiWpw5UvvdMB2PyCaIXcphANAsFY3gsSD/tbZh5Q0aszPqSRM Q0n6hqQtnPKqeN0dWThzkZMD0FxJcmeT76trWjgPGV7iMXuY8f4JNpecBCiXUCzHG9/u 4EJhR4XyphIQE772BUDw9sRJ5BkRy55YarrUdf1UoFgPx0bm5mXz6jOeb+mxe8aFOtHX 5sk0nATyGiMw//l2IifhoGghKqQzJ1ocgfln8kSDavLZwfXwyFDsa5fJO0OS5qk+NzgC qY+A== X-Gm-Message-State: AOAM531Ut/NSi3o5dbyTQqZsHTsYjxef2JZekyY7XobYWvXR/psbhx9Z KUdnpq/VUogwN6C6LFcyqjOzoA== X-Received: by 2002:a17:90a:4301:: with SMTP id q1mr2674900pjg.57.1614146559264; Tue, 23 Feb 2021 22:02:39 -0800 (PST) Received: from localhost ([122.172.59.240]) by smtp.gmail.com with ESMTPSA id i25sm846441pgb.33.2021.02.23.22.02.38 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 23 Feb 2021 22:02:38 -0800 (PST) Date: Wed, 24 Feb 2021 11:32:36 +0530 From: Viresh Kumar To: Yue Hu Cc: rjw@rjwysocki.net, mingo@redhat.com, peterz@infradead.org, juri.lelli@redhat.com, vincent.guittot@linaro.org, linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, huyue2@yulong.com, zbestahu@163.com Subject: Re: [PATCH] cpufreq: schedutil: Call sugov_update_next_freq() before check to fast_switch_enabled Message-ID: <20210224060236.xaviwqfsujjvwnne@vireshk-i7> References: <20210224054232.1222-1-zbestahu@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210224054232.1222-1-zbestahu@gmail.com> User-Agent: NeoMutt/20180716-391-311a52 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 24-02-21, 13:42, Yue Hu wrote: > From: Yue Hu > > Note that sugov_update_next_freq() may return false, that means the > caller sugov_fast_switch() will do nothing except fast switch check. > > Similarly, sugov_deferred_update() also has unnecessary operations > of raw_spin_{lock,unlock} in sugov_update_single_freq() for that case. > > So, let's call sugov_update_next_freq() before the fast switch check > to avoid unnecessary behaviors above. Update the related interface > definitions accordingly. > > Signed-off-by: Yue Hu > --- > kernel/sched/cpufreq_schedutil.c | 28 ++++++++++++++-------------- > 1 file changed, 14 insertions(+), 14 deletions(-) > > diff --git a/kernel/sched/cpufreq_schedutil.c b/kernel/sched/cpufreq_schedutil.c > index 41e498b..d23e5be 100644 > --- a/kernel/sched/cpufreq_schedutil.c > +++ b/kernel/sched/cpufreq_schedutil.c > @@ -114,19 +114,13 @@ static bool sugov_update_next_freq(struct sugov_policy *sg_policy, u64 time, > return true; > } > > -static void sugov_fast_switch(struct sugov_policy *sg_policy, u64 time, > - unsigned int next_freq) > +static void sugov_fast_switch(struct sugov_policy *sg_policy, unsigned int next_freq) > { > - if (sugov_update_next_freq(sg_policy, time, next_freq)) > - cpufreq_driver_fast_switch(sg_policy->policy, next_freq); > + cpufreq_driver_fast_switch(sg_policy->policy, next_freq); I will call this directly instead, no need of the wrapper anymore. > } > > -static void sugov_deferred_update(struct sugov_policy *sg_policy, u64 time, > - unsigned int next_freq) > +static void sugov_deferred_update(struct sugov_policy *sg_policy) > { > - if (!sugov_update_next_freq(sg_policy, time, next_freq)) > - return; > - > if (!sg_policy->work_in_progress) { > sg_policy->work_in_progress = true; > irq_work_queue(&sg_policy->irq_work); > @@ -368,16 +362,19 @@ static void sugov_update_single_freq(struct update_util_data *hook, u64 time, > sg_policy->cached_raw_freq = cached_freq; > } > > + if (!sugov_update_next_freq(sg_policy, time, next_f)) > + return; > + > /* > * This code runs under rq->lock for the target CPU, so it won't run > * concurrently on two different CPUs for the same target and it is not > * necessary to acquire the lock in the fast switch case. > */ > if (sg_policy->policy->fast_switch_enabled) { > - sugov_fast_switch(sg_policy, time, next_f); > + sugov_fast_switch(sg_policy, next_f); > } else { > raw_spin_lock(&sg_policy->update_lock); > - sugov_deferred_update(sg_policy, time, next_f); > + sugov_deferred_update(sg_policy); > raw_spin_unlock(&sg_policy->update_lock); > } > } > @@ -456,12 +453,15 @@ static unsigned int sugov_next_freq_shared(struct sugov_cpu *sg_cpu, u64 time) > if (sugov_should_update_freq(sg_policy, time)) { > next_f = sugov_next_freq_shared(sg_cpu, time); > > + if (!sugov_update_next_freq(sg_policy, time, next_f)) > + goto unlock; > + > if (sg_policy->policy->fast_switch_enabled) > - sugov_fast_switch(sg_policy, time, next_f); > + sugov_fast_switch(sg_policy, next_f); > else > - sugov_deferred_update(sg_policy, time, next_f); > + sugov_deferred_update(sg_policy); > } > - > +unlock: > raw_spin_unlock(&sg_policy->update_lock); > } -- viresh