From patchwork Fri May 19 06:23:44 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joel Fernandes X-Patchwork-Id: 9735883 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id D66EE6034C for ; Fri, 19 May 2017 06:24:25 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CE8A7204C1 for ; Fri, 19 May 2017 06:24:25 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C356226AE3; Fri, 19 May 2017 06:24:25 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, RCVD_IN_DNSWL_HI autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 44063204C1 for ; Fri, 19 May 2017 06:24:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932162AbdESGYX (ORCPT ); Fri, 19 May 2017 02:24:23 -0400 Received: from mail-pg0-f45.google.com ([74.125.83.45]:35263 "EHLO mail-pg0-f45.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932119AbdESGYK (ORCPT ); Fri, 19 May 2017 02:24:10 -0400 Received: by mail-pg0-f45.google.com with SMTP id q125so33559290pgq.2 for ; Thu, 18 May 2017 23:24:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=kq4R12OPfY8rySCU3N35vmfI8WxrPBMtjViDWlD/KJs=; b=LYU8Mf92FUev9roIHuBKya7c+pPtiOJdX5DeKugzCSLXKiII4pEZFtM8uSKwPSDI3E eUlc+Lt2PIiHOd1BRVosTaZ9c7MFPsX9RNG6IfCN/WSEET8B/pcgszsKq+/3MK7X8lRE Zxc1UV5TXHX8N3le8f+YKa3FY/RgAe6PNT7+hw8/fwZJEJ6wGNT4MhFH7445vm/JpB9V tnxe0oS0MCgtHBcfm47UcZUozSRXQsAlQtvf09hgFFqqdgvE8MUjvfi2E61dwT/L7pgH wmZyd88+qastu8C3gYHzhife+310nNpVdmCmKOrsnE8PXjMhjHP28LhAAgyyqtNWua/c MaBg== 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; bh=kq4R12OPfY8rySCU3N35vmfI8WxrPBMtjViDWlD/KJs=; b=uc7avCczud/nMyx263r2xNEvupwFgt/UAtf7f0RLOnRBj/xvVGc6Qa757lrd2pYzV6 ILb9cXOcSJFRMy3Pn+JoZ6AmmoGf70Y9/qo0eEYtQzyxOrLLnWzQaacEG+otE2Efiwxy j9bCV+2y+BQVFDVUai+DbbVdb3lTmFDjgLZdW9O1Kg8rAXnPpjKsmio13eOeZPlf0ZeR OKK+hXCEvJhKKxULjRad7ZYzYx4SxPjZOUJXdDd60mFChwDTWLuAz+ANNP0EnuCOAV2o aQY+rDPd228zmQtv0BeiuhnpR2o/tgVgl/K64dqydnf2+NvcEDW90XMIu0Lg9Dks6xdQ 2pQw== X-Gm-Message-State: AODbwcAvuF8ZuRheSpk9waJDs3cLOC4wk/gCnGKCal46DJkqLZs6UdKq bF2GjH7etArBJsHp X-Received: by 10.84.254.2 with SMTP id b2mr9412712plm.185.1495175044040; Thu, 18 May 2017 23:24:04 -0700 (PDT) Received: from joelaf-glaptop0.corp.google.com ([172.26.49.149]) by smtp.gmail.com with ESMTPSA id t79sm8613361pfk.106.2017.05.18.23.24.02 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 18 May 2017 23:24:03 -0700 (PDT) From: Joel Fernandes To: linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Joel Fernandes , Srinivas Pandruvada , Len Brown , "Rafael J . Wysocki" , Viresh Kumar , Ingo Molnar , Peter Zijlstra Subject: [PATCH v2 2/2] sched: Make iowait_boost optional in schedutil Date: Thu, 18 May 2017 23:23:44 -0700 Message-Id: <20170519062344.27692-3-joelaf@google.com> X-Mailer: git-send-email 2.13.0.303.g4ebf302169-goog In-Reply-To: <20170519062344.27692-1-joelaf@google.com> References: <20170519062344.27692-1-joelaf@google.com> Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP We should apply the iowait boost only if cpufreq policy has iowait boost enabled. Also make it a schedutil configuration from sysfs so it can be turned on/off if needed (by default initialize it to the policy value). For systems that don't need/want it enabled, such as those on arm64 based mobile devices that are battery operated, it saves energy when the cpufreq driver policy doesn't have it enabled (details below): Here are some results for energy measurements collected running a YouTube video for 30 seconds: Before: 8.042533 mWh After: 7.948377 mWh Energy savings is ~1.2% Cc: Srinivas Pandruvada Cc: Len Brown Cc: Rafael J. Wysocki Cc: Viresh Kumar Cc: Ingo Molnar Cc: Peter Zijlstra Signed-off-by: Joel Fernandes Acked-by: Saravana Kannan --- kernel/sched/cpufreq_schedutil.c | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/kernel/sched/cpufreq_schedutil.c b/kernel/sched/cpufreq_schedutil.c index 76877a62b5fa..0e392b58b9b3 100644 --- a/kernel/sched/cpufreq_schedutil.c +++ b/kernel/sched/cpufreq_schedutil.c @@ -24,6 +24,7 @@ struct sugov_tunables { struct gov_attr_set attr_set; unsigned int rate_limit_us; + bool iowait_boost_enable; }; struct sugov_policy { @@ -171,6 +172,11 @@ static void sugov_get_util(unsigned long *util, unsigned long *max) static void sugov_set_iowait_boost(struct sugov_cpu *sg_cpu, u64 time, unsigned int flags) { + struct sugov_policy *sg_policy = sg_cpu->sg_policy; + + if (!sg_policy->tunables->iowait_boost_enable) + return; + if (flags & SCHED_CPUFREQ_IOWAIT) { sg_cpu->iowait_boost = sg_cpu->iowait_boost_max; } else if (sg_cpu->iowait_boost) { @@ -386,10 +392,34 @@ static ssize_t rate_limit_us_store(struct gov_attr_set *attr_set, const char *bu return count; } +static ssize_t iowait_boost_enable_show(struct gov_attr_set *attr_set, + char *buf) +{ + struct sugov_tunables *tunables = to_sugov_tunables(attr_set); + + return sprintf(buf, "%u\n", tunables->iowait_boost_enable); +} + +static ssize_t iowait_boost_enable_store(struct gov_attr_set *attr_set, + const char *buf, size_t count) +{ + struct sugov_tunables *tunables = to_sugov_tunables(attr_set); + bool enable; + + if (kstrtobool(buf, &enable)) + return -EINVAL; + + tunables->iowait_boost_enable = enable; + + return count; +} + static struct governor_attr rate_limit_us = __ATTR_RW(rate_limit_us); +static struct governor_attr iowait_boost_enable = __ATTR_RW(iowait_boost_enable); static struct attribute *sugov_attributes[] = { &rate_limit_us.attr, + &iowait_boost_enable.attr, NULL }; @@ -543,6 +573,8 @@ static int sugov_init(struct cpufreq_policy *policy) tunables->rate_limit_us *= lat; } + tunables->iowait_boost_enable = policy->iowait_boost_enable; + policy->governor_data = sg_policy; sg_policy->tunables = tunables;