Received: by 2002:a05:6358:bb9e:b0:b9:5105:a5b4 with SMTP id df30csp92719rwb; Fri, 2 Sep 2022 10:40:50 -0700 (PDT) X-Google-Smtp-Source: AA6agR4LA3zHYS/p4Xp1VlwRUkPneEMgIF1PKIc9Tb9TK2GJegbcr7x/tdlZNif8KbJt0F7Qt4rc X-Received: by 2002:a17:902:d704:b0:175:479a:82a8 with SMTP id w4-20020a170902d70400b00175479a82a8mr12074319ply.25.1662140450630; Fri, 02 Sep 2022 10:40:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1662140450; cv=none; d=google.com; s=arc-20160816; b=PJVRv/VlJkGd8XO2X2Raaz/agNnPuYhrg2uXjmzG6T47q2jG5VfuyiUE6GouG8YbdR vSMwZZhJPAM9Wy9vgut17NKwYDNXmIGrrMf5ngwuMpINPejWVyiflo3f4bjiPDEpjbKH S448R0UkWHlQ0eDvhpqaQC9jd/EVBrzPC51gfT+3cN16dUddlUlxPhR/l85aGdFcomyc bImDGU2ALKGo3jVNsHgzyOBwRqZd4+cyQmbRLgBC3U0IV5r8/lLpB8HDoq6kpHaC5X5m klIHD9VqMpS9k24oom7jojcSJVWEGDxw5VKDVPcAos/UuSck046ssi6vJSd6lAnmiCuw kfXg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:robot-unsubscribe :robot-id:message-id:mime-version:references:in-reply-to:cc:subject :to:reply-to:sender:from:dkim-signature:dkim-signature:date; bh=cgRoNYONY177gv/d1dFqiMdDLkHqPWmXgx++I7ksaVI=; b=k3a7IuMOndeXLS+66H0glGRwMb7xtONUBqEv5MDpXSR7KBmxnKeP4g1uQSwgJbBem8 et4cWb4GhkgCEY/LDIQe/NVu7SPqxh5o/nwr5oPaaPCAwmHq9ul8F28KMYKwbqR/zDHC 3UlhqIdVRZDln1zHeZUVMQKG5QT7yKvJ1bYyKIA4MuWYwirPQJwW9H5oU7ghPX5WBW8P IppssPuKy/ypIeXtX0lapp86Z7O3qcBaZ6yDhFX+fiVsc8xNzbDzhEgjLnzZZzC6A1Tt 7/ZWsHvUEQVlCnGyGCBo1LSgWlb9hMqhKICpXy45vaQGCmxD9BVMFTMhGh1BE+Czdd7a qbYw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=a54CLRW3; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e; 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=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id cp8-20020a056a00348800b005380c21168esi2525972pfb.272.2022.09.02.10.40.35; Fri, 02 Sep 2022 10:40:50 -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; dkim=pass header.i=@linutronix.de header.s=2020 header.b=a54CLRW3; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e; 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=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236810AbiIBR2l (ORCPT + 99 others); Fri, 2 Sep 2022 13:28:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49050 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236339AbiIBR2d (ORCPT ); Fri, 2 Sep 2022 13:28:33 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [IPv6:2a0a:51c0:0:12e:550::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1D240D346B; Fri, 2 Sep 2022 10:28:32 -0700 (PDT) Date: Fri, 02 Sep 2022 17:28:29 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1662139710; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=cgRoNYONY177gv/d1dFqiMdDLkHqPWmXgx++I7ksaVI=; b=a54CLRW3eFQr8Mmbg7xRkGDr0TfSmmb5t0TQbAruEubgSWJfVBUOC5ZXmDx4fM/IXytV4x Vu9gEt7mpKQzQ0bdya5hr8LhJrZ0mLGMDkn34eUE58SOuMSR4ccDRm/l2gv2UliuI9515I VnKsUToFnu228NkjnoRmCwT3OvbhHovwbzEVvH7pvwjEXTOp6deND5bwxNBGtYO/H7J6J5 eeq5hWiPd6zZJ2gE+3K2HBWawZTo+WEg4bf0YDZ7ghV/onKpWJ9MnHXf8i98mShwx9WXIZ et5ERqwYKre+cFKfZJyxWDMbfJXNHKup8Ol80WR5k8P/Ne02HIZS8yX9LMdPFw== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1662139710; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=cgRoNYONY177gv/d1dFqiMdDLkHqPWmXgx++I7ksaVI=; b=4k7iOzmIz6u7FuzrjgLFW/xQGr6muoOSSIJj7vsCeuHpoTTovNrUAj8sKxTWaQ1Z24TeXR o85xfmdg49A6rNAA== From: "tip-bot2 for Shang XiaoJing" Sender: tip-bot2@linutronix.de Reply-to: linux-kernel@vger.kernel.org To: linux-tip-commits@vger.kernel.org Subject: [tip: sched/core] sched/deadline: Add replenish_dl_new_period helper Cc: Shang XiaoJing , "Peter Zijlstra (Intel)" , Daniel Bristot de Oliveira , x86@kernel.org, linux-kernel@vger.kernel.org In-Reply-To: <20220826100037.12146-1-shangxiaojing@huawei.com> References: <20220826100037.12146-1-shangxiaojing@huawei.com> MIME-Version: 1.0 Message-ID: <166213970919.401.16005611865289043769.tip-bot2@tip-bot2> Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_PASS,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 The following commit has been merged into the sched/core branch of tip: Commit-ID: 96458e7f7dc5ad14bd7577cbf1638e1504ad79dd Gitweb: https://git.kernel.org/tip/96458e7f7dc5ad14bd7577cbf1638e1504ad79dd Author: Shang XiaoJing AuthorDate: Fri, 26 Aug 2022 18:00:37 +08:00 Committer: Peter Zijlstra CommitterDate: Thu, 01 Sep 2022 11:19:54 +02:00 sched/deadline: Add replenish_dl_new_period helper Wrap repeated code in helper function replenish_dl_new_period, which set the deadline and runtime of input dl_se based on pi_of(dl_se). Note that setup_new_dl_entity originally set the deadline and runtime base on dl_se, which should equals to pi_of(dl_se) for non-boosted task. Signed-off-by: Shang XiaoJing Signed-off-by: Peter Zijlstra (Intel) Reviewed-by: Daniel Bristot de Oliveira Link: https://lore.kernel.org/r/20220826100037.12146-1-shangxiaojing@huawei.com --- kernel/sched/deadline.c | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/kernel/sched/deadline.c b/kernel/sched/deadline.c index 34271af..3bf4b12 100644 --- a/kernel/sched/deadline.c +++ b/kernel/sched/deadline.c @@ -770,6 +770,14 @@ static void enqueue_task_dl(struct rq *rq, struct task_struct *p, int flags); static void __dequeue_task_dl(struct rq *rq, struct task_struct *p, int flags); static void check_preempt_curr_dl(struct rq *rq, struct task_struct *p, int flags); +static inline void replenish_dl_new_period(struct sched_dl_entity *dl_se, + struct rq *rq) +{ + /* for non-boosted task, pi_of(dl_se) == dl_se */ + dl_se->deadline = rq_clock(rq) + pi_of(dl_se)->dl_deadline; + dl_se->runtime = pi_of(dl_se)->dl_runtime; +} + /* * We are being explicitly informed that a new instance is starting, * and this means that: @@ -803,8 +811,7 @@ static inline void setup_new_dl_entity(struct sched_dl_entity *dl_se) * future; in fact, we must consider execution overheads (time * spent on hardirq context, etc.). */ - dl_se->deadline = rq_clock(rq) + dl_se->dl_deadline; - dl_se->runtime = dl_se->dl_runtime; + replenish_dl_new_period(dl_se, rq); } /* @@ -836,10 +843,8 @@ static void replenish_dl_entity(struct sched_dl_entity *dl_se) * This could be the case for a !-dl task that is boosted. * Just go with full inherited parameters. */ - if (dl_se->dl_deadline == 0) { - dl_se->deadline = rq_clock(rq) + pi_of(dl_se)->dl_deadline; - dl_se->runtime = pi_of(dl_se)->dl_runtime; - } + if (dl_se->dl_deadline == 0) + replenish_dl_new_period(dl_se, rq); if (dl_se->dl_yielded && dl_se->runtime > 0) dl_se->runtime = 0; @@ -866,8 +871,7 @@ static void replenish_dl_entity(struct sched_dl_entity *dl_se) */ if (dl_time_before(dl_se->deadline, rq_clock(rq))) { printk_deferred_once("sched: DL replenish lagged too much\n"); - dl_se->deadline = rq_clock(rq) + pi_of(dl_se)->dl_deadline; - dl_se->runtime = pi_of(dl_se)->dl_runtime; + replenish_dl_new_period(dl_se, rq); } if (dl_se->dl_yielded) @@ -1024,8 +1028,7 @@ static void update_dl_entity(struct sched_dl_entity *dl_se) return; } - dl_se->deadline = rq_clock(rq) + pi_of(dl_se)->dl_deadline; - dl_se->runtime = pi_of(dl_se)->dl_runtime; + replenish_dl_new_period(dl_se, rq); } }