From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796221326; b=r9Trbtrx9bmMI5rDtzV8IOXvcgjGN7AzfvY1SSYAUhPBL+kgWOuoC12mxATciTL2r6dz X2S7+5VjvewxgRWxQY515f84lTwYI55Hm6/kAOFb9uHYZkLvxGCcWUKejAeOo9tf4uW1v cEus2QlcXieyqR4Y0fA6OqKijH0Oq5H9cbZPY0+VCzA8PclOy/IIfhU43HrzuTGcI8NYx 3NDKJ6gG7WY19p4YheY4OKAFBiG/XE/Erjo4WxeipvTancuSAp2f8/XUWemzavJfoN+G9 0ntRoPedG5HU+gMRLP6xV0iqkUXPEzOT24VdOxpzJDIcVu0L5SZ7PzBVsEQuA4ctCHg== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796221326; h=Received:DKIM-Signature:Subject:To:Cc:From:Date:Message-ID: MIME-Version:Content-Type:Content-Transfer-Encoding; bh=bxUmM3WuGfXv21HHg7pMfPXu+RNEibAIKyERBXFKHVI=; b=h1OVtNAVv3ff5+nVZ9Rxf+I/45rrr84HRbnKKZV1JKjbwTt+gWiv+nxpsDzzy0WzF3/I Z94fxP6SX31uZ0HZ3Hky+up1uYzWed2IHyk+EkCjkptProt1ia47Skxq8xyzB9IIDpsH0 z7xMccueLV59gZHvJMcIdfVz9ySaioWA30PBuBXenjyrmm0xPLzDH69nvJWmrHW03syZj cmldq7TctVtHnw8bUf7r15z/pFQYTn99rAMC1xP/c1RKEdA63MruQX/h4UXXfmlo0l/o8 t84dnRzdFQjurZIbhucvoaIPfzjEEccRksprZuBkPoBmXh/8m0rRlRTOEnhI92YkT7A== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=Ong7LEU8; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 94BE5606A32C for ; Wed, 2 Dec 2026 14:22:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=Ong7LEU8 Received: by smtp.kernel.org (Postfix) with ESMTPSA id EA5EE1F00896; Wed, 2 Dec 2026 14:22:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1796221326; bh=bxUmM3WuGfXv21HHg7pMfPXu+RNEibAIKyERBXFKHVI=; h=Subject:To:Cc:From:Date; b=Ong7LEU8fYgHgiOms/cZ3cMx5hT/DztzItW0OEoRZAp8pEebIkv6rt1k4lhW7euc1 wz/aczWvvJb78xlztNGJvlcwIHp4vRfFp2I+V2i0tlxLthd7HUFuAMEXc95KhKEse7 npOPlTBEk+mgKL9cawb5Td7ZjcOwH+wUe5U+BE7k= Subject: FAILED: patch "[PATCH] ring-buffer: Do not check si_mem_available() before deferred" failed to apply to 6.18-stable tree To: amachhiw@linux.ibm.com,msuchanek@suse.de,rostedt@goodmis.org,vdonnefort@google.com Cc: From: Date: Wed, 02 Dec 2026 14:40:15 +0100 Message-ID: <2026120215-snazzy-reflector-835e@gregkh> X-Mailing-List: stable@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The patch below does not apply to the 6.18-stable tree. If someone wants it applied there, or to any other stable or longterm tree, then please email the backport, including the original git commit id to . To reproduce the conflict and resubmit, you may use the following commands: git fetch https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/ linux-6.18.y git checkout FETCH_HEAD git cherry-pick -x abf7185109d3986c1f945641d2fb20e44527f7c6 # git commit -s git send-email --to '' --in-reply-to '2026120215-snazzy-reflector-835e@gregkh' --subject-prefix 'PATCH 6.18.y' 'HEAD^..' Possible dependencies: thanks, greg k-h ------------------ original commit in Linus's tree ------------------ >From abf7185109d3986c1f945641d2fb20e44527f7c6 Mon Sep 17 00:00:00 2001 From: Amit Machhiwal Date: Thu, 19 Nov 2026 00:02:35 +0530 Subject: [PATCH] ring-buffer: Do not check si_mem_available() before deferred init completes MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit With CONFIG_DEFERRED_STRUCT_PAGE_INIT=y, only about one memory section per node is initialized early in boot (16 MiB on powerpc). The rest is initialized on demand by deferred_grow_zone() when an allocation would otherwise fail, or later by page_alloc_init_late(). Until then NR_FREE_PAGES can be close to zero, because early allocations (SLUB, vmalloc, ftrace records) use up the first section. si_mem_available() is derived from NR_FREE_PAGES, so it under-reports. __rb_allocate_pages() returns -ENOMEM when si_mem_available() is below the requested size. This check wrongly fails the buffers allocated for the boot CPU in early_trace_init() and for secondary CPUs in smp_init(), both of which run before page_alloc_init_late(). The resulting boot log shows: ERROR: Failed to allocate trace buffer ERROR: tracer: failed to allocate ring buffer! Skip the check until SYSTEM_FREEING_INITMEM on CONFIG_DEFERRED_STRUCT_PAGE_INIT kernels. The allocation itself still fails if memory really is short. This is the second half of the fix for the early boot crash reported on ppc64le KVM guests. Commit b3b974008388 ("tracing: Do not initialize tracefs work if tracing is disabled") stopped the NULL pointer dereference in __find_event_file() that followed the failed allocation. This patch fixes the allocation failure itself. Cc: stable@vger.kernel.org Fixes: 2a872fa4e9c8 ("ring-buffer: Check if memory is available before allocation") Link: https://patch.msgid.link/20261118183235.63310-1-amachhiw@linux.ibm.com Reported-by: Michal Suchánek Closes: https://lore.kernel.org/all/arYskzbiaNzBR9MD@kunlun.suse.cz/ Reviewed-by: Vincent Donnefort Signed-off-by: Amit Machhiwal Signed-off-by: Steven Rostedt diff --git a/kernel/trace/ring_buffer.c b/kernel/trace/ring_buffer.c index 0a1c7f98159e..a5a0adc934fa 100644 --- a/kernel/trace/ring_buffer.c +++ b/kernel/trace/ring_buffer.c @@ -2468,8 +2468,17 @@ static int __rb_allocate_pages(struct ring_buffer_per_cpu *cpu_buffer, * memory. It may not be accurate. But we don't care, we just want * to prevent doing any allocation when it is obvious that it is * not going to succeed. + * + * With CONFIG_DEFERRED_STRUCT_PAGE_INIT, si_mem_available() + * will reflect the actual available memory only after + * SYSTEM_FREEING_INITMEM. */ - i = si_mem_available(); + if (IS_ENABLED(CONFIG_DEFERRED_STRUCT_PAGE_INIT) && + unlikely(system_state < SYSTEM_FREEING_INITMEM)) + i = LONG_MAX; + else + i = si_mem_available(); + if (i < (nr_pages << subbuf_order)) return -ENOMEM;