# Pre-emptive vs low-latency patch discrepancy?

## kerframil

I noticed that the latest Gentoo kernel sources include the options of both Robert Love's pre-emptive patch and Andrew Morton's low-latency patch. This is all well and good. But I am a little concerned that both patches are from different contributors and am suspicious that they might not co-exist effectively. Mr Love has created the lock-breaking patch (to reduce spinlocks mainly in VM/VFS kernel code - preemption cannot occur under a spinlock apparently) to go with the pre-emptive kernel patch and this is what he has to say about it:

 *Quote:*   

> With the preemptible kernel, the need for explicit scheduling points, like in the low-latency patches, are no more

 

Surely he is referring to the Morton's "low latency patch" as we know it? And in the README:

 *Quote:*   

> Lock breaking patch for the fully preemptible linux kernel. Or, a low-latency patch for preempt kernel

 

To me, this implies that Morton's low-latency patch is redundant if you are using Love's preemptive kernel. So shouldn't we be using either the Love's stuff or Morton's stuff but not both? Yet, the Gentoo kernel allows you to enable both and doesn't have Love's lock-break patch right?

Further input would be welcome as there seems to be a scarcity of material about the implications. The 6 million dollar question is which one is better but also what are the technical implications of either beyond its mechanics ..? All I know is that increased preemption will result in slightly lower I/O throughput over the long term - I guess that is why Microso$t Windows NT Workstation has a lower "quanta" setting than Windows NT Server for example. Any kernel experts out there who could shed some light on all of this?

----------

## friedmud

I was wanting some people to chime in and give their opinions on whether low-latency and pre-empt are good for desktop systems.

I have found through my own (very non-rigorous) testing that Pre-empt does seem to speed up my desktop some - but it seems as if the low-latency patches actually SLOW DOWN the desktop experience.

Therefore I run Pre-empt only.

Anybody else?

----------

## kerframil

I'm glad somebody else brought this up! Have a look at my earlier posting here: https://forums.gentoo.org/viewtopic.php?t=2144

I think I'm on the right track with the points expressed in that post, namely: Robert Love's patch is getting more exposure/publicity and, from what I know, is getting more support. And I'll quote him again:

 *Quote:*   

> With the premptible kernel, the need for explicit scheduling points, like in the low-latency patches, are no more

 

As no-one has yet offered any real information to the contrary, nor have I found any yet - I'm voting for pre-emptive only! Pre-emptive implies lower latencies anyway and I don't believe it is sensible to have two individual patches which affect the kernel in such a fundamental matter. The issue of improving kernel latency needs to be approached broadly and carefully, not with a mish-mash of 3rd party patches. That's asking for trouble I reckon. Any Gentoo luminaries reading? If so, please add the lock-breaking patch ... cheers!   :Wink: 

IMHO, the Linux kernel definitely needs it - especially for desktop use. As a Windows XP/FreeBSD/OpenBSD user also, my Linux box isn't matching up .. yet. As a matter of fact, I just finished recompiling the kernel with pre-emption so let me see ...

----------

## arkane

I was wondering what the preempt thing does anyway?  I know what preemptive multitasking is (versus cooperative, Win3.1/MacOS style) but I thought Linux was preemptive already?  Or was I wrong?  (wow, that'd be a first! *jk*)

I tried the preempt selection and I didn't really notice much of a difference.  Well, stuff in the foreground like mozilla went a bit faster (not alot though), and compiling a kernel made it mozilla's screen refresh shakey. (without the pre-empt selection I can do both without a problem)

----------

## Coogee

 *arkane wrote:*   

> I was wondering what the preempt thing does anyway?  I know what preemptive multitasking is (versus cooperative, Win3.1/MacOS style) but I thought Linux was preemptive already?  Or was I wrong?  (wow, that'd be a first! *jk*)
> 
> 

 

Linux is pre-emptive, but only in user space = outside of the kernel.

----------

## Malakin

 *Quote:*   

> Linux is pre-emptive, but only in user space = outside of the kernel.

 From what I've read so are most other OS's like winxp.

The main difference between the two is preempt is a simple and clean way to offer low latency so that the kernel preempts whenever it can. The low latency patches instead patch a lot of places in the kernel allowing preemption in places where it's not normally possible. According to tests done low latency patches are more effective but since it patches a ton of places in the kernel it not a clean simple solution, it's more a big mess and is more likely to conflict with other patches. Either produce results effective enough for most users. If someone requires super low latency for some specific reason they can combine the patches.

I use just the preempt patch myself, note that Preempt was officially accepted into 2.5x

Here's a good article comparing the two:

http://www.linuxdevices.com/articles/AT8906594941.html

And here's the slashdot comments on it:

http://slashdot.org/article.pl?sid=02/03/22/0320238&mode=thread

----------

## Malakin

I posted some links you can read in this thread, they answer your questions:

https://forums.gentoo.org/viewtopic.php?t=2164

But a brief answer is, no preempt doesn't make low latency redundant. They can be combined for a greater effect. Low latency has a greater effect but Preempt is a much better way of doing it which is why it was accepted into 2.5.

----------

## c_kuzmanic

I tried using them both and for the first time ever experienced some rather nasty X11 crashes when using mplayer to play avi's. Now i'm just using preemptive and my system is rock-stable once more. It does seem that the compination of both of these patches is problematic.

----------

## AutoBot

 *c_kuzmanic wrote:*   

> I tried using them both and for the first time ever experienced some rather nasty X11 crashes when using mplayer to play avi's. Now i'm just using preemptive and my system is rock-stable once more. It does seem that the compination of both of these patches is problematic.

 

This has not been a problem for me, so it must be configuration independent.

----------

