From patchwork Thu May 25 17:56:23 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amit Pundir X-Patchwork-Id: 100532 Delivered-To: patch@linaro.org Received: by 10.140.96.100 with SMTP id j91csp880012qge; Thu, 25 May 2017 10:56:32 -0700 (PDT) X-Received: by 10.84.138.165 with SMTP id 34mr4709524plp.184.1495734992334; Thu, 25 May 2017 10:56:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1495734992; cv=none; d=google.com; s=arc-20160816; b=0GpSbUXHqqKkPz1c9AHtI221iEnB9NODMCM54HuV64KCjn77bmzFnB/KDy55ypiDaU ZkdLYApb0sitSUBDkCUsKc8eAyL8rYMUqWGAVlrxGBqK5mfr/QLxA9yQV22EZHJgCd/0 GMWqfkAsiAkp5dzeM6bEbn84/WuyESTv0rwvXj7in5GzW3GArmkqZmWa3DcNlqTPpeXe vmu3caJ1OkNKrIOYZONTVPmhy/3NFXsbRthmFGvM2/tBG+oz4WtiX22O1ZrP0UOvV8C1 kTbh3vbPVw5r7ZDrWJQodhbb234TK3cu1oxdwtGeSyWHxO8VOOcJBR0dM8y0DhL6I1jk 7wqg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :dkim-signature:arc-authentication-results; bh=gtHe0a34qz8nTuwXbEsMVKcLbU9QMN4K725lKtz+vuo=; b=bFmCpK6vhZPQz/3s29AsGKobkjTTYyBdxw3HK+ut9/BBpkFZk8Af6NsJS/EUzNs5Cd JVsG4UlZVLD88I5RS7D7g9CTd7hkB1IokpVWCsdA+SGxk0lb28U/JfmNbBqX8mxISKa7 um2Ugw+pu8EKj6g4gg0B0cwORyI0oz0y2atdP0wVLTxyVDP1CnM+exvIM5uxV/93fQ6G SUAKvVh+Sm9mFH6yf7XF1uOowrjrq4UNTJqb96XdS/XU3wgKotHeCiCm64JWre6yBeoE VCdwz1Weo1FP9DZ3OzBTmgVRq2/wnClS5sI9C7hzRObHBPtvetAq6y/avaaPigBWzN3e A2JQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org; spf=pass (google.com: best guess record for domain of stable-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=stable-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id r1si28812155plj.260.2017.05.25.10.56.32; Thu, 25 May 2017 10:56:32 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of stable-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 stable-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=stable-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 S1760213AbdEYR4b (ORCPT + 6 others); Thu, 25 May 2017 13:56:31 -0400 Received: from mail-pf0-f173.google.com ([209.85.192.173]:35050 "EHLO mail-pf0-f173.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1760188AbdEYR4a (ORCPT ); Thu, 25 May 2017 13:56:30 -0400 Received: by mail-pf0-f173.google.com with SMTP id n23so173890538pfb.2 for ; Thu, 25 May 2017 10:56:30 -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; bh=gtHe0a34qz8nTuwXbEsMVKcLbU9QMN4K725lKtz+vuo=; b=N/f7+t64gR9XgoXRuyaatuggf9XibEM7kZ53IkyauhPHEUfzfA8JFVtW7PS6YrafAA dD9ume1kbzCu6jtP5cfphRv8MdaKh7qTwmWBtpj8cSmvQ+MF37fRQFVZFXtHXdsAwWfV Fpi7w4vQ+oLY1Fs4gThWSrW6J1VpBB/QbbcoY= 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; bh=gtHe0a34qz8nTuwXbEsMVKcLbU9QMN4K725lKtz+vuo=; b=PNlun1o3YeHtX1eqLnsPTzunfpxRTUwm6Vfy6jxHOoZg+aPO+rmdc5kYVtNPfgiVNb F9OKAkSohOJVmc+wqMP4ckBtWweCGgog3SvggPcoUPj7mppYHsSOzh7l7DeVlbWhUKuW Hfz/Mt9ZWNq9zEkHH5jguxhjUKeKfzAlrUFzqnUB3h/OpjR/RICLFcJT+4JNNltkRI78 VblU2YWlytEB9JUkt5aaHp6dIoATfoSox3SnisF15X9l2LbUji8E55kSxB1ziMmU1I2y NF/Dqv/agzE3BauBOh2ZQQ48fY1A1BhOqZBgimIo2+RPEfyb3VcZkGVYmh7/lgCEJRWn NlBQ== X-Gm-Message-State: AODbwcCTYuv5RkD2dGJEmkfKiULScQwS61fX5fwz7ivA6JL3HT5K6hmj DlQHsH2Hzku76ZfmIw+YnA== X-Received: by 10.98.152.214 with SMTP id d83mr46274334pfk.7.1495734989604; Thu, 25 May 2017 10:56:29 -0700 (PDT) Received: from localhost.localdomain ([106.51.139.211]) by smtp.gmail.com with ESMTPSA id 15sm14483369pfj.59.2017.05.25.10.56.27 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 25 May 2017 10:56:28 -0700 (PDT) From: Amit Pundir To: Greg KH Cc: Stable , Viresh Kumar , "Rafael J . Wysocki" Subject: [PATCH for-4.9 1/2] cpufreq: schedutil: move cached_raw_freq to struct sugov_policy Date: Thu, 25 May 2017 23:26:23 +0530 Message-Id: <1495734984-26879-1-git-send-email-amit.pundir@linaro.org> X-Mailer: git-send-email 2.7.4 Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Viresh Kumar commit 6c4f0fa643cb9e775dcc976e3db00d649468ff1d upstream. 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. Fixes: 5cbea46984d6 (cpufreq: schedutil: map raw required frequency to driver frequency) Signed-off-by: Viresh Kumar Signed-off-by: Rafael J. Wysocki Signed-off-by: Amit Pundir --- kernel/sched/cpufreq_schedutil.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) -- 2.7.4 diff --git a/kernel/sched/cpufreq_schedutil.c b/kernel/sched/cpufreq_schedutil.c index 69e06898997d..6415c04be3f8 100644 --- a/kernel/sched/cpufreq_schedutil.c +++ b/kernel/sched/cpufreq_schedutil.c @@ -32,6 +32,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; @@ -46,7 +47,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; @@ -140,9 +140,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); } @@ -502,6 +502,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); @@ -512,7 +513,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,