From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id F3EA8606A31A for ; Tue, 1 Dec 2026 02:04:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=bombadil.20210309 header.b=0lHgXueZ; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=ZC+QFdnw DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From: Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Unsubscribe-Post: List-Owner; bh=SMA6Xlbveodyn9bPTTbuu49jg9xCZkI5eW6FA2/lhxI=; b=0lHgXueZNzL3M+ SCm1z+tk0JDIauw2b/4iGRPZaWqrZ3UE1kWNYdQscB0fjsvkqOlDuhr2PxMCXKAJkk5THxlmHAhzh Hb5bVum6+wIQ71/5AnrzAYrxGu4sA/eUEA0bVlf2Lm7kgPrwaL5pjSa7uB0KjMinEtGAYGvou5MrH lc9ZY3tpY/8Q7k2aObKqy+e0u10TwZzfnkUap6C+zmy0bk0hXnrSnMQYsSbekhJsnRqwr/Ht7ZsYZ HP4L9cSryWciHbvv0/n756XJHfG5c3HqJdoxncEIuWqyIKStB9KxrY81fj5BwJ0SWdu0myz266VLh NX9qumIZPDt33R3Y971A==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.100.1 #2 (Red Hat Linux)) id 1xYD49-00000006E7R-2z0g; Tue, 01 Dec 2026 01:53:57 +0000 Received: from mail-wm1-x32f.google.com ([2a00:1450:4864:20::32f]) by bombadil.infradead.org with esmtps (Exim 4.100.1 #2 (Red Hat Linux)) id 1xYD3C-00000006DGv-0wG3 for linux-arm-kernel@lists.infradead.org; Tue, 01 Dec 2026 01:53:00 +0000 Received: by mail-wm1-x32f.google.com with SMTP id 5b1f17b1804b1-4b79502c27aso111954655e9.1 for ; Mon, 30 Nov 2026 17:52:57 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20260707; t=1796089975; x=1796694775; darn=lists.infradead.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=SMA6Xlbveodyn9bPTTbuu49jg9xCZkI5eW6FA2/lhxI=; b=ZC+QFdnw9YirU+iwTzw2A3QbWLJ+KXBw3wCjiNRHmqvbaGOUYK0fhHg4/+zF3GdxRA 9J3hKa7GjwmUzMdILiKyqr7teChszjFkKyn0tv9a2aqC6stXToWPeGLeo2gmR97ntIjF 3gXKY1rd//0SrdhufqzGsNYjSwPWNkHV1FjwAA77hfXe7jFxK7e8HUKXBGrdxyqpDMSs 2YFWtYqG97gK3lmTDZEfNx902VEWTeM7P1uEwxwd2bmjhzkJ47L3ZpaXkZRelzOYzsuO TmorpSkzDAr4VqUVIZZjXdCpEkcEodbhaeUHt9j/AKQ3+xAh0WK5UPwXT/V5PFDDkHRf f6bg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796089975; x=1796694775; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=SMA6Xlbveodyn9bPTTbuu49jg9xCZkI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+ULNt8F38rAFbBgITQYaFNTvq/g6FdJaF2Vk56Z rus+jZHqrC0C3j0Z5lQcijEdLdVSr9VHUDD/rA== X-Received: by 2002:a05:600c:1d86:b0:4a1:fa27:df7c with SMTP id 5b1f17b1804b1-4bb88922972mr738326415e9.34.1796089975558; Mon, 30 Nov 2026 17:52:55 -0800 (PST) Received: from NULL.Home.net ([2001:8a0:7280:4000:12d:c3b9:cecc:8966]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4bb884911e3sm1199037055e9.6.2026.11.30.17.52.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 30 Nov 2026 17:52:54 -0800 (PST) From: Eric Curtin To: linux-arm-kernel@lists.infradead.org Cc: Ryan Roberts , David Hildenbrand , "Liam R. Howlett" , Vlastimil Babka , Mike Rapoport , Michal Hocko , Andrew Morton , linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [RFC PATCH v2 06/43] mm/vmstat: Use THREAD_SIZE_MAX for the KSTACK_* counters Date: Tue, 1 Dec 2026 01:51:38 +0000 Message-ID: <20261201015240.1017259-7-ericcurtin17@gmail.com> X-Mailer: git-send-email 2.56.1 In-Reply-To: <20261201015240.1017259-1-ericcurtin17@gmail.com> References: <20261201015240.1017259-1-ericcurtin17@gmail.com> X-Archived-By: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.9.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20261130_175258_304595_9EDDCAC1 X-CRM114-Status: GOOD ( 12.97 ) X-Spam-Score: -1.9 (-) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=4.0.1 X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-26) on aws-us-west-2-korg-listserv-alma10-1 From: Ryan Roberts THREAD_SIZE depends on PAGE_SIZE when boot-time page size selection is used, so it is not a compile-time constant and cannot be used in C preprocessor conditionals. Test THREAD_SIZE_MAX instead in the #if directives that decide which KSTACK_nK vm event items exist, in vm_event_item.h, vmstat_text[] in mm/vmstat.c, and kstack_histogram() in kernel/exit.c. With a smaller runtime THREAD_SIZE, the counters for sizes above it are still defined but simply never incremented. No functional change for compile-time page sizes. Signed-off-by: Ryan Roberts Signed-off-by: Eric Curtin (cherry picked from commit bf0856284bb664002b756e3785d35aa050d766c9) --- include/linux/vm_event_item.h | 14 +++++++------- kernel/exit.c | 14 +++++++------- mm/vmstat.c | 14 +++++++------- 3 files changed, 21 insertions(+), 21 deletions(-) diff --git a/include/linux/vm_event_item.h b/include/linux/vm_event_item.h index 2628ccda076a..d1bca28052ef 100644 --- a/include/linux/vm_event_item.h +++ b/include/linux/vm_event_item.h @@ -153,25 +153,25 @@ enum vm_event_item { PGPGIN, PGPGOUT, PSWPIN, PSWPOUT, #endif #ifdef CONFIG_DEBUG_STACK_USAGE KSTACK_1K, -#if THREAD_SIZE > 1024 +#if THREAD_SIZE_MAX > 1024 KSTACK_2K, #endif -#if THREAD_SIZE > 2048 +#if THREAD_SIZE_MAX > 2048 KSTACK_4K, #endif -#if THREAD_SIZE > 4096 +#if THREAD_SIZE_MAX > 4096 KSTACK_8K, #endif -#if THREAD_SIZE > 8192 +#if THREAD_SIZE_MAX > 8192 KSTACK_16K, #endif -#if THREAD_SIZE > 16384 +#if THREAD_SIZE_MAX > 16384 KSTACK_32K, #endif -#if THREAD_SIZE > 32768 +#if THREAD_SIZE_MAX > 32768 KSTACK_64K, #endif -#if THREAD_SIZE > 65536 +#if THREAD_SIZE_MAX > 65536 KSTACK_REST, #endif #endif /* CONFIG_DEBUG_STACK_USAGE */ diff --git a/kernel/exit.c b/kernel/exit.c index d5e7bc2af804..a8453363d1fd 100644 --- a/kernel/exit.c +++ b/kernel/exit.c @@ -813,31 +813,31 @@ static inline void kstack_histogram(unsigned long used_stack) #ifdef CONFIG_VM_EVENT_COUNTERS if (used_stack <= 1024) count_vm_event(KSTACK_1K); -#if THREAD_SIZE > 1024 +#if THREAD_SIZE_MAX > 1024 else if (used_stack <= 2048) count_vm_event(KSTACK_2K); #endif -#if THREAD_SIZE > 2048 +#if THREAD_SIZE_MAX > 2048 else if (used_stack <= 4096) count_vm_event(KSTACK_4K); #endif -#if THREAD_SIZE > 4096 +#if THREAD_SIZE_MAX > 4096 else if (used_stack <= 8192) count_vm_event(KSTACK_8K); #endif -#if THREAD_SIZE > 8192 +#if THREAD_SIZE_MAX > 8192 else if (used_stack <= 16384) count_vm_event(KSTACK_16K); #endif -#if THREAD_SIZE > 16384 +#if THREAD_SIZE_MAX > 16384 else if (used_stack <= 32768) count_vm_event(KSTACK_32K); #endif -#if THREAD_SIZE > 32768 +#if THREAD_SIZE_MAX > 32768 else if (used_stack <= 65536) count_vm_event(KSTACK_64K); #endif -#if THREAD_SIZE > 65536 +#if THREAD_SIZE_MAX > 65536 else count_vm_event(KSTACK_REST); #endif diff --git a/mm/vmstat.c b/mm/vmstat.c index c6beac6be2bc..248ab936410c 100644 --- a/mm/vmstat.c +++ b/mm/vmstat.c @@ -1481,25 +1481,25 @@ const char * const vmstat_text[] = { #endif #ifdef CONFIG_DEBUG_STACK_USAGE [I(KSTACK_1K)] = "kstack_1k", -#if THREAD_SIZE > 1024 +#if THREAD_SIZE_MAX > 1024 [I(KSTACK_2K)] = "kstack_2k", #endif -#if THREAD_SIZE > 2048 +#if THREAD_SIZE_MAX > 2048 [I(KSTACK_4K)] = "kstack_4k", #endif -#if THREAD_SIZE > 4096 +#if THREAD_SIZE_MAX > 4096 [I(KSTACK_8K)] = "kstack_8k", #endif -#if THREAD_SIZE > 8192 +#if THREAD_SIZE_MAX > 8192 [I(KSTACK_16K)] = "kstack_16k", #endif -#if THREAD_SIZE > 16384 +#if THREAD_SIZE_MAX > 16384 [I(KSTACK_32K)] = "kstack_32k", #endif -#if THREAD_SIZE > 32768 +#if THREAD_SIZE_MAX > 32768 [I(KSTACK_64K)] = "kstack_64k", #endif -#if THREAD_SIZE > 65536 +#if THREAD_SIZE_MAX > 65536 [I(KSTACK_REST)] = "kstack_rest", #endif #endif /* CONFIG_DEBUG_STACK_USAGE */