Re: [PATCH -mm 5/6] slqb: introduce __kfree_rcu

From: Pekka Enberg
Date: Mon Mar 23 2009 - 03:55:22 EST


On Tue, 2009-03-03 at 21:44 +0800, Lai Jiangshan wrote:
> Introduce __kfree_rcu() for kfree_rcu()
>
> It like __kfree_rcu() in slab.c, slub.c
> We can calculate the object poiter from a poiter inside this
> object in slqb.c, so we can use it for rcu callback and free
> the object.
>
> Signed-off-by: Lai Jiangshan <laijs@xxxxxxxxxxxxxx>
> ---
> diff --git a/mm/slqb.c b/mm/slqb.c
> index 48bdf3b..c258ddc 100644
> --- a/mm/slqb.c
> +++ b/mm/slqb.c
> @@ -2482,6 +2484,23 @@ void kfree(const void *object)
> }
> EXPORT_SYMBOL(kfree);
>
> +static void kfree_rcu_callback(struct rcu_head *rcu)
> +{
> + void *portion = rcu;
> + struct slqb_page *page = virt_to_head_slqb_page(portion);
> + struct kmem_cache *s = page->list->cache;
> + unsigned int index = (portion - page->s_mem) / s->size;
> + void *object = page->s_mem + s->size * index;

Basically the same nit as with the other patches as well: please
separate variable declarations from the initializations for readability.

> +
> + slab_free(s, page, object);
> +}
> +
> +void __kfree_rcu(const void *objp, struct rcu_head *rcu)
> +{
> + call_rcu(rcu, kfree_rcu_callback);
> +}
> +EXPORT_SYMBOL(__kfree_rcu);
> +
> static void kmem_cache_trim_percpu(void *arg)
> {
> int cpu = smp_processor_id();
>
>
>
>
>

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