From patchwork Thu Mar 9 11:45:14 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 9613181 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 44C3F604D9 for ; Thu, 9 Mar 2017 11:48:45 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 22DEC285C2 for ; Thu, 9 Mar 2017 11:48:45 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1693A285CA; Thu, 9 Mar 2017 11:48:45 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.5 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,RCVD_IN_DNSWL_HI,RCVD_IN_SORBS_SPAM autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 14DF0285C2 for ; Thu, 9 Mar 2017 11:48:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932263AbdCILp7 (ORCPT ); Thu, 9 Mar 2017 06:45:59 -0500 Received: from mail-pf0-f182.google.com ([209.85.192.182]:36493 "EHLO mail-pf0-f182.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932217AbdCILp5 (ORCPT ); Thu, 9 Mar 2017 06:45:57 -0500 Received: by mail-pf0-f182.google.com with SMTP id o126so28072852pfb.3 for ; Thu, 09 Mar 2017 03:45:57 -0800 (PST) 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 :in-reply-to:references; bh=m2zi9E1Wzn/Q0NQ3CDi+IzVAr0zLPwDntGZ7IMHpt8Q=; b=FeqKiZzrtFqLj2elriJc+UatB4AtaqQPf+v/rD8qJJc605QJYT6nsrChpWrzBpSA6s JPFDTSs6QxTz3ewWlqo6BoYurZGsE91EODxKOPlrt4uD3f/+zRPIvSoHoR6RCMVljqtf U3h+Bl5o1HjGQYIb/jpm7DLSTyiGKK+1mYlXo= 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:in-reply-to:references; bh=m2zi9E1Wzn/Q0NQ3CDi+IzVAr0zLPwDntGZ7IMHpt8Q=; b=Xb4l6L1/B8s0eMWyOQzNfvaje8lijPs/MFcBMxQaZhhn4HMi+VvEtDlmM+a+Dr2MYw EK8rEJBlhOZJyBFAH0wRciSmuJ2M5tLyNfY1V3JypctI23zVHLqjUQDSqrjym9uAICpA mdD9tvUG8k8b/HL9D3Tdn2bOK8SrlpDKE5rgH2ImFnHu+RbGrWmjGJdIAc6YFgqrP2SK Ubya3CZfwwBRG52x9G7Q7tGkqGmaAi9Udjk3cJIlJam2Pcj3L8TvAtNqis7zFgmzmqBh ZQDIi66N3s1uDa2n2Fa+ntqLG6FcADoKVRDYKncuq2w1GAK6IgYq29F5HPU20MOPPIik WdRg== X-Gm-Message-State: AMke39mcAF+y6IHSz3wHnni+FjBq4fB2RyDfAhbWGWwDZiw61t1iVVWV3m7sffTkEh2riGkI X-Received: by 10.98.4.71 with SMTP id 68mr13594411pfe.92.1489059951709; Thu, 09 Mar 2017 03:45:51 -0800 (PST) Received: from localhost ([122.171.239.200]) by smtp.gmail.com with ESMTPSA id z74sm12078777pfd.70.2017.03.09.03.45.50 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 09 Mar 2017 03:45:50 -0800 (PST) From: Viresh Kumar To: Rafael Wysocki , Ingo Molnar , Peter Zijlstra Cc: linaro-kernel@lists.linaro.org, linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, Vincent Guittot , smuckle.linux@gmail.com, juri.lelli@arm.com, Morten.Rasmussen@arm.com, patrick.bellasi@arm.com, eas-dev@lists.linaro.org, Viresh Kumar Subject: [RFC 4/9] sched: cpufreq: extend irq work to support fast switches Date: Thu, 9 Mar 2017 17:15:14 +0530 Message-Id: <9d2ff35af95f5accb40d3447e6ff5970c0ba405e.1489058244.git.viresh.kumar@linaro.org> X-Mailer: git-send-email 2.7.1.410.g6faf27b In-Reply-To: References: In-Reply-To: References: Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Steve Muckle In preparation for schedutil receiving sched cpufreq callbacks for remote CPUs, extend the irq work in schedutil to support policies with fast switching enabled in addition to policies using the slow path. Signed-off-by: Steve Muckle [ vk: minor code updates ] Signed-off-by: Viresh Kumar --- kernel/sched/cpufreq_schedutil.c | 28 ++++++++++++++++++++-------- 1 file changed, 20 insertions(+), 8 deletions(-) diff --git a/kernel/sched/cpufreq_schedutil.c b/kernel/sched/cpufreq_schedutil.c index f5ffe241812e..a418544c51b1 100644 --- a/kernel/sched/cpufreq_schedutil.c +++ b/kernel/sched/cpufreq_schedutil.c @@ -88,6 +88,17 @@ static bool sugov_should_update_freq(struct sugov_policy *sg_policy, u64 time) return delta_ns >= sg_policy->freq_update_delay_ns; } +static void sugov_fast_switch(struct cpufreq_policy *policy, + unsigned int next_freq) +{ + next_freq = cpufreq_driver_fast_switch(policy, next_freq); + if (next_freq == CPUFREQ_ENTRY_INVALID) + return; + + policy->cur = next_freq; + trace_cpu_frequency(next_freq, smp_processor_id()); +} + static void sugov_update_commit(struct sugov_policy *sg_policy, u64 time, unsigned int next_freq) { @@ -100,12 +111,7 @@ static void sugov_update_commit(struct sugov_policy *sg_policy, u64 time, } sg_policy->next_freq = next_freq; sg_policy->last_freq_update_time = time; - next_freq = cpufreq_driver_fast_switch(policy, next_freq); - if (next_freq == CPUFREQ_ENTRY_INVALID) - return; - - policy->cur = next_freq; - trace_cpu_frequency(next_freq, smp_processor_id()); + sugov_fast_switch(policy, next_freq); } else if (sg_policy->next_freq != next_freq) { sg_policy->next_freq = next_freq; sg_policy->last_freq_update_time = time; @@ -303,9 +309,15 @@ static void sugov_work(struct kthread_work *work) static void sugov_irq_work(struct irq_work *irq_work) { - struct sugov_policy *sg_policy; + struct sugov_policy *sg_policy = container_of(irq_work, struct + sugov_policy, irq_work); + struct cpufreq_policy *policy = sg_policy->policy; - sg_policy = container_of(irq_work, struct sugov_policy, irq_work); + if (policy->fast_switch_enabled) { + sugov_fast_switch(policy, sg_policy->next_freq); + sg_policy->work_in_progress = false; + return; + } /* * For RT and deadline tasks, the schedutil governor shoots the