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: 9599699 X-Patchwork-Delegate: rjw@sisk.pl 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 5247260429 for ; Thu, 2 Mar 2017 08:39:59 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 504AC28588 for ; Thu, 2 Mar 2017 08:39:59 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 438182858A; Thu, 2 Mar 2017 08:39:59 +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=-6.5 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM autolearn=ham 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 E05DB28588 for ; Thu, 2 Mar 2017 08:39:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753587AbdCBIj5 (ORCPT ); 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 X-Virus-Scanned: ClamAV using ClamSMTP 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(-) 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,