From patchwork Wed Dec 13 09:53: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: 121730 Delivered-To: patch@linaro.org Received: by 10.140.22.227 with SMTP id 90csp5257561qgn; Wed, 13 Dec 2017 01:55:53 -0800 (PST) X-Google-Smtp-Source: ACJfBot0wv4KMqTLDY3yhM227h2ACKIVnbPZLczVN/vu74GpMY2jaIkN7Swwew693oiIr8T0IA/6 X-Received: by 10.159.218.143 with SMTP id w15mr5547273plp.38.1513158952844; Wed, 13 Dec 2017 01:55:52 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1513158952; cv=none; d=google.com; s=arc-20160816; b=gazCOo9x50v6zUd89gdItBEhDMoZQUq4Lpll41E7ED8Eknh4TNxksrehcA91c3+ply FnbyuaZ/Vf4wol2A9ZyAdrH+FXhmt46YfJ/3iBBWLEJDd7GaNcDFyBrky7p70OhY0s0a yB9UPACFxa42ORYNvZpEtvNGKDey9dWjOa2rEGBRAtpMuqTetE5655AvpDXXcKcv9HZs nWUt+5OGUUMC+PVBUKYi+CFURMrWOeoKq16X4ocA1auBevjugN7P5yc16rGXxPKUDkVo 8RdX9q7MCFxZjxXse4j86B8lj8f+crLnvxmombEhuWWEUpDPBOerWgLJsFx3lPxcMYk2 Ujqw== 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:references :in-reply-to:message-id:date:subject:cc:to:from:dkim-signature :arc-authentication-results; bh=kKjnF/kCYI8xHDD/6GJGan6O1Vda+TONCV3Nbh/y2W0=; b=Exsy0AuVRNG/X8zMTWjSy6vS49fKe4aKr9AnBdB6IP2Ih/YN6Bf1VOq6SWz4wcpBBV Fo1BM3bUKfpQCDPmReixsijcjZFONL29t6dpVisJ77MiA0aZXLd6O/ACR+H4LSAJOEU1 aXWBXlR3v62kqSBXvOfl3G0+V3fQaVu2nD9EjmZSUnhlhFW0FENYYUT8drOuK5BDMDLL LAR4giQzFT14L+xbVo5oT5N0enx3NRFtimc0p5gUOmGry5QaDw8LNI+pMSSk3MWoJVpE Rw8A8I7DlnRgWg8c6Lgv/LrGW1rL2xzEJZE2KFXgovuQPp1UB3qwbD5vNgjxw0FnBE/0 awDw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=J7xZM4tJ; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id s189si1013128pgb.104.2017.12.13.01.55.52; Wed, 13 Dec 2017 01:55:52 -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 header.s=google header.b=J7xZM4tJ; 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 S1751076AbdLMJzv (ORCPT + 11 others); Wed, 13 Dec 2017 04:55:51 -0500 Received: from mail-pg0-f65.google.com ([74.125.83.65]:33312 "EHLO mail-pg0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752586AbdLMJxb (ORCPT ); Wed, 13 Dec 2017 04:53:31 -0500 Received: by mail-pg0-f65.google.com with SMTP id g7so1047627pgs.0 for ; Wed, 13 Dec 2017 01:53:31 -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=kKjnF/kCYI8xHDD/6GJGan6O1Vda+TONCV3Nbh/y2W0=; b=J7xZM4tJk4RjmHvXp7jUpl+L2NEBG2LBNOT3DFK+9FSff0sXZuUuUsLuD7f+mA+O4q fF2VO/RVoXQXQ2o5D4oQfqXNKEWCRHcsWlVjXVDoY0wrnRDMFlub3inaXzK4adCCuxlU 9vu5eKIRYhrOHhaYSlfCKdaCQUOzCylcnQCkY= 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=kKjnF/kCYI8xHDD/6GJGan6O1Vda+TONCV3Nbh/y2W0=; b=onhjIGDIcU7F6zXkA13/oSc2RfuTZvr+bAued65X9v7fbX0sW9jkbSGDy2oBvM8B35 KUUY6bXjSUFsT1oY+sHF0vQQ0H6emnUkQcLSt7nWbtMFb371P/6hoc3qz4X1s6PrET5b ez+pxJFGfwKDXSEOVjbQNyQR7xdmR1RzdKmUsMYdpxiggKFdm73rfkWi6H7qQr5TJ4n8 VTtaNfI1ri0EzolUyvtIfUYrV5lzrH1ZUJmwbFFIAbtwWDXHEybEvVrNpbW+u8v0A/Nf RZcSCvoA8IKM4plvTlWhLABMFVBB+G5uOjPv3Eq5ZIK4HRW2xTTCQ7nddmB0ISpK5Km3 ICRA== X-Gm-Message-State: AKGB3mI3bkuUKKTze+MWVBa78FAzACeSnkhGjk6kiC9J43bgJTviSNjq KWDeBY3/62QRZE/Iu7mvrodgqg== X-Received: by 10.98.65.84 with SMTP id o81mr1647022pfa.55.1513158811234; Wed, 13 Dec 2017 01:53:31 -0800 (PST) Received: from localhost ([122.172.99.7]) by smtp.gmail.com with ESMTPSA id l21sm2551816pgc.76.2017.12.13.01.53.30 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 13 Dec 2017 01:53:30 -0800 (PST) From: Viresh Kumar To: Rafael Wysocki , Ingo Molnar , Peter Zijlstra Cc: Viresh Kumar , linux-pm@vger.kernel.org, Vincent Guittot , dietmar.eggemann@arm.com, morten.rasmussen@arm.com, juri.lelli@redhat.com, tkjos@android.com, joelaf@google.com, linux-kernel@vger.kernel.org Subject: [PATCH 1/4] cpufreq: schedutil: Initialize sg_cpu->flags to 0 Date: Wed, 13 Dec 2017 15:23:20 +0530 Message-Id: <763feda6424ced8486b25a0c52979634e6104478.1513158452.git.viresh.kumar@linaro.org> X-Mailer: git-send-email 2.15.0.194.g9af6a3dea062 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 Initializing sg_cpu->flags to SCHED_CPUFREQ_RT has no obvious benefit. The flags field wouldn't be used until the utilization update handler is called for the first time, and once that is called we will overwrite flags anyway. Initialize it to 0. Change-Id: I028dbb40c5c242cff52fe1b14aeaff37f29a2f8d Signed-off-by: Viresh Kumar --- kernel/sched/cpufreq_schedutil.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) -- 2.15.0.194.g9af6a3dea062 Reviewed-by: Juri Lelli diff --git a/kernel/sched/cpufreq_schedutil.c b/kernel/sched/cpufreq_schedutil.c index 2f52ec0f1539..e8ccfa30f01a 100644 --- a/kernel/sched/cpufreq_schedutil.c +++ b/kernel/sched/cpufreq_schedutil.c @@ -655,7 +655,7 @@ static int sugov_start(struct cpufreq_policy *policy) memset(sg_cpu, 0, sizeof(*sg_cpu)); sg_cpu->cpu = cpu; sg_cpu->sg_policy = sg_policy; - sg_cpu->flags = SCHED_CPUFREQ_RT; + sg_cpu->flags = 0; sg_cpu->iowait_boost_max = policy->cpuinfo.max_freq; } From patchwork Wed Dec 13 09:53:21 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 121727 Delivered-To: patch@linaro.org Received: by 10.140.22.227 with SMTP id 90csp5255853qgn; Wed, 13 Dec 2017 01:53:42 -0800 (PST) X-Google-Smtp-Source: ACJfBovKzn50f/1uRt1tO97ADjL35s7C6ztVnwv2efnd+hipxofEwNhq1K1678rKVNb8lF/mEdDa X-Received: by 10.99.98.67 with SMTP id w64mr4936266pgb.213.1513158822228; Wed, 13 Dec 2017 01:53:42 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1513158822; cv=none; d=google.com; s=arc-20160816; b=c9OI7UAlk3KR6SAXyC2o59IGl+ry5KauV0Fyz9M3nmin+NXWEgtlxkKcgQweu0gmdJ ldRsTgAvSdarkEDRSSDTdFKQExJjYRqKy4flGp38j8wXgKKCz3vNRFLH9xVCz/ywa/je NF/hLnoCZMYnxhq1tUFInr06Pbwpy0kiSPw+UX5aIZbMeubn35foHPEqqMLVd79T/iRI JuvHQexulIpCvGkREa2wwcj7h6Lz7a/HL5OXaMIPGjmC5tq9/DMKy3DBpkGs8gmSWQ4g /5vMUQYGPgsgl61eWD3KUSJ/L5r7x/AhZDKCp3Bsv17XcbXGzB/w92Xm7eO/qnBUXa7I vm1g== 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:references :in-reply-to:message-id:date:subject:cc:to:from:dkim-signature :arc-authentication-results; bh=ZQlBGXYqfjwPfMo6vJyuu1hnl/sMwhj5Nh/CmbtTC5U=; b=sDjs6WNS6FdKz+VDxz8Zz1akx4iFh/zDBbIkCub2/e6VcIaZ2/z8KxpWM7lYqjH9Rs jAQrde5zOiouxJ6XwWD/S43pZNqbtVAbQkasSCsuhV6dnRhIWvNP9VOQbEx4T4rNzQvw 6dZ//2ZF1B8jd9O+GmI/wcazqUn6fX+JHLFCWRtMDT+w5LJV++equke2It5koeaC5Jwe 1WnFDt2RE5TVukpccVy/cJhBqZxKGQk7n2BSNfnzlke8cUMhsjQFnTzEWis3QPD8PRY5 4iOvYXAsdlSPH3BIBMnXYClxCRjqPrx7CzlfZrL5euVMUWtj1HMcwaV/nDzd+T6Q/Wt2 0DAw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=QkVr/9bo; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id y14si1128896pfi.164.2017.12.13.01.53.42; Wed, 13 Dec 2017 01:53:42 -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 header.s=google header.b=QkVr/9bo; 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 S1752640AbdLMJxk (ORCPT + 11 others); Wed, 13 Dec 2017 04:53:40 -0500 Received: from mail-pg0-f66.google.com ([74.125.83.66]:40364 "EHLO mail-pg0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752497AbdLMJxf (ORCPT ); Wed, 13 Dec 2017 04:53:35 -0500 Received: by mail-pg0-f66.google.com with SMTP id k15so1035678pgr.7 for ; Wed, 13 Dec 2017 01:53:34 -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=ZQlBGXYqfjwPfMo6vJyuu1hnl/sMwhj5Nh/CmbtTC5U=; b=QkVr/9boRtRBvcl3jfmyopT6z5CMqviHpVbZb7z2hWPnMEaWMUdtyelFCPSySGY9Zb pv5Joz6iWnfb+lMiXT31bnF/msH4qivwv0CA+4X6BegroMzy1JySfXY4hK0h2fiLQqea ravJPPC784sanS/0pncexuTre7KmDLdqsCi9Y= 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=ZQlBGXYqfjwPfMo6vJyuu1hnl/sMwhj5Nh/CmbtTC5U=; b=n9MNJSxUUXAICiE9LvUU8iplFBjCmP3iqaZmRx6DR7hr1rW6Kd5mieenZbHYo+rCJH EencwxKIxfvWajeomW1bvB4izXSqj75S4Bmp53bhJFqzJStqX/lasCKBrjxfeidxyeb0 FLzVfONh//3Rr10r6yuzKqQ17n7B6UHTgs70UTXku7yIkHB3ZKYz39+QOWrexCn9cGGF qq144rgxO7U144de2B2lDknpVPwKsF4/yj7tcIva8DHOtTvsGCFeU2cgmg4hdeHe5i6U MgvtTHMUvgaDDtOj9AOXocHcUZbuelQSOJOIn10TghTInMgX3WiVMCPPUMUUTu7yU5Dd eTuA== X-Gm-Message-State: AKGB3mJlkhnwlMkZ1eZq3/RhQOKkaak/4t/C9GU/PxgwxTIpbe+bQ34U LKoGo5rrzYidIAKCUqSbx/kI1w== X-Received: by 10.99.127.88 with SMTP id p24mr4737596pgn.377.1513158814428; Wed, 13 Dec 2017 01:53:34 -0800 (PST) Received: from localhost ([122.172.99.7]) by smtp.gmail.com with ESMTPSA id 13sm2761096pfs.112.2017.12.13.01.53.33 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 13 Dec 2017 01:53:33 -0800 (PST) From: Viresh Kumar To: Rafael Wysocki , Ingo Molnar , Peter Zijlstra Cc: Viresh Kumar , linux-pm@vger.kernel.org, Vincent Guittot , dietmar.eggemann@arm.com, morten.rasmussen@arm.com, juri.lelli@redhat.com, tkjos@android.com, joelaf@google.com, linux-kernel@vger.kernel.org Subject: [PATCH 2/4] sched: cpufreq: Keep track of cpufreq utilization update flags Date: Wed, 13 Dec 2017 15:23:21 +0530 Message-Id: <17ff0b5d83a1275a98f0d1b87daf275f3e964af3.1513158452.git.viresh.kumar@linaro.org> X-Mailer: git-send-email 2.15.0.194.g9af6a3dea062 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 Currently the schedutil governor overwrites the sg_cpu->flags field on every call to the utilization handler. It was pretty good as the initial implementation of utilization handlers, there are several drawbacks though. The biggest drawback is that the sg_cpu->flags field doesn't always represent the correct type of tasks that are enqueued on a CPU's rq. For example, if a fair task is enqueued while a RT or DL task is running, we will overwrite the flags with value 0 and that may take the CPU to lower OPPs unintentionally. There can be other corner cases as well which we aren't aware of currently. This patch changes the current implementation to keep track of all the task types that are currently enqueued to the CPUs rq. A new flag: CLEAR is introduced and is set by the scheduling classes when their last task is dequeued. When the CLEAR flag bit is set, the schedutil governor resets all the other flag bits that are present in the flags parameter. For now, the util update handlers return immediately if they were called to clear the flag. Signed-off-by: Viresh Kumar --- include/linux/sched/cpufreq.h | 7 ++++++- kernel/sched/cpufreq_schedutil.c | 21 ++++++++++++++++++--- kernel/sched/deadline.c | 4 ++++ kernel/sched/fair.c | 8 ++++++-- kernel/sched/rt.c | 4 ++++ 5 files changed, 38 insertions(+), 6 deletions(-) -- 2.15.0.194.g9af6a3dea062 Reviewed-by: Juri Lelli diff --git a/include/linux/sched/cpufreq.h b/include/linux/sched/cpufreq.h index d1ad3d825561..6f6641e61236 100644 --- a/include/linux/sched/cpufreq.h +++ b/include/linux/sched/cpufreq.h @@ -8,10 +8,15 @@ * Interface between cpufreq drivers and the scheduler: */ +#define SCHED_CPUFREQ_CLEAR (1U << 31) #define SCHED_CPUFREQ_RT (1U << 0) #define SCHED_CPUFREQ_DL (1U << 1) -#define SCHED_CPUFREQ_IOWAIT (1U << 2) +#define SCHED_CPUFREQ_CFS (1U << 2) +#define SCHED_CPUFREQ_IOWAIT (1U << 3) +#define SCHED_CPUFREQ_RT_CLEAR (SCHED_CPUFREQ_RT | SCHED_CPUFREQ_CLEAR) +#define SCHED_CPUFREQ_DL_CLEAR (SCHED_CPUFREQ_DL | SCHED_CPUFREQ_CLEAR) +#define SCHED_CPUFREQ_CFS_CLEAR (SCHED_CPUFREQ_CFS | SCHED_CPUFREQ_CLEAR) #define SCHED_CPUFREQ_RT_DL (SCHED_CPUFREQ_RT | SCHED_CPUFREQ_DL) #ifdef CONFIG_CPU_FREQ diff --git a/kernel/sched/cpufreq_schedutil.c b/kernel/sched/cpufreq_schedutil.c index e8ccfa30f01a..60a2dea4c8cc 100644 --- a/kernel/sched/cpufreq_schedutil.c +++ b/kernel/sched/cpufreq_schedutil.c @@ -191,6 +191,8 @@ static void sugov_set_iowait_boost(struct sugov_cpu *sg_cpu, u64 time, unsigned int flags) { if (flags & SCHED_CPUFREQ_IOWAIT) { + sg_cpu->flags &= ~SCHED_CPUFREQ_IOWAIT; + if (sg_cpu->iowait_boost_pending) return; @@ -264,6 +266,13 @@ static void sugov_update_single(struct update_util_data *hook, u64 time, unsigned int next_f; bool busy; + if (unlikely(flags & SCHED_CPUFREQ_CLEAR)) { + sg_cpu->flags &= ~flags; + return; + } + + sg_cpu->flags |= flags; + sugov_set_iowait_boost(sg_cpu, time, flags); sg_cpu->last_update = time; @@ -272,7 +281,7 @@ static void sugov_update_single(struct update_util_data *hook, u64 time, busy = sugov_cpu_is_busy(sg_cpu); - if (flags & SCHED_CPUFREQ_RT_DL) { + if (sg_cpu->flags & SCHED_CPUFREQ_RT_DL) { next_f = policy->cpuinfo.max_freq; } else { sugov_get_util(&util, &max, sg_cpu->cpu); @@ -345,15 +354,20 @@ static void sugov_update_shared(struct update_util_data *hook, u64 time, raw_spin_lock(&sg_policy->update_lock); + if (unlikely(flags & SCHED_CPUFREQ_CLEAR)) { + sg_cpu->flags &= ~flags; + goto unlock; + } + sg_cpu->util = util; sg_cpu->max = max; - sg_cpu->flags = flags; + sg_cpu->flags |= flags; sugov_set_iowait_boost(sg_cpu, time, flags); sg_cpu->last_update = time; if (sugov_should_update_freq(sg_policy, time)) { - if (flags & SCHED_CPUFREQ_RT_DL) + if (sg_cpu->flags & SCHED_CPUFREQ_RT_DL) next_f = sg_policy->policy->cpuinfo.max_freq; else next_f = sugov_next_freq_shared(sg_cpu, time); @@ -361,6 +375,7 @@ static void sugov_update_shared(struct update_util_data *hook, u64 time, sugov_update_commit(sg_policy, time, next_f); } +unlock: raw_spin_unlock(&sg_policy->update_lock); } diff --git a/kernel/sched/deadline.c b/kernel/sched/deadline.c index 2473736c7616..d9c7c6887493 100644 --- a/kernel/sched/deadline.c +++ b/kernel/sched/deadline.c @@ -1472,6 +1472,10 @@ static void dequeue_task_dl(struct rq *rq, struct task_struct *p, int flags) */ if (flags & DEQUEUE_SLEEP) task_non_contending(p); + + /* Clear cpufreq flags after last deadline task is dequeued */ + if (!rq->dl.dl_nr_running) + cpufreq_update_util(rq, SCHED_CPUFREQ_DL_CLEAR); } /* diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c index 2915c0d95107..492188c3ee2d 100644 --- a/kernel/sched/fair.c +++ b/kernel/sched/fair.c @@ -3033,7 +3033,7 @@ static inline void cfs_rq_util_change(struct cfs_rq *cfs_rq) * * See cpu_util(). */ - cpufreq_update_util(rq, 0); + cpufreq_update_util(rq, SCHED_CPUFREQ_CFS); } } @@ -5214,7 +5214,7 @@ enqueue_task_fair(struct rq *rq, struct task_struct *p, int flags) * passed. */ if (p->in_iowait) - cpufreq_update_util(rq, SCHED_CPUFREQ_IOWAIT); + cpufreq_update_util(rq, SCHED_CPUFREQ_CFS | SCHED_CPUFREQ_IOWAIT); for_each_sched_entity(se) { if (se->on_rq) @@ -5309,6 +5309,10 @@ static void dequeue_task_fair(struct rq *rq, struct task_struct *p, int flags) sub_nr_running(rq, 1); hrtick_update(rq); + + /* Clear cpufreq flags after last CFS task is dequeued */ + if (!rq->cfs.nr_running) + cpufreq_update_util(rq, SCHED_CPUFREQ_CFS_CLEAR); } #ifdef CONFIG_SMP diff --git a/kernel/sched/rt.c b/kernel/sched/rt.c index 862a513adca3..c9e8a8e5641b 100644 --- a/kernel/sched/rt.c +++ b/kernel/sched/rt.c @@ -1337,6 +1337,10 @@ static void dequeue_task_rt(struct rq *rq, struct task_struct *p, int flags) dequeue_rt_entity(rt_se, flags); dequeue_pushable_task(rq, p); + + /* Clear cpufreq flags after last rt task is dequeued */ + if (!rq->rt.rt_nr_running) + cpufreq_update_util(rq, SCHED_CPUFREQ_RT_CLEAR); } /* From patchwork Wed Dec 13 09:53: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: 121729 Delivered-To: patch@linaro.org Received: by 10.140.22.227 with SMTP id 90csp5256993qgn; Wed, 13 Dec 2017 01:55:14 -0800 (PST) X-Google-Smtp-Source: ACJfBouIMnG038zmSt9Mj2irTg9oitpeagVmf1412jsGiM3+68r1MBy1f/o89ItKqBPf5lEyXh2W X-Received: by 10.99.142.73 with SMTP id k70mr4928178pge.426.1513158914170; Wed, 13 Dec 2017 01:55:14 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1513158914; cv=none; d=google.com; s=arc-20160816; b=k4Bl20UaOnG5r/M9vA+vu2P0zL+B1OH7D1PicvCRz8dwz7QF/60uONtyM3TMSeda00 WZfwnh4ONPsLKT6zHNmLodL6iJ+8RFmP59PgjoZBnJXRxODOY8IN/k1AcJCmczBevdz4 PEAWJDOKJZRbUiNrhYWgm+f7DUUin/1i5DzrAawqpxwHg6/rPsUnOxzfzGdMkcjpW78g FVdk+LSzHuIiDicJTxZZLnlOEPaYlYUkpzL7UsF1gr7UGnc16Y9du56+nprZiyD7eJ6W +ZSlkPIzEWLBESvOwJs98+/1r0XnYawLATlrZ87fFF2iHa48dtQ5fHS5DVl9Rne3GgXG 3qBw== 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:references :in-reply-to:message-id:date:subject:cc:to:from:dkim-signature :arc-authentication-results; bh=feT0mkzsi4yWrZLiEjaEY4NfSgsS7ip6gjhGbZvoQBU=; b=yf5WCJG+xkXTsEvbHOAovvgvF/3rMf3XyLIIXlx/alzeZkEVBv+MoKWsohUzCs22BG 3CLCgtbdPbcBTz/sYouymO1GNESh7R2M7+8aFtihfXW1s407G6GBPgcavpWDY7DRdRW8 +WZ6FqeKH0BPMuFsoYKuyx6wR9S0UPh/t+6kmVHg9rE9G/6u8tsE86XXhWZt8vjgX3ce YlTDGB5P65juPEE4B8gWdh50/jd4YS5KadqWzDsM6jadC+79U5noG29v+QymgplI2bEA SFusINFQ5TC5nYxAzBuHmCaLu5asJ57lfiDZP9sx+PAG5E25OXGpz1LqoTI+jLIIjQZy UsuA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=jOwOoBSd; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id c20si1140380pfd.107.2017.12.13.01.55.13; Wed, 13 Dec 2017 01:55:14 -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 header.s=google header.b=jOwOoBSd; 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 S1752172AbdLMJzM (ORCPT + 11 others); Wed, 13 Dec 2017 04:55:12 -0500 Received: from mail-pf0-f193.google.com ([209.85.192.193]:43937 "EHLO mail-pf0-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752625AbdLMJxi (ORCPT ); Wed, 13 Dec 2017 04:53:38 -0500 Received: by mail-pf0-f193.google.com with SMTP id e3so1096280pfi.10 for ; Wed, 13 Dec 2017 01:53:37 -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=feT0mkzsi4yWrZLiEjaEY4NfSgsS7ip6gjhGbZvoQBU=; b=jOwOoBSdHME1rukBPY+lYH8diTBFsvR0jjiyDUtjx/HkfCDLx+m2XjyD0bugq3wjR+ CIAwVDM63+8QqRtD3mtOsznLxcZEaenczpzZ0eL9QrDY7Zt3jieME6Z3RpTUWq3sapqi q52yN0tUEeVIQ2+nELzBomB7/08u1CVKdYn4w= 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=feT0mkzsi4yWrZLiEjaEY4NfSgsS7ip6gjhGbZvoQBU=; b=A4cEparogcByg21e/sCtYwMbEulKgZRaKsRnXRGh2rvPqwQD3ooV/fxfDrPrdbWaOj KkbQGqHkkWRbXMJ9jcY8Gc6Jx7skHN+SHg5aRXThqXw7upXbpMi37+ZB6iKGf39ktMuA EdeVAuwK7+LHLilpMKmHZYIlEY34s5qraw9pQ7VbrflwQopdZoFQwiIo3470enWLJ23+ nXVQvVDHFtBwdwy6YuZkYSht4piGJwCCKhUmvl/Vf+ySnZZF/GEenA+THnGuYluYVLwM sneCAqK9CagbjsUXMNo9vnpxuNvUB2TEXVIyJrf50wozNAVYrEAtNPdDz327zu8O2V+h leaw== X-Gm-Message-State: AKGB3mIzzJ/wCDRIrs3EViY6wPi9pjcZTzslmh6dDH9ksFsdZCDoo8My pRon3Bu+v9tkO9We8U5XVrSLCQ== X-Received: by 10.101.100.77 with SMTP id s13mr4816506pgv.15.1513158817125; Wed, 13 Dec 2017 01:53:37 -0800 (PST) Received: from localhost ([122.172.99.7]) by smtp.gmail.com with ESMTPSA id d81sm3005183pfj.163.2017.12.13.01.53.36 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 13 Dec 2017 01:53:36 -0800 (PST) From: Viresh Kumar To: Rafael Wysocki , Ingo Molnar , Peter Zijlstra Cc: Viresh Kumar , linux-pm@vger.kernel.org, Vincent Guittot , dietmar.eggemann@arm.com, morten.rasmussen@arm.com, juri.lelli@redhat.com, tkjos@android.com, joelaf@google.com, linux-kernel@vger.kernel.org Subject: [PATCH 3/4] cpufreq: schedutil: Don't pass flags to sugov_set_iowait_boost() Date: Wed, 13 Dec 2017 15:23:22 +0530 Message-Id: <4ec5562b1a87e146ebab11fb5dde1ca9c763a7fb.1513158452.git.viresh.kumar@linaro.org> X-Mailer: git-send-email 2.15.0.194.g9af6a3dea062 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 We are already passing sg_cpu as argument to sugov_set_iowait_boost() helper and the same can be used to retrieve the flags value. Get rid of the redundant argument. Signed-off-by: Viresh Kumar --- kernel/sched/cpufreq_schedutil.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) -- 2.15.0.194.g9af6a3dea062 diff --git a/kernel/sched/cpufreq_schedutil.c b/kernel/sched/cpufreq_schedutil.c index 60a2dea4c8cc..7edfdc59ee8f 100644 --- a/kernel/sched/cpufreq_schedutil.c +++ b/kernel/sched/cpufreq_schedutil.c @@ -187,10 +187,9 @@ static void sugov_get_util(unsigned long *util, unsigned long *max, int cpu) *max = cfs_max; } -static void sugov_set_iowait_boost(struct sugov_cpu *sg_cpu, u64 time, - unsigned int flags) +static void sugov_set_iowait_boost(struct sugov_cpu *sg_cpu, u64 time) { - if (flags & SCHED_CPUFREQ_IOWAIT) { + if (sg_cpu->flags & SCHED_CPUFREQ_IOWAIT) { sg_cpu->flags &= ~SCHED_CPUFREQ_IOWAIT; if (sg_cpu->iowait_boost_pending) @@ -273,7 +272,7 @@ static void sugov_update_single(struct update_util_data *hook, u64 time, sg_cpu->flags |= flags; - sugov_set_iowait_boost(sg_cpu, time, flags); + sugov_set_iowait_boost(sg_cpu, time); sg_cpu->last_update = time; if (!sugov_should_update_freq(sg_policy, time)) @@ -363,7 +362,7 @@ static void sugov_update_shared(struct update_util_data *hook, u64 time, sg_cpu->max = max; sg_cpu->flags |= flags; - sugov_set_iowait_boost(sg_cpu, time, flags); + sugov_set_iowait_boost(sg_cpu, time); sg_cpu->last_update = time; if (sugov_should_update_freq(sg_policy, time)) { From patchwork Wed Dec 13 09:53:23 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 121728 Delivered-To: patch@linaro.org Received: by 10.140.22.227 with SMTP id 90csp5256767qgn; Wed, 13 Dec 2017 01:54:54 -0800 (PST) X-Google-Smtp-Source: ACJfBoubUr4Ynv38ubb/lXC3hTZcYAvEKsZZ3jLuG9749as14NLwICnIUcpGJJKjGL+t/ZYqFofW X-Received: by 10.84.229.5 with SMTP id b5mr5410649plk.405.1513158894633; Wed, 13 Dec 2017 01:54:54 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1513158894; cv=none; d=google.com; s=arc-20160816; b=r8C9fzrxkt5C8Ot6XPqt1UyShw1bhUZ+D8hw+iBRHZCNxD2AYRanl7QOp4m50E+g16 FI1x/dPVdrjMHkwKcupuzBunZwOy88Zze/JhNr3BlJ/urdEiuD40BjSb4/xemTFftiK1 IN5Csc15R8SDmt6j6SZtDu1dnQLxJvQG/WjomeFdbcI8p8xbB1qBgXBEkpS3Of0/WYAA Bt4eI9JS1kv3epCBZaYROPWCf0vMlxGSOC5bLNJFs+w6JE1GzG2vibF2RmNfqpoSJkUm Rdg+ej5g2gOUya7mkicoOSdke51hlDugLEuNlPJ2qQvmXiyxcwK3h1MYxdODQ4fXwSTa fhbg== 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:references :in-reply-to:message-id:date:subject:cc:to:from:dkim-signature :arc-authentication-results; bh=MNyW4kgQ5pnS086d9WcWZVi8B/+mwgi5ZXFkwUOIQH8=; b=V29tD16oT0rQCoSZSp7XoAr3N5O5FvECfoZiVwxPFdrdwIMwkVOvrJm6CzbsWJJQEI AYjyUk14LHZljFTuMJxINcXWplI3dKEOCjq29htexXUMiYTl8s7NIhAur/bT+aZZH0nZ RqQ59ToMbyDWB8akknX8bNE9qBGH/b+EKGleTBc2qy0hTURziKiRBHKXsng2mfJGAmOP gslIJxsuIHJuP7tAX3kwUaIWlGoK0Bc69nfR8gEDh0qbi6pCRl3+JA0Z9dY7L7dp/dhe jJenIyUYwEJdR+dOYc+0mQ30BvQ7Uq4IiccNC9tPBEJ/tIY3skIBuymiJ2j2za5aT1Qo 6m5w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=OIQ8jZtL; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id c20si1140380pfd.107.2017.12.13.01.54.54; Wed, 13 Dec 2017 01:54:54 -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 header.s=google header.b=OIQ8jZtL; 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 S1751479AbdLMJyu (ORCPT + 11 others); Wed, 13 Dec 2017 04:54:50 -0500 Received: from mail-pl0-f66.google.com ([209.85.160.66]:43640 "EHLO mail-pl0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752638AbdLMJxk (ORCPT ); Wed, 13 Dec 2017 04:53:40 -0500 Received: by mail-pl0-f66.google.com with SMTP id z5so697885plo.10 for ; Wed, 13 Dec 2017 01:53: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=MNyW4kgQ5pnS086d9WcWZVi8B/+mwgi5ZXFkwUOIQH8=; b=OIQ8jZtLxlJ3y+daO852rb9fYtmrMFMUyUyOFG9ibWLV8HKeTOG1wPhqiZ7cuIJ3X1 6zSMKf4DdW8mDW3m+NLBSY+WhUB5k0ixlai1dGKHQDepD7CDVey51BVhINJHG+FzvYCm i2I2O5fLgs5SB4eD/j8T1ge/dKqIRiqX/C04k= 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=MNyW4kgQ5pnS086d9WcWZVi8B/+mwgi5ZXFkwUOIQH8=; b=GrrQgUkdqynYCQKOP3dpCQWx8dg1BalJdQ1X3EETyzpDQbTR49EYu51yPMd0+/ByDq 6sVtPWmMS9L0wp6REsA/I7Xqh6vuG1efpw64wYZg9HV9z/UOkFUiKuKNyDBFf5Y1Iql3 PPduwhu02kSZnVWCTc0FtRHNUXuc/2HyawHM86TMqNIIQINrunvzMSLItvdpFF3lCzFE /kGlwhhRxoveyJGKR8fxrHPHjRm5UWUiY9VwRL4cfuYoI7kDF85SE/JF72vPhKmPlmgF VCnVaslZWXURW55PgjGAZFCMbFDZK/BPj52PdpJYi5kvXJBxTs+jtmLhPA9l0EP0EgOg byYA== X-Gm-Message-State: AKGB3mJJRX6QLh1VUaWpVd5jle9eAO2TQnZ6JC41jdtSqNUmak/8rHI2 ucVvsN/ujXZFgYL2L97x3kTaag== X-Received: by 10.159.231.22 with SMTP id w22mr5443147plq.167.1513158819860; Wed, 13 Dec 2017 01:53:39 -0800 (PST) Received: from localhost ([122.172.99.7]) by smtp.gmail.com with ESMTPSA id m9sm2581358pff.3.2017.12.13.01.53.39 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 13 Dec 2017 01:53:39 -0800 (PST) From: Viresh Kumar To: Rafael Wysocki , Ingo Molnar , Peter Zijlstra Cc: Viresh Kumar , linux-pm@vger.kernel.org, Vincent Guittot , dietmar.eggemann@arm.com, morten.rasmussen@arm.com, juri.lelli@redhat.com, tkjos@android.com, joelaf@google.com, linux-kernel@vger.kernel.org Subject: [PATCH 4/4] cpufreq: schedutil: Don't call sugov_get_util() unnecessarily Date: Wed, 13 Dec 2017 15:23:23 +0530 Message-Id: <7b0698a61bcb959704f58dbabe8c70d657210301.1513158452.git.viresh.kumar@linaro.org> X-Mailer: git-send-email 2.15.0.194.g9af6a3dea062 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 sugov_update_shared() may get called to clear the scheduling class flags and we would return immediately in that case. Calling sugov_get_util() in that case isn't going to be of any use then. Move invocation of sugov_get_util() after the clear flag is checked. Signed-off-by: Viresh Kumar --- kernel/sched/cpufreq_schedutil.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) -- 2.15.0.194.g9af6a3dea062 Reviewed-by: Joel Fernandes diff --git a/kernel/sched/cpufreq_schedutil.c b/kernel/sched/cpufreq_schedutil.c index 7edfdc59ee8f..b69c37c867fe 100644 --- a/kernel/sched/cpufreq_schedutil.c +++ b/kernel/sched/cpufreq_schedutil.c @@ -349,8 +349,6 @@ static void sugov_update_shared(struct update_util_data *hook, u64 time, unsigned long util, max; unsigned int next_f; - sugov_get_util(&util, &max, sg_cpu->cpu); - raw_spin_lock(&sg_policy->update_lock); if (unlikely(flags & SCHED_CPUFREQ_CLEAR)) { @@ -358,6 +356,8 @@ static void sugov_update_shared(struct update_util_data *hook, u64 time, goto unlock; } + sugov_get_util(&util, &max, sg_cpu->cpu); + sg_cpu->util = util; sg_cpu->max = max; sg_cpu->flags |= flags;