Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp802403pxf; Thu, 18 Mar 2021 11:54:38 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy69xadS+b5ETLsMLFhIhKbG89fhZhdAfr+ClSudBETLbofNBJ7lexUJqeS0k4r6DSq4WqF X-Received: by 2002:a17:907:2d24:: with SMTP id gs36mr23479ejc.344.1616093677842; Thu, 18 Mar 2021 11:54:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1616093677; cv=none; d=google.com; s=arc-20160816; b=gzQEEYGaB5KlCCxkoTIj5WHW2StHsTNhg6AeT1yr5eOINwzgzHXMsxfxlIFgKp/qLi fcS5XzrX/5vikMgrEylOyP7q1oASmcu22Z2WC0a7Yvj/LAFpez/GQy8CWupuVGU57ePU Dto6AiLhkX2EWo44YyT1FGq/Qkv71r/Dgb1kBiriYCTfLH7Fo/z/7mWRJ5PS7pNS5/Nh 8PabetsdEpBtVPCTJkghTZ71b2Cr+1o+yKuSl3RnLvgQVGlUlYCswmqRsZ2/6Y6EGPU7 AP0Asx8yC9q9ReCfWmOBkMLPiYAgei4L5q7d7DHrWSpOg4vDld62ji1XiRja+Wf8aw2v RtsQ== 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=xE/+zwrG8Sz1bNHFmDwKKVFIzwhY9mhnwyiscge5jEE=; b=RKAZ/jBVoBDOSob0UQfJdfOXkKZSpHp7f5ntQsGH+wr1V9n1fZk/Aws3qfytCk0pfB yOOkiE4tvqdLCm7xwHZssQPEe7Mmx2i7YDkzzEv9tbmCLyf6sNbejGAijU+49szvxzOY wJluQ8X4+Up70+uEz5dZRvfstpCKuJR2pnuhd6Avx0J8+diMDJRRBqLJ6i82LT05bksH 2/W3rZH1JZq6f7BRtHzsH1p019FaNh0+Tx9yDSxhSF3jxJCvsDP2zmsVOaVVfEZbvGZ2 tqOo8eYnD1azilCHtqrZq82mdJS/hkOdG4P4nYtspQ6oaZOJk8Z8QkNnugxjn5A9Gvkg JwKw== 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 qc18si2204611ejb.574.2021.03.18.11.54.14; Thu, 18 Mar 2021 11:54:37 -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 S232357AbhCRSvT (ORCPT + 99 others); Thu, 18 Mar 2021 14:51:19 -0400 Received: from mail-oo1-f45.google.com ([209.85.161.45]:36783 "EHLO mail-oo1-f45.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232502AbhCRSuq (ORCPT ); Thu, 18 Mar 2021 14:50:46 -0400 Received: by mail-oo1-f45.google.com with SMTP id w1-20020a4adec10000b02901bc77feac3eso1686758oou.3; Thu, 18 Mar 2021 11:50:45 -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=xE/+zwrG8Sz1bNHFmDwKKVFIzwhY9mhnwyiscge5jEE=; b=Nr54tlfnRT2ceElKMccWjwzzh6bSpVCA0UZu34HV3DKG9KSKlZ7pAfhW0JDcLctgZE v62hQ8OlSnGHqrD4JoCc6vZ7cNgVQYBHAT1Fd2FhKn+7zgNaBYpsw0ZujaQV3I6FJeYj 3LQKP4c1US+MGmhi8Z/X8jb+hGMwwtOcqSwBNdLpisnEKs7GiX5iWE11i4R8kaTnjM3t rYgRz4VRSQSVCUZ0EH67cR30Lii6ltT7DzQnYeRMf6MIvdEQr3uL4AdTkGJB9j8/Hc0j 4HOZ/YBjlcAZqDBXN+IqLKpc+s245hkLJ53YdYT1mAjiOzg/XwN5OV398htezhYmYbqK 2Eqg== X-Gm-Message-State: AOAM531lutk3b7fwyGD6CTeHdrL8V21Om9Dgfcl8JoXByFIWofZSnQBX ozj2LJS96NKtCdz8afjrx/wUcGs6SJLOIqD80Ek= X-Received: by 2002:a4a:bb14:: with SMTP id f20mr8743168oop.1.1616093445406; Thu, 18 Mar 2021 11:50:45 -0700 (PDT) MIME-Version: 1.0 References: <20210224054232.1222-1-zbestahu@gmail.com> In-Reply-To: <20210224054232.1222-1-zbestahu@gmail.com> From: "Rafael J. Wysocki" Date: Thu, 18 Mar 2021 19:50:34 +0100 Message-ID: Subject: Re: [PATCH] cpufreq: schedutil: Call sugov_update_next_freq() before check to fast_switch_enabled To: Yue Hu Cc: "Rafael J. Wysocki" , Viresh Kumar , Ingo Molnar , Peter Zijlstra , Juri Lelli , Vincent Guittot , Linux PM , Linux Kernel Mailing List , Yue Hu , Yue Hu Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Feb 24, 2021 at 6:44 AM 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); > } > > -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); > } > > -- Applied as 5.13 material, thanks!