From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753214AbeCNInf (ORCPT ); Wed, 14 Mar 2018 04:43:35 -0400 Received: from mail-lf0-f67.google.com ([209.85.215.67]:35980 "EHLO mail-lf0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751228AbeCNInd (ORCPT ); Wed, 14 Mar 2018 04:43:33 -0400 X-Google-Smtp-Source: AG47ELsR6Lu2lttZyUeukgIv5KXuCu9rm1ehkKk+56rmvZLucibi/HaLRniPhOzhby5jt/9xUxWrZg== Date: Wed, 14 Mar 2018 11:43:29 +0300 From: Vladimir Davydov To: Shakeel Butt Cc: Christopher Lameter , Suleiman Souhlal , Greg Thelen , Andrew Morton , Pekka Enberg , David Rientjes , Joonsoo Kim , Linux MM , LKML Subject: Re: [PATCH] slab, slub: remove size disparity on debug kernel Message-ID: <20180314084329.y7735ecw2is5i5pd@esperanza> References: <20180313165428.58699-1-shakeelb@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Mar 13, 2018 at 10:36:52AM -0700, Shakeel Butt wrote: > On Tue, Mar 13, 2018 at 10:19 AM, Christopher Lameter wrote: > > On Tue, 13 Mar 2018, Shakeel Butt wrote: > > > >> However for SLUB in debug kernel, the sizes were same. On further > >> inspection it is found that SLUB always use kmem_cache.object_size to > >> measure the kmem_cache.size while SLAB use the given kmem_cache.size. In > >> the debug kernel the slab's size can be larger than its object_size. > >> Thus in the creation of non-root slab, the SLAB uses the root's size as > >> base to calculate the non-root slab's size and thus non-root slab's size > >> can be larger than the root slab's size. For SLUB, the non-root slab's > >> size is measured based on the root's object_size and thus the size will > >> remain same for root and non-root slab. > > > > Note that the object_size and size may differ for SLUB based on kernel > > parameters and slab configuration. For SLAB these are compilation options. > > > > Thanks for the explanation. > > >> @@ -379,7 +379,7 @@ struct kmem_cache *find_mergeable(unsigned int size, unsigned int align, > >> } > >> > >> static struct kmem_cache *create_cache(const char *name, > >> - unsigned int object_size, unsigned int size, unsigned int align, > >> + unsigned int object_size, unsigned int align, > >> slab_flags_t flags, unsigned int useroffset, > > > > Why was both the size and object_size passed during cache creation in the > > first place? From the flags etc the slab logic should be able to compute > > the actual bytes required for each object and its metadata. > > > > +Vladimir > > I think it was introduced by 794b1248be4e7 ("memcg, slab: separate > memcg vs root cache creation paths") but I could not find out the > reason. This was a mistake - I missed that __kmem_cache_create() overwrites kmem_cache->size. Thanks for fixing this.