From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pd0-f180.google.com (mail-pd0-f180.google.com [209.85.192.180]) by kanga.kvack.org (Postfix) with ESMTP id D45AD6B00CD for ; Mon, 24 Nov 2014 13:02:48 -0500 (EST) Received: by mail-pd0-f180.google.com with SMTP id p10so10201402pdj.11 for ; Mon, 24 Nov 2014 10:02:48 -0800 (PST) Received: from mailout4.w1.samsung.com (mailout4.w1.samsung.com. [210.118.77.14]) by mx.google.com with ESMTPS id kj8si22569609pdb.175.2014.11.24.10.02.45 for (version=TLSv1 cipher=RC4-MD5 bits=128/128); Mon, 24 Nov 2014 10:02:46 -0800 (PST) Received: from eucpsbgm2.samsung.com (unknown [203.254.199.245]) by mailout4.w1.samsung.com (Oracle Communications Messaging Server 7u4-24.01(7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTP id <0NFK001LC291MD00@mailout4.w1.samsung.com> for linux-mm@kvack.org; Mon, 24 Nov 2014 18:05:25 +0000 (GMT) From: Andrey Ryabinin Subject: [PATCH v7 05/12] mm: slub: introduce virt_to_obj function. Date: Mon, 24 Nov 2014 21:02:18 +0300 Message-id: <1416852146-9781-6-git-send-email-a.ryabinin@samsung.com> In-reply-to: <1416852146-9781-1-git-send-email-a.ryabinin@samsung.com> References: <1404905415-9046-1-git-send-email-a.ryabinin@samsung.com> <1416852146-9781-1-git-send-email-a.ryabinin@samsung.com> Sender: owner-linux-mm@kvack.org List-ID: To: Andrew Morton Cc: Andrey Ryabinin , Dmitry Vyukov , Konstantin Serebryany , Dmitry Chernenkov , Andrey Konovalov , Yuri Gribov , Konstantin Khlebnikov , Sasha Levin , Christoph Lameter , Joonsoo Kim , Dave Hansen , Andi Kleen , Vegard Nossum , "H. Peter Anvin" , Dave Jones , x86@kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.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 --- include/linux/slub_def.h | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/include/linux/slub_def.h b/include/linux/slub_def.h index d82abd4..c75bc1d 100644 --- a/include/linux/slub_def.h +++ b/include/linux/slub_def.h @@ -110,4 +110,9 @@ static inline void sysfs_slab_remove(struct kmem_cache *s) } #endif +static inline void *virt_to_obj(struct kmem_cache *s, void *slab_page, void *x) +{ + return x - ((x - slab_page) % s->size); +} + #endif /* _LINUX_SLUB_DEF_H */ -- 2.1.3 -- 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