Re: [PATCH 02/36] scsi,rcu: convert call_rcu(fc_rport_free_rcu) tokfree_rcu()
From: Paul E. McKenney
Date: Wed Mar 23 2011 - 18:25:15 EST
On Wed, Mar 23, 2011 at 09:05:51AM -0500, James Bottomley wrote:
> On Tue, 2011-03-22 at 23:50 -0700, Paul E. McKenney wrote:
> > The kfree_rcu() definition is as
> > follows:
> > #define kfree_rcu(ptr, rcu_head) \
> > __kfree_rcu(&((ptr)->rcu_head), offsetof(typeof(*(ptr)), rcu_head))
> Isn't this one of those cases where the obvious use of the interface is
> definitely wrong?
> It's also another nasty pseudo C prototype. I know we do this sort of
> thing for container_of et al, but I don't really think we want to extend
> Why not make the interface take a pointer to the embedding structure and
> one to the rcu_head ... that way all pointer mathematics can be
> contained inside the RCU routines.
If you pass in a pair of pointers, then it is difficult for RCU to detect
bugs where the two pointers are unrelated. Yes, you can do some sanity
checks, but these get cumbersome and have corner cases where they can
be fooled. In contrast, Lai's interface allows the compiler to do the
needed type checking -- unless the second argument is a field of type
struct rcu_head in the structure pointed to by the first argument, the
compiler will complain.
Either way, the pointer mathematics are buried in the RCU API.
Or am I missing something here?
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/