From patchwork Mon Aug 1 18:53:35 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dietmar Eggemann X-Patchwork-Id: 73132 Delivered-To: patch@linaro.org Received: by 10.140.29.52 with SMTP id a49csp2862283qga; Mon, 1 Aug 2016 12:30:52 -0700 (PDT) X-Received: by 10.66.123.105 with SMTP id lz9mr59066162pab.56.1470079851757; Mon, 01 Aug 2016 12:30:51 -0700 (PDT) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id lk5si36377129pab.204.2016.08.01.12.30.51; Mon, 01 Aug 2016 12:30:51 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754899AbcHATao (ORCPT + 27 others); Mon, 1 Aug 2016 15:30:44 -0400 Received: from foss.arm.com ([217.140.101.70]:35486 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754860AbcHATab (ORCPT ); Mon, 1 Aug 2016 15:30:31 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 0FEC628; Mon, 1 Aug 2016 11:54:59 -0700 (PDT) Received: from [10.1.210.41] (e107985-lin.cambridge.arm.com [10.1.210.41]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id CCC7F3F213; Mon, 1 Aug 2016 11:53:36 -0700 (PDT) Subject: Re: [PATCH v3 08/13] sched: Store maximum per-cpu capacity in root domain To: Morten Rasmussen , peterz@infradead.org, mingo@redhat.com References: <1469453670-2660-1-git-send-email-morten.rasmussen@arm.com> <1469453670-2660-9-git-send-email-morten.rasmussen@arm.com> Cc: yuyang.du@intel.com, vincent.guittot@linaro.org, mgalbraith@suse.de, sgurrappadi@nvidia.com, freedom.tan@mediatek.com, keita.kobayashi.ym@renesas.com, linux-kernel@vger.kernel.org From: Dietmar Eggemann Message-ID: <26c69258-9947-f830-a53e-0c54e7750646@arm.com> Date: Mon, 1 Aug 2016 19:53:35 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.2.0 MIME-Version: 1.0 In-Reply-To: <1469453670-2660-9-git-send-email-morten.rasmussen@arm.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 25/07/16 14:34, Morten Rasmussen wrote: [...] > @@ -6923,11 +6924,22 @@ static int build_sched_domains(const struct cpumask *cpu_map, > /* Attach the domains */ > rcu_read_lock(); > for_each_cpu(i, cpu_map) { > + rq = cpu_rq(i); > sd = *per_cpu_ptr(d.sd, i); > + > + /* Use READ_ONCE/WRITE_ONCE to avoid load/store tearing */ > + if (rq->cpu_capacity_orig > READ_ONCE(rq->rd->max_cpu_capacity)) > + WRITE_ONCE(rq->rd->max_cpu_capacity, rq->cpu_capacity_orig); We have to use d.rd rather rq->rd here since from v3 on we have this if condition in front of the cpu_attach_domain() call which replaces rq->rd with d.rd. Fixed patch below. > + > cpu_attach_domain(sd, d.rd, i); > } > rcu_read_unlock(); > > + if (rq) { > + pr_info("span: %*pbl (max cpu_capacity = %lu)\n", > + cpumask_pr_args(cpu_map), rq->rd->max_cpu_capacity); > + } > + > ret = 0; > error: > __free_domain_allocs(&d, alloc_state, cpu_map); [...] -- >8 -- From: Dietmar Eggemann To be able to compare the capacity of the target cpu with the highest available cpu capacity, store the maximum per-cpu capacity in the root domain. The max per-cpu capacity should be 1024 for all systems except SMT, where the capacity is currently based on smt_gain and the number of hardware threads and is <1024. If SMT can be brought to work with a per-thread capacity of 1024, this patch can be dropped and replaced by a hard-coded max capacity of 1024 (=SCHED_CAPACITY_SCALE). cc: Ingo Molnar cc: Peter Zijlstra Signed-off-by: Dietmar Eggemann Signed-off-by: Morten Rasmussen --- kernel/sched/core.c | 12 ++++++++++++ kernel/sched/sched.h | 2 ++ 2 files changed, 14 insertions(+) -- 1.9.1 diff --git a/kernel/sched/core.c b/kernel/sched/core.c index a0a74b2d9f41..db03e6226d54 100644 --- a/kernel/sched/core.c +++ b/kernel/sched/core.c @@ -6873,6 +6873,7 @@ static int build_sched_domains(const struct cpumask *cpu_map, enum s_alloc alloc_state; struct sched_domain *sd; struct s_data d; + struct rq *rq = NULL; int i, ret = -ENOMEM; alloc_state = __visit_domain_allocation_hell(&d, cpu_map); @@ -6923,11 +6924,22 @@ static int build_sched_domains(const struct cpumask *cpu_map, /* Attach the domains */ rcu_read_lock(); for_each_cpu(i, cpu_map) { + rq = cpu_rq(i); sd = *per_cpu_ptr(d.sd, i); + + /* Use READ_ONCE/WRITE_ONCE to avoid load/store tearing */ + if (rq->cpu_capacity_orig > READ_ONCE(d.rd->max_cpu_capacity)) + WRITE_ONCE(d.rd->max_cpu_capacity, rq->cpu_capacity_orig); + cpu_attach_domain(sd, d.rd, i); } rcu_read_unlock(); + if (rq) { + pr_info("span: %*pbl (max cpu_capacity = %lu)\n", + cpumask_pr_args(cpu_map), rq->rd->max_cpu_capacity); + } + ret = 0; error: __free_domain_allocs(&d, alloc_state, cpu_map); diff --git a/kernel/sched/sched.h b/kernel/sched/sched.h index f44da95c70cd..444d8f38743f 100644 --- a/kernel/sched/sched.h +++ b/kernel/sched/sched.h @@ -565,6 +565,8 @@ struct root_domain { */ cpumask_var_t rto_mask; struct cpupri cpupri; + + unsigned long max_cpu_capacity; }; extern struct root_domain def_root_domain;