From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pa0-f49.google.com (mail-pa0-f49.google.com [209.85.220.49]) by kanga.kvack.org (Postfix) with ESMTP id 4125F900014 for ; Mon, 27 Oct 2014 12:47:48 -0400 (EDT) Received: by mail-pa0-f49.google.com with SMTP id lj1so1679121pab.22 for ; Mon, 27 Oct 2014 09:47:47 -0700 (PDT) Received: from mailout3.w1.samsung.com (mailout3.w1.samsung.com. [210.118.77.13]) by mx.google.com with ESMTPS id wi2si10949580pab.92.2014.10.27.09.47.46 for (version=TLSv1 cipher=RC4-MD5 bits=128/128); Mon, 27 Oct 2014 09:47:47 -0700 (PDT) Received: from eucpsbgm1.samsung.com (unknown [203.254.199.244]) by mailout3.w1.samsung.com (Oracle Communications Messaging Server 7u4-24.01(7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTP id <0NE400KE144D31A0@mailout3.w1.samsung.com> for linux-mm@kvack.org; Mon, 27 Oct 2014 16:50:37 +0000 (GMT) From: Andrey Ryabinin Subject: [PATCH v5 06/12] mm: slub: introduce virt_to_obj function. Date: Mon, 27 Oct 2014 19:46:53 +0300 Message-id: <1414428419-17860-7-git-send-email-a.ryabinin@samsung.com> In-reply-to: <1414428419-17860-1-git-send-email-a.ryabinin@samsung.com> References: <1404905415-9046-1-git-send-email-a.ryabinin@samsung.com> <1414428419-17860-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.2 -- 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