From nobody Tue Apr 7 00:37:11 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id BE76DECAAD5 for ; Thu, 1 Sep 2022 01:34:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231660AbiIABeW (ORCPT ); Wed, 31 Aug 2022 21:34:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54386 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232644AbiIABeF (ORCPT ); Wed, 31 Aug 2022 21:34:05 -0400 Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8511A155D60 for ; Wed, 31 Aug 2022 18:34:04 -0700 (PDT) Received: from dggemv711-chm.china.huawei.com (unknown [172.30.72.54]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4MJ3PG16hqzYd44; Thu, 1 Sep 2022 09:29:38 +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; Thu, 1 Sep 2022 09:34:01 +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; Thu, 1 Sep 2022 09:34:00 +0800 From: Shang XiaoJing To: , , , , , , , , , , CC: Subject: [PATCH v2] sched/deadline: Add should_push_task_dl helper Date: Thu, 1 Sep 2022 10:08:55 +0800 Message-ID: <20220901020855.29951-1-shangxiaojing@huawei.com> X-Mailer: git-send-email 2.17.1 MIME-Version: 1.0 X-Originating-IP: [10.175.100.227] X-ClientProxiedBy: dggems701-chm.china.huawei.com (10.3.19.178) To kwepemm600008.china.huawei.com (7.193.23.88) X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Wrap complex and repeated code in helper function should_push_task_dl, which will return true when task p should be pushed to other cores because of current task. Signed-off-by: Shang XiaoJing Reviewed-by: Daniel Bristot de Oliveira --- changes in v2: - pick a more descriptive function name rather than should_push_task_away. - adjust name of args. --- kernel/sched/deadline.c | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/kernel/sched/deadline.c b/kernel/sched/deadline.c index daa9a7fb5917..d0fa30a3f1b3 100644 --- a/kernel/sched/deadline.c +++ b/kernel/sched/deadline.c @@ -1814,6 +1814,15 @@ static void yield_task_dl(struct rq *rq) =20 #ifdef CONFIG_SMP =20 +static inline bool should_push_task_dl(struct task_struct *curr, + struct task_struct *p) +{ + return unlikely(dl_task(curr)) && + (curr->nr_cpus_allowed < 2 || + !dl_entity_preempt(&p->dl, &curr->dl)) && + p->nr_cpus_allowed > 1; +} + static int find_later_rq(struct task_struct *task); =20 static int @@ -1840,10 +1849,7 @@ select_task_rq_dl(struct task_struct *p, int cpu, in= t flags) * other hand, if it has a shorter deadline, we * try to make it stay here, it might be important. */ - select_rq =3D unlikely(dl_task(curr)) && - (curr->nr_cpus_allowed < 2 || - !dl_entity_preempt(&p->dl, &curr->dl)) && - p->nr_cpus_allowed > 1; + select_rq =3D should_push_task_dl(curr, p); =20 /* * Take the capacity of the CPU into account to @@ -2477,10 +2483,7 @@ static void task_woken_dl(struct rq *rq, struct task= _struct *p) { if (!task_running(rq, p) && !test_tsk_need_resched(rq->curr) && - p->nr_cpus_allowed > 1 && - dl_task(rq->curr) && - (rq->curr->nr_cpus_allowed < 2 || - !dl_entity_preempt(&p->dl, &rq->curr->dl))) { + should_push_task_dl(rq->curr, p)) { push_dl_tasks(rq); } } --=20 2.17.1