Received: by 2002:a05:6358:45e:b0:b5:b6eb:e1f9 with SMTP id 30csp1260186rwe; Thu, 25 Aug 2022 20:10:41 -0700 (PDT) X-Google-Smtp-Source: AA6agR7Qm2mKM86Kdxdpv5rVbrO2O6+MRHLg22pDRjeJH3c8jauzfRx2L5IFaxuKXkEHzpHW1ZBl X-Received: by 2002:a17:902:eb86:b0:173:325f:1121 with SMTP id q6-20020a170902eb8600b00173325f1121mr1879079plg.145.1661483441413; Thu, 25 Aug 2022 20:10:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1661483441; cv=none; d=google.com; s=arc-20160816; b=bpKCs7hpX2PpJtwidRUe0Rmlu26WFeAgqB7a1u2XrrcZLdf5OxOG2ccGYw3us9It/V evdKa+h6eDZboRnGByPlxFKwptSkcc8e+WyiqlPzpT7desMhuwOOGRI7276ea8WsFOqi 20vYpPHmR5MOAHoU4/6qnES4B0CEgFtrGmilEt41IDMD6msZdFNMCWGZguy5ztldc5k7 Rd7CQ2V23+pFpUFYwbLh+BGbN+E1vEnKlHLpIlbIFNljj4shHEjHBXYDLjREywu28UMO yArCsV7hMRwHTklcxi2ab5iBrYqe1LqRxsAwpv7MbVQ1ytitf0S2d9O6gcqtBjaDpWoR nH0g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:message-id:date:subject:cc:to:from; bh=YCV1cVuNixCt9LrPspVKGt5Pt9KGGXTPBjMBnTXUZRw=; b=0XmpQdmkx7MiFGj6DaHMhGHdBQ9glT8ZfMjNTAS6cquUOozIev1MrifZwKzAXmOL4n p5tRJZzuVbItiWgcFd88pUqePtnJeIJaI0uNf+cGHUY2lyCFjiAULdX2M0xu8oYNWN28 Si2AGZkZWMWT1CZurIt5oWCLfbK0if5o7Qor7doiHlhWiAUTglQqHdvtSxhF80crql6D Xez8D63NquKeBxBptivjfsFjTnOhU/QXIof+vzSXFt14jrnC3eywgUc3JVZXfzaobKvt oLJIU3m6l9on2o6Bzih1FNaGD/AvaX56X+IG03bzuxh2QGRLWh1FVg3DLrEIje7/V20H fj/w== 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=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id f23-20020a631f17000000b0041bd3212b81si694945pgf.254.2022.08.25.20.10.30; Thu, 25 Aug 2022 20:10:41 -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=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S244659AbiHZCkZ (ORCPT + 99 others); Thu, 25 Aug 2022 22:40:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46772 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239526AbiHZCkW (ORCPT ); Thu, 25 Aug 2022 22:40:22 -0400 Received: from szxga03-in.huawei.com (szxga03-in.huawei.com [45.249.212.189]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AAFB41AF00 for ; Thu, 25 Aug 2022 19:40:19 -0700 (PDT) Received: from dggemv711-chm.china.huawei.com (unknown [172.30.72.56]) by szxga03-in.huawei.com (SkyGuard) with ESMTP id 4MDPCb4gFMzGprV; Fri, 26 Aug 2022 10:38:35 +0800 (CST) Received: from kwepemm600008.china.huawei.com (7.193.23.88) by dggemv711-chm.china.huawei.com (10.1.198.66) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.24; Fri, 26 Aug 2022 10:40:17 +0800 Received: from huawei.com (10.175.100.227) by kwepemm600008.china.huawei.com (7.193.23.88) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.24; Fri, 26 Aug 2022 10:40:16 +0800 From: Shang XiaoJing To: , , , , , , , , , , CC: Subject: [PATCH -next] sched/deadline: Add start_new_instance helper Date: Fri, 26 Aug 2022 11:15:21 +0800 Message-ID: <20220826031521.13391-1-shangxiaojing@huawei.com> X-Mailer: git-send-email 2.17.1 MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.175.100.227] X-ClientProxiedBy: dggems705-chm.china.huawei.com (10.3.19.182) To kwepemm600008.china.huawei.com (7.193.23.88) X-CFilter-Loop: Reflected X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,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 Wrap repeated code in helper function start_new_instance, which set the deadline and runtiem 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 --- kernel/sched/deadline.c | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/kernel/sched/deadline.c b/kernel/sched/deadline.c index 4a40a462717c..5e9c28847610 100644 --- a/kernel/sched/deadline.c +++ b/kernel/sched/deadline.c @@ -770,6 +770,13 @@ 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 start_new_instance(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 +810,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; + start_new_instance(dl_se, rq); } /* @@ -836,10 +842,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) + start_new_instance(dl_se, rq); if (dl_se->dl_yielded && dl_se->runtime > 0) dl_se->runtime = 0; @@ -866,8 +870,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; + start_new_instance(dl_se, rq); } if (dl_se->dl_yielded) @@ -1024,8 +1027,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; + start_new_instance(dl_se, rq); } } -- 2.17.1