ULE Scheduler

Oliver Fromme olli at lurza.secnetix.de
Tue Jun 12 12:03:28 UTC 2012


Momchil Ivanov <momchil at xaxo.eu> wrote:
 > I was just curious why both processes are hopping around,
 > because I would naively think that should not happen.

I'll try to explain ...

There are always many more processes and threads being executed
beside the two CPU-bound ones that you see at the top of the
top(1) display.  For example, there are at least 15 threads
inside the kernel (see "ps -auxww") that are scheduled every
now and then.  Or look at "vmstat -i" output to see the
interrupt statistics:  Several hundred times per second,
the interrupt handlers have to be executed.

So, what happens is that an interrupt occurs (from a hardware
clock, from a hard disk controller, from an input device, or
anything else).  Then your process is _removed_ from the core
on which it is currently executing, and the interrupt handler
starts executing.  The same can happen on the second core at
the same time, because different kernel threads can execute
simultaneously (if they don't share resources).  Now, if the
interrupt handler on one of the two cores is done, your own
process has a chance to be scheduled again.  In this moment,
it does not matter at all on which core it is going to be
executed.  The only difference is cache contents, but the
first-level-caches are usually too small anyway.  The ULE
scheduler takes a lot of information into account when making
the decision, including cache affinity (the 4BSD scheduler
doesn't know about that at all).

All of that happens several hundreds times per second.  You
don't have a chance to see it with a tool like top(1).

 > > Have you read Daniel Kalchev's reply in this thread?
 > > He explained very well why that's not a problem usually.
 > 
 > No, I haven't received that one.

Ok, I've appended it below.

Best regards
   Oliver

-------- begin of quoted text --------

From: Daniel Kalchev <daniel at digsys.bg>
Subject: Re: ULE Scheduler
Date: Thu, 7 Jun 2012 12:19:43 +0200 (CEST)
Message-ID: <4FD07EA0.8020401 at digsys.bg>

On 07.06.12 11:16, Momchil Ivanov wrote:
 > Though, it was strange seeing both processes hopping around... I will
 > probably go back to the 4BSD scheduler if my laptop does another
 > self-shutdown in the next few days as Doug suggested.

You never run just two processes on FreeBSD, ever. The kernel too runs
multiple threads.

However small the CPU usage of the other processes is, they must run
from time to time, kicking out at least one of your CPU intensive
processes, possibly kicking them out both, as well. When that happens,
and they are queued to run again it does not matter much on which core
they ran before, because chances are it's cache will be invalidated
anyway. Also, different CPUs have different cache affinity. ULE is
supposed to be aware of this, while the 4BSD scheduler is not.

In any case, on an older single/dual core CPU there is rarely any
difference between both schedulers. Differences might appear in modern
multi-core CPUs..

Daniel

-------- end of quoted text --------


-- 
Oliver Fromme, secnetix GmbH & Co. KG, Marktplatz 29, 85567 Grafing b. M.
Handelsregister: Registergericht Muenchen, HRA 74606,  Geschäftsfuehrung:
secnetix Verwaltungsgesellsch. mbH, Handelsregister: Registergericht Mün-
chen, HRB 125758,  Geschäftsführer: Maik Bachmann, Olaf Erb, Ralf Gebhart

FreeBSD-Dienstleistungen, -Produkte und mehr:  http://www.secnetix.de/bsd

"What is this talk of 'release'?  We do not make software 'releases'.
Our software 'escapes', leaving a bloody trail of designers and quality
assurance people in its wake."


More information about the freebsd-stable mailing list