Received: by 2002:ab2:788f:0:b0:1ee:8f2e:70ae with SMTP id b15csp77459lqi; Wed, 6 Mar 2024 10:27:47 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCUSzMfHlsvv22hZaUNAWKy2ZMBZhPS/tChSRhuh0XHSYF9jlsqUS3bQreaR9tMuxm/kR76u/VyOd8ybOyLtEyV8cEgCBpso9Dkcuh7wDw== X-Google-Smtp-Source: AGHT+IHgH2yfEkewz0yDuXhHk6qYLY123XiHsCV0elwPCRWFjWZTFkl2boTFLgyAC/fMKynplr1G X-Received: by 2002:a05:622a:1015:b0:42e:c87e:e8b7 with SMTP id d21-20020a05622a101500b0042ec87ee8b7mr6788524qte.16.1709749667227; Wed, 06 Mar 2024 10:27:47 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709749667; cv=pass; d=google.com; s=arc-20160816; b=zjrWkQIZehUZ92Hj+TLwmuPqsG1ptH1VqL7n47ImqZlx6xtN+Gn2QRxu/er7Tl+xwO 1a7J2CkAHcU5zxAmNW2Sl/hfI8YhRlQqVIhUcNca46ZNd6o+VIwAzD8qkD5/Ur+WooCB t4glKMJA9GHZknLDldd+t6MOk31gYb33o2KlEHgx8k3pouwXMXu2Zm6zdgGMRN2M6DcG 1Q62Cxhzgb+XJSJn8d3PBfckV2363qUi2mTFI22GFRKGwg8+6CTt9vIv4vA6zDi5O+kI 3AG696jrBSatkB6G8pOMKdzxzOmt2TylcM1lSHt3txQjjB0XZUMqybP3zfqo2aEf6USo sNWw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=cc:to:from:subject:message-id:references:mime-version :list-unsubscribe:list-subscribe:list-id:precedence:in-reply-to:date :dkim-signature; bh=MWCYv1v0m9ThdSU1Yjo1XvUgYihcegNMceRH273060M=; fh=7yPPJz9alrOCvh9yBMYjEFvgnlGkP7rQS62vCtTyW44=; b=n7kG/2qkdwlC4ZL+RxmtLuQV6Wy2CrmxVFclCVZzu2DwXxnh5fT0GKfSGw7oypv62u GL2A5er4+RyropsyKvh207vPLlXJk8no8ldLaPYMVKlDnxfImN+VzMWjbC47ESPOqUQp kN7PQlKnbq83KTXXpmh3UcMM2WDUj1U5Wrd+rjI/5u875CQS5jzbCN1H3Z7kQOwYQDdi dEmVudOlI05hi2RvhRpZ9rGLVj5fTVxgHTPx5AazNIjLTyiYjxew20ZGW5nwo/ADxHs6 2Fmym0tSd5iuNSQceTe5TC7KzlBqdbT6TmfUlI7Yw1v31e3MziRfwU/0WjzZK5o3acjI Mi0A==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=vdL50ccR; arc=pass (i=1 spf=pass spfdomain=flex--surenb.bounces.google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-94399-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-94399-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id ay17-20020a05622a229100b0042ef52c87b5si6729244qtb.200.2024.03.06.10.27.47 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Mar 2024 10:27:47 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-94399-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=vdL50ccR; arc=pass (i=1 spf=pass spfdomain=flex--surenb.bounces.google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-94399-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-94399-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id E0ADC1C212D5 for ; Wed, 6 Mar 2024 18:27:46 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id EDCFB14402F; Wed, 6 Mar 2024 18:25:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="vdL50ccR" Received: from mail-yb1-f201.google.com (mail-yb1-f201.google.com [209.85.219.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3EE5B143C6C for ; Wed, 6 Mar 2024 18:25:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709749505; cv=none; b=TCRiJt1xTyI6weTM0kvwY0FLU3Tdl6PkVccRD3Mzv2T0yNVSsO8VSxyE2c6lgaaFVQxdjiVHXP8YtYG/nE2+66R/oC6tUy2YxboVS05WuonKxR4CBuApxLv1cqZ7YAdeYd0nl+QAyxatV7+GEorqSd+qtAxEsnSIvd9KW7zgU+E= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709749505; c=relaxed/simple; bh=mR/WH4/rGc0Yxkm2oc530v0+CTDwReRkmqPn4EB+6Eg=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=WXr7x+imF2l58YHIYr0C4Qb5+128wZEyPj7dVSf4Qp2oJihWF6hzFZr8JsMy/Vb40PYjho902JJTt6e1D2VGUs7+sPFCLorK8Oc8biuxKTd7oWE18Qzgv9O1KmT3wo2c8FzPObMsRVpN9zAIw3MWS9RGdIqoWUoIKEs9z5a762s= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--surenb.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=vdL50ccR; arc=none smtp.client-ip=209.85.219.201 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--surenb.bounces.google.com Received: by mail-yb1-f201.google.com with SMTP id 3f1490d57ef6-dc6b5d1899eso1603111276.0 for ; Wed, 06 Mar 2024 10:25:03 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1709749502; x=1710354302; darn=vger.kernel.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=MWCYv1v0m9ThdSU1Yjo1XvUgYihcegNMceRH273060M=; b=vdL50ccRjoB/oXSJD6TM7743OkFzxKWggMNNZzSLtf+6y546eprVGJCSP35bl3yBE6 PcCwog/rDnwT3rUu6b96Y7Qe4XBxn5Dvd2ZGSFLoxDpcyuEOj6iMsTW8fBLxD74R/XMY ZNT6oLe/c/V0K0Vk5cByzUdscSQ2+ESkH0ZDRifQwcd5aWAvQfz1qAtkqrMjfi/pw4ym a71xL69B1tYy/I8hJ93m0hNjDl22vfh/JBiby030K24cCipE8A5fv02R72gQjbOJjxUD dhIfPOhjEAfM98A6cHvErycDFx1EGkybQgMntxw1A0QKFq4xZ4Mk47Ett1dxNE2aUs92 QQlg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709749502; x=1710354302; 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=MWCYv1v0m9ThdSU1Yjo1XvUgYihcegNMceRH273060M=; b=o0TOTpZdWtrfchmuyfw84n17E6poRyCdDr2YYWNT0dBhfiKYnBjiTRZNhJKm/1auhZ vR7UX5ykSxVW/tA/XDv3mgIXvvxKJJbG7kr8OfHqv+GaJEdZmp7S/q48Z8N7FaiA0O/W MaVGHhHkon9w9F916KqfUbcNFXBP2wp0Ryx8CylKrGIXgPfOng8TjP/UHg5q9E2LgtsP kVwEwu6/qMAyxImZGlQCT7dwpGywrsy5fAbS2RNSTJP/tNX5bgPkJVHE6i0Tr/oTfupu ZPiYCEhPhT7MsF5N662619iofMakTD61Qrrl62QsIWPtthT2jSt+X622VMBkbXvLnomq LXgQ== X-Forwarded-Encrypted: i=1; AJvYcCWKjRCAbxllY0SIxmgtOcM9c/bkGxrzBcgNtTzUzb2XNEC551AFbSdPzXHn83QLlGWcV8XvmwR9taPtl5cRBvqD70at1XtUIlEAmBmq X-Gm-Message-State: AOJu0YxTgV9dX5fpDqGhH0r148fReUHYGAtc099QkM7hZHbUG4J/X6/8 TYLNzoHs56YfZmSjtnUhH448sBqZ+gUsi2vhTaAHH7fQG8oHfCQVsJ9Yi8E00rcp2wXS0K9IDYD iJg== X-Received: from surenb-desktop.mtv.corp.google.com ([2620:15c:211:201:85f0:e3db:db05:85e2]) (user=surenb job=sendgmr) by 2002:a5b:54c:0:b0:dc7:5925:92d2 with SMTP id r12-20020a5b054c000000b00dc7592592d2mr1248065ybp.1.1709749502066; Wed, 06 Mar 2024 10:25:02 -0800 (PST) Date: Wed, 6 Mar 2024 10:24:06 -0800 In-Reply-To: <20240306182440.2003814-1-surenb@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20240306182440.2003814-1-surenb@google.com> X-Mailer: git-send-email 2.44.0.278.ge034bb2e1d-goog Message-ID: <20240306182440.2003814-9-surenb@google.com> Subject: [PATCH v5 08/37] 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, jhubbard@nvidia.com, 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, aliceryhl@google.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 Content-Type: text/plain; charset="UTF-8" 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 2ba5d7b2711d..e94d3cc1b270 100644 --- a/mm/slub.c +++ b/mm/slub.c @@ -5704,7 +5704,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); @@ -5714,7 +5715,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); -- 2.44.0.278.ge034bb2e1d-goog