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: 148116 Delivered-To: patch@linaro.org Received: by 2002:a2e:8595:0:0:0:0:0 with SMTP id b21-v6csp863919lji; Thu, 4 Oct 2018 05:04:16 -0700 (PDT) X-Google-Smtp-Source: ACcGV6069oiz/lO3AG2jmmAcYToJdj7NpfPtMREAh2MMk3M30Eh/fCANwW3bedxsypJMXJS/P4jN X-Received: by 2002:a17:902:6b45:: with SMTP id g5-v6mr6251083plt.41.1538654655880; Thu, 04 Oct 2018 05:04:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1538654655; cv=none; d=google.com; s=arc-20160816; b=lzA51c0KlJiwolM0Gd5Ifu30/yv9GOFYEGmGLY2nWB5vr7cPN7jb5EIOrIUa69xA+g AymFoKkj1vNvIL5nvYN+kYPnAHBVGzbjo2Q3aEriFKyw9isKgBzgmh5yeLdDCqmy21BY LEZi5y5QKbFOEbk+9rQQauIFDKKSMFjrKoOvjxrDHfZTtnAsRwDwX+sSzPccgWsWDky8 kJb52vPU6yksV21dozR2EOJTeqybkVrdbw1UAa9DThSVj9BuY9QtvhS5+SHPamR3y8l4 5ymZUSBLsSgibBSpP3KOhblIF9jlXnM4Z5ajk3IZb34si/ne4pguzE1zxKdaJhrAwNY5 ycbQ== 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; bh=x4J7xQAH031mjKHecE55aBySuA5+RK8ZxvbBGd/a5Lg=; b=u+VQ73i4Kymu7UlMlb4adiAYeXmJSP2aBKTRvZIdmq//vpMdJCwBuKni/13mhG90An ZgOkkI4jvQPqpCm6wFhTfvMzEP6iEMjANaOaASanXqCzo5jkhmP6YaaXqn+/pgvSVamZ so2jUzhjLybVQL+PaASFIqXJ7WRBNtPt4EkpquZmuBPJMWOKta3+S4Jpa6ATPYGkz/Lh 7ibsKXTYC6BwzLj1gQvaz94Rmqb0yy6EhSwvIrwZYXhsrSKL5U/TgQCYCFCOLvOxBbOS PYvQqVjLze/d+lPR9Ws0eMWKpVF+5Sbjk7VmnNOPwti4Cd1VwkGjQkaVLDQi+laP8tyO 3ZVg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=kXKUDqF1; 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 q27-v6si5127316pfd.285.2018.10.04.05.04.15; Thu, 04 Oct 2018 05:04:15 -0700 (PDT) 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=kXKUDqF1; 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 S1727370AbeJDS5M (ORCPT + 10 others); 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-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 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 --- kernel/sched/core.c | 41 ++++++++++++++++++++--------------------- 1 file changed, 20 insertions(+), 21 deletions(-) -- 2.7.4 Acked-by: Mel Gorman Reviewed-by: Rafael J. Wysocki Acked-by: Peter Zijlstra (Intel) Acked-by: Peter Zijlstra (Intel) 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 /*