lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <20220901020855.29951-1-shangxiaojing@huawei.com>
Date:   Thu, 1 Sep 2022 10:08:55 +0800
From:   Shang XiaoJing <shangxiaojing@...wei.com>
To:     <mingo@...hat.com>, <peterz@...radead.org>,
        <juri.lelli@...hat.com>, <vincent.guittot@...aro.org>,
        <dietmar.eggemann@....com>, <rostedt@...dmis.org>,
        <bsegall@...gle.com>, <mgorman@...e.de>, <bristot@...hat.com>,
        <vschneid@...hat.com>, <linux-kernel@...r.kernel.org>
CC:     <shangxiaojing@...wei.com>
Subject: [PATCH v2] sched/deadline: Add should_push_task_dl helper

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 <shangxiaojing@...wei.com>
---
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)
 
 #ifdef CONFIG_SMP
 
+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);
 
 static int
@@ -1840,10 +1849,7 @@ select_task_rq_dl(struct task_struct *p, int cpu, int flags)
 	 * other hand, if it has a shorter deadline, we
 	 * try to make it stay here, it might be important.
 	 */
-	select_rq = unlikely(dl_task(curr)) &&
-		    (curr->nr_cpus_allowed < 2 ||
-		     !dl_entity_preempt(&p->dl, &curr->dl)) &&
-		    p->nr_cpus_allowed > 1;
+	select_rq = should_push_task_dl(curr, p);
 
 	/*
 	 * 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);
 	}
 }
-- 
2.17.1

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ