From patchwork Tue Oct 24 13:46:06 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Suren Baghdasaryan X-Patchwork-Id: 13434578 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id E9A3AC25B48 for ; Tue, 24 Oct 2023 13:47:09 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 9E7476B0269; Tue, 24 Oct 2023 09:47:04 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 96F536B026A; Tue, 24 Oct 2023 09:47:04 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 79A246B026B; Tue, 24 Oct 2023 09:47:04 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id 5D22D6B0269 for ; Tue, 24 Oct 2023 09:47:04 -0400 (EDT) Received: from smtpin27.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id 333E41A093D for ; Tue, 24 Oct 2023 13:47:04 +0000 (UTC) X-FDA: 81380481168.27.88C5FCE Received: from mail-yw1-f201.google.com (mail-yw1-f201.google.com [209.85.128.201]) by imf28.hostedemail.com (Postfix) with ESMTP id 81978C0015 for ; Tue, 24 Oct 2023 13:47:02 +0000 (UTC) Authentication-Results: imf28.hostedemail.com; dkim=pass header.d=google.com header.s=20230601 header.b=d9biDiIg; spf=pass (imf28.hostedemail.com: domain of 31co3ZQYKCHoqspclZemmejc.amkjglsv-kkitYai.mpe@flex--surenb.bounces.google.com designates 209.85.128.201 as permitted sender) smtp.mailfrom=31co3ZQYKCHoqspclZemmejc.amkjglsv-kkitYai.mpe@flex--surenb.bounces.google.com; dmarc=pass (policy=reject) header.from=google.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1698155222; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=BlkdsRQXiDN3rg6CmmMqMbDupjvE+Qo4H/i7Q99VP7E=; b=4X3MqUG840xLzZ89IVUMoyj1N3Vibt8h2RXQ8srhAf63HM2jWejXd1f4EVu5l9ZZaSo63u AuSboxrDCisXJ5QNGOHkHN7lS2uPlr6uWTNACxdElqiwj4G28/iMcDbf3eYjvxK+nwIQnJ JNLP3ZpU7SlP2qnSpKMl7qD59qIG+6s= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1698155222; a=rsa-sha256; cv=none; b=uB4u46t06ZddjyM/NjGeZ77mbk6Z3HMVMLMZ0MDOs+F88oOZmatn9v0zyRyOqLG9rlvtMU 8GvcGBHoN46QJ/n5upUR8jFhm20X4ZeFYFvZLiE24KCET+rOZtTWhZGBhOX5a3l4UmlLzz ylwNhSJWUQsbvfZZmozdK0mGdpiSUV4= ARC-Authentication-Results: i=1; imf28.hostedemail.com; dkim=pass header.d=google.com header.s=20230601 header.b=d9biDiIg; spf=pass (imf28.hostedemail.com: domain of 31co3ZQYKCHoqspclZemmejc.amkjglsv-kkitYai.mpe@flex--surenb.bounces.google.com designates 209.85.128.201 as permitted sender) smtp.mailfrom=31co3ZQYKCHoqspclZemmejc.amkjglsv-kkitYai.mpe@flex--surenb.bounces.google.com; dmarc=pass (policy=reject) header.from=google.com Received: by mail-yw1-f201.google.com with SMTP id 00721157ae682-5a7b53a48e5so59332537b3.1 for ; Tue, 24 Oct 2023 06:47:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1698155221; x=1698760021; darn=kvack.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=BlkdsRQXiDN3rg6CmmMqMbDupjvE+Qo4H/i7Q99VP7E=; b=d9biDiIgURrh97vUF6hS51AyL9BGYBqpFnfutoG4qmyjwq+IMlp7nHHHquV4d+CktV 7LncsKLsuNR1hffFDbxmR8uJ3WwIJfZ/enpFodC73d1urIGfky14C6SSlOlZ9Wm4Ki8p oUyl7h6Qobc48yeTbj7V3cB84UqWe/f+0dtOU1oif67qgxd4A2SADqP/KnpJWODzgrAQ 0vak+63pwa4IdWNpSfPJQ4AY4bGcHZgovxmxgmajeLBFqVyUWg7dlkmgxSGnp7hJ1L4X PjpeI4sxbFatAvLVcA1DP9VrrU+/442PqrOzGiaVnrb6lTpyKPlCHdk4uitosKJpe2Cf ogUA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1698155221; x=1698760021; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=BlkdsRQXiDN3rg6CmmMqMbDupjvE+Qo4H/i7Q99VP7E=; b=WrspXN+g3PwNJP94a38bpenqHbcNQLiIu5ph1Ad93GkfEn9KEcwC2gTGPLog90PIrL zRZTwAIU+LQcQA+IndL2lnmoIiBClK2ir3Gw8d5iQ25nzNfKX9WiffA0nBsmvjuzud6l /fhfueMtyum1cGeRFzvEM7FFAOs8OOTvgJ5lUdSsKJxou5hpbqbeYzxaky0tVfqoSwtk X8SISP/YLIrInqiLkGZ1OLY+505ZJMrn612+7zx0c04sRb/P4WhI5tck6azXmWCKzNeb Pw/oya2/heeRQtYlsly/j7pVO1lt4q2IYVxkOexRaYcvQs3yBZL0MrTTDmxcoZLmpRDW nD2w== X-Gm-Message-State: AOJu0YxtvCASIH7YeioC78wHEzwQafztULrvmvVD5ZzvcGj2+qRnQygJ beGS1MZAm5ibk2cSxrXrXaRfDGNjDxM= X-Google-Smtp-Source: AGHT+IH4vkQmrXlidCVXKzYYty2ay4HPBInW5lCi3Eqpl3vZeKIQVqiJUvatNMDtWsMNHeDdaowbWxA4kC0= X-Received: from surenb-desktop.mtv.corp.google.com ([2620:15c:211:201:45ba:3318:d7a5:336a]) (user=surenb job=sendgmr) by 2002:a0d:d50f:0:b0:5a7:be3f:159f with SMTP id x15-20020a0dd50f000000b005a7be3f159fmr287305ywd.5.1698155221495; Tue, 24 Oct 2023 06:47:01 -0700 (PDT) Date: Tue, 24 Oct 2023 06:46:06 -0700 In-Reply-To: <20231024134637.3120277-1-surenb@google.com> Mime-Version: 1.0 References: <20231024134637.3120277-1-surenb@google.com> X-Mailer: git-send-email 2.42.0.758.gaed0368e0e-goog Message-ID: <20231024134637.3120277-10-surenb@google.com> Subject: [PATCH v2 09/39] mm/slab: introduce SLAB_NO_OBJ_EXT to avoid obj_ext creation From: Suren Baghdasaryan To: akpm@linux-foundation.org Cc: kent.overstreet@linux.dev, mhocko@suse.com, vbabka@suse.cz, hannes@cmpxchg.org, roman.gushchin@linux.dev, mgorman@suse.de, dave@stgolabs.net, willy@infradead.org, liam.howlett@oracle.com, corbet@lwn.net, void@manifault.com, peterz@infradead.org, juri.lelli@redhat.com, ldufour@linux.ibm.com, catalin.marinas@arm.com, will@kernel.org, arnd@arndb.de, tglx@linutronix.de, mingo@redhat.com, dave.hansen@linux.intel.com, x86@kernel.org, peterx@redhat.com, david@redhat.com, axboe@kernel.dk, mcgrof@kernel.org, masahiroy@kernel.org, nathan@kernel.org, dennis@kernel.org, tj@kernel.org, muchun.song@linux.dev, rppt@kernel.org, paulmck@kernel.org, pasha.tatashin@soleen.com, yosryahmed@google.com, yuzhao@google.com, dhowells@redhat.com, hughd@google.com, andreyknvl@gmail.com, keescook@chromium.org, ndesaulniers@google.com, vvvvvv@google.com, gregkh@linuxfoundation.org, ebiggers@google.com, ytcoode@gmail.com, vincent.guittot@linaro.org, dietmar.eggemann@arm.com, rostedt@goodmis.org, bsegall@google.com, bristot@redhat.com, vschneid@redhat.com, cl@linux.com, penberg@kernel.org, iamjoonsoo.kim@lge.com, 42.hyeyoo@gmail.com, glider@google.com, elver@google.com, dvyukov@google.com, shakeelb@google.com, songmuchun@bytedance.com, jbaron@akamai.com, rientjes@google.com, minchan@google.com, kaleshsingh@google.com, surenb@google.com, kernel-team@android.com, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, iommu@lists.linux.dev, linux-arch@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, linux-modules@vger.kernel.org, kasan-dev@googlegroups.com, cgroups@vger.kernel.org X-Stat-Signature: 9tmeheic9cfkyyaz4aickk1u4xogw54u X-Rspamd-Server: rspam10 X-Rspamd-Queue-Id: 81978C0015 X-Rspam-User: X-HE-Tag: 1698155222-209666 X-HE-Meta: U2FsdGVkX1//CQTXzd6O/ADxu+xatackh9VlyQWzPWXVFifDC/40P/tEuUa84QyGNoRBeHWFuAdCDeGhutPYdN/TJEqlEn4nJfEgts3OmX2dISphew3l0XODY2oTdS15Mgst87KlvEkJ6dfJ3HYGTEAedWhnzUvJM2pibNZmhAAb9r4t1VogEFNLVhLvNEub9dlGuGlpJf8CesE201z908utsTtweDWuMdP5qNpibiAEO9ITwRYynbFTdBcV37QAXQerzYnQ/7y2ggUz1mPfPydI/P9JW07wIqyFqHaR9tNAuCYFuyNr491qdgBjCcujynqibtt6fTvZ+0e1affHtHpZoydESoBR328ouhUWpKZM9MOzGN/qrNYTh7u99WPQBckq5qMh/64L7J4GOE2bLmGhcHRbEnOvQBfY8A1HRtckumh9ac5b7ZH3iX7WfdMZNm7NcVSKllHnzBmG9JXCh0j7kRuSNKqhpQkmMe1VLYME+JHPCo2Ia8VMohKCqTQXSjExagWaLhC3tbjPwLu1f3a4V4098tsNbTTJpwxhEBojM7l/zmoupyr4zm0FwCheAyJt3WwHWEIIHXAmnNjYcQBN4dqXOJsQuRuvaEOWCePw7SyOfRlaEV+UvCAzxOQveIZW3NlFqq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: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: Slab extension objects can't be allocated before slab infrastructure is initialized. Some caches, like kmem_cache and kmem_cache_node, are created before slab infrastructure is initialized. Objects from these caches can't have extension objects. Introduce SLAB_NO_OBJ_EXT slab flag to mark these caches and avoid creating extensions for objects allocated from these slabs. Signed-off-by: Suren Baghdasaryan --- include/linux/slab.h | 7 +++++++ mm/slab.c | 2 +- mm/slub.c | 5 +++-- 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/include/linux/slab.h b/include/linux/slab.h index 8228d1276a2f..11ef3d364b2b 100644 --- a/include/linux/slab.h +++ b/include/linux/slab.h @@ -164,6 +164,13 @@ #endif #define SLAB_TEMPORARY SLAB_RECLAIM_ACCOUNT /* Objects are short-lived */ +#ifdef CONFIG_SLAB_OBJ_EXT +/* Slab created using create_boot_cache */ +#define SLAB_NO_OBJ_EXT ((slab_flags_t __force)0x20000000U) +#else +#define SLAB_NO_OBJ_EXT 0 +#endif + /* * ZERO_SIZE_PTR will be returned for zero sized kmalloc requests. * diff --git a/mm/slab.c b/mm/slab.c index 9ad3d0f2d1a5..cefcb7499b6c 100644 --- a/mm/slab.c +++ b/mm/slab.c @@ -1232,7 +1232,7 @@ void __init kmem_cache_init(void) create_boot_cache(kmem_cache, "kmem_cache", offsetof(struct kmem_cache, node) + nr_node_ids * sizeof(struct kmem_cache_node *), - SLAB_HWCACHE_ALIGN, 0, 0); + SLAB_HWCACHE_ALIGN | SLAB_NO_OBJ_EXT, 0, 0); list_add(&kmem_cache->list, &slab_caches); slab_state = PARTIAL; diff --git a/mm/slub.c b/mm/slub.c index f7940048138c..d16643492320 100644 --- a/mm/slub.c +++ b/mm/slub.c @@ -5043,7 +5043,8 @@ void __init kmem_cache_init(void) node_set(node, slab_nodes); create_boot_cache(kmem_cache_node, "kmem_cache_node", - sizeof(struct kmem_cache_node), SLAB_HWCACHE_ALIGN, 0, 0); + sizeof(struct kmem_cache_node), + SLAB_HWCACHE_ALIGN | SLAB_NO_OBJ_EXT, 0, 0); hotplug_memory_notifier(slab_memory_callback, SLAB_CALLBACK_PRI); @@ -5053,7 +5054,7 @@ void __init kmem_cache_init(void) create_boot_cache(kmem_cache, "kmem_cache", offsetof(struct kmem_cache, node) + nr_node_ids * sizeof(struct kmem_cache_node *), - SLAB_HWCACHE_ALIGN, 0, 0); + SLAB_HWCACHE_ALIGN | SLAB_NO_OBJ_EXT, 0, 0); kmem_cache = bootstrap(&boot_kmem_cache); kmem_cache_node = bootstrap(&boot_kmem_cache_node);