From patchwork Wed Mar 22 15:18:42 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lukasz Luba X-Patchwork-Id: 13184237 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id E8835C76195 for ; Wed, 22 Mar 2023 15:20:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231312AbjCVPUT (ORCPT ); Wed, 22 Mar 2023 11:20:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57224 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231601AbjCVPUS (ORCPT ); Wed, 22 Mar 2023 11:20:18 -0400 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id B68445DC8B; Wed, 22 Mar 2023 08:20:17 -0700 (PDT) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 6A60E15DB; Wed, 22 Mar 2023 08:21:01 -0700 (PDT) Received: from e123648.arm.com (unknown [10.57.18.173]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id BE2843F71E; Wed, 22 Mar 2023 08:20:14 -0700 (PDT) From: Lukasz Luba To: linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org Cc: rostedt@goodmis.org, mhiramat@kernel.org, mingo@redhat.com, peterz@infradead.org, juri.lelli@redhat.com, vincent.guittot@linaro.org, dietmar.eggemann@arm.com, bsegall@google.com, mgorman@suse.de, bristot@redhat.com, vschneid@redhat.com, delyank@fb.com, lukasz.luba@arm.com, qyousef@google.com Subject: [PATCH 2/3] cpufreq: schedutil: Refactor sugov_update_shared() internals Date: Wed, 22 Mar 2023 15:18:42 +0000 Message-Id: <20230322151843.14390-3-lukasz.luba@arm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20230322151843.14390-1-lukasz.luba@arm.com> References: <20230322151843.14390-1-lukasz.luba@arm.com> Precedence: bulk List-ID: X-Mailing-List: linux-trace-kernel@vger.kernel.org Remove the if section block. Use the simple check to bail out and jump to the unlock at the end. That makes the code more readable and ready for some future tracing. Signed-off-by: Lukasz Luba --- kernel/sched/cpufreq_schedutil.c | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/kernel/sched/cpufreq_schedutil.c b/kernel/sched/cpufreq_schedutil.c index e3211455b203..f462496e5c07 100644 --- a/kernel/sched/cpufreq_schedutil.c +++ b/kernel/sched/cpufreq_schedutil.c @@ -446,17 +446,19 @@ sugov_update_shared(struct update_util_data *hook, u64 time, unsigned int flags) ignore_dl_rate_limit(sg_cpu); - if (sugov_should_update_freq(sg_policy, time)) { - next_f = sugov_next_freq_shared(sg_cpu, time); + if (!sugov_should_update_freq(sg_policy, time)) + goto unlock; - if (!sugov_update_next_freq(sg_policy, time, next_f)) - goto unlock; + 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) + cpufreq_driver_fast_switch(sg_policy->policy, next_f); + else + sugov_deferred_update(sg_policy); - if (sg_policy->policy->fast_switch_enabled) - cpufreq_driver_fast_switch(sg_policy->policy, next_f); - else - sugov_deferred_update(sg_policy); - } unlock: raw_spin_unlock(&sg_policy->update_lock); }