Re: How to do lockless stacking (was Re: LSM Stacker)

From: Greg KH (greg@private)
Date: Mon Dec 20 2004 - 15:46:49 PST


On Mon, Dec 20, 2004 at 06:23:47PM -0500, David A. Wheeler wrote:
> Greg KH wrote:
> >RCU is lockless-on-reading from what I remember.
> 
> I vaguely remembered that there was an issue with RCU
> that made that not quite true.  My thanks to someone
> else who emailed me and reminded me of at least one issue:
> kernel preemption.
> 
> RCU isn't lockless if kernel preemption is enabled.

No distros enable preemption.

> Yes, currently many distributions don't turn on pre-emption
> by default, but the low-latency benefits of preemption are nice.

Not true.  See the _many_ threads about this on lkml.  People are
activly working to get the "low latency" fixes into the main kernel
tree, without any preemption needed.

> I think it's worth thinking about an even more lockless version
> of invoking each module & getting any relevant security
> blobs.  I believe you can do that with some
> pointer fiddling and careful alignment; my old draft
> made it possible to do lockless module chaining, without
> locking even in the presence of preemption.
> I could be mistaken; these newer stackers are trying to
> do things that mine wasn't trying to do.
> But it's worth thinking about.

I think that using a well defined, and debugged, and documented data
structure (like RCU) offsets any custom type of lock and other fun
tricks.  In short, try using RCU first.  And if, over time, it turns out
that the downside to RCU is too great, then work on customizing it.

What's that good quote about optimizing too early... :)

thanks,

greg k-h



This archive was generated by hypermail 2.1.3 : Mon Dec 20 2004 - 15:47:21 PST