From patchwork Fri Sep 23 21:49:47 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sai X-Patchwork-Id: 9348933 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 9FE45607D0 for ; Fri, 23 Sep 2016 21:54:16 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 90A282AE55 for ; Fri, 23 Sep 2016 21:54:16 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8501E2AE57; Fri, 23 Sep 2016 21:54:16 +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.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI 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 CFE512AE55 for ; Fri, 23 Sep 2016 21:54:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S935087AbcIWVyO (ORCPT ); Fri, 23 Sep 2016 17:54:14 -0400 Received: from hqemgate15.nvidia.com ([216.228.121.64]:11927 "EHLO hqemgate15.nvidia.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S934834AbcIWVyO (ORCPT ); Fri, 23 Sep 2016 17:54:14 -0400 Received: from hqnvupgp08.nvidia.com (Not Verified[216.228.121.13]) by hqemgate15.nvidia.com id ; Fri, 23 Sep 2016 14:54:12 -0700 Received: from HQMAIL101.nvidia.com ([172.20.12.94]) by hqnvupgp08.nvidia.com (PGP Universal service); Fri, 23 Sep 2016 14:48:25 -0700 X-PGP-Universal: processed; by hqnvupgp08.nvidia.com on Fri, 23 Sep 2016 14:48:25 -0700 Received: from [172.17.187.121] (172.17.187.121) by HQMAIL101.nvidia.com (172.20.187.10) with Microsoft SMTP Server (TLS) id 15.0.1210.3; Fri, 23 Sep 2016 21:53:38 +0000 Message-ID: <57E5A37B.8010802@nvidia.com> Date: Fri, 23 Sep 2016 14:49:47 -0700 From: Sai Gurrappadi User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.7.0 MIME-Version: 1.0 To: "rafael.j.wysocki@intel.com" CC: Peter Boonstoppel , Peter Zijlstra , Colin Cross , Arjan van de Ven , Subject: [RFC] sched/core: Fix up load metric exposed to cpuidle X-NVConfidentiality: public X-Originating-IP: [172.17.187.121] X-ClientProxiedBy: HQMAIL106.nvidia.com (172.18.146.12) To HQMAIL101.nvidia.com (172.20.187.10) 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 When triaging a performance degradation of ~5% on some use cases between our k3.18 and k4.4 trees, we found that the menu cpuidle governor on k4.4 was way more aggressive when requesting for deeper idle states. It would often get it wrong though resulting in perf loss. The menu governor tries to bias picking shallower idle states based on the historical load on the CPU. The busier the CPU, the shallower the idle state. However, after commit "3289bdb sched: Move the loadavg code to a more obvious location", the load metric it looks at is rq->load.weight which is the instantaneous se->load.weight sum for top level entities on the rq which on idle entry is always 0 (for the common case at least) because there is nothing on the cfs rq. The previous metric the menu governor used was rq->cpu_load[0] which is a snap shot of the weighted_cpuload at the previous load update point so it isn't always 0 on idle entry. Unfortunately, it isn't straightforward to switch the metric being used to rq->cfs.load_avg or rq->cfs.util_avg because they overestimate the load a lot more than rq->cpu_load[0] (include blocked task contrib.). That would potentially require redoing the magic constants in the menu governor's performance_multiplier...so for now, use rq->cpu_load[0] instead to preserve old behaviour. Reported-by: Juha Lainema Signed-off-by: Sai Gurrappadi --- * I realize this might not be the best thing to do hence the RFC tag. Thoughts? kernel/sched/core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kernel/sched/core.c b/kernel/sched/core.c index 44817c6..d1aea12 100644 --- a/kernel/sched/core.c +++ b/kernel/sched/core.c @@ -2955,7 +2955,7 @@ void get_iowait_load(unsigned long *nr_waiters, unsigned long *load) { struct rq *rq = this_rq(); *nr_waiters = atomic_read(&rq->nr_iowait); - *load = rq->load.weight; + *load = rq->cpu_load[0]; } #ifdef CONFIG_SMP