From patchwork Wed Jul 26 09:22:32 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 108739 Delivered-To: patch@linaro.org Received: by 10.140.101.44 with SMTP id t41csp572967qge; Wed, 26 Jul 2017 02:23:40 -0700 (PDT) X-Received: by 10.84.231.198 with SMTP id g6mr320545pln.110.1501061020250; Wed, 26 Jul 2017 02:23:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1501061020; cv=none; d=google.com; s=arc-20160816; b=B1rsrJZbC/UyfZsg6dlI4ME8uwMbfqS2wbSBrMWnBI35uxbiKi793xmNcOWOmeA4tf KB0ouj8xWw8ink0MAcxvW/wnPdc/A/TLu0KDUcNyuu5/QAEg5XttKYTZ7uWicziJIfAk SLa18btwtBZ97jvYWYqHbOPQp3aJc4Tj4KQLdauaw6Gjx/hsgm6RtIdw7LzIuh+I5HiH WVy872xImGhjW+/30qZVODsPrPgsJkpKnUkY8VOhfDZAi9FnNzHuk5mOnpCD5frctSF1 AUw9Ji07mJ3+5eIc1YUMKDFAXs7UD7V+2WYU0ypaOgT2A5T6gEAX2WOBtQbP28QwHiCz 0UKw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:references :in-reply-to:message-id:date:subject:cc:to:from:dkim-signature :arc-authentication-results; bh=GKPCGAlE/KXREGT7fLWH/Y5WMH2Bt8ptMeFR4CCQe98=; b=T2T/vxIHN2cJaRRWjzk7GdwvGB5fF/bWs7GjQVQmWNi/ouIVdxih5rljo5ze9GjokF +c/BAYklTDgk33+Ny33vkuCpocKE2Gqrn4uKbdGz+li1unNDjtKFnSMInX+YIXKVmaZ2 EwpRFYdMeSGSLfTtgYY4wf4JZpAPFmBOg0fOIRWEhiYMePHjB0Ju4AMgbquqDIKZbsv2 wglTvmV4/vm+BbiiPSwOKS6cU1XdNPS/0tyYQiqdAiFNtPoOA+SwMYMrPECijeIAWlxD aq4++BaFl3W3h62pfZx0mrpAGLq5fc254enuyIzXblmwbLrfcs1d3uUDnh/y4+raEbXm c4eg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.b=Cbea9axy; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id h13si10025749pln.4.2017.07.26.02.23.39; Wed, 26 Jul 2017 02:23:40 -0700 (PDT) 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 header.b=Cbea9axy; 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 S1751502AbdGZJXg (ORCPT + 26 others); Wed, 26 Jul 2017 05:23:36 -0400 Received: from mail-pf0-f174.google.com ([209.85.192.174]:35503 "EHLO mail-pf0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751413AbdGZJXc (ORCPT ); Wed, 26 Jul 2017 05:23:32 -0400 Received: by mail-pf0-f174.google.com with SMTP id h29so33751399pfd.2 for ; Wed, 26 Jul 2017 02:23:32 -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 :in-reply-to:references; bh=GKPCGAlE/KXREGT7fLWH/Y5WMH2Bt8ptMeFR4CCQe98=; b=Cbea9axycyXpbGZ+AhVOGtwdTbrB6JBzXah03DI0PLQebDp6CO/Nflv6j1mLgjspAj ozH9/pNJGX5RkpYgloX2+BWoLNcNp62BPUmP8JQj3Ggu+JP371moyJATB6xQoCN7P1In XMGe42aSM8pufyh46gzZp1b2wh2dCVAOVTcxw= 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=GKPCGAlE/KXREGT7fLWH/Y5WMH2Bt8ptMeFR4CCQe98=; b=nmI6516oYC6+ficeoE0RakrobuVYJub6O5VHaasMZRelT9JNAZ1XpyTJU8CxfrmigT PODR+4EzrhRmaR4IcYnWic0byhE5dgRAAqeLbmYIz+e+DSK782lDj9oAGi6pCSETZBNE H0N0ynzt69FODrxT0X881RAsS/nxyi2MIKYCk8zkXQiX8akQfDUV5VL37+0b2koA3Hq/ dEAbaR7gOyTJzLqLaM368OFYQXQ0rpfLBqRE1EF0KqZmWQgF1Qs08CE4tB3K8ebY60az A2uywqHiPsOE8bTtVoAHmal8jiOlo03epkyStUcGeaTV8gXoFjmmqaNQ3XXGs8SC8CZy e+aA== X-Gm-Message-State: AIVw1110ywPsJVW2iRRY5PWE+SsIbNb0YwjK7z6epAyKgc6rqILw1qXq m3yvH3BETcACK/Kx X-Received: by 10.84.130.108 with SMTP id 99mr308686plc.76.1501061011775; Wed, 26 Jul 2017 02:23:31 -0700 (PDT) Received: from localhost ([122.171.79.89]) by smtp.gmail.com with ESMTPSA id 124sm31923469pgi.62.2017.07.26.02.23.30 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 26 Jul 2017 02:23:31 -0700 (PDT) From: Viresh Kumar To: Rafael Wysocki , Viresh Kumar , Srinivas Pandruvada , Len Brown , Ingo Molnar , Peter Zijlstra Cc: linux-pm@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, linux-kernel@vger.kernel.org Subject: [PATCH V4 1/3] sched: cpufreq: Allow remote cpufreq callbacks Date: Wed, 26 Jul 2017 14:52:32 +0530 Message-Id: <8797d4993baa6580e3af741d081be492032ce9dd.1501060871.git.viresh.kumar@linaro.org> X-Mailer: git-send-email 2.13.0.71.gd7076ec9c9cb 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 We do not call cpufreq callbacks from scheduler core for remote (non-local) CPUs currently. But there are cases where such remote callbacks are useful, specially in the case of shared cpufreq policies. This patch updates the scheduler core to call the cpufreq callbacks for remote CPUs as well. For now, all the registered utilization update callbacks are updated to return early if remote callback is detected. That is, this patch just moves the decision making down in the hierarchy. Later patches would enable remote callbacks for shared policies. Based on initial work from Steve Muckle. Signed-off-by: Viresh Kumar --- drivers/cpufreq/cpufreq_governor.c | 4 ++++ drivers/cpufreq/intel_pstate.c | 8 ++++++++ include/linux/sched/cpufreq.h | 1 + kernel/sched/cpufreq.c | 1 + kernel/sched/cpufreq_schedutil.c | 11 ++++++++--- kernel/sched/deadline.c | 2 +- kernel/sched/fair.c | 8 +++++--- kernel/sched/rt.c | 2 +- kernel/sched/sched.h | 10 ++-------- 9 files changed, 31 insertions(+), 16 deletions(-) -- 2.13.0.71.gd7076ec9c9cb diff --git a/drivers/cpufreq/cpufreq_governor.c b/drivers/cpufreq/cpufreq_governor.c index eed069ecfd5e..5499796cf9a8 100644 --- a/drivers/cpufreq/cpufreq_governor.c +++ b/drivers/cpufreq/cpufreq_governor.c @@ -272,6 +272,10 @@ static void dbs_update_util_handler(struct update_util_data *data, u64 time, struct policy_dbs_info *policy_dbs = cdbs->policy_dbs; u64 delta_ns, lst; + /* Don't allow remote callbacks */ + if (smp_processor_id() != data->cpu) + return; + /* * The work may not be allowed to be queued up right now. * Possible reasons: diff --git a/drivers/cpufreq/intel_pstate.c b/drivers/cpufreq/intel_pstate.c index 89bbc0c11b22..0dd14c8edd2d 100644 --- a/drivers/cpufreq/intel_pstate.c +++ b/drivers/cpufreq/intel_pstate.c @@ -1747,6 +1747,10 @@ static void intel_pstate_update_util_pid(struct update_util_data *data, struct cpudata *cpu = container_of(data, struct cpudata, update_util); u64 delta_ns = time - cpu->sample.time; + /* Don't allow remote callbacks */ + if (smp_processor_id() != data->cpu) + return; + if ((s64)delta_ns < pid_params.sample_rate_ns) return; @@ -1764,6 +1768,10 @@ static void intel_pstate_update_util(struct update_util_data *data, u64 time, struct cpudata *cpu = container_of(data, struct cpudata, update_util); u64 delta_ns; + /* Don't allow remote callbacks */ + if (smp_processor_id() != data->cpu) + return; + if (flags & SCHED_CPUFREQ_IOWAIT) { cpu->iowait_boost = int_tofp(1); } else if (cpu->iowait_boost) { diff --git a/include/linux/sched/cpufreq.h b/include/linux/sched/cpufreq.h index d2be2ccbb372..8256a8f35f22 100644 --- a/include/linux/sched/cpufreq.h +++ b/include/linux/sched/cpufreq.h @@ -16,6 +16,7 @@ #ifdef CONFIG_CPU_FREQ struct update_util_data { void (*func)(struct update_util_data *data, u64 time, unsigned int flags); + unsigned int cpu; }; void cpufreq_add_update_util_hook(int cpu, struct update_util_data *data, diff --git a/kernel/sched/cpufreq.c b/kernel/sched/cpufreq.c index dbc51442ecbc..ee4c596b71b4 100644 --- a/kernel/sched/cpufreq.c +++ b/kernel/sched/cpufreq.c @@ -42,6 +42,7 @@ void cpufreq_add_update_util_hook(int cpu, struct update_util_data *data, return; data->func = func; + data->cpu = cpu; rcu_assign_pointer(per_cpu(cpufreq_update_util_data, cpu), data); } EXPORT_SYMBOL_GPL(cpufreq_add_update_util_hook); diff --git a/kernel/sched/cpufreq_schedutil.c b/kernel/sched/cpufreq_schedutil.c index 45fcf21ad685..bb834747e49b 100644 --- a/kernel/sched/cpufreq_schedutil.c +++ b/kernel/sched/cpufreq_schedutil.c @@ -72,10 +72,15 @@ static DEFINE_PER_CPU(struct sugov_cpu, sugov_cpu); /************************ Governor internals ***********************/ -static bool sugov_should_update_freq(struct sugov_policy *sg_policy, u64 time) +static bool sugov_should_update_freq(struct sugov_policy *sg_policy, u64 time, + int target_cpu) { s64 delta_ns; + /* Don't allow remote callbacks */ + if (smp_processor_id() != target_cpu) + return false; + if (sg_policy->work_in_progress) return false; @@ -221,7 +226,7 @@ static void sugov_update_single(struct update_util_data *hook, u64 time, sugov_set_iowait_boost(sg_cpu, time, flags); sg_cpu->last_update = time; - if (!sugov_should_update_freq(sg_policy, time)) + if (!sugov_should_update_freq(sg_policy, time, hook->cpu)) return; busy = sugov_cpu_is_busy(sg_cpu); @@ -301,7 +306,7 @@ static void sugov_update_shared(struct update_util_data *hook, u64 time, sugov_set_iowait_boost(sg_cpu, time, flags); sg_cpu->last_update = time; - if (sugov_should_update_freq(sg_policy, time)) { + if (sugov_should_update_freq(sg_policy, time, hook->cpu)) { if (flags & SCHED_CPUFREQ_RT_DL) next_f = sg_policy->policy->cpuinfo.max_freq; else diff --git a/kernel/sched/deadline.c b/kernel/sched/deadline.c index 755bd3f1a1a9..5c3bf4bd0327 100644 --- a/kernel/sched/deadline.c +++ b/kernel/sched/deadline.c @@ -1136,7 +1136,7 @@ static void update_curr_dl(struct rq *rq) } /* kick cpufreq (see the comment in kernel/sched/sched.h). */ - cpufreq_update_this_cpu(rq, SCHED_CPUFREQ_DL); + cpufreq_update_util(rq, SCHED_CPUFREQ_DL); schedstat_set(curr->se.statistics.exec_max, max(curr->se.statistics.exec_max, delta_exec)); diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c index c95880e216f6..d378d02fdfcb 100644 --- a/kernel/sched/fair.c +++ b/kernel/sched/fair.c @@ -3278,7 +3278,9 @@ static inline void set_tg_cfs_propagate(struct cfs_rq *cfs_rq) {} static inline void cfs_rq_util_change(struct cfs_rq *cfs_rq) { - if (&this_rq()->cfs == cfs_rq) { + struct rq *rq = rq_of(cfs_rq); + + if (&rq->cfs == cfs_rq) { /* * There are a few boundary cases this might miss but it should * get called often enough that that should (hopefully) not be @@ -3295,7 +3297,7 @@ static inline void cfs_rq_util_change(struct cfs_rq *cfs_rq) * * See cpu_util(). */ - cpufreq_update_util(rq_of(cfs_rq), 0); + cpufreq_update_util(rq, 0); } } @@ -4875,7 +4877,7 @@ enqueue_task_fair(struct rq *rq, struct task_struct *p, int flags) * passed. */ if (p->in_iowait) - cpufreq_update_this_cpu(rq, SCHED_CPUFREQ_IOWAIT); + cpufreq_update_util(rq, SCHED_CPUFREQ_IOWAIT); for_each_sched_entity(se) { if (se->on_rq) diff --git a/kernel/sched/rt.c b/kernel/sched/rt.c index 45caf937ef90..0af5ca9e3e3f 100644 --- a/kernel/sched/rt.c +++ b/kernel/sched/rt.c @@ -970,7 +970,7 @@ static void update_curr_rt(struct rq *rq) return; /* Kick cpufreq (see the comment in kernel/sched/sched.h). */ - cpufreq_update_this_cpu(rq, SCHED_CPUFREQ_RT); + cpufreq_update_util(rq, SCHED_CPUFREQ_RT); schedstat_set(curr->se.statistics.exec_max, max(curr->se.statistics.exec_max, delta_exec)); diff --git a/kernel/sched/sched.h b/kernel/sched/sched.h index eeef1a3086d1..aa9d5b87b4f8 100644 --- a/kernel/sched/sched.h +++ b/kernel/sched/sched.h @@ -2070,19 +2070,13 @@ static inline void cpufreq_update_util(struct rq *rq, unsigned int flags) { struct update_util_data *data; - data = rcu_dereference_sched(*this_cpu_ptr(&cpufreq_update_util_data)); + data = rcu_dereference_sched(*per_cpu_ptr(&cpufreq_update_util_data, + cpu_of(rq))); if (data) data->func(data, rq_clock(rq), flags); } - -static inline void cpufreq_update_this_cpu(struct rq *rq, unsigned int flags) -{ - if (cpu_of(rq) == smp_processor_id()) - cpufreq_update_util(rq, flags); -} #else static inline void cpufreq_update_util(struct rq *rq, unsigned int flags) {} -static inline void cpufreq_update_this_cpu(struct rq *rq, unsigned int flags) {} #endif /* CONFIG_CPU_FREQ */ #ifdef arch_scale_freq_capacity From patchwork Wed Jul 26 09:22:33 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 108741 Delivered-To: patch@linaro.org Received: by 10.140.101.44 with SMTP id t41csp573334qge; Wed, 26 Jul 2017 02:24:05 -0700 (PDT) X-Received: by 10.99.2.68 with SMTP id 65mr247438pgc.403.1501061045010; Wed, 26 Jul 2017 02:24:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1501061045; cv=none; d=google.com; s=arc-20160816; b=NVcbwk8U/WV5b80iS5SNs6jUBoI2nnvDKNCTRgsELGhpkUcBjcho+w5DkmIOegJ6vt Gf8XZQtRZxBgD/Ll6iIDWqzm3w+c3uDi0GeBt1h29TsmLsD8gNoGeG+M5BvYuC/DY9xw 21C6TCVPMsUWlUXGETTQddSnJPCmhQ3yodGzOkoOWEA1xnQ5h0Tm/sKfxUtMRFFVgaGR yqLnQ/LtenQEFShPq9tesrQamFG/b7uu922cCYi0DF1HFj1TiWL/KrTzaKKu1OGyfcTD iXjxNNG1Wk4bQnMzpAVMp8obRSPQyzR3OBVUxYGfV06mf2bYUhurJejpGxUhForPYHN+ qD7w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:references :in-reply-to:message-id:date:subject:cc:to:from:dkim-signature :arc-authentication-results; bh=HuNZS0Yzmpfia66uJs0Xfb3I/p6ZIoFA9E6JZbiId4o=; b=CGRLpmhsMZmUUV/fFJ7T6wBjFtcrHgi1wxE7qQFJvCpYHCyvC0x8HLnalmcsGfeu2z 1L0uOvZ9WQUDR3M7nfXDQZbF66pJuNXkAZ8CftEJntX04EwwAcAN2Wnf4j0A6zmqERpJ 0paq2rD0LIOyku9HM4hyIDpEzac8eejB2X9AbgRlRKJ+H7CvVhpARRbIyec6ORQqssnv sQfyz/nRKyz5uBJ0+LKsa39j18fvFY0JlDrNnApZtU1zL/mF6HlCcaLRr45LhLiEobcN 1yBv3hjirjNaA/zQPmf7xKf0DXsNgiYQ7wn6flfirhoNRMkLxpNzwGQ1YA/digHrayad GQQg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.b=GU/e4TLQ; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id i1si9944157pld.128.2017.07.26.02.24.04; Wed, 26 Jul 2017 02:24:04 -0700 (PDT) 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 header.b=GU/e4TLQ; 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 S1751616AbdGZJYC (ORCPT + 26 others); Wed, 26 Jul 2017 05:24:02 -0400 Received: from mail-pf0-f180.google.com ([209.85.192.180]:33526 "EHLO mail-pf0-f180.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751427AbdGZJXf (ORCPT ); Wed, 26 Jul 2017 05:23:35 -0400 Received: by mail-pf0-f180.google.com with SMTP id d67so902223pfc.0 for ; Wed, 26 Jul 2017 02:23:34 -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 :in-reply-to:references; bh=HuNZS0Yzmpfia66uJs0Xfb3I/p6ZIoFA9E6JZbiId4o=; b=GU/e4TLQU/wCLA3/b+sboQY2JATRE9juDMbv4c+Fr02pKOY8g44UeF7gfW5BLP3VhV ON3hrV+wDsTkZX+oQLUDvvn5ANguLnl2eKv1rLaW4Cb8wxD03zsFVZICgmPBglWLmoBJ Pg4urIWu31RNRS7wROIHJuG4uaq8n9BPTlcJM= 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=HuNZS0Yzmpfia66uJs0Xfb3I/p6ZIoFA9E6JZbiId4o=; b=DCsagWkJlOYHy5W3HZ6t4T6hBVFRCbQ60+sNoxfGzPjHNoRn3f4ekt5NXzTAvott7G XlfX0Yy56C4FJ0NA+GGknOjqfdvB0D4Erpq3LEDQk9b2loSpM85+I3e0e0xpX/2WhJgF SCRDwyyUE0vUBXa46vYc6Dg6Kh6tqJzcXE3GvW1EmDbrBeIJA9fLlxE+9iZxKCoIzZ7e yfBcteHJSDx9utpd/z689jL1KkDoA50zxC+STqeA9l7UAV/W/gEAQi7TaaX+azBgEDwM YDlip1ryx0Sldej03qj//37jCoiVxmsisccEm0SYLz/z/bEFK9ioUKJU8YTmvVPCF6td YP4w== X-Gm-Message-State: AIVw111MB1VRCLnid2xG+UNAyuoaYxkWofmZmCTuCIsoBCIFcqm4EiVd knssfLp1Rjjaa4It X-Received: by 10.99.117.94 with SMTP id f30mr282879pgn.366.1501061014665; Wed, 26 Jul 2017 02:23:34 -0700 (PDT) Received: from localhost ([122.171.79.89]) by smtp.gmail.com with ESMTPSA id p22sm33947306pfd.71.2017.07.26.02.23.33 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 26 Jul 2017 02:23:34 -0700 (PDT) From: Viresh Kumar To: Rafael Wysocki , Ingo Molnar , Peter Zijlstra Cc: Viresh Kumar , linux-pm@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, linux-kernel@vger.kernel.org Subject: [PATCH V4 2/3] cpufreq: schedutil: Process remote callback for shared policies Date: Wed, 26 Jul 2017 14:52:33 +0530 Message-Id: X-Mailer: git-send-email 2.13.0.71.gd7076ec9c9cb 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 This patch updates the schedutil governor to process cpufreq utilization update hooks called for remote CPUs where the remote CPU is managed by the cpufreq policy of the local CPU. Based on initial work from Steve Muckle. Signed-off-by: Viresh Kumar --- kernel/sched/cpufreq_schedutil.c | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) -- 2.13.0.71.gd7076ec9c9cb diff --git a/kernel/sched/cpufreq_schedutil.c b/kernel/sched/cpufreq_schedutil.c index bb834747e49b..c3baf70d360c 100644 --- a/kernel/sched/cpufreq_schedutil.c +++ b/kernel/sched/cpufreq_schedutil.c @@ -72,13 +72,12 @@ static DEFINE_PER_CPU(struct sugov_cpu, sugov_cpu); /************************ Governor internals ***********************/ -static bool sugov_should_update_freq(struct sugov_policy *sg_policy, u64 time, - int target_cpu) +static bool sugov_should_update_freq(struct sugov_policy *sg_policy, u64 time) { s64 delta_ns; - /* Don't allow remote callbacks */ - if (smp_processor_id() != target_cpu) + /* Allow remote callbacks only on the CPUs sharing cpufreq policy */ + if (!cpumask_test_cpu(smp_processor_id(), sg_policy->policy->cpus)) return false; if (sg_policy->work_in_progress) @@ -159,12 +158,12 @@ static unsigned int get_next_freq(struct sugov_policy *sg_policy, return cpufreq_driver_resolve_freq(policy, freq); } -static void sugov_get_util(unsigned long *util, unsigned long *max) +static void sugov_get_util(unsigned long *util, unsigned long *max, int cpu) { - struct rq *rq = this_rq(); + struct rq *rq = cpu_rq(cpu); unsigned long cfs_max; - cfs_max = arch_scale_cpu_capacity(NULL, smp_processor_id()); + cfs_max = arch_scale_cpu_capacity(NULL, cpu); *util = min(rq->cfs.avg.util_avg, cfs_max); *max = cfs_max; @@ -226,7 +225,7 @@ static void sugov_update_single(struct update_util_data *hook, u64 time, sugov_set_iowait_boost(sg_cpu, time, flags); sg_cpu->last_update = time; - if (!sugov_should_update_freq(sg_policy, time, hook->cpu)) + if (!sugov_should_update_freq(sg_policy, time)) return; busy = sugov_cpu_is_busy(sg_cpu); @@ -234,7 +233,7 @@ static void sugov_update_single(struct update_util_data *hook, u64 time, if (flags & SCHED_CPUFREQ_RT_DL) { next_f = policy->cpuinfo.max_freq; } else { - sugov_get_util(&util, &max); + sugov_get_util(&util, &max, hook->cpu); sugov_iowait_boost(sg_cpu, &util, &max); next_f = get_next_freq(sg_policy, util, max); /* @@ -295,7 +294,7 @@ static void sugov_update_shared(struct update_util_data *hook, u64 time, unsigned long util, max; unsigned int next_f; - sugov_get_util(&util, &max); + sugov_get_util(&util, &max, hook->cpu); raw_spin_lock(&sg_policy->update_lock); @@ -306,7 +305,7 @@ static void sugov_update_shared(struct update_util_data *hook, u64 time, sugov_set_iowait_boost(sg_cpu, time, flags); sg_cpu->last_update = time; - if (sugov_should_update_freq(sg_policy, time, hook->cpu)) { + if (sugov_should_update_freq(sg_policy, time)) { if (flags & SCHED_CPUFREQ_RT_DL) next_f = sg_policy->policy->cpuinfo.max_freq; else From patchwork Wed Jul 26 09:22:34 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 108740 Delivered-To: patch@linaro.org Received: by 10.140.101.44 with SMTP id t41csp573056qge; Wed, 26 Jul 2017 02:23:44 -0700 (PDT) X-Received: by 10.99.177.78 with SMTP id g14mr269467pgp.131.1501061024223; Wed, 26 Jul 2017 02:23:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1501061024; cv=none; d=google.com; s=arc-20160816; b=px7s9SJGG92Z+wYJ4Teq+47cHg4yTVbmfnkGDWmGTKYcluayJhmRa5NHY92k/gYOGn QwlVj25KvwWB8uWZzU+w9mkkS7W9a4NR2zYNPP1V7sRVUXV8roAa/TD2a0Kj9+u9Wuiw vnp8rBJ8l5O3ScrYs2tIoEB+B3TE8Fe3mYsFWSGXu0BotBjbb9VUWxJVpnez1QdS9oSt pVD6H9a3Txwms5liK8+nE9xfiEKYa6kFKPfGzYHPgoIaiG4YYzgkOySyYp2STswn8F2q KQzkkN6ii5vpk+UhCY6T2kUpTvZx9gVpJqWfg8ouOoOFkZ62PTmWBwn5idHcIkcrzFpV 6yHA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:references :in-reply-to:message-id:date:subject:cc:to:from:dkim-signature :arc-authentication-results; bh=bYMuHgyWhrhaTrRCgWddelfFOhfkUbm+sHIPzIWxAJY=; b=HCqJMSQfIPE/PtNYibqZhTAonz7RUsoa6/+w4eqMGaIKocmZ/MG1jSbxnR0IO+jx19 8eBKZKChmqCXJrksA/gHcPa7cAiY6DKeOaw9A2OMFZqOrOr0GYkSp8ufyy0uq6woGbds dxdGmao5UnYPpznqiU0hnYkF3kz0azuUhZuLgKB4z16WcUuXZk4rMphWPHvUGSLqCEqq r8XSMRbVl1rVdj7xzpduPV8e4tdD0xHOcDy25eT5iTiO0Y/U7426T+EdYXqd8gBkboa7 OrAyobUkNNn0EQ5srCbNxJeD/LJeyMKZmmYPzjysD2s/sgpUwaQom9U90xQLRzDcYEp6 lKqQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.b=Nr1TgvPS; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id r63si9908697plb.589.2017.07.26.02.23.43; Wed, 26 Jul 2017 02:23:44 -0700 (PDT) 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 header.b=Nr1TgvPS; 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 S1751568AbdGZJXk (ORCPT + 26 others); Wed, 26 Jul 2017 05:23:40 -0400 Received: from mail-pf0-f170.google.com ([209.85.192.170]:36813 "EHLO mail-pf0-f170.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751503AbdGZJXi (ORCPT ); Wed, 26 Jul 2017 05:23:38 -0400 Received: by mail-pf0-f170.google.com with SMTP id z129so29293505pfb.3 for ; Wed, 26 Jul 2017 02:23:38 -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 :in-reply-to:references; bh=bYMuHgyWhrhaTrRCgWddelfFOhfkUbm+sHIPzIWxAJY=; b=Nr1TgvPS0usgQyehRPcHAvmqyfuG23ZV4soraxGaMgPMj39GV80DRDH+bSMyeN27Cx tc1d4nTgmG/A+Pqhk/w7ZLxQj5HctQ68EZwgg4uhd3hR1JdvItXikrh8YBgz9hHmBDeN hYHE69sOQADxZ3Rgqatp90JQ4QFewYquj2Tl8= 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=bYMuHgyWhrhaTrRCgWddelfFOhfkUbm+sHIPzIWxAJY=; b=GdFJbGN1qndrorAYY0maKYKm87y/vbOQEjBb5hOdiSd4/J7YwMqFhz0rvgOEQRuhbG FAn8fO62PoeDi1uvi5gojJ3LTBSMtCcpnaJlHiRSYTc0GjjEto1sZ0m6dWlaWYseqQzp hhNGtDXnaHLhWWN62R323UnBxDynZ8hSLsGx8Ps25w6Knc7Q7b0FU/9/zZO3C5Q9PaK6 4TW2Ds9HhZcpJtAB9wOBcxmvjOiXXfa/nqEUPVwAbMRc152m/WW6eVrmSC+kjE2wupMV BIDn5BDLwR8EDfvbaHkUrf4h/awr/fmYPzXz6SCqixlyYJXSr8ViRXP86KiDDeRLORzW pqNw== X-Gm-Message-State: AIVw1116T4f0zPBkSDLC5A5365hhzSHetLM2Q5NcBoq+cFyITFIUO+12 hJXUz0ReK0GPeLix X-Received: by 10.98.215.74 with SMTP id v10mr259222pfl.314.1501061017692; Wed, 26 Jul 2017 02:23:37 -0700 (PDT) Received: from localhost ([122.171.79.89]) by smtp.gmail.com with ESMTPSA id f15sm31128824pga.5.2017.07.26.02.23.36 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 26 Jul 2017 02:23:36 -0700 (PDT) From: Viresh Kumar To: Rafael Wysocki , Viresh Kumar Cc: linux-pm@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, linux-kernel@vger.kernel.org Subject: [PATCH V4 3/3] cpufreq: governor: Process remote callback for shared policies Date: Wed, 26 Jul 2017 14:52:34 +0530 Message-Id: <36285b16e7c6a60613097ec8e258a9af2f6ab736.1501060871.git.viresh.kumar@linaro.org> X-Mailer: git-send-email 2.13.0.71.gd7076ec9c9cb 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 This patch updates the legacy governors (ondemand/conservative) to process cpufreq utilization update hooks to be called for remote CPUs. Proper locking is already in place for shared policies and nothing extra is required to be done. Based on initial work from Steve Muckle. Signed-off-by: Viresh Kumar --- drivers/cpufreq/cpufreq_governor.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) -- 2.13.0.71.gd7076ec9c9cb diff --git a/drivers/cpufreq/cpufreq_governor.c b/drivers/cpufreq/cpufreq_governor.c index 5499796cf9a8..b1bf84149526 100644 --- a/drivers/cpufreq/cpufreq_governor.c +++ b/drivers/cpufreq/cpufreq_governor.c @@ -272,8 +272,8 @@ static void dbs_update_util_handler(struct update_util_data *data, u64 time, struct policy_dbs_info *policy_dbs = cdbs->policy_dbs; u64 delta_ns, lst; - /* Don't allow remote callbacks */ - if (smp_processor_id() != data->cpu) + /* Allow remote callbacks only on the CPUs sharing cpufreq policy */ + if (!cpumask_test_cpu(smp_processor_id(), policy_dbs->policy->cpus)) return; /*