From patchwork Wed Apr 20 02:39:29 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steve Muckle X-Patchwork-Id: 8885681 Return-Path: X-Original-To: patchwork-linux-pm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 721F19F36E for ; Wed, 20 Apr 2016 02:40:36 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 8D93420260 for ; Wed, 20 Apr 2016 02:40:35 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 97417201FA for ; Wed, 20 Apr 2016 02:40:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753843AbcDTCkF (ORCPT ); Tue, 19 Apr 2016 22:40:05 -0400 Received: from mail-pf0-f181.google.com ([209.85.192.181]:34276 "EHLO mail-pf0-f181.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753488AbcDTCjg (ORCPT ); Tue, 19 Apr 2016 22:39:36 -0400 Received: by mail-pf0-f181.google.com with SMTP id c20so12899224pfc.1 for ; Tue, 19 Apr 2016 19:39:36 -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; bh=ZIAzyRcdvKGo79DLBkCRgapRZcrnpVTlB+/ub+Qi3K8=; b=Q4yLrz2Oclnc3Vz5j2hD4HwB/jXYhaDMqjsKhj06vmYf4LM5lOn/BCJqzraLAZQ3cj ioMnjNuKqqajFMWPOAz7dKZAoklZmPqH6S0J1/QQLAKLF6F7w59i6DaAFo48dCwaoIjY cEmw0+ANvP2EBxWlj4LuC2WGm7FDO1vmx/yec= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=ZIAzyRcdvKGo79DLBkCRgapRZcrnpVTlB+/ub+Qi3K8=; b=WE+MOsl0LeMxOu2Z4kZywqz3U3lM/uqZq9nEr9NX6EK6H/6nqvOf1+Ee7+ibjEYelD pGfr1PK9eOcFgMYSuYXIscIDFV5IJtRlZwzy48o/bo2LMM1WmCRLg3jQjM9I2GV0Jvha Rd9b6jxpangKPNN2mn625oQOJbuXUYBDpJ2NMOaG8zK3LpDOJibn56cLrCrZ08rfMdst 7ts+6Zic5c+2N3QyQqIQ6BooulAZ9RVFjd0BGfwXjamZrOgslWRvPOXmejVl9+/MavjJ orCduhQwOcx3QqiTUMNu3gp00StMZNBh/zolPdMKrsaSaDOsvxTDiKStl9IIKADpiImj AJdw== X-Gm-Message-State: AOPr4FX2f1AXaLogMcL/7tv1+uPMMIdaJoz1OtPKrtNfLomgyl+N5/xv5FQTTJFhjaXmunob X-Received: by 10.98.66.146 with SMTP id h18mr8775258pfd.27.1461119975700; Tue, 19 Apr 2016 19:39:35 -0700 (PDT) Received: from graphite.smuckle.net (cpe-76-167-105-107.san.res.rr.com. [76.167.105.107]) by smtp.gmail.com with ESMTPSA id 9sm93833526pfm.10.2016.04.19.19.39.34 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 19 Apr 2016 19:39:35 -0700 (PDT) From: Steve Muckle X-Google-Original-From: Steve Muckle To: "Rafael J. Wysocki" , Viresh Kumar Cc: linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org, Peter Zijlstra , Ingo Molnar , Vincent Guittot , Morten Rasmussen , Dietmar Eggemann , Juri Lelli , Patrick Bellasi , Michael Turquette Subject: [RFC PATCH 4/4] sched/fair: call cpufreq hook for remote wakeups Date: Tue, 19 Apr 2016 19:39:29 -0700 Message-Id: <1461119969-10371-4-git-send-email-smuckle@linaro.org> X-Mailer: git-send-email 2.4.10 In-Reply-To: <1461119969-10371-1-git-send-email-smuckle@linaro.org> References: <1461119969-10371-1-git-send-email-smuckle@linaro.org> Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org X-Spam-Status: No, score=-7.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,RP_MATCHES_RCVD,T_DKIM_INVALID,UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Without calling the cpufreq hook for a remote wakeup it is possible for such a wakeup to go unnoticed by cpufreq on the target CPU for up to a full tick. This can occur if the target CPU is running a CPU-bound task. Signed-off-by: Steve Muckle --- kernel/sched/fair.c | 8 +++----- kernel/sched/sched.h | 17 ++++++++++------- 2 files changed, 13 insertions(+), 12 deletions(-) diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c index b06c1e938cb9..d21a80a44b6e 100644 --- a/kernel/sched/fair.c +++ b/kernel/sched/fair.c @@ -2826,15 +2826,13 @@ static inline void cfs_rq_util_change(struct cfs_rq *cfs_rq) struct rq *rq = rq_of(cfs_rq); int cpu = cpu_of(rq); - if (cpu == smp_processor_id() && &rq->cfs == cfs_rq) { + if (&rq->cfs == cfs_rq) { unsigned long max = rq->cpu_capacity_orig; /* * There are a few boundary cases this might miss but it should * get called often enough that that should (hopefully) not be - * a real problem -- added to that it only calls on the local - * CPU, so if we enqueue remotely we'll miss an update, but - * the next tick/schedule should update. + * a real problem. * * It will not get called when we go idle, because the idle * thread is a different class (!fair), nor will the utilization @@ -2845,7 +2843,7 @@ static inline void cfs_rq_util_change(struct cfs_rq *cfs_rq) * * See cpu_util(). */ - cpufreq_update_util(rq_clock(rq), + cpufreq_update_util(cpu, rq_clock(rq), min(cfs_rq->avg.util_avg, max), max); } } diff --git a/kernel/sched/sched.h b/kernel/sched/sched.h index 921d6e5d33b7..a8a1eb603263 100644 --- a/kernel/sched/sched.h +++ b/kernel/sched/sched.h @@ -1799,6 +1799,7 @@ DECLARE_PER_CPU(struct update_util_data *, cpufreq_update_util_data); /** * cpufreq_update_util - Take a note about CPU utilization changes. + * @cpu: Target CPU. * @time: Current time. * @util: Current utilization. * @max: Utilization ceiling. @@ -1808,13 +1809,14 @@ DECLARE_PER_CPU(struct update_util_data *, cpufreq_update_util_data); * * It can only be called from RCU-sched read-side critical sections. */ -static inline void cpufreq_update_util(u64 time, unsigned long util, unsigned long max) +static inline void cpufreq_update_util(int cpu, u64 time, unsigned long util, + unsigned long max) { - struct update_util_data *data; + struct update_util_data *data; - data = rcu_dereference_sched(*this_cpu_ptr(&cpufreq_update_util_data)); - if (data) - data->func(data, time, util, max); + data = rcu_dereference_sched(per_cpu(cpufreq_update_util_data, cpu)); + if (data) + data->func(data, time, util, max); } /** @@ -1835,10 +1837,11 @@ static inline void cpufreq_update_util(u64 time, unsigned long util, unsigned lo */ static inline void cpufreq_trigger_update(u64 time) { - cpufreq_update_util(time, ULONG_MAX, 0); + cpufreq_update_util(smp_processor_id(), time, ULONG_MAX, 0); } #else -static inline void cpufreq_update_util(u64 time, unsigned long util, unsigned long max) {} +static inline void cpufreq_update_util(int cpu, u64 time, unsigned long util, + unsigned long max) {} static inline void cpufreq_trigger_update(u64 time) {} #endif /* CONFIG_CPU_FREQ */