Received: by 2002:a25:6193:0:0:0:0:0 with SMTP id v141csp445047ybb; Wed, 8 Apr 2020 03:07:47 -0700 (PDT) X-Google-Smtp-Source: APiQypLWnLfVR1V51icqLhqxZJgAaG7cyeT2kLgiWXkZ4PSM8i3r7Ir5y07f842ox8EOMRYyId2O X-Received: by 2002:a9d:2963:: with SMTP id d90mr4775412otb.149.1586340467290; Wed, 08 Apr 2020 03:07:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1586340467; cv=none; d=google.com; s=arc-20160816; b=SjoG469GuAJbTmpNWrEptqMm+NCQFvTdu/90U0+rbKfyTD/E+QrO7LmiPnO/xIeur+ ERvfv/e9EJ8AZohIjTQ5l4jefIdRvscgO0/4D46xWw3SjrYcMql+1e61sET5XynPr0k7 gt166rJr9cFh/dsO795pPRHU3GP13PnZB5g1dPcbHxDJfsPhUcF135F+q7fcvU/wrFW9 rLHdBsuKubWPTvuweZVm8i4FGT3v7f2YZjlprT+vqBeswuCNRkk628IGdsgMIwXsQhaZ 2bi0kkhiaEbhitKe1YeXFuP86wNyP0pZ41dx7Xd39Qw1FskzR9RqVtS+nd1kmeIo6vyT uNfg== 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:message-id:date :subject:cc:to:from; bh=cbg6HVglPRPKsQ6o+BWt+eEbsP5b2/RXMXvTZCpjXU4=; b=ZO/x9PHpYwVXxj7CwlMF970/huuYtZPxxPiWVXfQU6GvDvPFnL5iJE3ef7Tj9WaaEj G3ElXRl9edQgOAj5rQ66tBLBEBGSm5bmlS/42LZeFhGErsFbbyCaKRRZG0SoDwVyroTd HT/i1/NoTyif04AtmxTAJXsldpg+xQaFbwTCygfehYFYuNqCWqjYCzaW3Vba017FdmKb la8MILjfcvHlCZMUlkzL0z74SejjbUAeN2VfeGz+l3bsJ5oLcn2+GDRV0DHIEu+MVpdd 1fG1BlEfkxwW7hB8Qo2Fnrzvp4dxox+QhdixOx+k5+9GRdbEjfnWVTws5gDlNkPEN8UZ Vvrg== ARC-Authentication-Results: i=1; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id e26si2398619otq.50.2020.04.08.03.07.33; Wed, 08 Apr 2020 03:07:47 -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 S1727958AbgDHJu3 (ORCPT + 99 others); Wed, 8 Apr 2020 05:50:29 -0400 Received: from foss.arm.com ([217.140.110.172]:36290 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725932AbgDHJu2 (ORCPT ); Wed, 8 Apr 2020 05:50:28 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 9CAF41045; Wed, 8 Apr 2020 02:50:28 -0700 (PDT) Received: from macbook.arm.com (unknown [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id BDDEA3F73D; Wed, 8 Apr 2020 02:50:25 -0700 (PDT) From: Dietmar Eggemann To: Ingo Molnar , Peter Zijlstra , Juri Lelli Cc: Vincent Guittot , Steven Rostedt , Luca Abeni , Daniel Bristot de Oliveira , Wei Wang , Quentin Perret , Alessio Balsini , Pavan Kondeti , Patrick Bellasi , Morten Rasmussen , Valentin Schneider , Qais Yousef , linux-kernel@vger.kernel.org Subject: [PATCH 1/4] sched/topology: Store root domain CPU capacity sum Date: Wed, 8 Apr 2020 11:50:09 +0200 Message-Id: <20200408095012.3819-2-dietmar.eggemann@arm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200408095012.3819-1-dietmar.eggemann@arm.com> References: <20200408095012.3819-1-dietmar.eggemann@arm.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Add the sum of (original) CPU capacity of all member CPUs to the root domain. This is needed for capacity-aware SCHED_DEADLINE admission control. Signed-off-by: Dietmar Eggemann --- kernel/sched/sched.h | 11 +++++++++++ kernel/sched/topology.c | 14 ++++++++++---- 2 files changed, 21 insertions(+), 4 deletions(-) diff --git a/kernel/sched/sched.h b/kernel/sched/sched.h index 1e72d1b3d3ce..91bd0cb0c529 100644 --- a/kernel/sched/sched.h +++ b/kernel/sched/sched.h @@ -797,6 +797,7 @@ struct root_domain { cpumask_var_t rto_mask; struct cpupri cpupri; + unsigned long sum_cpu_capacity; unsigned long max_cpu_capacity; /* @@ -2393,6 +2394,16 @@ static inline unsigned long capacity_orig_of(int cpu) { return cpu_rq(cpu)->cpu_capacity_orig; } + +static inline unsigned long rd_capacity(int cpu) +{ + return cpu_rq(cpu)->rd->sum_cpu_capacity; +} +#else +static inline unsigned long rd_capacity(int cpu) +{ + return SCHED_CAPACITY_SCALE; +} #endif /** diff --git a/kernel/sched/topology.c b/kernel/sched/topology.c index 8344757bba6e..74b0c0fa4b1b 100644 --- a/kernel/sched/topology.c +++ b/kernel/sched/topology.c @@ -2052,12 +2052,17 @@ build_sched_domains(const struct cpumask *cpu_map, struct sched_domain_attr *att /* Attach the domains */ rcu_read_lock(); for_each_cpu(i, cpu_map) { + unsigned long cap = arch_scale_cpu_capacity(i); + 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); + if (cap > READ_ONCE(d.rd->max_cpu_capacity)) + WRITE_ONCE(d.rd->max_cpu_capacity, cap); + + WRITE_ONCE(d.rd->sum_cpu_capacity, + READ_ONCE(d.rd->sum_cpu_capacity) + cap); cpu_attach_domain(sd, d.rd, i); } @@ -2067,8 +2072,9 @@ build_sched_domains(const struct cpumask *cpu_map, struct sched_domain_attr *att static_branch_inc_cpuslocked(&sched_asym_cpucapacity); if (rq && sched_debug_enabled) { - pr_info("root domain span: %*pbl (max cpu_capacity = %lu)\n", - cpumask_pr_args(cpu_map), rq->rd->max_cpu_capacity); + pr_info("root domain span: %*pbl (capacity = %lu max cpu_capacity = %lu)\n", + cpumask_pr_args(cpu_map), rq->rd->sum_cpu_capacity, + rq->rd->max_cpu_capacity); } ret = 0; -- 2.17.1