SCHED_ULE and function sched_shouldpreempt

Ivan Klymenko fidaj at ukr.net
Mon Nov 25 22:26:01 UTC 2013


Hello all.

sched_shouldpreempt function can return only 2 values: 0 or 1

there is a set of specific conditions under which the function returns
1 if the remaining conditions - it will return 0.
why use a kung fu which is currently in use?
not be simpler to use that variant?:

--- sched_ule.c.orig    2013-11-18 17:41:52.000000000 +0200
+++ sched_ule.c 2013-11-18 17:48:21.000000000 +0200
@@ -419,32 +419,7 @@
 static inline int
 sched_shouldpreempt(int pri, int cpri, int remote)
 {
-       /*
-        * If the new priority is not better than the current priority there is
-        * nothing to do.
-        */
-       if (pri >= cpri)
-               return (0);
-       /*
-        * Always preempt idle.
-        */
-       if (cpri >= PRI_MIN_IDLE)
-               return (1);
-       /*
-        * If preemption is disabled don't preempt others.
-        */
-       if (preempt_thresh == 0)
-               return (0);
-       /*
-        * Preempt if we exceed the threshold.
-        */
-       if (pri <= preempt_thresh)
-               return (1);
-       /*
-        * If we're interactive or better and there is non-interactive
-        * or worse running preempt only remote processors.
-        */
-       if (remote && pri <= PRI_MAX_INTERACT && cpri > PRI_MAX_INTERACT)
+       if ((remote && pri <= PRI_MAX_INTERACT && cpri > PRI_MAX_INTERACT)||(pri <= preempt_thresh)||(cpri >= PRI_MIN_IDLE))
                return (1);
        return (0);
 }

or indeed there is some uneven distribution fulfillment of certain conditions under which the execution time of that function will be much more?

or to use the original variant there is any other reasons?

Thanks.


More information about the freebsd-hackers mailing list