Messages in this thread Patch in this message | | | From | Andrey Ryabinin <> | Subject | [RFC/PATCH v2 04/10] mm: slub: introduce virt_to_obj function. | Date | Wed, 10 Sep 2014 18:31:21 +0400 |
| |
virt_to_obj takes kmem_cache address, address of slab page, address x pointing somewhere inside slab object, and returns address of the begging of object.
Signed-off-by: Andrey Ryabinin <a.ryabinin@samsung.com> --- mm/slab.h | 6 ++++++ 1 file changed, 6 insertions(+)
diff --git a/mm/slab.h b/mm/slab.h index 026e7c3..3e3a6ae 100644 --- a/mm/slab.h +++ b/mm/slab.h @@ -346,4 +346,10 @@ static inline struct kmem_cache_node *get_node(struct kmem_cache *s, int node) void *slab_next(struct seq_file *m, void *p, loff_t *pos); void slab_stop(struct seq_file *m, void *p); +static inline void *virt_to_obj(struct kmem_cache *s, void *slab_page, void *x) +{ + return x - ((x - slab_page) % s->size); +} + + #endif /* MM_SLAB_H */ -- 1.8.5.5
| |