* [PATCH -mm 5/6] slqb: introduce __kfree_rcu
@ 2009-03-03 13:44 Lai Jiangshan
2009-03-03 14:07 ` Ingo Molnar
2009-03-23 7:54 ` Pekka Enberg
0 siblings, 2 replies; 3+ messages in thread
From: Lai Jiangshan @ 2009-03-03 13:44 UTC (permalink / raw)
To: Andrew Morton
Cc: Pekka Enberg, Christoph Lameter, Nick Piggin, Paul E. McKenney,
Manfred Spraul, Ingo Molnar, Peter Zijlstra, linux-kernel
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@cn.fujitsu.com>
---
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;
+
+ 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();
^ permalink raw reply related [flat|nested] 3+ messages in thread* Re: [PATCH -mm 5/6] slqb: introduce __kfree_rcu
2009-03-03 13:44 [PATCH -mm 5/6] slqb: introduce __kfree_rcu Lai Jiangshan
@ 2009-03-03 14:07 ` Ingo Molnar
2009-03-23 7:54 ` Pekka Enberg
1 sibling, 0 replies; 3+ messages in thread
From: Ingo Molnar @ 2009-03-03 14:07 UTC (permalink / raw)
To: Lai Jiangshan
Cc: Andrew Morton, Pekka Enberg, Christoph Lameter, Nick Piggin,
Paul E. McKenney, Manfred Spraul, Peter Zijlstra, linux-kernel
* Lai Jiangshan <laijs@cn.fujitsu.com> 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.
s/poiter/pointer
(that typo is in other patches too.)
Ingo
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH -mm 5/6] slqb: introduce __kfree_rcu
2009-03-03 13:44 [PATCH -mm 5/6] slqb: introduce __kfree_rcu Lai Jiangshan
2009-03-03 14:07 ` Ingo Molnar
@ 2009-03-23 7:54 ` Pekka Enberg
1 sibling, 0 replies; 3+ messages in thread
From: Pekka Enberg @ 2009-03-23 7:54 UTC (permalink / raw)
To: Lai Jiangshan
Cc: Andrew Morton, Christoph Lameter, Nick Piggin, Paul E. McKenney,
Manfred Spraul, Ingo Molnar, Peter Zijlstra, linux-kernel
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@cn.fujitsu.com>
> ---
> 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();
>
>
>
>
>
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2009-03-23 7:55 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-03-03 13:44 [PATCH -mm 5/6] slqb: introduce __kfree_rcu Lai Jiangshan
2009-03-03 14:07 ` Ingo Molnar
2009-03-23 7:54 ` Pekka Enberg
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.