From patchwork Mon Mar 14 05:22:12 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Turquette X-Patchwork-Id: 8576421 Return-Path: X-Original-To: patchwork-linux-pm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id B47C7C0553 for ; Mon, 14 Mar 2016 05:27:04 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id D5D482042C for ; Mon, 14 Mar 2016 05:27:03 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id D90C720429 for ; Mon, 14 Mar 2016 05:27:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933522AbcCNF0e (ORCPT ); Mon, 14 Mar 2016 01:26:34 -0400 Received: from mail-pa0-f51.google.com ([209.85.220.51]:35544 "EHLO mail-pa0-f51.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933518AbcCNF0b (ORCPT ); Mon, 14 Mar 2016 01:26:31 -0400 Received: by mail-pa0-f51.google.com with SMTP id td3so121785048pab.2 for ; Sun, 13 Mar 2016 22:26:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=vBa24+oh3mPeUEMyctlolw6jcRY+HV2dtyzw9XNB0l0=; b=bxDggwrS2PJ8hKVcqvVVd3Opl7aajw07X1dTpr5zuIYeJJQx6ck4Khr4MIBsSMV1ri SQrw7+uYGImc6p32mxW89cSMBNWUFOoqMySzMy2jxd4HZsKKznER3+AR1L4vbnmY86lx IO4P6k46HiZR0tXeErbUnqFX4JNmwkLC6962aMS1SYv90fXjBuZBmvv8iZgYJn6YQLeG hj3LmBbsp4LKCb2pSxZavrQBVKUZ2Fg5LurCyHl2nFJynWH3bpteWpibnIv4lYjTh5Zt NsjyO+w3HNXUtm7rHw6XwehWbD/RVzlhfmGy/nnrqtQCyIffWVu/OVp/+5VeDY2R/R4a Y4VQ== 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=vBa24+oh3mPeUEMyctlolw6jcRY+HV2dtyzw9XNB0l0=; b=VaXK6M9UQCThbXvd9nAkzlJGbDWbhOyDaH2eJUSII+ij/QBqY2OprRmLKsyWIxzZQw 7Dp3K5ALYTpRQLUy1wPgZ/RWXy/U3TjM7F32rvtLLedsNtMIe6u8jkW4+oSlu10uFj8L 3CkeAAYBrm1jNXas0rBJBbin6mjt0Q3+QGihJXIgD90h4xbtOOxODVYJGom7+eR2Ji7m fMxu1ph1QjILvaunXzurxYwlLpV+ByDuML33qYaNo9Acp5WE89ma2NekdqtCe6zPiJj7 zBxaTvHVNmXEQtzxQ4lRYSa5b0HjgX3SDHYt8xlt/pgMlAehszE6YhBTbU47iq4kahDQ 4M1w== X-Gm-Message-State: AD7BkJJetM9gFLPdBaq4C6Dx3SILqOXhiiyBoDS4gJt0yWXtuJOhOEiwPvv7rmuvDAGKUy1k X-Received: by 10.66.118.7 with SMTP id ki7mr35330263pab.152.1457933190631; Sun, 13 Mar 2016 22:26:30 -0700 (PDT) Received: from localhost (cpe-172-248-200-249.socal.res.rr.com. [172.248.200.249]) by smtp.gmail.com with ESMTPSA id p74sm28639762pfa.11.2016.03.13.22.26.29 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 13 Mar 2016 22:26:29 -0700 (PDT) From: Michael Turquette X-Google-Original-From: Michael Turquette To: peterz@infradead.org, rjw@rjwysocki.net Cc: linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org, Juri.Lelli@arm.com, steve.muckle@linaro.org, morten.rasmussen@arm.com, dietmar.eggemann@arm.com, vincent.guittot@linaro.org, Michael Turquette Subject: [PATCH 8/8] sched: prefer cpufreq_scale_freq_capacity Date: Sun, 13 Mar 2016 22:22:12 -0700 Message-Id: <1457932932-28444-9-git-send-email-mturquette+renesas@baylibre.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1457932932-28444-1-git-send-email-mturquette+renesas@baylibre.com> References: <1457932932-28444-1-git-send-email-mturquette+renesas@baylibre.com> Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org X-Spam-Status: No, score=-6.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 arch_scale_freq_capacity is weird. It specifies an arch hook for an implementation that could easily vary within an architecture or even a chip family. This patch helps to mitigate this weirdness by defaulting to the cpufreq-provided implementation, which should work for all cases where CONFIG_CPU_FREQ is set. If CONFIG_CPU_FREQ is not set, then try to use an implementation provided by the architecture. Failing that, fall back to SCHED_CAPACITY_SCALE. It may be desirable for cpufreq drivers to specify their own implementation of arch_scale_freq_capacity in the future. The same is true for platform code within an architecture. In both cases an efficient implementation selector will need to be created and this patch adds a comment to that effect. Signed-off-by: Michael Turquette --- kernel/sched/sched.h | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/kernel/sched/sched.h b/kernel/sched/sched.h index 469d11d..37502ea 100644 --- a/kernel/sched/sched.h +++ b/kernel/sched/sched.h @@ -1368,7 +1368,21 @@ static inline int hrtick_enabled(struct rq *rq) #ifdef CONFIG_SMP extern void sched_avg_update(struct rq *rq); -#ifndef arch_scale_freq_capacity +/* + * arch_scale_freq_capacity can be implemented by cpufreq, platform code or + * arch code. We select the cpufreq-provided implementation first. If it + * doesn't exist then we default to any other implementation provided from + * platform/arch code. If those do not exist then we use the default + * SCHED_CAPACITY_SCALE value below. + * + * Note that if cpufreq drivers or platform/arch code have competing + * implementations it is up to those subsystems to select one at runtime with + * an efficient solution, as we cannot tolerate the overhead of indirect + * functions (e.g. function pointers) in the scheduler fast path + */ +#ifdef CONFIG_CPU_FREQ +#define arch_scale_freq_capacity cpufreq_scale_freq_capacity +#elif !defined(arch_scale_freq_capacity) static __always_inline unsigned long arch_scale_freq_capacity(struct sched_domain *sd, int cpu) {