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 DEE3F280035; Sat, 1 Aug 2026 12:25:45 +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=1785587147; cv=none; b=rF9APQ3chrUgvlFYiPgdKfRLo0INPMJxJqu1TMJZtUgR7KryHDrd6gkze8LMHmUa3uBgr5NlbV//+i4qI2zQtTok48eM4PPRx8l+u0DJG/WqPVq+wvjmutj3vV2upAkyPa7x7NEiTvyyuuq7L6xyS36cRDndaQQ3wzUpGQJDuUM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785587147; c=relaxed/simple; bh=PR3me3Pq9mra7Mow3JXcUqquBDuQsrVeTSKm2iP3Ils=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=LAL+M5DE1BtQHTikeujk2FOtXtrzpNYVqbYLnDC0Cp3a+kniH4X8yH51O4RTfYzeawpFNqL0yBY0lnxuAfmQGP/cOfZNYh5LUKaPIQy7YvL7D7/iNUP0rSXYj125MUpCDIFXSNcqbaVtUOTNLSy1K9NXl1/rXKe2TFtFFb8n1Zo= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=RzOwbCuD; 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="RzOwbCuD" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6AD8B1F00AC4; Sat, 1 Aug 2026 12:25:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1785587145; bh=oCy5bIVtYQxaWyXI8Dl7cmjAZ6Z+ut7Uf+oQ6OT3GMU=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=RzOwbCuDSnCP913cQqRNIX5YpQ1FBuMuir92WwGtgL2MMHMBN03zq19hltowL6rTo 2coSPOwO4F21Ey6kPAMSl6fmWglrpAk+lgK0JbL59Um9Y4lVwHAV1Lc0AF1gNrAWyX J9EWAoZ/I3YVkXendqI1gGoXLn5b2u3dziNG6zH/b+FgVJkrzT8RITz9xRHDJp3wWH 0Oas6siKzXp7RMUbZiwu1AoAk9VMC6cnIaYi8PB86UtY30gb3Ketia+sWgcx2GriiU v5m86ov0+kx8KxnICb8rXPxAjsq9ehQ0MkzTm1dlcU8++KvszyjJSlDkGsF1kpl4W4 bLHkmhAwfOnLw== From: Harry Yoo To: Danielle Costantino , Shakeel Butt , Suren Baghdasaryan , Hao Ge , Vlastimil Babka , Harry Yoo , Andrew Morton , Hao Li , Christoph Lameter , David Rientjes , Roman Gushchin , Kees Cook , Pedro Falcato , "Liam R . Howlett" Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, stable@vger.kernel.org Subject: [7.1.y 2/3] lib/alloc_tag: introduce mem_alloc_profiling_permanently_disabled() Date: Sat, 1 Aug 2026 12:25:32 +0000 Message-ID: <20260801122533.319272-3-harry@kernel.org> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260801122533.319272-1-harry@kernel.org> References: <20260801122533.319272-1-harry@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit From: "Harry Yoo (Oracle)" commit a37b0066a10aabf3c968b4566706fb866eaf9a85 upstream. 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. Signed-off-by: Harry Yoo (Oracle) Acked-by: Suren Baghdasaryan Link: https://patch.msgid.link/20260713-kmalloc-no-objext-v3-3-47c7bd138de7@kernel.org Signed-off-by: Vlastimil Babka (SUSE) Signed-off-by: Harry Yoo --- 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 02de2ede560f..7e7cdc7612be 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 a9ab88f416b9..e3a923594604 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