From nobody Fri Apr 3 05:04:02 2026 Received: from fanzine2.igalia.com (fanzine2.igalia.com [213.97.179.56]) (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 7B98A378814 for ; Tue, 17 Feb 2026 19:58:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=213.97.179.56 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1771358333; cv=none; b=iwQlQE4F4ISAqoaJTxJJ6h+IMdvThq9QmZpOJnAYXScqyLVwIhHFd14sRvcbQBSgwk/MmaW3buCc+/qj/lINtdHEmXqGgjlyko98bN6ZfMIiIDe95loh/vtUxlWeXJCPk51WnR9OUYDI7SDzXTa672DKiXAtVL2r4IKf0bmE6lA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1771358333; c=relaxed/simple; bh=9JqGs394cOl+sFrE2NHwxlB4jeThJ0h+Bs5IcjhMtIQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=KRkXYejhODUC7++SsJJo17BgKgCE8bT0gLI+R3eVp3/NS37RHgKndHX78KtzmOyDXpmLw52n9rggsEyFy1zsaotzsPKP8Qy309EKCsHItPeqeGMeX73JHZ7G9t9OxA+g9k7gNYBEGLo+qASadq8YibdiXUHqQZ7Fnhi0p3Kx7J8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=igalia.com; spf=pass smtp.mailfrom=igalia.com; dkim=pass (2048-bit key) header.d=igalia.com header.i=@igalia.com header.b=LaqiP1tK; arc=none smtp.client-ip=213.97.179.56 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=igalia.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=igalia.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=igalia.com header.i=@igalia.com header.b="LaqiP1tK" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=igalia.com; s=20170329; h=Content-Transfer-Encoding:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:Cc:To:From:Sender:Reply-To:Content-Type:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=RXuAwV7EvPnrzwYm1Nj10RW4qIvW3kT9YlwlXXuuzFI=; b=LaqiP1tKNet3KRNu+1d8iYOjO3 2lVUrYVDdGpWPsZ/HTe/NbzLZ6AqlI4ETF3MXFNCy500uMdTck8cpWYjuRHT2cSVxfNarRCim54rt TBydzckayuRqC1JqqxucOk+jiV/EHiVMtJIJ62wq6Rsk9V9C0Cn9RoAw0GwvdgiV4ijVufKMJXYN8 pqsoOi0m77R1RAfjUUbvfUqL97ViqvAjR+fytqhD/RYzOyj0nDWpYRfC2DAvuFemlBwFTwK/Z44tM NGxrEJrIzMFgjn33UHOwiKdorOJGxT4LqhdZEnGDwXEhuHyu1f9mxZKMGdvxq7VQ09oMVPnUHBk/u W2Vvp5YQ==; Received: from [177.45.213.208] (helo=localhost) by fanzine2.igalia.com with esmtpsa (Cipher TLS1.3:ECDHE_SECP256R1__RSA_PSS_RSAE_SHA256__AES_256_GCM:256) (Exim) id 1vsRDX-001nLA-3A; Tue, 17 Feb 2026 20:58:43 +0100 From: "Guilherme G. Piccoli" To: linux-mm@kvack.org Cc: linux-kernel@vger.kernel.org, kernel-dev@igalia.com, kernel@gpiccoli.net, gpiccoli@igalia.com, Andrew Morton , Mike Rapoport , Steven Rostedt Subject: [PATCH 1/2] mm/memblock: Print out errors on reserve_mem parser Date: Tue, 17 Feb 2026 16:45:06 -0300 Message-ID: <20260217195816.861684-2-gpiccoli@igalia.com> X-Mailer: git-send-email 2.50.1 In-Reply-To: <20260217195816.861684-1-gpiccoli@igalia.com> References: <20260217195816.861684-1-gpiccoli@igalia.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" The parsing of kernel parameter "reserve_mem=3D" is subject to multiple failures, like duplicate naming, malformed expression or even lack of available memory. Right now, all of these fail silently. Let's add some messages so the kernel log can provide useful information in case of failures. Cc: Andrew Morton Cc: Mike Rapoport Cc: Steven Rostedt Signed-off-by: Guilherme G. Piccoli --- mm/memblock.c | 28 +++++++++++++++++++--------- 1 file changed, 19 insertions(+), 9 deletions(-) diff --git a/mm/memblock.c b/mm/memblock.c index b3ddfdec7a80..2d2646f7a120 100644 --- a/mm/memblock.c +++ b/mm/memblock.c @@ -2642,23 +2642,25 @@ static int __init reserve_mem(char *p) int len; =20 if (!p) - return -EINVAL; + goto err_param; =20 /* Check if there's room for more reserved memory */ - if (reserved_mem_count >=3D RESERVE_MEM_MAX_ENTRIES) + if (reserved_mem_count >=3D RESERVE_MEM_MAX_ENTRIES) { + pr_err("reserve_mem: no more room for reserved memory\n"); return -EBUSY; + } =20 oldp =3D p; size =3D memparse(p, &p); if (!size || p =3D=3D oldp) - return -EINVAL; + goto err_param; =20 if (*p !=3D ':') - return -EINVAL; + goto err_param; =20 align =3D memparse(p+1, &p); if (*p !=3D ':') - return -EINVAL; + goto err_param; =20 /* * memblock_phys_alloc() doesn't like a zero size align, @@ -2672,7 +2674,7 @@ static int __init reserve_mem(char *p) =20 /* name needs to have length but not too big */ if (!len || len >=3D RESERVE_MEM_NAME_SIZE) - return -EINVAL; + goto err_param; =20 /* Make sure that name has text */ for (p =3D name; *p; p++) { @@ -2680,11 +2682,13 @@ static int __init reserve_mem(char *p) break; } if (!*p) - return -EINVAL; + goto err_param; =20 /* Make sure the name is not already used */ - if (reserve_mem_find_by_name(name, &start, &tmp)) + if (reserve_mem_find_by_name(name, &start, &tmp)) { + pr_err("reserve_mem: name \"%s\" was already used\n", name); return -EBUSY; + } =20 /* Pick previous allocations up from KHO if available */ if (reserve_mem_kho_revive(name, size, align)) @@ -2692,12 +2696,18 @@ static int __init reserve_mem(char *p) =20 /* TODO: Allocation must be outside of scratch region */ start =3D memblock_phys_alloc(size, align); - if (!start) + if (!start) { + pr_err("reserve_mem: memblock allocation failed\n"); return -ENOMEM; + } =20 reserved_mem_add(start, size, name); =20 return 1; +err_param: + pr_err("reserve_mem: empty or malformed parameter\n"); + return -EINVAL; + } __setup("reserve_mem=3D", reserve_mem); =20 --=20 2.50.1 From nobody Fri Apr 3 05:04:02 2026 Received: from fanzine2.igalia.com (fanzine2.igalia.com [213.97.179.56]) (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 E060436EAB3 for ; Tue, 17 Feb 2026 19:58:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=213.97.179.56 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1771358330; cv=none; b=rvbVMHiIvgDS9Stkg1opPQ0CYgU2s/nZotCgxrBRdvBYVHkFSLu4yokJ5zrexUY+4xJTJBYPzXuR4WhMSX7mPABftaHuq3l75drx58MGbemx2MXAlgX+FbLEIhABMyEu0Q1pS+K3PCLRQhAh5XEjJlNzi8b7dM0Jxqwk+Lh1RNg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1771358330; c=relaxed/simple; bh=6E/NM9QrXZremAfYgMrKqmtPy0r87Cxa8X3dZT+wUl4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=ZnwUnI2wPkEJMf8SnCja+6wUDY+DtuZJXLZnIsTGJQnhPz5q5mKJOBZN0jTazCHEylQzNSxfq/F5+vERMcHpOIiYUqkvJoCwsoKZMAhK6trMllEbODWhTTWPH/SJhFRfDkUsajJtda2vxf1+/2u0rG76Mcd4Lr+O1RNQ9KC1q6A= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=igalia.com; spf=pass smtp.mailfrom=igalia.com; dkim=pass (2048-bit key) header.d=igalia.com header.i=@igalia.com header.b=qhDBichY; arc=none smtp.client-ip=213.97.179.56 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=igalia.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=igalia.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=igalia.com header.i=@igalia.com header.b="qhDBichY" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=igalia.com; s=20170329; h=Content-Transfer-Encoding:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:Cc:To:From:Sender:Reply-To:Content-Type:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=wdGM+3FwIaQuf6hPkPkSLAphz0/4CuAqXxirGxGLDPc=; b=qhDBichYhwo1xrMfx+LlNeZNyu WN8w/c3qh4fwEJKdklUDc1KbQfGhsgjhLc2KevtcSpIK0blzrNwyScHCDSE7HyRKFfY70pbhKP3C2 SP2fvYGqrUGf0PDBmjQKgXATF0iC0tZ0e93dux7tD5mbqbKzvPgs3sLJwlhExukH/DDu+/eg5rFSc 6JsIfLwOzQUA+OA1XPVUZug0sdo6mA/poMIi1+omJRHDySExtCM+CoSiIc44/UNldBTWo8NDFQL6e YClBqAMT344tFwoMdQd4UfhnljM897Ebi5wiZV/SocsSCq9PNIpksSYDFFg106A/Endm/gpwEhCPD TutEO5Qg==; Received: from [177.45.213.208] (helo=localhost) by fanzine2.igalia.com with esmtpsa (Cipher TLS1.3:ECDHE_SECP256R1__RSA_PSS_RSAE_SHA256__AES_256_GCM:256) (Exim) id 1vsRDa-001nLM-80; Tue, 17 Feb 2026 20:58:46 +0100 From: "Guilherme G. Piccoli" To: linux-mm@kvack.org Cc: linux-kernel@vger.kernel.org, kernel-dev@igalia.com, kernel@gpiccoli.net, gpiccoli@igalia.com, Andrew Morton , Mike Rapoport , Steven Rostedt Subject: [PATCH 2/2] mm/memblock: Add reserve_mem debugfs info Date: Tue, 17 Feb 2026 16:45:07 -0300 Message-ID: <20260217195816.861684-3-gpiccoli@igalia.com> X-Mailer: git-send-email 2.50.1 In-Reply-To: <20260217195816.861684-1-gpiccoli@igalia.com> References: <20260217195816.861684-1-gpiccoli@igalia.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" 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=3D") 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=3D" 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 =20 +#ifdef CONFIG_DEBUG_FS +#include +#endif + #ifdef CONFIG_KEXEC_HANDOVER #include #include @@ -2711,7 +2715,7 @@ static int __init reserve_mem(char *p) } __setup("reserve_mem=3D", reserve_mem); =20 -#if defined(CONFIG_DEBUG_FS) && defined(CONFIG_ARCH_KEEP_MEMBLOCK) +#ifdef CONFIG_DEBUG_FS static const char * const flagname[] =3D { [ilog2(MEMBLOCK_HOTPLUG)] =3D "HOTPLUG", [ilog2(MEMBLOCK_MIRROR)] =3D "MIRROR", @@ -2722,7 +2726,8 @@ static const char * const flagname[] =3D { [ilog2(MEMBLOCK_KHO_SCRATCH)] =3D "KHO_SCRATCH", }; =20 -static int memblock_debug_show(struct seq_file *m, void *private) +#ifdef CONFIG_ARCH_KEEP_MEMBLOCK +static void memblock_debugfs_files(struct seq_file *m) { struct memblock_type *type =3D m->private; struct memblock_region *reg; @@ -2754,6 +2759,30 @@ static int memblock_debug_show(struct seq_file *m, v= oid *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 =3D=3D &reserved_mem_table[0]) { + struct reserve_mem_table *map; + char txtsz[16]; + + for (int i =3D 0; i < reserved_mem_count; i++) { + map =3D &reserved_mem_table[i]; + if (!map->size) + continue; + + memset(txtsz, 0, 16); + string_get_size((u64)(map->size), 1, STRING_UNITS_2, txtsz, 16); + seq_printf(m, "%s\t\t%pa\t(%s)\n", + map->name, &map->start, txtsz); + } + } 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 =3D debugfs_create_dir("memblock", NULL); =20 + 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 =20 +#endif /* CONFIG_ARCH_KEEP_MEMBLOCK */ return 0; } __initcall(memblock_init_debugfs); --=20 2.50.1