Received: by 2002:ab2:6857:0:b0:1ef:ffd0:ce49 with SMTP id l23csp596570lqp; Thu, 21 Mar 2024 09:48:02 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWQEm3YCl6pCkZo9NA9SwH2/56olK10FTCpBad+Wuw/UBY/B/ybpvA/9bWjl0FNQIiPXyFfIuQHR4xyDytDa7zzTNjptfwNQzX3SNU58Q== X-Google-Smtp-Source: AGHT+IF9JaB+dKmm8yt7WceYDbOOi89Kybh2augi9B4OxebJcvrt8W6EX/iEforNsPPbTIq2Jx4J X-Received: by 2002:a17:906:16ce:b0:a46:fabc:aacf with SMTP id t14-20020a17090616ce00b00a46fabcaacfmr2947561ejd.7.1711039682393; Thu, 21 Mar 2024 09:48:02 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1711039682; cv=pass; d=google.com; s=arc-20160816; b=lCBqDJWOVniqgqQCUNK6ePwapPyKtJttGVcj6DRUBk8w9ErF3lh3chQEfzO67gHLlO 7vNIj0al3YmwsX7BZbcOWh85ScZc88ZdpfHlkuAdvQJWwsaUtx9OGAve+05ppdF2K8H6 cbGTp1iTItxUiQebCjvNpCOxeJAsBME/KU/HNpatArE1VmajU9UH62dFYPSun7jLxxdN 8mOvFrAfWeY/3XtUIX52fe87C1mYxxMEyTIJ5bzqG9b7EmRgew16pcCW+fOzPaAyq0fA xhtM8gyrCxEY4PPR4vcRMbG6T4S0eftT1ppEzexhkXX1tMhrDIGHC5PPWh3tqq3rnbhR a2Gw== 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=SHSiwfbVG9SSjDRWdVOT6ZUhatpmkb8bIc+SfDPMGsQ=; fh=0jTTYBf40nbyuEmItfoO1uyvCGaw5ZSea4vhcinYBA0=; b=XgREz6ktnGmkjCXx1T5JO6ULRCF+kvImH812LMbYYWKEm+AzfU/TqdWPAUh3n6e6T9 8E2g8EQvtkkiKKB+JDtBkz5iW2NiTxbNOdB7nghLcqmT2V2fuMatxlkYewhla/uW8vsY rNyJ9YwzkHoEo1XBvOnEcARsvfFk6eOGmkDjcuOi1l531YAkZzHrgQMKWgGMrt2IBvLv m9CESBDalqSMCuIs8RZjBcBBOAc8ykRDgV0L4uWev8LXEGwkoguRedIVFJqfwvpzJbHB VmLKQvAZz6nqMBNRtv3D3OvKIKskMdEVjrHLnOVmmEtM2vDjWWxzUDlD5oBosO+foZS1 o12A==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=zJ2BUltC; 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-110362-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-110362-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id l17-20020a1709060cd100b00a443be8cd2asi95639ejh.209.2024.03.21.09.48.02 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 Mar 2024 09:48:02 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-110362-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=zJ2BUltC; 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-110362-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-110362-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 am.mirrors.kernel.org (Postfix) with ESMTPS id 3698C1F24EF8 for ; Thu, 21 Mar 2024 16:40:36 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id A1D7913541B; Thu, 21 Mar 2024 16:37:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="zJ2BUltC" Received: from mail-yw1-f201.google.com (mail-yw1-f201.google.com [209.85.128.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 3F6331350CD for ; Thu, 21 Mar 2024 16:37:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711039050; cv=none; b=FpIjDcLY21uSOs679NXyIvk3CdZ8bJT9tcNLL5CR0/1x5EiQ/iapqFsN3yjb1GkV9wHwATX6LgkQHDDLySuDgR5DLgTlEveXRNE6mMpDPJd8ERUpVG/wNoEeaE/qeFO6M4nKkTH/lEOdby+qZtfCp0DGN+/G8faDwgzIX9+Fhus= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711039050; c=relaxed/simple; bh=asIGq+p6AxXY7sp0t9UK+2zZ/r825IxMduiccQ5trR4=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=cUI5Jn/do4h5emzta9sqFGfdad2hOZWRtEseqj1/PV4rwr839NeF9oV09+gg4PUP3r0N7hD82lyT6TnpCP26uUy6IIZU0lovr5IFon9wKk7TF1pkkV+m7oJDAOUtisGEUrttyQ8qFYvt4Pm8sqd3TVh4J20nTTDyQjdsaG/iapc= 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=zJ2BUltC; arc=none smtp.client-ip=209.85.128.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-yw1-f201.google.com with SMTP id 00721157ae682-60cbba6f571so21982407b3.1 for ; Thu, 21 Mar 2024 09:37:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1711039047; x=1711643847; 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=SHSiwfbVG9SSjDRWdVOT6ZUhatpmkb8bIc+SfDPMGsQ=; b=zJ2BUltCVbrGki07q11jmQ1yfTwvNYYx65fFGH8MsDwEm1Z4p+ojlooUDcZxCvld1v xJAj0QfibxpCRtc4xP5ZpUlmftZ3b8TDD69xmFAg46ol33FTHGG6HKeibigW/cCCLb11 VKXW3KXb1pm4hdEv85MrIcQsRN15Hmr3E/ZKdl/cyIor4XI7ziakLrC2nGo9o0thE+1z j/bEkb8kQ9pGyds5Qwf3OE8Q/1zgypiMLTkIPFWp4Wnifyytxfk+aNntJVWKx1fczrIq YMVGyI7IMhCGXiqFkamoMGS49qmmGMVn+BxkWRQ35qXzGySt694exclTLQuJA3P7vWMj i66w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1711039047; x=1711643847; 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=SHSiwfbVG9SSjDRWdVOT6ZUhatpmkb8bIc+SfDPMGsQ=; b=boxQh8BcLbXmYTZVJ13QnbbvVTruufXm/W3iH9zf2ImVcpntmcmkU9QWddjA1tSjs3 dlgw9iS2Weaa/8ZhtyISdv+NgyXpirwlfI9NTOPUJVQW29JrrYKOVz+39qCFy1oUQ2o3 ub+YRKOOti9itvlQxYV8RUl4TdeaIK4SgUFtBAfwRzJcF0G800GGQkTLDRQS/Ah6EQv3 dAyACtomJGVyKt3P4mJ4YVZEnmpTcIqWB6U6JiqjOyozdXByyCX1N+8PDXRqeNfBHUBk 3H9+lRPTAUPg7u9exLLhCiZZuwBJBtNN+tn69Njt1ILqs9jJ014Hq70ZFY+s3ysRB9Jq fpjw== X-Forwarded-Encrypted: i=1; AJvYcCUxNNu7lY+wSSjfG1eNo6LqkRVyuf+n34AnQ+87rc0uHpY2ExgvDB2l742bTBNyY16uBfdrAWahVV7q3tkVsT96vq2e2THR2cuofyii X-Gm-Message-State: AOJu0YzlMyF2HFoelYH2fDpe9yJBQc0/iegSTsEstCUcqQ5dah4VPfmD WyuOJQc2S6pL8+zydtcTnO+8JdsaP8aZEpePNLj/1NPTUjW8pKTqdbyPpK0EMF6la4U26Wzo0q1 WoQ== X-Received: from surenb-desktop.mtv.corp.google.com ([2620:15c:211:201:a489:6433:be5d:e639]) (user=surenb job=sendgmr) by 2002:a05:690c:d0b:b0:610:e0de:1387 with SMTP id cn11-20020a05690c0d0b00b00610e0de1387mr2235869ywb.2.1711039047349; Thu, 21 Mar 2024 09:37:27 -0700 (PDT) Date: Thu, 21 Mar 2024 09:36:30 -0700 In-Reply-To: <20240321163705.3067592-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: <20240321163705.3067592-1-surenb@google.com> X-Mailer: git-send-email 2.44.0.291.gc1ea87d7ee-goog Message-ID: <20240321163705.3067592-9-surenb@google.com> Subject: [PATCH v6 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, 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 | 10 ++++++++++ mm/slub.c | 5 +++-- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/include/linux/slab.h b/include/linux/slab.h index e53cbfa18325..68ff754b85a4 100644 --- a/include/linux/slab.h +++ b/include/linux/slab.h @@ -56,6 +56,9 @@ enum _slab_flag_bits { #endif _SLAB_OBJECT_POISON, _SLAB_CMPXCHG_DOUBLE, +#ifdef CONFIG_SLAB_OBJ_EXT + _SLAB_NO_OBJ_EXT, +#endif _SLAB_FLAGS_LAST_BIT }; @@ -202,6 +205,13 @@ enum _slab_flag_bits { #endif #define SLAB_TEMPORARY SLAB_RECLAIM_ACCOUNT /* Objects are short-lived */ +/* Slab created using create_boot_cache */ +#ifdef CONFIG_SLAB_OBJ_EXT +#define SLAB_NO_OBJ_EXT __SLAB_FLAG_BIT(_SLAB_NO_OBJ_EXT) +#else +#define SLAB_NO_OBJ_EXT __SLAB_FLAG_UNUSED +#endif + /* * ZERO_SIZE_PTR will be returned for zero sized kmalloc requests. * diff --git a/mm/slub.c b/mm/slub.c index 2cb53642a091..666dcc3b8a26 100644 --- a/mm/slub.c +++ b/mm/slub.c @@ -5693,7 +5693,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); @@ -5703,7 +5704,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.291.gc1ea87d7ee-goog