Re: [PATCH v2] netlink: Replace rhash_portid with bound

From: Herbert Xu
Date: Wed Sep 23 2015 - 22:55:08 EST


On Wed, Sep 23, 2015 at 10:46:08PM -0400, Tejun Heo wrote:
>
> Hmm... It looks like I'm failing at communicating. Lemme try again.
> There are two situations where we do this.
>
> 1. When there are different locking contexts. In this case, the write
> path is. It's already protected by the spinlock so the barrier
> isn't necessary.
>
> 2. When the path is hot enough for the cost of smp_rmb() to matter and
> the specifics of individual deref allows for micro optimization and
> justifies the added overhead in terms of increased fragility,
> complexity and need for documentation.
>
> In both cases, we want to make reasonable trade-offs like any other
> choices we make. We don't go off and run to one extreme or the other
> just because barriers are involved. One good measure to use is
> whether the extra documentation necessary is justifiable. In this
> case, on each unprotected derefs, we want to explain why the
> unprotected deref is okay and justified.

What I am concerned about is the next guy who comes along and
does a rewrite like the one that introduced the netlink_bind
bug. That person needs to fully understand what each primitive
is protecting against.

Using primitives where they're not needed can lead to misunderstandings
which may end up causing bugs.

Honestly I don't care whether you have a barrier there or not as
I only use x86. But you very much should add a comment at least
saying that the barrier isn't needed for the cases where I left it
out so that future developers don't get confused.

Cheers,
--
Email: Herbert Xu <herbert@xxxxxxxxxxxxxxxxxxx>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
--
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/