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: 9050001 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 0C57D9F30C for ; Mon, 9 May 2016 21:20:57 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 2DD6D20123 for ; Mon, 9 May 2016 21:20:56 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 5586D2011E for ; Mon, 9 May 2016 21:20:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752887AbcEIVU1 (ORCPT ); Mon, 9 May 2016 17:20:27 -0400 Received: from mail-pf0-f178.google.com ([209.85.192.178]:34341 "EHLO mail-pf0-f178.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752834AbcEIVUY (ORCPT ); Mon, 9 May 2016 17:20:24 -0400 Received: by mail-pf0-f178.google.com with SMTP id y69so79525201pfb.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=ltnCKVVKjlUHrIZcrx8UNt4B/j4VykFcsRjmuJRkmms+j12y3fGIfOJmHL7SMOpmdm wRCXNuPonzRwgUzUfGL6//G9iEFRnB+DyIeAoqxw6I82j1L9He7m3Hf9gEzNMGUwUWye lJhAH9T/rYAE0qwT+CmVhhTHgAIv7GKYLMQ4cLtwxFMDBrElPzR8yN6dXR6VRQni2vAi wJNCQEaSVRiD8AgUAO8OL7WBb+dI747PNkkVOHvp/wQY5lIay1IXMqyTWOuMMnE6rkQ4 lbAiixxUBqqGEJ6HzxRLrVpuTJVZtc1zHwAWYMqEzZsKirJXnXrLEc+FhLIE77RAEMph b+OQ== X-Gm-Message-State: AOPr4FX/8oJreidQPxw0p9YQC+rDHXr+WQdpR3GC99lhRDdFSvDmGFldDfkeSAT37l9sBXo7 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-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org X-Spam-Status: No, score=-8.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,RP_MATCHES_RCVD,T_DKIM_INVALID,UNPARSEABLE_RELAY autolearn=ham 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 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(-) 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,