From patchwork Thu Mar 2 08:33:20 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 94765 Delivered-To: patch@linaro.org Received: by 10.140.82.71 with SMTP id g65csp62752qgd; Thu, 2 Mar 2017 00:40:13 -0800 (PST) X-Received: by 10.99.114.66 with SMTP id c2mr13850982pgn.4.1488444013236; Thu, 02 Mar 2017 00:40:13 -0800 (PST) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id i15si6843685pfj.285.2017.03.02.00.40.12; Thu, 02 Mar 2017 00:40:13 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-pm-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-pm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-pm-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753587AbdCBIj5 (ORCPT + 13 others); Thu, 2 Mar 2017 03:39:57 -0500 Received: from mail-pf0-f177.google.com ([209.85.192.177]:33293 "EHLO mail-pf0-f177.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750733AbdCBIjy (ORCPT ); Thu, 2 Mar 2017 03:39:54 -0500 Received: by mail-pf0-f177.google.com with SMTP id w189so20002517pfb.0 for ; Thu, 02 Mar 2017 00:39:53 -0800 (PST) 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 :in-reply-to:references; bh=Q+IqbGxSVXNs3g58fQ8Ts46FuloR7CrW4bR898B8SuU=; b=epar1Tr1O4P7Kn+Iw3mgdOBYxshm0Uk7E4UiWI65sz+MwAtdp/lplA2030RGVp6/IE UhGN5L2bQBMRmuKQqZajF7pHFaa2lIvVzqbvmZdUI0Ar7hbh6o9TrKM8YtJmntvObN5N CobbcPA3Us2tico8Yd2/UvcRDJ6cEDccLxbps= 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:in-reply-to:references; bh=Q+IqbGxSVXNs3g58fQ8Ts46FuloR7CrW4bR898B8SuU=; b=pJHReyuuQ5tpziUOKkbtwS8XpHcsZaRBSwBRCxTcFvamBFU41lMeth9hH9YKXT1zV4 GpZ09MHJX5LAVIrj5ioqTEjf0TiZdXOiG1lWt5Z/yhMrlI8rGRLYsXKomNbJy1dHfboH POk9v1PT6LjUcgnWUvXP534kOXbFQvZKI5x/g8IwdUY241+Xdgo96wbjQeH4rJIQSxYI XtcX8OSVN86txx3XGfruJ8W0uZqz3UYb9idfrxK/hunTZ2T/il+VCgx4DaXnS74eMcdn Qzu2W8xa5eFuBWxYo2ZqTtuMteyybYNhWC6puO+KuccIwgfsDyFHNviT4lBw+yCY8UzY IJnw== X-Gm-Message-State: AMke39kObx9TcrsD3SGq4v3U25N3+W8A9RJhv2hJ42vux6hNiPidJTJAKwPy20OwW1YWD3mU X-Received: by 10.99.122.13 with SMTP id v13mr14307896pgc.31.1488443613838; Thu, 02 Mar 2017 00:33:33 -0800 (PST) Received: from localhost ([122.172.165.189]) by smtp.gmail.com with ESMTPSA id e129sm15243603pfe.8.2017.03.02.00.33.32 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 02 Mar 2017 00:33:33 -0800 (PST) From: Viresh Kumar To: Rafael Wysocki , Ingo Molnar , Peter Zijlstra Cc: linaro-kernel@lists.linaro.org, linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, Vincent Guittot , Viresh Kumar Subject: [PATCH 1/3] cpufreq: schedutil: move cached_raw_freq to struct sugov_policy Date: Thu, 2 Mar 2017 14:03:20 +0530 Message-Id: <0ee63c640d47281997d544d05f9dd543aef80588.1488437503.git.viresh.kumar@linaro.org> X-Mailer: git-send-email 2.7.1.410.g6faf27b In-Reply-To: References: In-Reply-To: References: Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org cached_raw_freq applies to the entire cpufreq policy and not individual CPUs. Apart from wasting per-cpu memory, it is actually wrong to keep it in struct sugov_cpu as we may end up comparing next_freq with a stale cached_raw_freq of a random CPU. Move cached_raw_freq to struct sugov_policy. Signed-off-by: Viresh Kumar --- kernel/sched/cpufreq_schedutil.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) -- 2.7.1.410.g6faf27b diff --git a/kernel/sched/cpufreq_schedutil.c b/kernel/sched/cpufreq_schedutil.c index 306d97e7b57c..721f4e011366 100644 --- a/kernel/sched/cpufreq_schedutil.c +++ b/kernel/sched/cpufreq_schedutil.c @@ -35,6 +35,7 @@ struct sugov_policy { u64 last_freq_update_time; s64 freq_update_delay_ns; unsigned int next_freq; + unsigned int cached_raw_freq; /* The next fields are only needed if fast switch cannot be used. */ struct irq_work irq_work; @@ -51,7 +52,6 @@ struct sugov_cpu { struct update_util_data update_util; struct sugov_policy *sg_policy; - unsigned int cached_raw_freq; unsigned long iowait_boost; unsigned long iowait_boost_max; u64 last_update; @@ -145,9 +145,9 @@ static unsigned int get_next_freq(struct sugov_cpu *sg_cpu, unsigned long util, freq = (freq + (freq >> 2)) * util / max; - if (freq == sg_cpu->cached_raw_freq && sg_policy->next_freq != UINT_MAX) + if (freq == sg_policy->cached_raw_freq && sg_policy->next_freq != UINT_MAX) return sg_policy->next_freq; - sg_cpu->cached_raw_freq = freq; + sg_policy->cached_raw_freq = freq; return cpufreq_driver_resolve_freq(policy, freq); } @@ -579,6 +579,7 @@ static int sugov_start(struct cpufreq_policy *policy) sg_policy->next_freq = UINT_MAX; sg_policy->work_in_progress = false; sg_policy->need_freq_update = false; + sg_policy->cached_raw_freq = 0; for_each_cpu(cpu, policy->cpus) { struct sugov_cpu *sg_cpu = &per_cpu(sugov_cpu, cpu); @@ -589,7 +590,6 @@ static int sugov_start(struct cpufreq_policy *policy) sg_cpu->max = 0; sg_cpu->flags = SCHED_CPUFREQ_RT; sg_cpu->last_update = 0; - sg_cpu->cached_raw_freq = 0; sg_cpu->iowait_boost = 0; sg_cpu->iowait_boost_max = policy->cpuinfo.max_freq; cpufreq_add_update_util_hook(cpu, &sg_cpu->update_util, From patchwork Thu Mar 2 08:33:22 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 94763 Delivered-To: patch@linaro.org Received: by 10.140.82.71 with SMTP id g65csp61693qgd; Thu, 2 Mar 2017 00:35:56 -0800 (PST) X-Received: by 10.98.60.20 with SMTP id j20mr14329786pfa.128.1488443756295; Thu, 02 Mar 2017 00:35:56 -0800 (PST) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 123si6833327pgj.217.2017.03.02.00.35.56; Thu, 02 Mar 2017 00:35:56 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-pm-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-pm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-pm-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754482AbdCBIfv (ORCPT + 13 others); Thu, 2 Mar 2017 03:35:51 -0500 Received: from mail-pf0-f178.google.com ([209.85.192.178]:34284 "EHLO mail-pf0-f178.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754004AbdCBIef (ORCPT ); Thu, 2 Mar 2017 03:34:35 -0500 Received: by mail-pf0-f178.google.com with SMTP id e66so1568221pfe.1 for ; Thu, 02 Mar 2017 00:33:40 -0800 (PST) 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 :in-reply-to:references; bh=K8JYOM9B4tWqM1N6+LwfKTsuBbFRzafW9mfbWQenpxQ=; b=CI3As44y6jTWhMfLlgkJfWPnRa+1EA5snv3/gvsApnBtAjZH1Swgvmm+y7mPwf9jeL PFm7GkL7bpY/2RYepM/PSuhqwmdDPpTffk4xpNqkmxi9WfvwclHp2fzE4Sgo7pHBRia4 zbxwpZxihhouCW8kadBPw0VD/agLY+kRmfdqE= 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:in-reply-to:references; bh=K8JYOM9B4tWqM1N6+LwfKTsuBbFRzafW9mfbWQenpxQ=; b=eRnRrgIuLDzDfyHNOLCi7OEVyAzZWMzQTPHMkAzTwDdXhPmihujDPcW9rwHMXghQ7a NzB/xz49wpGUzbDV+ZSS6aEaoC/0rCEXD+FfjbjGhdyrAAsUXTCmj4ZaNZPy8IMjOhPx L+tgRo1VwRLJRM8XoaeKz2kUE8pK0LGi1B32e6CuAMzjAhaaa/4Lhg6tQ078/jooWiRH vrdo79B+oiE4AMai0h/09Awz14UiUus1dakxfuaYHMe0lQKycA01JnBf4FsHpD2h5ELC sSRIKW6/mhC5evIT/Zwf+f/a0M4HY53sDn70DMnLfZXydpGuy/3nFvga2j4dCXq4pddT ++pg== X-Gm-Message-State: AMke39ngJmD9s8zvUM+IUZz6LLkBK/Bn4JapHLh1pvkPpi4LWrnwmHUn1O+JDMssBOJVeo8z X-Received: by 10.98.56.2 with SMTP id f2mr14262772pfa.130.1488443620099; Thu, 02 Mar 2017 00:33:40 -0800 (PST) Received: from localhost ([122.172.165.189]) by smtp.gmail.com with ESMTPSA id m3sm15237693pfc.66.2017.03.02.00.33.39 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 02 Mar 2017 00:33:39 -0800 (PST) From: Viresh Kumar To: Rafael Wysocki , Ingo Molnar , Peter Zijlstra Cc: linaro-kernel@lists.linaro.org, linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, Vincent Guittot , Viresh Kumar Subject: [PATCH 3/3] cpufreq: schedutil: remove redundant code from sugov_next_freq_shared() Date: Thu, 2 Mar 2017 14:03:22 +0530 Message-Id: <639aad743bac7f3292146738f44dbd1480169c8e.1488437503.git.viresh.kumar@linaro.org> X-Mailer: git-send-email 2.7.1.410.g6faf27b In-Reply-To: References: In-Reply-To: References: Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org The same code is present both within and outside the loop and it doesn't look like it provides any additional benefit. Remove the special handling of sg_cpu and let it happen within the loop. With this change we will do two extra comparisons for the sg_cpu in the loop, but the loop will do one less comparison for every other CPU in the policy. While at it, also remove the excess parameters of sugov_next_freq_shared(). Signed-off-by: Viresh Kumar --- kernel/sched/cpufreq_schedutil.c | 18 ++++-------------- 1 file changed, 4 insertions(+), 14 deletions(-) -- 2.7.1.410.g6faf27b diff --git a/kernel/sched/cpufreq_schedutil.c b/kernel/sched/cpufreq_schedutil.c index 570925ea7253..ec56537429a8 100644 --- a/kernel/sched/cpufreq_schedutil.c +++ b/kernel/sched/cpufreq_schedutil.c @@ -216,30 +216,20 @@ static void sugov_update_single(struct update_util_data *hook, u64 time, sugov_update_commit(sg_policy, time, next_f); } -static unsigned int sugov_next_freq_shared(struct sugov_cpu *sg_cpu, - unsigned long util, unsigned long max, - unsigned int flags) +static unsigned int sugov_next_freq_shared(struct sugov_cpu *sg_cpu) { struct sugov_policy *sg_policy = sg_cpu->sg_policy; struct cpufreq_policy *policy = sg_policy->policy; unsigned int max_f = policy->cpuinfo.max_freq; u64 last_freq_update_time = sg_policy->last_freq_update_time; + unsigned long util = 0, max = 1; unsigned int j; - if (flags & SCHED_CPUFREQ_RT_DL) - return max_f; - - sugov_iowait_boost(sg_cpu, &util, &max); - for_each_cpu(j, policy->cpus) { - struct sugov_cpu *j_sg_cpu; + struct sugov_cpu *j_sg_cpu = &per_cpu(sugov_cpu, j); unsigned long j_util, j_max; s64 delta_ns; - if (j == smp_processor_id()) - continue; - - j_sg_cpu = &per_cpu(sugov_cpu, j); /* * If the CPU utilization was last updated before the previous * frequency update and the time elapsed between the last update @@ -288,7 +278,7 @@ static void sugov_update_shared(struct update_util_data *hook, u64 time, sg_cpu->last_update = time; if (sugov_should_update_freq(sg_policy, time)) { - next_f = sugov_next_freq_shared(sg_cpu, util, max, flags); + next_f = sugov_next_freq_shared(sg_cpu); sugov_update_commit(sg_policy, time, next_f); }