From patchwork Thu Oct 4 12:04:02 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Lezcano X-Patchwork-Id: 10626045 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-2.web.codeaurora.org (Postfix) with ESMTP id 695E615A6 for ; Thu, 4 Oct 2018 12:04:16 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5AE6728F5D for ; Thu, 4 Oct 2018 12:04:16 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4F59428F5A; Thu, 4 Oct 2018 12:04: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=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,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 DFAD028F56 for ; Thu, 4 Oct 2018 12:04:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727370AbeJDS5M (ORCPT ); Thu, 4 Oct 2018 14:57:12 -0400 Received: from mail-wm1-f65.google.com ([209.85.128.65]:36796 "EHLO mail-wm1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727322AbeJDS5M (ORCPT ); Thu, 4 Oct 2018 14:57:12 -0400 Received: by mail-wm1-f65.google.com with SMTP id a8-v6so4753578wmf.1 for ; Thu, 04 Oct 2018 05:04:13 -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=x4J7xQAH031mjKHecE55aBySuA5+RK8ZxvbBGd/a5Lg=; b=kXKUDqF1MBWFEBNw+mIUqUAZqpJ+WENtc/vqic+3IR/vuAtf6dwWz7RkrBN8axWJYu 223pXr+fxONGIiXE1sDrqKq2MbbqOyIBcdmvagLOetrW2eGvqULHxh67bqL+hJ9vg8// 74xOxLT2bVn8O34hKuVgMtV7ylDsUymiLvCTA= 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=x4J7xQAH031mjKHecE55aBySuA5+RK8ZxvbBGd/a5Lg=; b=V0cksImV+G7UHYEnrwXANnXQF+RT5oOk/O2Czp4e4iQQ9XGzOn2N7dDqM2bfU2sJuX bkcZyuKBPEm9DhPkFde+PVln3j4zBBo497HFpJ9vdqYYGC6c+7XIeWfCZwUJj8nVOMrq yOgz+TsNybRF94vj/NTcV7n/q3Z/ajlwfUB8l8trAjHxtID4hXBEpcpKT6oLZKa2Idl5 CZUQvIz2vjdjrDjy9Qh16ZlqkIQ4VwgLnD2mgfpYucVn63UlkRkycNdrnoNYwl04wybl legnrV44m/q92OJrQXM82tGxBY8HhPw0C84Atky3BlcnX7fkgDxXHmYnjklAPc+46lfS Jl/g== X-Gm-Message-State: ABuFfoiOoS8QtLKH68+WhEr99UXQsWFJDD1VgDgtU0ree0Pn4h2G3Ig/ R8KgjWyEEKr8IX4GuR36Jm9jUg== X-Google-Smtp-Source: ACcGV61ckI2zNfd7HPWQOnopKq3Iq1VLlicRHcBYh2ZvqhPMjrvX/N29TK/OdpHhdCyQeGZyWmYYsw== X-Received: by 2002:a1c:c784:: with SMTP id x126-v6mr4757189wmf.90.1538654652811; Thu, 04 Oct 2018 05:04:12 -0700 (PDT) Received: from localhost.localdomain (101.142.88.92.rev.sfr.net. [92.88.142.101]) by smtp.gmail.com with ESMTPSA id p11-v6sm4477132wrd.74.2018.10.04.05.04.11 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 04 Oct 2018 05:04:12 -0700 (PDT) From: Daniel Lezcano To: rafael@kernel.org Cc: rjw@rjwysocki.net, linux-pm@vger.kernel.org, Ingo Molnar , Peter Zijlstra , linux-kernel@vger.kernel.org (open list:SCHEDULER) Subject: [PATCH V2 1/2] sched: Factor out nr_iowait and nr_iowait_cpu Date: Thu, 4 Oct 2018 14:04:02 +0200 Message-Id: <1538654644-32705-1-git-send-email-daniel.lezcano@linaro.org> X-Mailer: git-send-email 2.7.4 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 The function nr_iowait_cpu() can be used directly by nr_iowait() instead of duplicating code. Call nr_iowait_cpu() from nr_iowait() Reviewed-by: Rafael J. Wysocki Signed-off-by: Daniel Lezcano Acked-by: Peter Zijlstra (Intel) --- kernel/sched/core.c | 41 ++++++++++++++++++++--------------------- 1 file changed, 20 insertions(+), 21 deletions(-) diff --git a/kernel/sched/core.c b/kernel/sched/core.c index 625bc98..43efb74 100644 --- a/kernel/sched/core.c +++ b/kernel/sched/core.c @@ -2875,6 +2875,25 @@ unsigned long long nr_context_switches(void) } /* + * Consumers of these two interfaces, like for example the cpufreq menu + * governor are using nonsensical data. Boosting frequency for a CPU that has + * IO-wait which might not even end up running the task when it does become + * runnable. + */ + +unsigned long nr_iowait_cpu(int cpu) +{ + return atomic_read(&cpu_rq(cpu)->nr_iowait); +} + +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; +} + +/* * IO-wait accounting, and how its mostly bollocks (on SMP). * * The idea behind IO-wait account is to account the idle time that we could @@ -2909,31 +2928,11 @@ unsigned long nr_iowait(void) unsigned long i, sum = 0; for_each_possible_cpu(i) - sum += atomic_read(&cpu_rq(i)->nr_iowait); + sum += nr_iowait_cpu(i); return sum; } -/* - * Consumers of these two interfaces, like for example the cpufreq menu - * governor are using nonsensical data. Boosting frequency for a CPU that has - * IO-wait which might not even end up running the task when it does become - * runnable. - */ - -unsigned long nr_iowait_cpu(int cpu) -{ - struct rq *this = cpu_rq(cpu); - return atomic_read(&this->nr_iowait); -} - -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; -} - #ifdef CONFIG_SMP /*