Re: bkl cleanup in do_sysctl

From: Dave Hansen
Date: Tue Aug 10 2004 - 13:07:24 EST


On Tue, 2004-08-10 at 09:58, Josh Aas wrote:
> I'd like to hear people's thoughts on replacing the bkl in do_sysctl
> with a localized spin lock that protects the sysctl structures. Instead
> of grabbing the bkl, anyone that needs to mess with those values could
> grab the localized lock (1 to protect all structures). Such a localized
> lock would allow us to get rid of bkl usage in at least one other place
> as well (do_coredump). In order to do this though, we would have to make
> sure all code that grabs the bkl instead of the localized lock while
> using sysctl values switches to the new lock. Might be a big job, but
> perhaps it would be a good one to start after 2.6.8 is out the door.

Remember that the BKL isn't a plain-old spinlock. You're allowed to
sleep while holding it and it can be recursively held, which isn't true
for other spinlocks.

So, if you want to replace it with a spinlock, you'll need to do audits
looking for sysctl users that might_sleep() or get called recursively
somehow. The might_sleep() debugging checks should help immensely for
the first part, but all you'll get are deadlocks at runtime for any
recursive holders. But, those cases are increasingly rare, so you might
luck out and not have any.

Or, you could just make it a semaphore and forget about the no sleeping
requirement.

-- Dave

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/