Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 26 Nov 2013 00:25:57 +0200
From:      Ivan Klymenko <fidaj@ukr.net>
To:        freebsd-hackers@freebsd.org, freebsd-questions@freebsd.org
Subject:   SCHED_ULE and function sched_shouldpreempt
Message-ID:  <20131126002557.6820c60e@nonamehost.local>

next in thread | raw e-mail | index | archive | help
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.



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20131126002557.6820c60e>