Received: by 2002:ac0:e350:0:0:0:0:0 with SMTP id g16csp205210imn; Fri, 29 Jul 2022 04:43:19 -0700 (PDT) X-Google-Smtp-Source: AGRyM1tm0VeEKyzfWlgWt+ncUATXnC8uFXOLElTztApNab21Bw6CXN1uAwdpUWljtdS99Gc/pfjd X-Received: by 2002:a17:907:7fa2:b0:72b:60c4:a04e with SMTP id qk34-20020a1709077fa200b0072b60c4a04emr2596511ejc.290.1659094999268; Fri, 29 Jul 2022 04:43:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1659094999; cv=none; d=google.com; s=arc-20160816; b=PexKr28OCXAEvRc44yNPCZlGfcYFHydPyuaBtiB4pL0jxJhep/p5vt1snwCjiqqgM5 x0c4U4Kr5mDWcDrH6Q1r8P1gXHX/fmkN0fmmXrPKN9H+HGDFWi8aDd/F2TP/SuwMsiVm Md+jy1Wz/7mhFC3x1EJn5KKWLkcl6IdyH/azqcyI/knVmMx3Yye6I6xVgNwHLAIKO2DX DYqzRUzfjQnEE3GX2NsuCBi86hqeYn2+t4d/bgcvZKI8eJTAsQmF7+5COrbOvYIQLB4q JbDFiKQ0iEDpT3xBkxrZGRvsCzTLhJKcaeLlkZBcfIRd8Aq3awLRLLXaOngXHQNqtewc Q7kg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=makxGnIdkxd2x7gdXyOFixBHIk/k2/kTdvjLav8eZFw=; b=0m1uJmYM+gZdvL7pMND6KRYqTaoPbQLE9b/3XeXNTpGDJpmyqECbGZCNIdXNVxvOJZ Eg8FlG56jOIqYqdxNihc39YLbc6LIN7ZzgZ8Sn3TNlduE+LdF9LBsA7VkQ1ojY8yevpq AasHphj8PFukkvYcIG49I/Nq8MH2sRdmnSAwWcfbSxLfEYCgeifwfDVNaw8EhZ1Yp/rC lol1yGLT0S5UkCihV7JiDtNFU8wUparpIxpTf5/7QG1l1TqoEtu3zpsCuc+uIWiIcwWW KkCKgw+1Lml68ndxHDns8TV8uIdUB9r+hMDkq3ck+XGarEBmNarxs53bM5zihVrC316n W+qA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id gh4-20020a170906e08400b0072a84044156si2658966ejb.849.2022.07.29.04.42.49; Fri, 29 Jul 2022 04:43:19 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235867AbiG2LNg (ORCPT + 99 others); Fri, 29 Jul 2022 07:13:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34120 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235871AbiG2LNc (ORCPT ); Fri, 29 Jul 2022 07:13:32 -0400 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 3CD5A7B34C for ; Fri, 29 Jul 2022 04:13:31 -0700 (PDT) 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 A061B1570; Fri, 29 Jul 2022 04:13:31 -0700 (PDT) Received: from localhost.localdomain (unknown [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id A39E33F73D; Fri, 29 Jul 2022 04:13:28 -0700 (PDT) From: Dietmar Eggemann To: Ingo Molnar , Peter Zijlstra , Juri Lelli , Vincent Guittot , Steven Rostedt Cc: Daniel Bristot de Oliveira , Valentin Schneider , Mel Gorman , Ben Segall , Luca Abeni , linux-kernel@vger.kernel.org Subject: [PATCH v2 2/3] sched/deadline: Make dl_cpuset_cpumask_can_shrink() capacity-aware Date: Fri, 29 Jul 2022 13:13:04 +0200 Message-Id: <20220729111305.1275158-3-dietmar.eggemann@arm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220729111305.1275158-1-dietmar.eggemann@arm.com> References: <20220729111305.1275158-1-dietmar.eggemann@arm.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_NONE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org dl_cpuset_cpumask_can_shrink() is used to validate whether there is still enough CPU capacity for DL tasks in the reduced cpuset. Currently it still operates on `# remaining CPUs in the cpuset` (1). Change this to use the already capacity-aware DL admission control __dl_overflow() for the `cpumask can shrink` test. dl_b->bw = sched_rt_period << BW_SHIFT / sched_rt_period dl_b->bw * (1) >= currently allocated bandwidth in root_domain (rd) Replace (1) w/ `\Sum CPU capacity in rd >> SCHED_CAPACITY_SHIFT` Adapt __dl_bw_capacity() to take a cpumask instead of a CPU number argument so that `rd->span` and `cpumask of the reduced cpuset` can be used here. Signed-off-by: Dietmar Eggemann --- kernel/sched/deadline.c | 24 +++++++++++------------- 1 file changed, 11 insertions(+), 13 deletions(-) diff --git a/kernel/sched/deadline.c b/kernel/sched/deadline.c index 3f9d90b8a8b6..34de6060dea6 100644 --- a/kernel/sched/deadline.c +++ b/kernel/sched/deadline.c @@ -124,15 +124,12 @@ static inline int dl_bw_cpus(int i) return cpus; } -static inline unsigned long __dl_bw_capacity(int i) +static inline unsigned long __dl_bw_capacity(const struct cpumask *mask) { - struct root_domain *rd = cpu_rq(i)->rd; unsigned long cap = 0; + int i; - RCU_LOCKDEP_WARN(!rcu_read_lock_sched_held(), - "sched RCU must be held"); - - for_each_cpu_and(i, rd->span, cpu_active_mask) + for_each_cpu_and(i, mask, cpu_active_mask) cap += capacity_orig_of(i); return cap; @@ -148,7 +145,10 @@ static inline unsigned long dl_bw_capacity(int i) capacity_orig_of(i) == SCHED_CAPACITY_SCALE) { return dl_bw_cpus(i) << SCHED_CAPACITY_SHIFT; } else { - return __dl_bw_capacity(i); + RCU_LOCKDEP_WARN(!rcu_read_lock_sched_held(), + "sched RCU must be held"); + + return __dl_bw_capacity(cpu_rq(i)->rd->span); } } @@ -3004,17 +3004,15 @@ bool dl_param_changed(struct task_struct *p, const struct sched_attr *attr) int dl_cpuset_cpumask_can_shrink(const struct cpumask *cur, const struct cpumask *trial) { - int ret = 1, trial_cpus; + unsigned long flags, cap; struct dl_bw *cur_dl_b; - unsigned long flags; + int ret = 1; rcu_read_lock_sched(); cur_dl_b = dl_bw_of(cpumask_any(cur)); - trial_cpus = cpumask_weight(trial); - + cap = __dl_bw_capacity(trial); raw_spin_lock_irqsave(&cur_dl_b->lock, flags); - if (cur_dl_b->bw != -1 && - cur_dl_b->bw * trial_cpus < cur_dl_b->total_bw) + if (__dl_overflow(cur_dl_b, cap, 0, 0)) ret = 0; raw_spin_unlock_irqrestore(&cur_dl_b->lock, flags); rcu_read_unlock_sched(); -- 2.25.1