From patchwork Wed Sep 2 07:24:44 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 248961 Delivered-To: patch@linaro.org Received: by 2002:a92:5b9c:0:0:0:0:0 with SMTP id c28csp190958ilg; Wed, 2 Sep 2020 00:25:14 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwDmA0RGTTUk6d1MtdGH7FuT817MzUgFhKV/i2BOZtxaOMl52ZT2C1CNO0m0MrrxQ2/w/2W X-Received: by 2002:a50:f081:: with SMTP id v1mr5447167edl.161.1599031514544; Wed, 02 Sep 2020 00:25:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1599031514; cv=none; d=google.com; s=arc-20160816; b=XccCrm92KPJcHF11skeZcdU/LNrPOS2gs0RXIJM1Sl01gBPizJ57l8eMSt32DtN8oJ KH/y7oRYS0ZuHGaAbYRFjAXx0qhiuPoXst2p5oDXv15QEUXueKyZ260TFMTuC+Jwem9L HEgKWJLlLaGMlGS4GrdGzTYwBhh8RlL6yED9RzR+1ZPK9B8Hl9NT5Bwrsx3wMqhKxrpf VzamJEJ/R2/8uH1RZfjPnTN9cwWLw6XNvAerdpV7sbA837vsV4kyzfM5AjiYRMlyihB2 G4ndktI3bGLKhXHzMyN6LrCzQ/vSqetVg+a1Q/0XRzghrvo19LH91zAO1Yqx/wD6vcy9 Pt3w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=j9iUKTmxDCnsjI9D2FE0HYnpMw3U8pIfYBDaFqDjR3Y=; b=Cd5oWUWrdpz8HtaUECTZJ2v0w9plkm3F5Lcxb4R9A6yWto3iru8rlv0eAb8wmAHsj7 fHVrUBMN5OVi9lSImhGQejowpRQQzE2+AP+2qqcX8Gee0KpXQkkip4N4sr45RK73L5HN Nz8CUfGxFtavQNgIUPAgw4I5DLClAAa5Kwe4fmshL218z8nLsVqcqUx2CK764IWG3+Fz q9LsFw1rqTgvxMTh8Kw52lw77iOv1F/EX0/hMrTdSFhfB4KpYz9S5d3n859+La2iYPho PSF5WkziO5ILgXYbH7evYdQ7TVGjuDQkQdyW1hI9UDGmgMq7ppey6Nkce3woHjpuqLOU loHA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=kQt3TjnH; spf=pass (google.com: domain of linux-pm-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-pm-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 d3si2053372edo.152.2020.09.02.00.25.14; Wed, 02 Sep 2020 00:25:14 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-pm-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=kQt3TjnH; spf=pass (google.com: domain of linux-pm-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-pm-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 S1727845AbgIBHZN (ORCPT + 10 others); Wed, 2 Sep 2020 03:25:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60204 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727824AbgIBHZL (ORCPT ); Wed, 2 Sep 2020 03:25:11 -0400 Received: from mail-pl1-x643.google.com (mail-pl1-x643.google.com [IPv6:2607:f8b0:4864:20::643]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3D41EC061244 for ; Wed, 2 Sep 2020 00:25:11 -0700 (PDT) Received: by mail-pl1-x643.google.com with SMTP id z15so1879198plo.7 for ; Wed, 02 Sep 2020 00:25:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=j9iUKTmxDCnsjI9D2FE0HYnpMw3U8pIfYBDaFqDjR3Y=; b=kQt3TjnH53yJTlq71MyV9vFyJS84thyJs1LOMPFhAgnL+ipFolq38cRsvGI+ZjULq6 5RnEoMl2TA4mjX6LGAcMMZ+xeaxxju8XuJTzD1CGCxCqkU8arjVrqUbyNv4iIXIjJJ4L V+T0vFkFUw5dr65LdX/ot8oYoZp3hP4nYxIDStJr0Hs5q7Gp0k/IBsa7LwX3qI1pMVNd B3Z7lbgLwLX2twOpkdBrUkV7SrkZs8sSIOb55vdq/CCvueQrqpomorSlFMJKqnKx8no5 rNlggaim9Pl0tkHcjliy+/zKU1KXD7FA2zpKIJuydPc3iUtlMKCdKiKGEkrI9yP57VB0 cGNA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=j9iUKTmxDCnsjI9D2FE0HYnpMw3U8pIfYBDaFqDjR3Y=; b=Eq2N+Ls3JlFypw8XOU5fv67j9U/Lu0VVKjBv2rwcTMRoH7uOkgr6BOzRUb97zPswL4 Y8kVeqA7512qG5m7eMK7pCG4FedHEGKf1gMEud5FgO/q1UkgBIYF2MhugVprflWjuqfN hVUCGc1DClMLZz/bhEZu+6Dg5ucUyFIZkRvYJtTQ6yqPh8/E2W3JBqULn8xIz+lgqDk/ 8eKwiFxct1qXHzAn1qyTun7s9CfACvt1jH+hPlaiYPjdkrcNTBC4fCjHEWjyyatAipk5 6hDaO8aE/p444VmmXptQxr4qatEkpJHEByBh86Z9oN2/pmAeAEaajGCFJeduQl5l8ces GFbQ== X-Gm-Message-State: AOAM532r7gEfzLTQqSvCJz/I/CoC5Pe5NkFdJIn5S/DBZ/q0Lj68Q+1P nDHmAwAw4cr4svXVJQ3SZlBaYg== X-Received: by 2002:a17:90a:d594:: with SMTP id v20mr1148478pju.227.1599031510786; Wed, 02 Sep 2020 00:25:10 -0700 (PDT) Received: from localhost ([122.167.135.199]) by smtp.gmail.com with ESMTPSA id y1sm4287781pgr.3.2020.09.02.00.25.09 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 02 Sep 2020 00:25:10 -0700 (PDT) From: Viresh Kumar To: Rafael Wysocki , Viresh Kumar , Ingo Molnar , Peter Zijlstra , Juri Lelli , Vincent Guittot , Dietmar Eggemann , Steven Rostedt , Ben Segall , Mel Gorman Cc: linux-pm@vger.kernel.org, Lukasz Luba , cristian.marussi@arm.com, sudeep.holla@arm.com, linux-kernel@vger.kernel.org Subject: [PATCH 4/4] cpufreq: Move traces and update to policy->cur to cpufreq core Date: Wed, 2 Sep 2020 12:54:44 +0530 Message-Id: <3f76b8bb243d522be5d858cbdf7f676b0e1f9e96.1599031227.git.viresh.kumar@linaro.org> X-Mailer: git-send-email 2.25.0.rc1.19.g042ed3e048af In-Reply-To: References: MIME-Version: 1.0 Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org The cpufreq core handles the updates to policy->cur and recording of cpufreq trace events for all the governors except schedutil's fast switch case. Move that as well to cpufreq core for consistency and readability. Signed-off-by: Viresh Kumar --- drivers/cpufreq/cpufreq.c | 14 ++++++++++++-- kernel/sched/cpufreq_schedutil.c | 12 +----------- 2 files changed, 13 insertions(+), 13 deletions(-) -- 2.25.0.rc1.19.g042ed3e048af diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c index d5fe64e96be9..bc930f6ecff6 100644 --- a/drivers/cpufreq/cpufreq.c +++ b/drivers/cpufreq/cpufreq.c @@ -2056,11 +2056,21 @@ EXPORT_SYMBOL(cpufreq_unregister_notifier); unsigned int cpufreq_driver_fast_switch(struct cpufreq_policy *policy, unsigned int target_freq) { + int cpu; + target_freq = clamp_val(target_freq, policy->min, policy->max); target_freq = cpufreq_driver->fast_switch(policy, target_freq); - if (target_freq) - cpufreq_stats_record_transition(policy, target_freq); + if (!target_freq) + return 0; + + policy->cur = target_freq; + cpufreq_stats_record_transition(policy, target_freq); + + if (trace_cpu_frequency_enabled()) { + for_each_cpu(cpu, policy->cpus) + trace_cpu_frequency(target_freq, cpu); + } return target_freq; } diff --git a/kernel/sched/cpufreq_schedutil.c b/kernel/sched/cpufreq_schedutil.c index e39008242cf4..28f6d1ad608b 100644 --- a/kernel/sched/cpufreq_schedutil.c +++ b/kernel/sched/cpufreq_schedutil.c @@ -115,21 +115,11 @@ static void sugov_fast_switch(struct sugov_policy *sg_policy, u64 time, unsigned int next_freq) { struct cpufreq_policy *policy = sg_policy->policy; - int cpu; if (!sugov_update_next_freq(sg_policy, time, next_freq)) return; - next_freq = cpufreq_driver_fast_switch(policy, next_freq); - if (!next_freq) - return; - - policy->cur = next_freq; - - if (trace_cpu_frequency_enabled()) { - for_each_cpu(cpu, policy->cpus) - trace_cpu_frequency(next_freq, cpu); - } + cpufreq_driver_fast_switch(policy, next_freq); } static void sugov_deferred_update(struct sugov_policy *sg_policy, u64 time,