From: Mike Rapoport <rppt@kernel.org>
To: Song Shuai <songshuaishuai@tinylab.org>
Cc: akpm@linux-foundation.org, linux-mm@kvack.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH] memblock: Add error message when memblock_can_resize is not ready
Date: Wed, 14 Jun 2023 19:07:10 +0300 [thread overview]
Message-ID: <20230614160710.GH52412@kernel.org> (raw)
In-Reply-To: <20230614131746.3670303-1-songshuaishuai@tinylab.org>
Hi,
On Wed, Jun 14, 2023 at 09:17:46PM +0800, Song Shuai wrote:
> The memblock APIs are always correct, thus the callers usually don't
> handle the return code. But the failure caused by unready memblock_can_resize
> is hard to recognize without the return code. Like this piece of log:
Please make it clear that failure is in memblock_double_array(), e.g.
But when memblock_double_array() is called before memblock_can_resize
is true, it is hard to understand the actual reason for the failure.
>
> ```
> [ 0.000000] memblock_phys_alloc_range: 4096 bytes align=0x1000 from=0x0000000000000000 max_addr=0x0000000000000000 alloc_pmd_fixmap+0x14/0x1c
> [ 0.000000] memblock_reserve: [0x000000017ffff000-0x000000017fffffff] memblock_alloc_range_nid+0xb8/0x128
> [ 0.000000] Oops - store (or AMO) access fault [#1]
> ```
>
> So add an error message for this kind of failure:
>
> ```
> [ 0.000000] memblock_phys_alloc_range: 4096 bytes align=0x1000 from=0x0000000000000000 max_addr=0x0000000000000000 alloc_pmd_fixmap+0x14/0x1c
> [ 0.000000] memblock_reserve: [0x000000017ffff000-0x000000017fffffff] memblock_alloc_range_nid+0xb8/0x128
> [ 0.000000] memblock: Can't double reserved array for area start 0x000000017ffff000 size 4096
> [ 0.000000] Oops - store (or AMO) access fault [#1]
> ```
>
> Signed-off-by: Song Shuai <songshuaishuai@tinylab.org>
> ---
> mm/memblock.c | 5 ++++-
> 1 file changed, 4 insertions(+), 1 deletion(-)
>
> diff --git a/mm/memblock.c b/mm/memblock.c
> index 3feafea06ab2..ab952a164f62 100644
> --- a/mm/memblock.c
> +++ b/mm/memblock.c
> @@ -418,8 +418,11 @@ static int __init_memblock memblock_double_array(struct memblock_type *type,
> /* We don't allow resizing until we know about the reserved regions
> * of memory that aren't suitable for allocation
> */
> - if (!memblock_can_resize)
> + if (!memblock_can_resize) {
> + pr_err("memblock: Can't double %s array for area start %pa size %ld\n",
> + type->name, &new_area_start, (unsigned long)new_area_size);
Most of the time memblock uses %llu and cast to u64 to print size, please
make this consistent.
> return -1;
> + }
>
> /* Calculate new doubled size */
> old_size = type->max * sizeof(struct memblock_region);
> --
> 2.20.1
>
>
--
Sincerely yours,
Mike.
next prev parent reply other threads:[~2023-06-14 16:07 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-06-14 13:17 [PATCH] memblock: Add error message when memblock_can_resize is not ready Song Shuai
2023-06-14 16:07 ` Mike Rapoport [this message]
2023-06-20 7:04 ` Song Shuai
2023-06-21 15:33 ` Mike Rapoport
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230614160710.GH52412@kernel.org \
--to=rppt@kernel.org \
--cc=akpm@linux-foundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=songshuaishuai@tinylab.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).