diff options
| author | Amit Machhiwal <amachhiw@linux.ibm.com> | 2026-11-19 00:02:35 +0530 |
|---|---|---|
| committer | Steven Rostedt <rostedt@goodmis.org> | 2026-11-20 10:02:38 -0500 |
| commit | abf7185109d3986c1f945641d2fb20e44527f7c6 (patch) | |
| tree | 86ebd251cbd62bc114c84cc27235e19700d7b8a2 /rust/kernel/alloc | |
| parent | 761a77e09577bc7e5fdaff1d11bbff3486a87bf9 (diff) | |
ring-buffer: Do not check si_mem_available() before deferred init completes
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 <msuchanek@suse.de>
Closes: https://lore.kernel.org/all/arYskzbiaNzBR9MD@kunlun.suse.cz/
Reviewed-by: Vincent Donnefort <vdonnefort@google.com>
Signed-off-by: Amit Machhiwal <amachhiw@linux.ibm.com>
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
Diffstat (limited to 'rust/kernel/alloc')
0 files changed, 0 insertions, 0 deletions
