From patchwork Thu Mar 9 11:45:16 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 95111 Delivered-To: patch@linaro.org Received: by 10.140.82.71 with SMTP id g65csp318817qgd; Thu, 9 Mar 2017 03:46:05 -0800 (PST) X-Received: by 10.84.209.203 with SMTP id y69mr16467311plh.179.1489059965782; Thu, 09 Mar 2017 03:46:05 -0800 (PST) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id n1si6219661pgc.376.2017.03.09.03.46.05; Thu, 09 Mar 2017 03:46:05 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 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 S932297AbdCILqE (ORCPT + 25 others); Thu, 9 Mar 2017 06:46:04 -0500 Received: from mail-pg0-f48.google.com ([74.125.83.48]:36400 "EHLO mail-pg0-f48.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932258AbdCILp7 (ORCPT ); Thu, 9 Mar 2017 06:45:59 -0500 Received: by mail-pg0-f48.google.com with SMTP id g2so8332165pge.3 for ; Thu, 09 Mar 2017 03:45:58 -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=k4czk0t9cFGmYvjDexUY9hydsMMKP1NDMYxCZM/mHlE=; b=Q0NAWGrKBkF00oz3jS4yUjaOVcefXNCBkCsMeQgqDwXxzG7KZUKonj6IQhPBQLXP7k kGenfM7edsy6+OKb6rWGk9I4OtjyHw7+2LuD/O33ofK+/uCrEg2cs01i6xktgGYQ3j7G mVMDwWkqf/E84T+a9+lAdeRFsfvZ7LQS5su9k= 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=k4czk0t9cFGmYvjDexUY9hydsMMKP1NDMYxCZM/mHlE=; b=XUHOctC0rK2lrqledAHY5vNSmojLMJNogJLWbB2rlgR24fPrQQhTkE0XYS2xVzfyWE 3bfvPf0QvxT+Evo4al8w2ytS2zYsh3y4omy35sIumtaQ1XxPv1WPfp1CCkVZQujY/4yV rfi0VfvHexcnRXnThFqHUx/5QBeqyuEmhETYi5yDoqmP5EtZD6/9A18N0rC0uUuvNmRR 0yGWYSqJh+bzMm2plAewzWQ2nxPYDe8Ejn+789ymW9rGstU2064fDzYoWbpO/7+C2KD5 TLqaN/0GWTAei1MJ9+y/pi/d/+s8aseWqRcBhKq99425Nrs7UcU9OXi1RUJ446NssEWk MVQA== X-Gm-Message-State: AMke39mzO+SswLVn5g2DCu9VT3rASbgsl6LnrElzI96b0j/FU6ssGbLo244Lg5/4s+4iami0 X-Received: by 10.84.229.10 with SMTP id b10mr16597110plk.148.1489059957941; Thu, 09 Mar 2017 03:45:57 -0800 (PST) Received: from localhost ([122.171.239.200]) by smtp.gmail.com with ESMTPSA id c195sm12089795pfb.60.2017.03.09.03.45.56 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 09 Mar 2017 03:45:57 -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 6/9] sched: cpufreq: detect, process remote callbacks Date: Thu, 9 Mar 2017 17:15:16 +0530 Message-Id: <2e807adcbf0d5136876f9de48c62e9e2dd2a5b06.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-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Steve Muckle A callback is considered remote if the target CPU is not the current CPU and if it is not managed by the policy managing the current CPU or the current CPU can't do DVFS on its behalf. Queue the irq work for remote callbacks on the destination CPU. The irq work will carry out the fast or slow switch as appropriate. Signed-off-by: Steve Muckle [ vk: commit log, code cleanups, introduce dvfs_possible_from_any_cpu and drop late callback support to avoid IPIs on remote CPUs. ] Signed-off-by: Viresh Kumar --- kernel/sched/cpufreq_schedutil.c | 40 +++++++++++++++++++++++++++++++++++----- 1 file changed, 35 insertions(+), 5 deletions(-) -- 2.7.1.410.g6faf27b diff --git a/kernel/sched/cpufreq_schedutil.c b/kernel/sched/cpufreq_schedutil.c index b168c31f1c8f..9bad579b6b08 100644 --- a/kernel/sched/cpufreq_schedutil.c +++ b/kernel/sched/cpufreq_schedutil.c @@ -100,11 +100,11 @@ static void sugov_fast_switch(struct cpufreq_policy *policy, } static void sugov_update_commit(struct sugov_policy *sg_policy, u64 time, - unsigned int next_freq) + int cpu, bool remote, unsigned int next_freq) { struct cpufreq_policy *policy = sg_policy->policy; - if (policy->fast_switch_enabled) { + if (policy->fast_switch_enabled && !remote) { if (sg_policy->next_freq == next_freq) { trace_cpu_frequency(policy->cur, policy->cpu); return; @@ -116,7 +116,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; sg_policy->work_in_progress = true; - irq_work_queue(&sg_policy->irq_work); + irq_work_queue_on(&sg_policy->irq_work, cpu); } } @@ -206,6 +206,20 @@ static void sugov_update_single(struct update_util_data *hook, u64 time, struct cpufreq_policy *policy = sg_policy->policy; unsigned long util, max; unsigned int next_f; + int cpu, this_cpu = smp_processor_id(); + bool remote; + + if (policy->dvfs_possible_from_any_cpu) { + /* + * Avoid sending IPI to 'hook->cpu' if this CPU can change + * frequency on its behalf. + */ + remote = false; + cpu = this_cpu; + } else { + cpu = hook->cpu; + remote = this_cpu != hook->cpu; + } sugov_set_iowait_boost(sg_cpu, time, flags); sg_cpu->last_update = time; @@ -220,7 +234,7 @@ static void sugov_update_single(struct update_util_data *hook, u64 time, sugov_iowait_boost(sg_cpu, &util, &max); next_f = get_next_freq(sg_policy, util, max); } - sugov_update_commit(sg_policy, time, next_f); + sugov_update_commit(sg_policy, time, cpu, remote, next_f); } static unsigned int sugov_next_freq_shared(struct sugov_cpu *sg_cpu) @@ -269,8 +283,24 @@ static void sugov_update_shared(struct update_util_data *hook, u64 time, { struct sugov_cpu *sg_cpu = container_of(hook, struct sugov_cpu, update_util); struct sugov_policy *sg_policy = sg_cpu->sg_policy; + struct cpufreq_policy *policy = sg_policy->policy; unsigned long util, max; unsigned int next_f; + int cpu, this_cpu = smp_processor_id(); + bool remote; + + if (policy->dvfs_possible_from_any_cpu || + cpumask_test_cpu(this_cpu, policy->cpus)) { + /* + * Avoid sending IPI to 'hook->cpu' if this CPU can change + * frequency on its behalf. + */ + remote = false; + cpu = this_cpu; + } else { + cpu = hook->cpu; + remote = this_cpu != hook->cpu; + } sugov_get_util(&util, &max, hook->cpu); @@ -289,7 +319,7 @@ static void sugov_update_shared(struct update_util_data *hook, u64 time, else next_f = sugov_next_freq_shared(sg_cpu); - sugov_update_commit(sg_policy, time, next_f); + sugov_update_commit(sg_policy, time, cpu, remote, next_f); } raw_spin_unlock(&sg_policy->update_lock);