Received: by 10.213.65.68 with SMTP id h4csp466117imn; Tue, 13 Mar 2018 09:57:07 -0700 (PDT) X-Google-Smtp-Source: AG47ELs3B/G0aRoljmbqDr6a/KDrg6xLoq/DiAaRbgMcJPYty/gGsOBLcAszH+tBmxuz+WjdHH+1 X-Received: by 10.99.172.84 with SMTP id z20mr999432pgn.273.1520960227563; Tue, 13 Mar 2018 09:57:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1520960227; cv=none; d=google.com; s=arc-20160816; b=m/op9LcRRLHtKtska26sGY9FxEGhWlBNyGt2icMzqcC9U6ijJlz2a/Vn0Cv/7vhwE/ FYQOaYExF2E/oqD0ha0qe+/C+YKVQ8Uyh8O9iydvh3Ig9IAxGiWtI0ZsfurgQXhTUY7o gpBKHkWUicx8ZjSUqPniL6T1n8UhmdHbjsOGHxVOY81wA00rbr7lHEfX/lx79+Mloc6C p+332fwliVNRJLQjBCE9puq9G7tYq9m5cXnwyrHVnkE/mV+9whybMom+y07Ru/BUMLaQ qV9k+78S3kLixnWGbRUCttui8FHhSq948GQ/2hBFnKHS/Ia9nmaVZfrgjP3SWrg+YDXL Nrtw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :dkim-signature:arc-authentication-results; bh=5A76XVNSc5aYLCoUaOMgWT4Yy7mEK6lZfxvVj5XhqDo=; b=yvt+qugPOhwqYO90iRAUzbHhFypUrr448oOYR91H+81s56I+taiI0opeNcWLa+lGbM aoV8ncxZPFV3g428vU15X3v+pxvpAdaIghPRPrj17LDHDEy2Rr/LiRhgiND39KCuW86c DQxFaNYh109ycI+lb3S9ZGgdO8TE13rTjqn0AN5LKtfdeVriaQOfDBN2zai0wyYq7qpC ZZOp7F+pyuinVgK8BCaGcjBcqx7uuqqopyJQYx4tPAAw+gFKWIM8UA7h81XceHAYf1nf Pue8mN+wXKkUwjvXnF6KXDdaluazfdYYomtz4hrkPmiY/5aTUe4BFQc77YtZDDkhVH9J V4rg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=TqpZ/2YG; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id e127si276855pgc.170.2018.03.13.09.56.53; Tue, 13 Mar 2018 09:57:07 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=TqpZ/2YG; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933138AbeCMQzA (ORCPT + 99 others); Tue, 13 Mar 2018 12:55:00 -0400 Received: from mail-pg0-f67.google.com ([74.125.83.67]:33636 "EHLO mail-pg0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751903AbeCMQy5 (ORCPT ); Tue, 13 Mar 2018 12:54:57 -0400 Received: by mail-pg0-f67.google.com with SMTP id g12so121098pgs.0 for ; Tue, 13 Mar 2018 09:54:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=5A76XVNSc5aYLCoUaOMgWT4Yy7mEK6lZfxvVj5XhqDo=; b=TqpZ/2YGgZnRaBwXSc+EZwH0DT6Lc1e4297KCYW5X4V6TFLn+s1NWl6uvn14Xu3RvI FJ5xbuLq09xMTfJ3kFXQAqpyD8yWP0n8i2NMaOXucg75WTHKh94BCOpS6rgnZjerNZ05 Q3vIl7SPIKuuybHSqitvfcL7NSmC/z2F5cf6I6EO7dLeGhkiunUmR2vEsaYZiy3/x9wk GdvBRjEbR647nF1OCz/N5jvLpDjHTZKkQpr3TGlrwyUpatTI+YVi8T3K4Vx1VDkJOHWU ynQnFVThXibMNwlsCOgtr2jJmM7sKdmRdwfMHQupEp69jweNIrmbrRiAMWD/IQNhImfd jHSA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=5A76XVNSc5aYLCoUaOMgWT4Yy7mEK6lZfxvVj5XhqDo=; b=taPkylV2P5LXH0Buc2hKHmlL54ZVwkLIjmTQ9hRDZKc1LeMSPwYluDPM98D30ry24Q j082PGbn1kGtrd2/9qLLuHN7k6UPxbsUUpAqUTnP2du8Lq8ink7Aj4IKX/J9Uko3a3IK 4ewHuIVpH2QJWzDFWRn62HBXI+MmmRgHyUo88wuCwCOXb2IRKxBDjO8+GX9hXfQkV1SB SWRs/CV6SVLOHujIO3cSJke10z2aBYDmSYB7Z2nG5r6nOjLMnR2EcHADPs5A2Ipl1hpV 4K/3gt4n9qMWosCfJqONNdys0Ydq5tsUdb/+z37wK0TShXfxpIqxSVSG9jdJZlJ2i4xO qTQQ== X-Gm-Message-State: AElRT7HsvQAO/DaWIUCO0oogNWyssohMN+LvzRGXEegeetcNrIxvZgeI 9LN3RS/0rfrDpVu8T/UakER/kw== X-Received: by 10.99.124.92 with SMTP id l28mr1020792pgn.51.1520960096685; Tue, 13 Mar 2018 09:54:56 -0700 (PDT) Received: from shakeelb.mtv.corp.google.com ([2620:15c:2cb:201:3a5f:3a4f:fa44:6b63]) by smtp.gmail.com with ESMTPSA id u133sm1041176pgc.93.2018.03.13.09.54.54 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 13 Mar 2018 09:54:55 -0700 (PDT) From: Shakeel Butt To: Suleiman Souhlal , Greg Thelen , Andrew Morton , Christoph Lameter , Pekka Enberg , David Rientjes , Joonsoo Kim Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, Shakeel Butt Subject: [PATCH] slab, slub: remove size disparity on debug kernel Date: Tue, 13 Mar 2018 09:54:28 -0700 Message-Id: <20180313165428.58699-1-shakeelb@google.com> X-Mailer: git-send-email 2.16.2.660.g709887971b-goog Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org I have noticed on debug kernel with SLAB, the size of some non-root slabs were larger than their corresponding root slabs. e.g. for radix_tree_node: $cat /proc/slabinfo | grep radix name ... radix_tree_node 15052 15075 4096 1 1 ... $cat /cgroup/memory/temp/memory.kmem.slabinfo | grep radix name ... radix_tree_node 1581 158 4120 1 2 ... 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. This patch makes slab's object_size the default base to measure the slab's size. Signed-off-by: Shakeel Butt --- mm/slab_common.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/mm/slab_common.c b/mm/slab_common.c index e41cbc18c57d..61ab2ca8bea7 100644 --- a/mm/slab_common.c +++ b/mm/slab_common.c @@ -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, unsigned int usersize, void (*ctor)(void *), struct mem_cgroup *memcg, struct kmem_cache *root_cache) @@ -396,8 +396,7 @@ static struct kmem_cache *create_cache(const char *name, goto out; s->name = name; - s->object_size = object_size; - s->size = size; + s->size = s->object_size = object_size; s->align = align; s->ctor = ctor; s->useroffset = useroffset; @@ -503,7 +502,7 @@ kmem_cache_create_usercopy(const char *name, goto out_unlock; } - s = create_cache(cache_name, size, size, + s = create_cache(cache_name, size, calculate_alignment(flags, align, size), flags, useroffset, usersize, ctor, NULL, NULL); if (IS_ERR(s)) { @@ -650,7 +649,7 @@ void memcg_create_kmem_cache(struct mem_cgroup *memcg, goto out_unlock; s = create_cache(cache_name, root_cache->object_size, - root_cache->size, root_cache->align, + root_cache->align, root_cache->flags & CACHE_CREATE_MASK, root_cache->useroffset, root_cache->usersize, root_cache->ctor, memcg, root_cache); -- 2.16.2.660.g709887971b-goog