From patchwork Wed May 24 05:29:54 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 100412 Delivered-To: patch@linaro.org Received: by 10.140.96.100 with SMTP id j91csp115397qge; Tue, 23 May 2017 22:30:57 -0700 (PDT) X-Received: by 10.99.97.68 with SMTP id v65mr36622350pgb.76.1495603857050; Tue, 23 May 2017 22:30:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1495603857; cv=none; d=google.com; s=arc-20160816; b=eTTQJIGkhndXj9FZeJyXGn0mFDSY+0rI0EnTrlEEl6WhG7N6GjZbSQxDDnY4wPn1Wo 8TAykYVlx15fKLNRy/y56B45F2CRnMGW6ctUI8P0uyiIVlw+6TwkaK5Ww+p73QspYCS1 +2CLpZhNRXheTha8+v5xUNvTZ8n4Evc1LolTXMbdyAo9Inl2E+45gAoIGb66/NatFpoO t12vjZOK453Blkwiwof9K0KXyBm3NbtUQ7DTsZl6J0k5w0Alfw7/XuHsW1W/TZYhh86G wYdlVObdtn/agvVr2/ngWpr8ZGBMCHgPYxIorGf8yMA+DMKa2aRhKz5ooNydmuVKAbsL j58g== 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=HJ6JH1I3dFqsa2dVOTAavMho2xFcyaeh7tg/FXhFaeM=; b=Sb8vC/mMEJwPpKoUVY5vFaNkriQ8rn3ZXLP7jIi4QC5Lwu3KHxQudbJS3Ahi1UKhZu r1CURausPY8jK8ZTfHzB3dIZMKvT4dW6ldC8pp/WXSLTEuJy2WFys+SPWDD3e8jqcJIM JdfXPbx/BLvZ+f7BXMpuYAL1iOhrk2Ra6EpvekXZq8tNW1u5mirOktkQA791ZRf67cI0 Ek44F5Zb+g5PCYmx/48IPGoejx0MsesUPPWPuN9TjRxaNPqs5rtIEdZjt67rW6YojjgW NXaEYpmPNwKru3mKiqk9nzxAwSp6CSayOKis1KEP15KSOZbU6D9plNwTsF3LEXYTQv/8 26Ow== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-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 b68si22954419pfk.341.2017.05.23.22.30.56; Tue, 23 May 2017 22:30:57 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-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 linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-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 S969210AbdEXFat (ORCPT + 25 others); Wed, 24 May 2017 01:30:49 -0400 Received: from mail-pf0-f177.google.com ([209.85.192.177]:34147 "EHLO mail-pf0-f177.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S966192AbdEXFag (ORCPT ); Wed, 24 May 2017 01:30:36 -0400 Received: by mail-pf0-f177.google.com with SMTP id 9so133523660pfj.1 for ; Tue, 23 May 2017 22:30:35 -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 :in-reply-to:references; bh=HJ6JH1I3dFqsa2dVOTAavMho2xFcyaeh7tg/FXhFaeM=; b=BFfRWE1AozJKcNds+a/iGOVXGkd5wG3SllbzUai5EM1VEMjp8JkKK0Od5T2Q5iY+S+ fpDEQGtHDxR8Qbp5eVpRB5muVsEOh70lI9ZTukwTzeKgBGDPM19BnirkSESccDOpCLZ9 I+EvR4WtP4DBsSohJ3AVePveUxkCoWwR/moIk= 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=HJ6JH1I3dFqsa2dVOTAavMho2xFcyaeh7tg/FXhFaeM=; b=CBvuNVnIUT9bEThMEsKcwTVBM/3FUapGh/fXE71Knzo8K7OnBae5dHv+keUOLW5LXe rCMtri8nX0I+kBb1k/epGjqJGC348OJ533vhA61Dv3Lb23M1QoAyMy03yYARKiS5Dx+w aL+XlJ1h9Ul0I3x2NSfUm9KpBVySe5I9tfWXVaK8J7ZZ5dAIvMf6nl8FkagEEtlVu7b3 GbA8+dCCZGSZM/1u35alsyQstK+oe85d/k9K2Br4qYbQkXNElU1evwR9wfZ2Fu6O1Pfb QRIq/PqhqjObmr/SXase1ds36s082Ao2XZpGLCaATF9HfnmiycAK0qSmObjxguWbQqnL Ifyg== X-Gm-Message-State: AODbwcD2ybdadcxjT0Bvfi17+lre/m1u/CW2OVopC0lbT8K6a8SjjvBr eKTImIcBD5tyFPn8CKvWNQ== X-Received: by 10.98.153.4 with SMTP id d4mr19035307pfe.223.1495603830149; Tue, 23 May 2017 22:30:30 -0700 (PDT) Received: from localhost ([122.167.143.58]) by smtp.gmail.com with ESMTPSA id o10sm4096720pge.67.2017.05.23.22.30.29 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 23 May 2017 22:30:29 -0700 (PDT) From: Viresh Kumar To: Ingo Molnar , Peter Zijlstra Cc: Viresh Kumar , linaro-kernel@lists.linaro.org, linux-kernel@vger.kernel.org, Vincent Guittot Subject: [PATCH 3/6] sched: fair: Pass rq to weighted_cpuload() Date: Wed, 24 May 2017 10:59:54 +0530 Message-Id: X-Mailer: git-send-email 2.13.0.70.g6367777092d9 In-Reply-To: References: In-Reply-To: References: Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org weighted_cpuload() uses the cpu number passed to it get pointer to the runqueue. Almost all callers of weighted_cpuload() already have the rq pointer with them and can send that directly to weighted_cpuload(). In some cases the callers actually get the CPU number by doing cpu_of(rq). It would be simpler to pass rq to weighted_cpuload(). Signed-off-by: Viresh Kumar --- kernel/sched/fair.c | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) -- 2.13.0.70.g6367777092d9 diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c index a0a97497c400..fe03efd3880a 100644 --- a/kernel/sched/fair.c +++ b/kernel/sched/fair.c @@ -1378,7 +1378,7 @@ bool should_numa_migrate_memory(struct task_struct *p, struct page * page, group_faults_cpu(ng, src_nid) * group_faults(p, dst_nid) * 4; } -static unsigned long weighted_cpuload(const int cpu); +static unsigned long weighted_cpuload(struct rq *rq); static unsigned long source_load(int cpu, int type); static unsigned long target_load(int cpu, int type); static unsigned long capacity_of(int cpu); @@ -1410,7 +1410,7 @@ static void update_numa_stats(struct numa_stats *ns, int nid) struct rq *rq = cpu_rq(cpu); ns->nr_running += rq->nr_running; - ns->load += weighted_cpuload(cpu); + ns->load += weighted_cpuload(rq); ns->compute_capacity += capacity_of(cpu); cpus++; @@ -5064,9 +5064,9 @@ static void cpu_load_update(struct rq *this_rq, unsigned long this_load, } /* Used instead of source_load when we know the type == 0 */ -static unsigned long weighted_cpuload(const int cpu) +static unsigned long weighted_cpuload(struct rq *rq) { - return cfs_rq_runnable_load_avg(&cpu_rq(cpu)->cfs); + return cfs_rq_runnable_load_avg(&rq->cfs); } #ifdef CONFIG_NO_HZ_COMMON @@ -5111,7 +5111,7 @@ static void cpu_load_update_idle(struct rq *this_rq) /* * bail if there's load or we're actually up-to-date. */ - if (weighted_cpuload(cpu_of(this_rq))) + if (weighted_cpuload(this_rq)) return; cpu_load_update_nohz(this_rq, READ_ONCE(jiffies), 0); @@ -5132,7 +5132,7 @@ void cpu_load_update_nohz_start(void) * concurrently we'll exit nohz. And cpu_load write can race with * cpu_load_update_idle() but both updater would be writing the same. */ - this_rq->cpu_load[0] = weighted_cpuload(cpu_of(this_rq)); + this_rq->cpu_load[0] = weighted_cpuload(this_rq); } /* @@ -5148,7 +5148,7 @@ void cpu_load_update_nohz_stop(void) if (curr_jiffies == this_rq->last_load_update_tick) return; - load = weighted_cpuload(cpu_of(this_rq)); + load = weighted_cpuload(this_rq); rq_lock(this_rq, &rf); update_rq_clock(this_rq); cpu_load_update_nohz(this_rq, curr_jiffies, load); @@ -5174,7 +5174,7 @@ static void cpu_load_update_periodic(struct rq *this_rq, unsigned long load) */ void cpu_load_update_active(struct rq *this_rq) { - unsigned long load = weighted_cpuload(cpu_of(this_rq)); + unsigned long load = weighted_cpuload(this_rq); if (tick_nohz_tick_stopped()) cpu_load_update_nohz(this_rq, READ_ONCE(jiffies), load); @@ -5192,7 +5192,7 @@ void cpu_load_update_active(struct rq *this_rq) static unsigned long source_load(int cpu, int type) { struct rq *rq = cpu_rq(cpu); - unsigned long total = weighted_cpuload(cpu); + unsigned long total = weighted_cpuload(rq); if (type == 0 || !sched_feat(LB_BIAS)) return total; @@ -5207,7 +5207,7 @@ static unsigned long source_load(int cpu, int type) static unsigned long target_load(int cpu, int type) { struct rq *rq = cpu_rq(cpu); - unsigned long total = weighted_cpuload(cpu); + unsigned long total = weighted_cpuload(rq); if (type == 0 || !sched_feat(LB_BIAS)) return total; @@ -5229,7 +5229,7 @@ static unsigned long cpu_avg_load_per_task(int cpu) { struct rq *rq = cpu_rq(cpu); unsigned long nr_running = READ_ONCE(rq->cfs.h_nr_running); - unsigned long load_avg = weighted_cpuload(cpu); + unsigned long load_avg = weighted_cpuload(rq); if (nr_running) return load_avg / nr_running; @@ -5651,7 +5651,7 @@ find_idlest_cpu(struct sched_group *group, struct task_struct *p, int this_cpu) shallowest_idle_cpu = i; } } else if (shallowest_idle_cpu == -1) { - load = weighted_cpuload(i); + load = weighted_cpuload(cpu_rq(i)); if (load < min_load || (load == min_load && i == this_cpu)) { min_load = load; least_loaded_cpu = i; @@ -7439,7 +7439,7 @@ static inline void update_sg_lb_stats(struct lb_env *env, sgs->nr_numa_running += rq->nr_numa_running; sgs->nr_preferred_running += rq->nr_preferred_running; #endif - sgs->sum_weighted_load += weighted_cpuload(i); + sgs->sum_weighted_load += weighted_cpuload(rq); /* * No need to call idle_cpu() if nr_running is not 0 */ @@ -7968,7 +7968,7 @@ static struct rq *find_busiest_queue(struct lb_env *env, capacity = capacity_of(i); - wl = weighted_cpuload(i); + wl = weighted_cpuload(rq); /* * When comparing with imbalance, use weighted_cpuload()