slqb: introduce __kfree_rcu
PATCH 5/6 slqb: introduce __kfree_rcu
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.
---
mm/slqb.c +17 -0
@@ -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 ();
Quoted 6 lines · Lai Jiangshan
Introduce
__kfree_rcu()forkfree_rcu()It like
__kfree_rcu()inslab.c,slub.c
We can calculate the object poiter from a poiter inside this object inslqb.c, so we can use it for rcu callback and free the object.
s/poiter/pointer
(that typo is in other patches too.)
Ingo
Quoted 14 lines · Lai Jiangshan
Introduce
__kfree_rcu()forkfree_rcu()It like
__kfree_rcu()inslab.c,slub.c
We can calculate the object poiter from a poiter inside this object inslqb.c, so we can use it for rcu callback and free the object.Signed-off-by Lai Jiangshan <[email protected]>---
mm/slqb.c +0
-0
mm/slqb.c void kfree(const void *object) · line 2493
Quoted 10 lines
mm/slqb.c +7
-0@@ -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.
Quoted 18 lines
mm/slqb.c +10
-0+ +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 ();