Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp575930iog; Wed, 29 Jun 2022 06:13:59 -0700 (PDT) X-Google-Smtp-Source: AGRyM1u9qAvSEX0elJHDsgJEqwJsyFtAOxrKTSWYK/85JzheBKJPYZI13SLfcbbB2xZsV0ZyYCm5 X-Received: by 2002:a17:906:b048:b0:6fe:be4a:3ecf with SMTP id bj8-20020a170906b04800b006febe4a3ecfmr3443346ejb.104.1656508439372; Wed, 29 Jun 2022 06:13:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1656508439; cv=none; d=google.com; s=arc-20160816; b=l1LzqEqdTPldSxTMfWJ21t011cVs3hsk1a8gLH2mMMDVP+rIdko3ka6n+L1cMnJI67 XHrvwlVIo6lI2Ia0ws2Rbko+5ZoUJYMf/CMHVnrd5AN8qf+095tPRMNNp8yOEWtZDEmT N0/nuWKdzXWUWpgWCzpeB03WzeQlsVjHe14MqcXNTBn2D2LpCf6wFg40XcdDlcFnHfuM /5N+LXPP7wjWAqgPCiA4MmA6qEoIOOswDFGIfBCAgUXbSHbgY53C4NbIcnxWqsYg5jJt gzdf8NXcPWop1OG4kiPEBJ5iOBvLNAQzJ4D4fCJrUZJWSbTm1gQvZPeHIuER8NDX9qMO /OHA== 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=hKIkMmvkQcDVWPqO42PFc41pqrH1WNEFaT/dmOW1bxY=; b=dUj9xBsIflV1JJDo7yF9MUL+MSBz8kqyW4bL972SKiqs+CaRVx/xMaCFvO9kO5R7il HEnwAl2alDp5yRVHItxxEchNhKN4KVj2C4CNcJ4om3QdRtlkZoWWp/0DMV2YDBgiluXv si5Nyzo989GCHufWsWo9FY6lJodzeMYV5bAYek4EV23viQbi3fw3SOKuZMcnZjENHEZ9 0K27qHlP9Tje9AZz3iE8jLbfGqqa9y+D45RnjbgTBJ4gzXFHho7a22h8NRMLS4rSmwQA MM1a906doA/ozMfNO7tpRWnFA8K20453FT2BVwbL60Mrz8nIKSHy2ep0AI4pMIR8xEKy nzyA== 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 b15-20020a056402278f00b00435781299b4si619357ede.357.2022.06.29.06.13.17; Wed, 29 Jun 2022 06:13:59 -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 S233158AbiF2MVc (ORCPT + 99 others); Wed, 29 Jun 2022 08:21:32 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54196 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233015AbiF2MV1 (ORCPT ); Wed, 29 Jun 2022 08:21:27 -0400 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 207A62FFF4 for ; Wed, 29 Jun 2022 05:21:27 -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 0DADA169C; Wed, 29 Jun 2022 05:21:27 -0700 (PDT) Received: from e125579.fritz.box (unknown [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 0AD0A3F66F; Wed, 29 Jun 2022 05:21:24 -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 3/3] sched/deadline: Use sched_dl_entity's dl_density in dl_task_fits_capacity() Date: Wed, 29 Jun 2022 14:20:53 +0200 Message-Id: <20220629122053.287165-4-dietmar.eggemann@arm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220629122053.287165-1-dietmar.eggemann@arm.com> References: <20220629122053.287165-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,T_SCC_BODY_TEXT_LINE 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 Save a multiplication in dl_task_fits_capacity() by using already maintained per-sched_dl_entity (i.e. per-task) `dl_runtime/dl_deadline` (dl_density). cap_scale(dl_deadline, cap) >= dl_runtime dl_deadline * cap >> SCHED_CAPACITY_SHIFT >= dl_runtime cap >= dl_runtime << SCHED_CAPACITY_SHIFT / dl_deadline with BW_SHIFT = 2 x SCHED_CAPACITY_SHIFT cap >= (dl_runtime << BW_SHIFT / dl_deadline) >> SCHED_CAPACITY_SHIFT cap >= dl_density >> SCHED_CAPACITY_SHIFT __sched_setscheduler()->__checkparam_dl() ensures that the 2 corner cases (if conditions) `runtime == RUNTIME_INF (-1)` and `period == 0` of to_ratio(deadline, runtime) are not met when setting dl_density in __sched_setscheduler()-> __setscheduler_params()->__setparam_dl(). Signed-off-by: Dietmar Eggemann --- kernel/sched/sched.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/kernel/sched/sched.h b/kernel/sched/sched.h index 79f65a6799c6..555f58d6c3a6 100644 --- a/kernel/sched/sched.h +++ b/kernel/sched/sched.h @@ -324,15 +324,15 @@ struct dl_bw { * Verify the fitness of task @p to run on @cpu taking into account the * CPU original capacity and the runtime/deadline ratio of the task. * - * The function will return true if the CPU original capacity of the - * @cpu scaled by SCHED_CAPACITY_SCALE >= runtime/deadline ratio of the - * task and false otherwise. + * The function will return true if the original capacity of @cpu is + * greater than or equal to task's deadline density right shifted by + * SCHED_CAPACITY_SHIFT and false otherwise. */ static inline bool dl_task_fits_capacity(struct task_struct *p, int cpu) { unsigned long cap = arch_scale_cpu_capacity(cpu); - return cap_scale(p->dl.dl_deadline, cap) >= p->dl.dl_runtime; + return cap >= p->dl.dl_density >> SCHED_CAPACITY_SHIFT; } extern void init_dl_bw(struct dl_bw *dl_b); -- 2.25.1