From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 09F1818C33 for ; Sat, 21 Feb 2026 08:52:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1771663963; cv=none; b=uPviFxOGFk9NFuUTnki6iIUGkpCAG6IZMcpOvcZ3aTXniVxO9w1PjA0yX+d7zMX0XXZzZnpuiHLejO2qN3zBkwwCoLRMloTOiP2QlmK6w+JPucLZ2awxUDXBfQLfCAy5bOdrLTYvoUYrxjB+ZJyKYvtoom/ivv/Q66XuQ6daagI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1771663963; c=relaxed/simple; bh=LVxpq5LSIJt0tx8mSURpoTHZALrogPMRrn+LIjNyQno=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=qXhaOrmk1CaBDq7IAVkUsqZN4Af9O3x05Xqv8ISJll+/ZTAOpmVyk3XIZG2wMJEkQOYxBVw7xhTI5AUUTDEW5Q9ZbgoobLNj++Ovdg33AJBvilsztZ1pM4cJT4AmXZKgvED12JtWKW20xq7LSXXLjOTN7scFH3fmCH4dERAiV+I= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=NzhTaumS; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="NzhTaumS" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0598CC4CEF7; Sat, 21 Feb 2026 08:52:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1771663962; bh=LVxpq5LSIJt0tx8mSURpoTHZALrogPMRrn+LIjNyQno=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=NzhTaumSzl77yt0uRhsXCatJgbXXp8qZkaYbO8lqPNQAJPW4eHHoFRQeN1eN3//NS /0ApTf4179bNiEoojPbuhM3EhTkhsu41x6qQvowOFkRSU8AvQSliW8OOZBEk81W26j RXdLikfGLHewb9Go3BBPS8CjPT32bxZVqP7qbYDgJU5cYGe2vgIeqacYUjWelflctX nRd+6WWblveZ1FKEwfFhEs9nLRy0dZBAMkVO2bsbYhfViXqiqdAICBlJTYeW7Bs0PZ /cwSpyeqAKeHxgepBqvgGmq7/uZSO8L9JISZEV5OgAgDcdQzulc2eFkgUiravYwH6l ZI+xL+VTGXuIQ== Date: Sat, 21 Feb 2026 10:52:36 +0200 From: Mike Rapoport To: "Guilherme G. Piccoli" Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, kernel-dev@igalia.com, kernel@gpiccoli.net, Andrew Morton , Steven Rostedt Subject: Re: [PATCH 2/2] mm/memblock: Add reserve_mem debugfs info Message-ID: References: <20260217195816.861684-1-gpiccoli@igalia.com> <20260217195816.861684-3-gpiccoli@igalia.com> 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=us-ascii Content-Disposition: inline In-Reply-To: <20260217195816.861684-3-gpiccoli@igalia.com> On Tue, Feb 17, 2026 at 04:45:07PM -0300, Guilherme G. Piccoli wrote: > When using the "reserve_mem" parameter, users aim at having an > area that (hopefully) persists across boots, so pstore infrastructure > (like ramoops module) can make use of that to save oops/ftrace logs, > for example. > > There is no easy way to determine if this kernel parameter is properly > set though; the kernel doesn't show information about this memory in > memblock debugfs, neither in /proc/iomem (like unused memory "set" using > "mem=") nor in the kernel log (like the "crashkernel" parameter does). > > Add here a new file under memblock debugfs showing properly set memory > reservations, with name, address and size as passed to "reserve_mem". > > Notice this addition makes the memblock folder *always available* under > debugfs, regardless of ARCH_KEEP_MEMBLOCK and even if there is no > "reserve_mem=" setting in the command-line. > > Cc: Andrew Morton > Cc: Mike Rapoport > Cc: Steven Rostedt > Signed-off-by: Guilherme G. Piccoli > --- > mm/memblock.c | 37 +++++++++++++++++++++++++++++++++++-- > 1 file changed, 35 insertions(+), 2 deletions(-) > > diff --git a/mm/memblock.c b/mm/memblock.c > index 2d2646f7a120..58439de0a59b 100644 > --- a/mm/memblock.c > +++ b/mm/memblock.c > @@ -18,6 +18,10 @@ > #include > #include > > +#ifdef CONFIG_DEBUG_FS > +#include > +#endif No need to ifdef this, a small additional header is not a big deal and it's anyway included in seq_file.h. > + > #ifdef CONFIG_KEXEC_HANDOVER > #include > #include > @@ -2711,7 +2715,7 @@ static int __init reserve_mem(char *p) > } > __setup("reserve_mem=", reserve_mem); > > -#if defined(CONFIG_DEBUG_FS) && defined(CONFIG_ARCH_KEEP_MEMBLOCK) > +#ifdef CONFIG_DEBUG_FS > static const char * const flagname[] = { Flag names only needed when ARCH_KEEP_MEMBLOCK is set ... > [ilog2(MEMBLOCK_HOTPLUG)] = "HOTPLUG", > [ilog2(MEMBLOCK_MIRROR)] = "MIRROR", > @@ -2722,7 +2726,8 @@ static const char * const flagname[] = { > [ilog2(MEMBLOCK_KHO_SCRATCH)] = "KHO_SCRATCH", > }; > > -static int memblock_debug_show(struct seq_file *m, void *private) > +#ifdef CONFIG_ARCH_KEEP_MEMBLOCK ... so this ifdef should go before the flagname declaration. > +static void memblock_debugfs_files(struct seq_file *m) > { > struct memblock_type *type = m->private; > struct memblock_region *reg; > @@ -2754,6 +2759,30 @@ static int memblock_debug_show(struct seq_file *m, void *private) > seq_printf(m, "%s\n", "NONE"); > } > } > +} > +#else > +static void memblock_debugfs_files(struct seq_file *m) {} > +#endif /* CONFIG_ARCH_KEEP_MEMBLOCK */ > + > +static int memblock_debug_show(struct seq_file *m, void *private) > +{ > + if (m->private == &reserved_mem_table[0]) { > + struct reserve_mem_table *map; > + char txtsz[16]; > + > + for (int i = 0; i < reserved_mem_count; i++) { > + map = &reserved_mem_table[i]; > + if (!map->size) > + continue; > + > + memset(txtsz, 0, 16); > + string_get_size((u64)(map->size), 1, STRING_UNITS_2, txtsz, 16); phys_addr_t should be casted automatically to u64 IMO. And please, no magic numbers. > + seq_printf(m, "%s\t\t%pa\t(%s)\n", > + map->name, &map->start, txtsz); Let's not expose the physical address, name and size should be enough to see which reserve_mem allocations succeeded. > + } You can define "reserve_mem" attribute separately, and leave the existing memblock_debug_show() as it was. > + } else > + memblock_debugfs_files(m); > + > return 0; > } > DEFINE_SHOW_ATTRIBUTE(memblock_debug); > @@ -2762,6 +2791,9 @@ static int __init memblock_init_debugfs(void) > { > struct dentry *root = debugfs_create_dir("memblock", NULL); No need to create memblock directory in debugfs if there's nothing to show. Could be something like if (i!(IS_ENABLED(CONFIG_ARCH_KEEP_MEMBLOCK) || reserved_mem_count)) return; root = debugfs_create_dir("memblock", NULL); > + debugfs_create_file("reserve_mem_param", 0444, root, > + &reserved_mem_table[0], &memblock_debug_fops); > +#ifdef CONFIG_ARCH_KEEP_MEMBLOCK > debugfs_create_file("memory", 0444, root, > &memblock.memory, &memblock_debug_fops); > debugfs_create_file("reserved", 0444, root, > @@ -2771,6 +2803,7 @@ static int __init memblock_init_debugfs(void) > &memblock_debug_fops); > #endif > > +#endif /* CONFIG_ARCH_KEEP_MEMBLOCK */ > return 0; > } > __initcall(memblock_init_debugfs); > -- > 2.50.1 > > -- Sincerely yours, Mike.