From patchwork Thu Jun 29 05:26:30 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 106607 Delivered-To: patch@linaro.org Received: by 10.140.101.44 with SMTP id t41csp704259qge; Wed, 28 Jun 2017 22:28:37 -0700 (PDT) X-Received: by 10.84.128.102 with SMTP id 93mr15804782pla.21.1498714117150; Wed, 28 Jun 2017 22:28:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1498714117; cv=none; d=google.com; s=arc-20160816; b=Pa6GkVzv8tfFEqKbQn9qJUKgOiFHjExAbxVAOHpMJ5wBfODDwJaCOi30MiC6WFkLbz 8jXT6yhFh5IfdYtuHV5K9IywTPiAeq2ovkgk2k6yTv8C96ATERquik6RtZGY9UbIIo/9 bpjTPgQ+x2FsGtrsZue+DaqKaRt4bW2ToAmy88Nx8CSIbas1KCjLPaLvoxY/ArT+odlX uxl0ESd0h/OJ7dYrr5dvJhmeI3o7rgrnZ1B+4ssSrNpqAqUXR5ObCuqwDBRkeMszx4/z 4vH1LExoBT1j5b5giqoV0+9bA3S/b+OVJ9yR02SyR5PiYYEiliKYbSjzc7XBmW+Xx+s6 X/GA== 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=wmP5Q5X+JSJ0vDsGUnlfJGfRlwEng18Xv9V32BkrYps=; b=Tr24znq1CqWz3pOLDNhIxigLMmN7aY0hSDzvxNjXmDDb7ywX4KBXN3wvvqiUBOam2W xN6FiOgGSy5ld2NoxHc31zJXMTk+e1OucSubAenh/wF4hFA2B6uqLrGtu0m1Z7lpFsqY wVScNkZwx+SGU9BDaXVbU9YIQU58sSPROhdIKy5OZ+guig1ByNWKphEyK0rJaxXIcsAn NHkztXvU8GIx8g6Y40kW3VrWyEee5bPTy8PuHJmWPwGJ2Zsk2hio0B+80b8tieYx16kd dCY4glN97cln29PDEIQUGQ1mj+/aEGBOIl3Vi7k5EJG0D6bbMNJFSSMQ59cMN+k+UXxz JlOQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.b=W1TJvEdf; spf=pass (google.com: best guess record for domain of linux-pm-owner@vger.kernel.org designates 209.132.180.67 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. [209.132.180.67]) by mx.google.com with ESMTP id 206si2969952pfb.354.2017.06.28.22.28.36; Wed, 28 Jun 2017 22:28:37 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-pm-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=W1TJvEdf; spf=pass (google.com: best guess record for domain of linux-pm-owner@vger.kernel.org designates 209.132.180.67 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 S1751747AbdF2F2e (ORCPT + 14 others); Thu, 29 Jun 2017 01:28:34 -0400 Received: from mail-pf0-f169.google.com ([209.85.192.169]:35337 "EHLO mail-pf0-f169.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751850AbdF2F15 (ORCPT ); Thu, 29 Jun 2017 01:27:57 -0400 Received: by mail-pf0-f169.google.com with SMTP id c73so44560181pfk.2 for ; Wed, 28 Jun 2017 22:27:57 -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=wmP5Q5X+JSJ0vDsGUnlfJGfRlwEng18Xv9V32BkrYps=; b=W1TJvEdfhNRKlFrqqik9sAuSOZHPmhoLlNp6uWEL+SIVDItXCgLWI0Z4jeh2cxKSwX sC6prRZpKP4LG7NAYDn3/Sqnk09Jz6aQsvCNBZvy8H2xfefDFxQ8rDU8KwYcwo8CoNyU c0qeDrTc4iWCEqYNXhna6g3dOc659Rd0242Ss= 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=wmP5Q5X+JSJ0vDsGUnlfJGfRlwEng18Xv9V32BkrYps=; b=fRfU0rY6RqIc7FnBCFlfh5aZhB8wmBpXmMh/9/KEyukG8wo79cnmx28ONQjq8J+9jq PnglES66GIKJLpGHRkEz8JQa0FAr1R8YJtrGv8DimyXNfvHDapOIYZCKZ5fmmIy8aCY5 B2ikEidxpVd/Txwoh1pbP2Xi2Eqg/HYUE9NQpqRB2lG/msw/M9+g8jhP/g6HfjeLN7Qt +bpwpGC1oAbxXdgqW0xGijRUADlYopynJ7L4HMKtXBRm+117wEDwBopkJhxc1Kij4iVu AjmsCA+I9J55bdjj5Y02ifFD6f3dxw5SD/XLsY0Q0HWhpGwrNfSZm1LDw42+Tt4WYS6U joQg== X-Gm-Message-State: AKS2vOxfRRdPZXCR5YM+u0R21DYF2Ndl8CCfFQo0x2YprD+yxx58GdLM rxDKoVuKwuXrFlUg X-Received: by 10.84.233.204 with SMTP id m12mr15921007pln.292.1498714076534; Wed, 28 Jun 2017 22:27:56 -0700 (PDT) Received: from localhost ([122.171.238.149]) by smtp.gmail.com with ESMTPSA id l63sm9183933pfc.132.2017.06.28.22.27.55 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 28 Jun 2017 22:27:56 -0700 (PDT) From: Viresh Kumar To: Rafael Wysocki , Ingo Molnar , Peter Zijlstra Cc: Viresh Kumar , linux-pm@vger.kernel.org, Vincent Guittot , linux-kernel@vger.kernel.org, smuckle.linux@gmail.com, juri.lelli@arm.com, Morten.Rasmussen@arm.com, patrick.bellasi@arm.com, eas-dev@lists.linaro.org Subject: [PATCH V2 1/4] cpufreq: schedutil: Process remote callback for shared policies Date: Thu, 29 Jun 2017 10:56:30 +0530 Message-Id: <643fe4ad707e3b02336ecf069e7f022d770bec98.1498712046.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-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org This patch updates the schedutil governor to process cpufreq utilization update hooks called for remote CPUs (i.e. For updates to the runqueue of other non-local CPUs). For now, we only support remote callbacks for CPUs which share their cpufreq policy with the local CPU. It may not be worth allowing remote callbacks in other cases, as we wouldn't be able to update the frequency on local CPU in that case. The schedutil governor already has proper locking in place for shared policy update hooks. This also adds a new field "cpu" in "struct update_util_data", to identify the remote CPU. Based on initial work from Steve Muckle. Signed-off-by: Steve Muckle Signed-off-by: Viresh Kumar --- include/linux/sched/cpufreq.h | 1 + kernel/sched/cpufreq.c | 1 + kernel/sched/cpufreq_schedutil.c | 19 ++++++++++++++----- 3 files changed, 16 insertions(+), 5 deletions(-) -- 2.13.0.71.gd7076ec9c9cb 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 076a2e31951c..3f9cae9ab326 100644 --- a/kernel/sched/cpufreq_schedutil.c +++ b/kernel/sched/cpufreq_schedutil.c @@ -154,12 +154,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; @@ -218,6 +218,10 @@ static void sugov_update_single(struct update_util_data *hook, u64 time, unsigned int next_f; bool busy; + /* Remote callbacks aren't allowed for policies which aren't shared */ + if (smp_processor_id() != hook->cpu) + return; + sugov_set_iowait_boost(sg_cpu, time, flags); sg_cpu->last_update = time; @@ -229,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); /* @@ -287,10 +291,15 @@ 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; - sugov_get_util(&util, &max); + /* Allow remote callbacks only on the CPUs sharing cpufreq policy */ + if (!cpumask_test_cpu(smp_processor_id(), policy->cpus)) + return; + + sugov_get_util(&util, &max, hook->cpu); raw_spin_lock(&sg_policy->update_lock);