Re: [PATCH] netfilter: use per-CPU r**ursive lock {XV}

From: Ingo Molnar
Date: Mon Apr 27 2009 - 14:55:35 EST



* Stephen Hemminger <shemminger@xxxxxxxxxx> wrote:

> > non of the linux kernel locking primitives have this -- with the
> > possible exception of the cpu-hotplug lock.
> >
> > What rwlock_t has, is reader bias to the point where you can
> > utterly starve writers, with the side effect that you can obtain
> > multiple read ownerships without causing a deadlock.
>
> But what happens when this side effect disappears?

Then well written code works, badly written code breaks.

> > [...]
> >
> > This is all common and well understood terminology, not
> > something Linus invented just to harras you with.
>
> In Documentation/ ? online ? Where is the definition? The only
> reference I se is indirectly in DocBook/kernel-locking.tmpl.

Sure, see:

http://tinyurl.com/c6fakc

> > Generally speaking we do not condone recursive locking
> > strategies -- and afaik reiserfs (as per the BKL) and the
> > network code (as per abusing rwlock_t unfairness) are the only
> > offenders.
> >
> > Like Linus stated, recursive locking is generally poor taste and
> > indicates you basically gave up on trying to find a proper
> > locking scheme. We should very much work towards getting rid of
> > these abberations instead of adding new ones.
>
> The people complaining about naming never seem to be the ones
> providing workable suggestions or patches.

The thing is, while you now have named your locking primitive
correctly, you are still abusing it by using it recursively.

So it's not 'just about naming'. You should not use read-locks as
recursive locks. It's poor code.

Ingo
--
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/