From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pd0-f179.google.com (mail-pd0-f179.google.com [209.85.192.179]) by kanga.kvack.org (Postfix) with ESMTP id C0C9A6B0082 for ; Mon, 6 Oct 2014 12:01:27 -0400 (EDT) Received: by mail-pd0-f179.google.com with SMTP id r10so3442221pdi.24 for ; Mon, 06 Oct 2014 09:01:27 -0700 (PDT) Received: from mailout1.w1.samsung.com (mailout1.w1.samsung.com. [210.118.77.11]) by mx.google.com with ESMTPS id ra6si13690350pab.43.2014.10.06.09.01.25 for (version=TLSv1 cipher=RC4-MD5 bits=128/128); Mon, 06 Oct 2014 09:01:26 -0700 (PDT) Received: from eucpsbgm2.samsung.com (unknown [203.254.199.245]) by mailout1.w1.samsung.com (Oracle Communications Messaging Server 7u4-24.01(7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTP id <0ND100IUN5Z6KT50@mailout1.w1.samsung.com> for linux-mm@kvack.org; Mon, 06 Oct 2014 17:04:18 +0100 (BST) From: Andrey Ryabinin Subject: [PATCH v4 06/13] mm: slub: introduce virt_to_obj function. Date: Mon, 06 Oct 2014 19:54:00 +0400 Message-id: <1412610847-27671-7-git-send-email-a.ryabinin@samsung.com> In-reply-to: <1412610847-27671-1-git-send-email-a.ryabinin@samsung.com> References: <1404905415-9046-1-git-send-email-a.ryabinin@samsung.com> <1412610847-27671-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" , Dave Jones , 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 --- 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