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>] [day] [month] [year] [list]
Message-ID: <CAHOvCC6JxwF51=-HHNS9wbv38H6MZ=rLjVDH7o_WGAQ6OFoTqw@mail.gmail.com>
Date:   Wed, 21 Sep 2022 17:12:20 +0900
From:   JaeJoon Jung <rgbi3307@...il.com>
To:     Peter Zijlstra <peterz@...radead.org>,
        Chris Hyser <chris.hyser@...cle.com>,
        Don Hiatt <dhiatt@...italocean.com>,
        Hongyu Ning <hongyu.ning@...ux.intel.com>,
        Vincent Guittot <vincent.guittot@...aro.org>,
        Cruz Zhao <CruzZhao@...ux.alibaba.com>
Cc:     linux-kernel@...r.kernel.org
Subject: [core-scheduling] Modify prio_less() with in CONFIG_SCHED_CORE on v5.19.x

Hello,
Since the priority of sched_class can be determined by pointer operation,
the prio_less() function can be modified as follows.
With this fix, the __task_prio() function is not needed.
Please review.

diff --git a/kernel/sched/core.c b/kernel/sched/core.c
index ee28253c9ac0..24b86773da04 100644
--- a/kernel/sched/core.c
+++ b/kernel/sched/core.c
@@ -154,21 +154,6 @@ __read_mostly int scheduler_running;

 DEFINE_STATIC_KEY_FALSE(__sched_core_enabled);

-/* kernel prio, less is more */
-static inline int __task_prio(struct task_struct *p)
-{
-       if (p->sched_class == &stop_sched_class) /* trumps deadline */
-               return -2;
-
-       if (rt_prio(p->prio)) /* includes deadline */
-               return p->prio; /* [-1, 99] */
-
-       if (p->sched_class == &idle_sched_class)
-               return MAX_RT_PRIO + NICE_WIDTH; /* 140 */
-
-       return MAX_RT_PRIO + MAX_NICE; /* 120, squash fair */
-}
-
 /*
  * l(a,b)
  * le(a,b) := !l(b,a)
@@ -179,22 +164,18 @@ static inline int __task_prio(struct task_struct *p)
 /* real prio, less is less */
 static inline bool prio_less(struct task_struct *a, struct
task_struct *b, bool in_fi)
 {
-
-       int pa = __task_prio(a), pb = __task_prio(b);
-
-       if (-pa < -pb)
-               return true;
-
-       if (-pb < -pa)
-               return false;
-
-       if (pa == -1) /* dl_prio() doesn't work because of stop_class above */
-               return !dl_time_before(a->dl.deadline, b->dl.deadline);
-
-       if (pa == MAX_RT_PRIO + MAX_NICE)       /* fair */
-               return cfs_prio_less(a, b, in_fi);
-
-       return false;
+        int less = a->sched_class - b->sched_class;
+
+        if (less) {
+                return (less > 0) ? true : false;
+        } else {
+                if (a->sched_class == &fair_sched_class)
+                       return cfs_prio_less(a, b, in_fi);
+                else if (a->sched_class == &dl_sched_class)
+                       return !dl_time_before(a->dl.deadline, b->dl.deadline);
+                else
+                        return (a->prio - b->prio > 0) ? true : false;
+        }
 }

Thanks,
JaeJoon Jung.

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ