From patchwork Mon Mar 14 05:22:07 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Turquette X-Patchwork-Id: 8576481 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 3B8809F3D1 for ; Mon, 14 Mar 2016 05:28:03 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 527E82042C for ; Mon, 14 Mar 2016 05:28:02 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 45C1720260 for ; Mon, 14 Mar 2016 05:28:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933435AbcCNF0W (ORCPT ); Mon, 14 Mar 2016 01:26:22 -0400 Received: from mail-pf0-f171.google.com ([209.85.192.171]:35472 "EHLO mail-pf0-f171.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933414AbcCNF0U (ORCPT ); Mon, 14 Mar 2016 01:26:20 -0400 Received: by mail-pf0-f171.google.com with SMTP id n5so90114297pfn.2 for ; Sun, 13 Mar 2016 22:26:19 -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=9qUn15T/Tk38s7XMxNn72Mt1lma0Jk8SktUh9mJEIy8=; b=SOJgn71IXJ8xZ+z6dlAD/s+G9ekCf2KS93JcIf9nsnxkVdhKO71e1BDbY9uD5siapI GokwGT1lKTZzfBz4P4VNv7eFpv3uk0v3JquBlYlUjdaOckjVtflxy710+DyPAgg+PeHv fhDZm6zZn/iFuZtJbQGn2MR5fW4HpTpfnQaF4KBqLbWUKbtyt87BeZBmfH1UilBu1u7s e6NUvAM2JWUsr92iucYdHAv+bhcm3+f5bBowGwYPUyo41OjQzwfQt6BdFrhbjpvXzL+S 09NdN2zEozbVNzazklOW/hTwb1uQZaa0JEnJhPd31aTme2GIZxZpbcuJlEjyTsA+LG5R lcyg== 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=9qUn15T/Tk38s7XMxNn72Mt1lma0Jk8SktUh9mJEIy8=; b=OviXvhcC5HE1w+KHmBy6652GNzJodgppJMuH/2UYdkd9MPdo6Z5Bi+/4NA9t7gdfE6 SQuchJuHdsKx5SgTi+OpgvJgOqnsn1fTdmFyIPGUXaubdpl2KzN/hry67aiB9jSvSIFI VouqYxMSZOq7UQ/F2insqtQqgCoU5HdUA86hDlIS6BbfHY4Q50fGDmVwwrt64a/RMLg6 ZmiGxO4jd0o769GOeRS/EeHCzyWiGp1qNwBQVaTIxQGZi3Or4vepvp6f88aLDr63NXgf eCP2zSFkHKQC8cELbS5ft3rA+QKA3wD/VR+tc2SYdSfz/fmqKVihRXla5S7EbzN2vl+1 d3Ww== X-Gm-Message-State: AD7BkJIeHPpjDDUHXNcmOB1V8tv3Plh0n/dpAFwKMmOy/Pfzg4pIxBiu1yv2RVswoGp2u+DY X-Received: by 10.98.16.150 with SMTP id 22mr27211803pfq.128.1457933179385; Sun, 13 Mar 2016 22:26:19 -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 ta2sm28636738pab.42.2016.03.13.22.26.18 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 13 Mar 2016 22:26:18 -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 3/8] sched/cpufreq: new cfs capacity margin helpers Date: Sun, 13 Mar 2016 22:22:07 -0700 Message-Id: <1457932932-28444-4-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 Introduce helper functions that allow cpufreq governors to change the value of the capacity margin applied to the cfs_rq->avg.util_avg signal. This allows for run-time tuning of the margin. A follow-up patch will update the schedutil governor to use these helpers. Signed-off-by: Michael Turquette --- include/linux/sched.h | 3 +++ kernel/sched/cpufreq.c | 53 ++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 56 insertions(+) diff --git a/include/linux/sched.h b/include/linux/sched.h index 1fa9b52..f18a99b 100644 --- a/include/linux/sched.h +++ b/include/linux/sched.h @@ -2372,6 +2372,9 @@ void cpufreq_set_freq_update_hook(int cpu, struct freq_update_hook *hook, void (*func)(struct freq_update_hook *hook, u64 time, unsigned long util, unsigned long max)); void cpufreq_clear_freq_update_hook(int cpu); +unsigned long cpufreq_get_cfs_capacity_margin(void); +void cpufreq_set_cfs_capacity_margin(unsigned long margin); +void cpufreq_reset_cfs_capacity_margin(void); #endif #ifdef CONFIG_SCHED_AUTOGROUP diff --git a/kernel/sched/cpufreq.c b/kernel/sched/cpufreq.c index bd012c2..a126b58 100644 --- a/kernel/sched/cpufreq.c +++ b/kernel/sched/cpufreq.c @@ -61,6 +61,59 @@ void cpufreq_clear_freq_update_hook(int cpu) EXPORT_SYMBOL_GPL(cpufreq_clear_freq_update_hook); /** + * cpufreq_get_cfs_capacity_margin - Get global cfs enqueue capacity margin + * + * margin is a percentage of capacity that is applied to the current + * utilization when selecting a new capacity state or cpu frequency. The value + * should be normalized to the range of [0..SCHED_CAPACITY_SCALE], where + * SCHED_CAPACITY_SCALE is 100% of the normalized capacity, or equivalent to + * multiplying the utilization by one. + * + * This function returns the current global cfs enqueue capacity margin + */ +unsigned long cpufreq_get_cfs_capacity_margin(void) +{ + return cfs_capacity_margin; +} +EXPORT_SYMBOL_GPL(cpufreq_get_cfs_capacity_margin); + +/** + * cpufreq_set_cfs_capacity_margin - Set global cfs enqueue capacity margin + * @margin: new capacity margin + * + * margin is a percentage of capacity that is applied to the current + * utilization when selecting a new capacity state or cpu frequency. The value + * should be normalized to the range of [0..SCHED_CAPACITY_SCALE], where + * SCHED_CAPACITY_SCALE is 100% of the normalized capacity, or equivalent to + * multiplying the utilization by one. + * + * For instance, to add a 25% margin to a utilization, margin should be 1280, + * which is 1.25x 1024, the default for SCHED_CAPACITY_SCALE. + */ +void cpufreq_set_cfs_capacity_margin(unsigned long margin) +{ + cfs_capacity_margin = margin; +} +EXPORT_SYMBOL_GPL(cpufreq_set_cfs_capacity_margin); + +/** + * cpufreq_reset_cfs_capacity_margin - Reset global cfs enqueue cap margin + * + * margin is a percentage of capacity that is applied to the current + * utilization when selecting a new capacity state or cpu frequency. The value + * should be normalized to the range of [0..SCHED_CAPACITY_SCALE], where + * SCHED_CAPACITY_SCALE is 100% of the normalized capacity, or equivalent to + * multiplying the utilization by one. + * + * This function resets the global margin to its default value. + */ +void cpufreq_reset_cfs_capacity_margin(void) +{ + cfs_capacity_margin = CAPACITY_MARGIN_DEFAULT; +} +EXPORT_SYMBOL_GPL(cpufreq_reset_cfs_capacity_margin); + +/** * cpufreq_update_util - Take a note about CPU utilization changes. * @time: Current time. * @util: CPU utilization.