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, From patchwork Thu May 25 17:56:24 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amit Pundir X-Patchwork-Id: 100533 Delivered-To: patch@linaro.org Received: by 10.140.96.100 with SMTP id j91csp880024qge; Thu, 25 May 2017 10:56:33 -0700 (PDT) X-Received: by 10.84.136.135 with SMTP id 7mr52359786pll.98.1495734993884; Thu, 25 May 2017 10:56:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1495734993; cv=none; d=google.com; s=arc-20160816; b=qptNJ7Qx8oTB98S19S7jzkTmbnsHwWOJJB2899Rt4187jWgHz7+sJ8PIi7eN8/0cEs vO/tDNwFuB2e8SURAQMI+zMCPzBcJo6k8N6GyfzgM9j9k1ImmFu+DGfrOjvcA8ifbRLY ED8IvVDOFoBNxI49adjbmeKOa7lLPV8+TeId8h/dL0g0JDL+zctyNir+pMSoPXo1lMYh sNcwoIAvx1SvV3cIrF1sL+pzHePgy8cQfcvYJlXpdzzVDqk9pdaRasIQw2rzD/ukvLDO Zg6QA7YA1EGEttXNljBRUU2KvhdGTQrZYmqMgpnSNJU+kfvf5VDN5FMagjaF5j949iN1 uLew== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=CjW4zICZ3daOylYm0TqaZq+E12G7vDDNpl5YdhjzH0I=; b=xeNhF8sQ0gV6zw52Sf6oslBhdr75O2LYHJGy2bRnF3nofoAzCTUBAYWRc3jPZUswvQ fCoDOXd2rdtKLiYmCNHq1uw1Zi1dJ9M4BT8mfvQfc+XfpOegM0v4iYzx1C+Ci1IonEXp LqWUYMF7ZlDr25hg9l3RFyKVf9SK7MDR3GP07QijZvQyRXJELgKDNzoHlWXhyPUQzyKN mwSAZ48S0ABIvcHGnP3O5WXmaJD6HPjk+FjEI9ujF7413pDqYgCKmDGCTMDAnXgM9ATg mifDoeP0R4anLnIJPcXBHtYqwamCpe62vjQQ6opWv7wg1Xgburui5h9C5x89t1OEOs0R ZGsg== 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.33; Thu, 25 May 2017 10:56:33 -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 S1761489AbdEYR4d (ORCPT + 6 others); Thu, 25 May 2017 13:56:33 -0400 Received: from mail-pf0-f175.google.com ([209.85.192.175]:33327 "EHLO mail-pf0-f175.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1760188AbdEYR4c (ORCPT ); Thu, 25 May 2017 13:56:32 -0400 Received: by mail-pf0-f175.google.com with SMTP id e193so174019902pfh.0 for ; Thu, 25 May 2017 10:56:32 -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=CjW4zICZ3daOylYm0TqaZq+E12G7vDDNpl5YdhjzH0I=; b=FfkVLYZDyKjbQBBtaWZf9ZKZAVbNK4+JQRFVbk3OfQEiT/Sc1nGBCYzJdraoGsKqDW zcaKBOUobaM31Diw38lUZnCvkTS4HBq9Q3QXWPDZ4Ok5siOpM/ohWEk7R24S137bYOUj QPOTwudVxjYwAGUX7HtI+R67b1iWw9Jlb8miw= 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; bh=CjW4zICZ3daOylYm0TqaZq+E12G7vDDNpl5YdhjzH0I=; b=Sx0kJX6swts1eFiY4Vclh/eStJgIcW9vgFoSpx7PKwIq+ZYi8SjIcOhArxzpn4vXBv FgDhVULTEyg6z+ZOfXJJPAGvTNZbZk3rTvRCh2vfIlBidgg/rQGriU9iAGSV/bx4eHHa iIP+onqFkpsMhuvII8tNKnPIxj6auLu9scxlbMRf1aYGmM1cTVScg2UTevptFiooDwCx SeVjuybuQh+hZCWmh+sBSdJMp5B3g00URRY+5pecloL2dohdEO1aJnGPBvOd+iLAK5hv Jv2ZlYfUnrE69A3zdZqh1Uh9GBYktlMtMZ1JbZZytjLTIQ83auYXq8utqQppMZm48FOC 9Q3Q== X-Gm-Message-State: AODbwcDM9KDmvZBdhPuN5HvnI9PkH3ET4QA4USgdJf4wRPqqjf4QM76e mPsdofyWsswW4xgenf3jLg== X-Received: by 10.98.37.68 with SMTP id l65mr47014298pfl.175.1495734991580; Thu, 25 May 2017 10:56:31 -0700 (PDT) Received: from localhost.localdomain ([106.51.139.211]) by smtp.gmail.com with ESMTPSA id 15sm14483369pfj.59.2017.05.25.10.56.29 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 25 May 2017 10:56:31 -0700 (PDT) From: Amit Pundir To: Greg KH Cc: Stable , "Rafael J. Wysocki" Subject: [PATCH for-4.9 2/2] cpufreq: schedutil: Fix per-CPU structure initialization in sugov_start() Date: Thu, 25 May 2017 23:26:24 +0530 Message-Id: <1495734984-26879-2-git-send-email-amit.pundir@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1495734984-26879-1-git-send-email-amit.pundir@linaro.org> References: <1495734984-26879-1-git-send-email-amit.pundir@linaro.org> Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: "Rafael J. Wysocki" commit 4296f23ed49a15d36949458adcc66ff993dee2a8 upstream. sugov_start() only initializes struct sugov_cpu per-CPU structures for shared policies, but it should do that for single-CPU policies too. That in particular makes the IO-wait boost mechanism work in the cases when cpufreq policies correspond to individual CPUs. Fixes: 21ca6d2c52f8 (cpufreq: schedutil: Add iowait boosting) Signed-off-by: Rafael J. Wysocki Acked-by: Viresh Kumar Cc: 4.9+ # 4.9+ Signed-off-by: Amit Pundir --- kernel/sched/cpufreq_schedutil.c | 20 +++++++------------- 1 file changed, 7 insertions(+), 13 deletions(-) -- 2.7.4 diff --git a/kernel/sched/cpufreq_schedutil.c b/kernel/sched/cpufreq_schedutil.c index 6415c04be3f8..cb771c76682e 100644 --- a/kernel/sched/cpufreq_schedutil.c +++ b/kernel/sched/cpufreq_schedutil.c @@ -507,20 +507,14 @@ static int sugov_start(struct cpufreq_policy *policy) for_each_cpu(cpu, policy->cpus) { struct sugov_cpu *sg_cpu = &per_cpu(sugov_cpu, cpu); + memset(sg_cpu, 0, sizeof(*sg_cpu)); sg_cpu->sg_policy = sg_policy; - if (policy_is_shared(policy)) { - sg_cpu->util = 0; - sg_cpu->max = 0; - sg_cpu->flags = SCHED_CPUFREQ_RT; - sg_cpu->last_update = 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, - sugov_update_shared); - } else { - cpufreq_add_update_util_hook(cpu, &sg_cpu->update_util, - sugov_update_single); - } + sg_cpu->flags = SCHED_CPUFREQ_RT; + sg_cpu->iowait_boost_max = policy->cpuinfo.max_freq; + cpufreq_add_update_util_hook(cpu, &sg_cpu->update_util, + policy_is_shared(policy) ? + sugov_update_shared : + sugov_update_single); } return 0; }