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

From: Arnd Bergmann
Date: Tue Mar 15 2011 - 08:02:43 EST


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