From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1758978AbbA2XMh (ORCPT ); Thu, 29 Jan 2015 18:12:37 -0500 Received: from mail.linuxfoundation.org ([140.211.169.12]:59137 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1758806AbbA2XMf (ORCPT ); Thu, 29 Jan 2015 18:12:35 -0500 Date: Thu, 29 Jan 2015 15:12:34 -0800 From: Andrew Morton To: Andrey Ryabinin Cc: linux-kernel@vger.kernel.org, Dmitry Vyukov , Konstantin Serebryany , Dmitry Chernenkov , Andrey Konovalov , Yuri Gribov , Konstantin Khlebnikov , Sasha Levin , Christoph Lameter , Joonsoo Kim , Dave Hansen , Andi Kleen , x86@kernel.org, linux-mm@kvack.org, Pekka Enberg , David Rientjes Subject: Re: [PATCH v10 04/17] mm: slub: introduce virt_to_obj function. Message-Id: <20150129151234.a94bea44ae34bc90dcd148b0@linux-foundation.org> In-Reply-To: <1422544321-24232-5-git-send-email-a.ryabinin@samsung.com> References: <1404905415-9046-1-git-send-email-a.ryabinin@samsung.com> <1422544321-24232-1-git-send-email-a.ryabinin@samsung.com> <1422544321-24232-5-git-send-email-a.ryabinin@samsung.com> X-Mailer: Sylpheed 3.4.1 (GTK+ 2.24.23; x86_64-pc-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, 29 Jan 2015 18:11:48 +0300 Andrey Ryabinin wrote: > 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. "beginning" The above text may as well be placed into slub_def.h as a comment. > Signed-off-by: Andrey Ryabinin > Acked-by: Christoph Lameter > --- > 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 9abf04e..eca3883 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); > +} "const void *x" would be better.