Re: [PATCH V4 1/1] rcu: introduce kfree_rcu()

Arnd Bergmann
2011-03-15T12:02:40Z

On Tuesday 15 March 2011, Paul E. McKenney wrote:
> > Another alternative might be to encode the difference between a
> > function pointer and an offset in one of the lower bits of the address.
>
> We discussed this some time back, and it turned out that there were
> CPUs that could legitimately have any combination of low-order bits
> set -- functions could start at any byte address.
>
> If this has changed, I would prefer to use the low-order bits, but
> if it has not, we can't. :-(

Ok, I see.

I just had another idea, which may or may not have new problems:

static inline void *kzalloc_rcu(size_t len, gfp_t flags)
{
struct rcu_head *head = kzalloc(len + sizeof (struct rcu_head), flags);
return head + 1;
}

void __kfree_rcu(struct rcu_head *head)
{
kfree(head);
}

static inline void kfree_rcu(void *p)
{
struct rcu_head *head = p - sizeof (struct rcu_head);
call_rcu(head, __kfree_rcu);
}

The only disadvantage I can see right now is that it messes
with the alignment of the structure.

Arnd