From patchwork Wed Feb 21 19:40:22 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Suren Baghdasaryan X-Patchwork-Id: 13566189 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 84720C5478A for ; Wed, 21 Feb 2024 19:41:24 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 9AC4F6B009B; Wed, 21 Feb 2024 14:41:19 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 935436B009C; Wed, 21 Feb 2024 14:41:19 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 7637E6B009D; Wed, 21 Feb 2024 14:41:19 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id 5846E6B009B for ; Wed, 21 Feb 2024 14:41:19 -0500 (EST) Received: from smtpin10.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 3FC801C0776 for ; Wed, 21 Feb 2024 19:41:19 +0000 (UTC) X-FDA: 81816829878.10.E4CE025 Received: from mail-yb1-f201.google.com (mail-yb1-f201.google.com [209.85.219.201]) by imf10.hostedemail.com (Postfix) with ESMTP id 70449C0011 for ; Wed, 21 Feb 2024 19:41:17 +0000 (UTC) Authentication-Results: imf10.hostedemail.com; dkim=pass header.d=google.com header.s=20230601 header.b=kRyPKlmM; dmarc=pass (policy=reject) header.from=google.com; spf=pass (imf10.hostedemail.com: domain of 33FHWZQYKCA8796t2qv33v0t.r310x29C-11zAprz.36v@flex--surenb.bounces.google.com designates 209.85.219.201 as permitted sender) smtp.mailfrom=33FHWZQYKCA8796t2qv33v0t.r310x29C-11zAprz.36v@flex--surenb.bounces.google.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1708544477; 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=zEkUZGmdT8FEHHQk8lZ544d0po9Jm+ENmRP2MkpUgMM=; b=bpAGAyPgr1maj6f5Su89djNO/ze9z/iqZK7+4FoLchqqU5+XPwU1a7MDoGOV6iQZN0Qs9C GuXLRsj7gqiRW/J6LY3dTDKzkRkHkbQsw40PmCTAo/dJPEtaNvOVcWCs0u3sjueDSOCHI/ MgvN21CZn4MTjU9duwz/9QLxTUOh8W4= ARC-Authentication-Results: i=1; imf10.hostedemail.com; dkim=pass header.d=google.com header.s=20230601 header.b=kRyPKlmM; dmarc=pass (policy=reject) header.from=google.com; spf=pass (imf10.hostedemail.com: domain of 33FHWZQYKCA8796t2qv33v0t.r310x29C-11zAprz.36v@flex--surenb.bounces.google.com designates 209.85.219.201 as permitted sender) smtp.mailfrom=33FHWZQYKCA8796t2qv33v0t.r310x29C-11zAprz.36v@flex--surenb.bounces.google.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1708544477; a=rsa-sha256; cv=none; b=oJpdk+juhUmfD0hNdnk1TGA8sIQ10INk4cWHWDB3x0tsJXNVnPEG2DAOaekF1ARuzkrODO U5gCWPNKaqefKtErm+j6sNNyLEGZoCFATw5e4b7kBTrl3a2SCWrCzeJxzneZxt1WkG+TbN OdllbumuNckJBdFJGMzhbeK0spM4FhY= Received: by mail-yb1-f201.google.com with SMTP id 3f1490d57ef6-dced704f17cso3554141276.1 for ; Wed, 21 Feb 2024 11:41:17 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1708544476; x=1709149276; 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=zEkUZGmdT8FEHHQk8lZ544d0po9Jm+ENmRP2MkpUgMM=; b=kRyPKlmMApLzp4YAh8avbwulFmKTfA/EnixXKYn4IBQHTk5+cfrmrhcMXxl7ZIhLv6 2PiHKvp/esVZeNFeIBMYNzY6tdi0ynIi+pyf0Jty8I/WyLBpIeswTZzU2DTFvQ8ct8Wj GN2S5HAb+t+w4tUkbq7EfXHl71CPKKg/KbTpnVau/+nG8bmUJWWx4CrE1LA1CmHqCG9m Hnh95T2pOdi7rgD+QgGEvLienVfDz/toR3dDKbWMA1iGn5JEvVfkE5R+ZPgZWEaT0w+N /7LkHjxI3TFEly7bgsrGYRzlc4kpAJ0U68FrIanvjZJd59FP1+pFPiCoekbsBDXd0vzy wRYw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708544476; x=1709149276; 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=zEkUZGmdT8FEHHQk8lZ544d0po9Jm+ENmRP2MkpUgMM=; b=PiOTgOLPUIfmfL+TGLv5eF/1F9rOuRqRnvNXu46hgjCOEBZFhDg9oIXwc/KrVMdBry it2lRFg47pnFJEd8C9W0a5PryUFBWG60SRux7/P3vrHRUgnBEzZtc345aPvVpqvrTFqF EDbdyIPY/SlxtBu8u08KH34N7GpQQKMxqTsAcA+OfLTuQS9ScE5w5MB96eGG1orUpgAp KggesuVclBK1CEB1WN/g0K8UGYZw74dEdsyy/JZmA8imKbTGqsDIWeHo9lHZbGsKeU+G BzaqrT8cxGzF8j/35mDuKYIhzwQ0FwE3PmAFLyia+TXXbjh0OHsXTiQpFJojG0UxKqS1 Bo9w== X-Forwarded-Encrypted: i=1; AJvYcCV4ktwuDx35ZOFOIaYFe/h64lNnxIZYqhwWU/JWv0whVy47wxn/ufptgwSc3h7O8tq2pso7YuAZKHVgC8E2oDJDpoE= X-Gm-Message-State: AOJu0YwkYakVdQhWNiEfwUi2kq/gRtOkIdaTqmtFPAci/TRuBreZBjIu JeyJvuBwyKnaLwEXYa1nx4nlypcpbDE54xQg8qTnsgbBe3rnI44IewscAKKjEWiPqjCdXPOJ9Sv vqg== X-Google-Smtp-Source: AGHT+IGFqZQMKrIKQYeCMZ0dyCYxCh2jZRWMkTdBUYYdfqnWgxWQSfzS1xjoTphhPvwCFL+Ef45OR+v8sww= X-Received: from surenb-desktop.mtv.corp.google.com ([2620:15c:211:201:953b:9a4e:1e10:3f07]) (user=surenb job=sendgmr) by 2002:a25:26cf:0:b0:dcc:41ad:fb3b with SMTP id m198-20020a2526cf000000b00dcc41adfb3bmr6923ybm.10.1708544476345; Wed, 21 Feb 2024 11:41:16 -0800 (PST) Date: Wed, 21 Feb 2024 11:40:22 -0800 In-Reply-To: <20240221194052.927623-1-surenb@google.com> Mime-Version: 1.0 References: <20240221194052.927623-1-surenb@google.com> X-Mailer: git-send-email 2.44.0.rc0.258.g7320e95886-goog Message-ID: <20240221194052.927623-10-surenb@google.com> Subject: [PATCH v4 09/36] 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, penguin-kernel@i-love.sakura.ne.jp, corbet@lwn.net, void@manifault.com, peterz@infradead.org, juri.lelli@redhat.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-Rspamd-Queue-Id: 70449C0011 X-Rspam-User: X-Rspamd-Server: rspam04 X-Stat-Signature: f8a8ijsr3oqu1n8kgcbcnbnt9b3q87wy X-HE-Tag: 1708544477-998720 X-HE-Meta: U2FsdGVkX1/Y2eZJ2UfKO1dG5hihH0jfwfg/46HslHKCfJki375V4wwIpgNJguWjYQy43nlJOOhcT1RXrjYIRDBrF2BYsgnMMVuwV+jN/KUFxwyswMpOWyuqjrOoFRdmyjzfHuwvFOmhHExks5kYvjya2laj0uFaTURIyRkP8TCa4s+69E2g9CBuRo8ahDvwOza8E5Ai+A275RvEDCeeFZEdpoUU08nNYY0Fnda/egJlyLuwSLgOPbLCYGYWiTRJh+w/yFLXo1QQg4VQBrwye8KmbtaW8Z3mbokwmWS0IE++GnXonIgky/cXpnAsxQMLZFepkcfVxPdTlL/N7hV6r8aOG+0PeuKawUpJ+JA9I8zwAmoM8n7+VLWPl8o6frvCBwFwH0tuq2SDYStK1npr2vVbWp2YhIWGxKuIVhoZHIklldQ/F20OwaoR38Brxk20p8AmtbRPC4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1I4KEVR5JhPiyVp12ESxDTzzkzjADWicvI6lNUsDcSm4geFl5h4XxNcYDle7Q29mDWt1i+gPzGs/88J9RtW/xnzxLRq1Xe0oCjAS66GD1Gqy5MvQKFObdx7+LluzO/012oUKmu7qsdC7XDczFmIeOvRDpotVAK2m8+TvbcqCv+o2SNs9DBnn4f86OTP9ZxG/hatlAn3aOdjs0raI2aupKRVwFAE4MsHbfXEpSmIoPa0G/19fmRj8ORHIdg== X-Bogosity: 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 Reviewed-by: Kees Cook Reviewed-by: Pasha Tatashin Reviewed-by: Vlastimil Babka --- include/linux/slab.h | 6 ++++++ mm/slub.c | 5 +++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/include/linux/slab.h b/include/linux/slab.h index b5f5ee8308d0..58794043ab5b 100644 --- a/include/linux/slab.h +++ b/include/linux/slab.h @@ -28,6 +28,12 @@ */ /* DEBUG: Perform (expensive) checks on alloc/free */ #define SLAB_CONSISTENCY_CHECKS ((slab_flags_t __force)0x00000100U) +/* Slab created using create_boot_cache */ +#ifdef CONFIG_SLAB_OBJ_EXT +#define SLAB_NO_OBJ_EXT ((slab_flags_t __force)0x00000200U) +#else +#define SLAB_NO_OBJ_EXT 0 +#endif /* DEBUG: Red zone objs in a cache */ #define SLAB_RED_ZONE ((slab_flags_t __force)0x00000400U) /* DEBUG: Poison objects */ diff --git a/mm/slub.c b/mm/slub.c index ca803b2949fc..5dc7beda6c0d 100644 --- a/mm/slub.c +++ b/mm/slub.c @@ -5697,7 +5697,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); @@ -5707,7 +5708,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);