From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pd0-f174.google.com (mail-pd0-f174.google.com [209.85.192.174]) by kanga.kvack.org (Postfix) with ESMTP id 5478D6B003B for ; Wed, 10 Sep 2014 10:38:36 -0400 (EDT) Received: by mail-pd0-f174.google.com with SMTP id v10so11317188pde.19 for ; Wed, 10 Sep 2014 07:38:36 -0700 (PDT) Received: from mailout2.w1.samsung.com (mailout2.w1.samsung.com. [210.118.77.12]) by mx.google.com with ESMTPS id ba9si12734453pdb.146.2014.09.10.07.38.34 for (version=TLSv1 cipher=RC4-MD5 bits=128/128); Wed, 10 Sep 2014 07:38:35 -0700 (PDT) Received: from eucpsbgm1.samsung.com (unknown [203.254.199.244]) by mailout2.w1.samsung.com (Oracle Communications Messaging Server 7u4-24.01(7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTP id <0NBO005M4WSYAY90@mailout2.w1.samsung.com> for linux-mm@kvack.org; Wed, 10 Sep 2014 15:41:22 +0100 (BST) 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 Message-id: <1410359487-31938-5-git-send-email-a.ryabinin@samsung.com> In-reply-to: <1410359487-31938-1-git-send-email-a.ryabinin@samsung.com> References: <1404905415-9046-1-git-send-email-a.ryabinin@samsung.com> <1410359487-31938-1-git-send-email-a.ryabinin@samsung.com> Sender: owner-linux-mm@kvack.org List-ID: To: linux-kernel@vger.kernel.org Cc: Andrey Ryabinin , Dmitry Vyukov , Konstantin Serebryany , Dmitry Chernenkov , Andrey Konovalov , Yuri Gribov , Konstantin Khlebnikov , Sasha Levin , Christoph Lameter , Joonsoo Kim , Andrew Morton , Dave Hansen , Andi Kleen , Vegard Nossum , "H. Peter Anvin" , x86@kernel.org, linux-mm@kvack.org, Pekka Enberg , David Rientjes 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 --- 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 -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to majordomo@kvack.org. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: email@kvack.org