From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 12D1F43747E for ; Mon, 13 Jul 2026 14:29:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783952956; cv=none; b=RtRyLwhEn649ZAiMDe57U11s5ztao59FIwlusgKfz4wUbIBR7QbEhiWtrnBcayQjSnSLkmUFo2yLagusmA4d07U3JO/MB77JCEwPW+ECxPzX7pLZ3bAzQY1t21sxaiIFw6n7ftH4oidc7rR9k7aB1Ms5F7V8dPlev7UnB0RuIPw= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783952956; c=relaxed/simple; bh=SVjaGVBQ6fVJ7TeOg7nz4OYxhsCIprN42ZdttG5AMUU=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=h3aP41NdbAYE0dfEEkRzPPwn7VA3zx53v5FkeirxG5CN4xM/7GodUaIDP2rFsaec+TmXSpnlP04uxVbv7jeqn7pSJx7B3MCQDQVLKJYkl4OJw4a1m9B+7zSJCoO8MNrrvTkgHRBlfBL21pgt29fG7eJunEJKuakhapMAjQ6Foco= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=LEQmqES1; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="LEQmqES1" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 768411F00A3A; Mon, 13 Jul 2026 14:29:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1783952955; bh=1wi/OOk6iyYw3fd8OIurB+6r9k/Y8S3vhngrBwnEdq4=; h=From:Date:Subject:References:In-Reply-To:To:Cc; b=LEQmqES12IM7BZYGacYv5CkjZGspMkqnLIom6M+NjntyYlJdl+QmrQSBCnIMDwraJ HIkc/SfwOyoxNJY3jNzXF2rIJPxUqe5gzty/+ey68UhtmgvthyIRA8PhjTWWvIMk+5 DHaVAiTwOGrDO57KH3f62eALuJeGz6lIICfiuxD6gKWFHIsBt0QYs0Rh9bYPVrY3Xj XWBcsfYxfAGSm2a03xVW9WGQg5c+rp7XJUVbdfUETtHhg8DKhF3q+IYLYTOj1QMJhh /3/gUfgw/r76Vh+cVLREKvrG+Dx6C7FYdaeBz4deKREOInQgxxcV4QOnfrBOcE6I6r DGfbRxALVxyDw== From: "Harry Yoo (Oracle)" Date: Mon, 13 Jul 2026 23:28:51 +0900 Subject: [PATCH slab/for-next-fixes v3 3/4] lib/alloc_tag: introduce mem_alloc_profiling_permanently_disabled() Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <20260713-kmalloc-no-objext-v3-3-47c7bd138de7@kernel.org> References: <20260713-kmalloc-no-objext-v3-0-47c7bd138de7@kernel.org> In-Reply-To: <20260713-kmalloc-no-objext-v3-0-47c7bd138de7@kernel.org> To: Vlastimil Babka , Harry Yoo , Andrew Morton , Hao Li , Christoph Lameter , David Rientjes , Roman Gushchin , "Liam R. Howlett" , Suren Baghdasaryan , Hao Ge , Kees Cook , Pedro Falcato , Shakeel Butt , Danielle Constantino Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org X-Mailer: b4 0.14.3 mem_alloc_profiling_enabled() tells whether memalloc profiling is currently enabled. However, even when this function returns false, it can be enabled later. However, this is not enough. Some optimizations can be applied only when memalloc profiling is permanently disabled. For example, to skip the creation of KMALLOC_NO_OBJ_EXT caches at boot time, mem_profiling must be set to "never", "0" w/ debugging on, or have been shutdown so that it can no longer be enabled. Introduce mem_alloc_profiling_permanently_disabled() for this purpose. Fixes: 4b8736964640 ("mm/slab: add allocation accounting into slab allocation and free paths") Cc: stable@vger.kernel.org Signed-off-by: Harry Yoo (Oracle) --- include/linux/alloc_tag.h | 3 +++ lib/alloc_tag.c | 9 +++++++++ 2 files changed, 12 insertions(+) diff --git a/include/linux/alloc_tag.h b/include/linux/alloc_tag.h index 068ba2e77c5d..6ed9f82e639f 100644 --- a/include/linux/alloc_tag.h +++ b/include/linux/alloc_tag.h @@ -134,6 +134,8 @@ static inline bool mem_alloc_profiling_enabled(void) &mem_alloc_profiling_key); } +bool mem_alloc_profiling_permanently_disabled(void); + static inline struct alloc_tag_counters alloc_tag_read(struct alloc_tag *tag) { struct alloc_tag_counters v = { 0, 0 }; @@ -239,6 +241,7 @@ static inline bool alloc_tag_is_inaccurate(struct alloc_tag *tag) #define DEFINE_ALLOC_TAG(_alloc_tag) static inline bool mem_alloc_profiling_enabled(void) { return false; } +static inline bool mem_alloc_profiling_permanently_disabled(void) { return true; } static inline void alloc_tag_add(union codetag_ref *ref, struct alloc_tag *tag, size_t bytes) {} static inline void alloc_tag_sub(union codetag_ref *ref, size_t bytes) {} diff --git a/lib/alloc_tag.c b/lib/alloc_tag.c index d9be1cf5187d..e5b218176c5a 100644 --- a/lib/alloc_tag.c +++ b/lib/alloc_tag.c @@ -26,6 +26,15 @@ static bool mem_profiling_support = true; static bool mem_profiling_support; #endif +/* + * Memory allocation profiling is permanently disabled and cannot be enabled. + * Must be called after setup_early_mem_profiling(). + */ +bool mem_alloc_profiling_permanently_disabled(void) +{ + return !mem_profiling_support; +} + static struct codetag_type *alloc_tag_cttype; #ifdef CONFIG_ARCH_MODULE_NEEDS_WEAK_PER_CPU -- 2.53.0