From patchwork Mon May 9 21:20:13 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steve Muckle X-Patchwork-Id: 67379 Delivered-To: patch@linaro.org Received: by 10.140.92.199 with SMTP id b65csp1798419qge; Mon, 9 May 2016 14:20:44 -0700 (PDT) X-Received: by 10.66.236.167 with SMTP id uv7mr54034626pac.75.1462828842190; Mon, 09 May 2016 14:20:42 -0700 (PDT) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id hy8si40864694pab.190.2016.05.09.14.20.41; Mon, 09 May 2016 14:20:42 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-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; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753027AbcEIVU3 (ORCPT + 29 others); Mon, 9 May 2016 17:20:29 -0400 Received: from mail-pf0-f177.google.com ([209.85.192.177]:34341 "EHLO mail-pf0-f177.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752839AbcEIVUY (ORCPT ); Mon, 9 May 2016 17:20:24 -0400 Received: by mail-pf0-f177.google.com with SMTP id y69so79525200pfb.1 for ; Mon, 09 May 2016 14:20:23 -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=/XwVB2V9ZcoVlbeV1lEXeNG6YXQdAqjtCrX2W1WMojM=; b=LeW8Rb7cFb1jIo7lpFApMvJzml5MStjZkfMTtNBbBFLNafhrK5mT4p7MarUoVVYUrK SRiTurIR6yDwWnNuElbETRliXFBB53aW3MGmyc2VibzhdGLp/gtnpv1sI27pn0LvJsK4 1I8BGN2HRDW64Scs1fZtu1GU2h3LauUQfnuUg= 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=/XwVB2V9ZcoVlbeV1lEXeNG6YXQdAqjtCrX2W1WMojM=; b=Ls2A6HARGdJT50pQ6dxZnn1z9fPZ6d5FsLfblUI1EH+HCt7zgYTYf6bdKpWUbJI3h6 IwfqyndAg0xBTCr3NfRNOLP5Qu2hYjWopCpbyCEJWmpKShc/gfjufroEGe2MdjuASD2f 8HhtBwwxGUjhG7I3ebkHVYEhht3cOE6456b2j3kTCTb6a1voGTp65z5sgE3LDbsV8Ye4 4hdOA9YEKiCQIM8G/poIGIFGi1uWaj5fMstFj0RLiEtIqF26Dc7WR0cWNmAH5syqP1Bk xDmAyqjP0ED7x+pcR7rmbR4pwROxKb4fZ/UIhNbk/RTx6I0rQieTHuAKCjXC+R1czCLg QGiw== X-Gm-Message-State: AOPr4FUtAcgYXfMT61h15KJgNEjPLGb6WY1e8g50IMxQQYEhc+JkWqKHuunXcuQXDOdrAWRc X-Received: by 10.98.102.20 with SMTP id a20mr53502936pfc.137.1462828823334; Mon, 09 May 2016 14:20:23 -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 g5sm42815345pac.1.2016.05.09.14.20.21 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 09 May 2016 14:20:22 -0700 (PDT) From: Steve Muckle X-Google-Original-From: Steve Muckle To: Peter Zijlstra , Ingo Molnar , "Rafael J. Wysocki" Cc: linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org, Vincent Guittot , Morten Rasmussen , Dietmar Eggemann , Juri Lelli , Patrick Bellasi , Michael Turquette , Viresh Kumar , Srinivas Pandruvada , Len Brown Subject: [PATCH 4/5] cpufreq: schedutil: map raw required frequency to CPU-supported frequency Date: Mon, 9 May 2016 14:20:13 -0700 Message-Id: <1462828814-32530-5-git-send-email-smuckle@linaro.org> X-Mailer: git-send-email 2.4.10 In-Reply-To: <1462828814-32530-1-git-send-email-smuckle@linaro.org> References: <1462828814-32530-1-git-send-email-smuckle@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The mechanisms for remote CPU updates and slow-path frequency transitions are relatively expensive - the former is an IPI while the latter requires waking up a thread to do work. These activities should be avoided if they are not necessary. To that end, calculate the actual target-supported frequency required by the new utilization value in schedutil. If it is the same as the previously requested frequency then there is no need to continue with the update. Signed-off-by: Steve Muckle --- kernel/sched/cpufreq_schedutil.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) -- 2.4.10 diff --git a/kernel/sched/cpufreq_schedutil.c b/kernel/sched/cpufreq_schedutil.c index 6cb2ecc204ec..e185075fcb5c 100644 --- a/kernel/sched/cpufreq_schedutil.c +++ b/kernel/sched/cpufreq_schedutil.c @@ -153,14 +153,26 @@ static void sugov_update_commit(struct sugov_cpu *sg_cpu, int cpu, u64 time, * next_freq = C * curr_freq * util_raw / max * * Take C = 1.25 for the frequency tipping point at (util / max) = 0.8. + * + * The lowest target-supported frequency which is equal or greater than the raw + * next_freq (as calculated above) is returned, or the CPU's max_freq if such + * a target-supported frequency does not exist. */ static unsigned int get_next_freq(struct cpufreq_policy *policy, unsigned long util, unsigned long max) { + struct cpufreq_frequency_table *entry; unsigned int freq = arch_scale_freq_invariant() ? policy->cpuinfo.max_freq : policy->cur; + unsigned int target_freq = UINT_MAX; + + freq = (freq + (freq >> 2)) * util / max; + + cpufreq_for_each_valid_entry(entry, policy->freq_table) + if (entry->frequency >= freq && entry->frequency < target_freq) + target_freq = entry->frequency; - return (freq + (freq >> 2)) * util / max; + return target_freq != UINT_MAX ? target_freq : policy->cpuinfo.max_freq; } static void sugov_update_single(struct update_util_data *hook, u64 time,