Received: by 2002:a25:868d:0:0:0:0:0 with SMTP id z13csp566892ybk; Wed, 20 May 2020 06:45:14 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy4srnRMs3Incs46k5UxHM3MgY1ZDREyaVKKcuGccknkmTZKuumD3a+FAS8D1N4f7NN8Ew0 X-Received: by 2002:a50:a9c4:: with SMTP id n62mr3292710edc.347.1589982314004; Wed, 20 May 2020 06:45:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1589982313; cv=none; d=google.com; s=arc-20160816; b=MFimtX3757ajZUD0aVy6vTSyGYa79CuLkJNT+/HZnqsrZxCDbLd9yusUmhb6hCDduI atdLwIFuuIGrmbofLMxrjR2753i5u5OA0ELgQAHXxndOlwigQCtm13aWGH5DnfwkY4os wJ38rjXPKzthkBe78jmwkaL73KepV/Faai3WGa13AabuZT5Z5iyIyB4c2o4JM8PXzYTU /rDaAo1a9OUAB8A1abXAwS5X9Ik3gTQAxOAKpj79tXggHDNpfA8VWLvUDooT6TBOkOiC pzTLoGbcMC1Qiutla5lPZDVvbwU1fPEpNCqCUfQAn9v970xXn5PwnMGEAO5Byy4H6qWb FcDQ== 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=qnHv7uR0NY4DITzp+ZFJn60zg6oHgCjvBIP6mob68KI=; b=iduIYnobP8bBv1I5yWnA8LJWJr3O4SDQNkHZ3hHh912UPYl3xr6vqHHmnjVcQkOLdM mSIzKUNw9wGj10ECaeWWxdYWh8lL+DF8RcXhnQAVer7YgisSYnnm++vJOLiRouAx/Fh8 AWSqE8OLpIbgLiNI+h0jxrPMkXJjTA4LygzZpZQCB1tMncR05B8eP6ESolRv/G+SQT7p u/Cbf+El7CLzFomhWSM9BHJwcBWSVQBrlx2vm5e+R7xrAhKuBzuXDCkHY1+2RW8SbKnF 0ZXQXAzWo+fsIHi7o1k9xuoNU2J53k8ScvgXYhO8LsdVFz3TXlTWCBlelPxoAPgNGSRr EFbg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id cn24si1352937edb.340.2020.05.20.06.44.50; Wed, 20 May 2020 06:45:13 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726833AbgETNnP (ORCPT + 99 others); Wed, 20 May 2020 09:43:15 -0400 Received: from foss.arm.com ([217.140.110.172]:56520 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726439AbgETNnO (ORCPT ); Wed, 20 May 2020 09:43:14 -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 A9133106F; Wed, 20 May 2020 06:43:13 -0700 (PDT) Received: from dell3630.arm.com (unknown [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id B68F03F52E; Wed, 20 May 2020 06:43:10 -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 v3 2/5] sched/deadline: Add dl_bw_capacity() Date: Wed, 20 May 2020 15:42:40 +0200 Message-Id: <20200520134243.19352-3-dietmar.eggemann@arm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200520134243.19352-1-dietmar.eggemann@arm.com> References: <20200520134243.19352-1-dietmar.eggemann@arm.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Capacity-aware SCHED_DEADLINE Admission Control (AC) needs root domain (rd) CPU capacity sum. Introduce dl_bw_capacity() which for a symmetric rd w/ a CPU capacity of SCHED_CAPACITY_SCALE simply relies on dl_bw_cpus() to return #CPUs multiplied by SCHED_CAPACITY_SCALE. For an asymmetric rd or a CPU capacity < SCHED_CAPACITY_SCALE it computes the CPU capacity sum over rd span and cpu_active_mask. A 'XXX Fix:' comment was added to highlight that if 'rq->rd == def_root_domain' AC should be performed against the capacity of the CPU the task is running on rather the rd CPU capacity sum. This issue already exists w/o capacity awareness. Signed-off-by: Dietmar Eggemann --- kernel/sched/deadline.c | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/kernel/sched/deadline.c b/kernel/sched/deadline.c index 4ae22bfc37ae..ea7282ce484c 100644 --- a/kernel/sched/deadline.c +++ b/kernel/sched/deadline.c @@ -69,6 +69,34 @@ static inline int dl_bw_cpus(int i) return cpus; } + +static inline unsigned long __dl_bw_capacity(int i) +{ + struct root_domain *rd = cpu_rq(i)->rd; + unsigned long cap = 0; + + RCU_LOCKDEP_WARN(!rcu_read_lock_sched_held(), + "sched RCU must be held"); + + for_each_cpu_and(i, rd->span, cpu_active_mask) + cap += capacity_orig_of(i); + + return cap; +} + +/* + * XXX Fix: If 'rq->rd == def_root_domain' perform AC against capacity + * of the CPU the task is running on rather rd's \Sum CPU capacity. + */ +static inline unsigned long dl_bw_capacity(int i) +{ + if (!static_branch_unlikely(&sched_asym_cpucapacity) && + capacity_orig_of(i) == SCHED_CAPACITY_SCALE) { + return dl_bw_cpus(i) << SCHED_CAPACITY_SHIFT; + } else { + return __dl_bw_capacity(i); + } +} #else static inline struct dl_bw *dl_bw_of(int i) { @@ -79,6 +107,11 @@ static inline int dl_bw_cpus(int i) { return 1; } + +static inline unsigned long dl_bw_capacity(int i) +{ + return SCHED_CAPACITY_SCALE; +} #endif static inline -- 2.17.1