All of lore.kernel.org
 help / color / mirror / Atom feed
From: Mike Rapoport <rppt@kernel.org>
To: mawupeng <mawupeng1@huawei.com>
Cc: akpm@linux-foundation.org, ardb@kernel.org, linux-mm@kvack.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH] mm: ignore nomap memory during mirror init
Date: Sun, 20 Jul 2025 15:38:19 +0300	[thread overview]
Message-ID: <aHzjOxg_oPp06blC@kernel.org> (raw)
In-Reply-To: <8d604308-36d3-4b55-8ddb-b33f8b586c1a@huawei.com>

On Fri, Jul 18, 2025 at 09:37:48AM +0800, mawupeng wrote:
> 
> 
> On 2025/7/17 21:37, Mike Rapoport wrote:
> > On Thu, Jul 17, 2025 at 07:06:52PM +0800, mawupeng wrote:
> >>
> >> On 2025/7/17 18:29, Mike Rapoport wrote:
> >>> On Thu, Jul 17, 2025 at 04:57:23PM +0800, Wupeng Ma wrote:
> >>>> When memory mirroring is enabled, the BIOS may reserve memory regions
> >>>> at the start of the physical address space without the MR flag. This will
> >>>> lead to zone_movable_pfn to be updated to the start of these reserved
> >>>> regions, resulting in subsequent mirrored memory being ignored.
> >>>>
> >>>> Here is the log with efi=debug enabled:
> >>>>   efi:   0x084004000000-0x0842bf37ffff [Conventional|   |  |MR|...|WB|WT|WC|  ]
> >>>>   efi:   0x0842bf380000-0x0842c21effff [Loader Code |   |  |MR|...|WB|WT|WC|  ]
> >>>>   efi:   0x0842c21f0000-0x0847ffffffff [Conventional|   |  |MR|...|WB|WT|WC|  ]
> >>>>   efi:   0x085000000000-0x085fffffffff [Conventional|   |  |  |...|WB|WT|WC|  ]
> >>>> ...
> >>>>   efi:   0x084000000000-0x084003ffffff [Reserved    |   |  |  |...|WB|WT|WC|  ]
> >>>>
> >>>> Since this kind of memory can not be used by kernel. ignore nomap memory to fix
> >>>> this issue.
> >>
> >> Since the first non-mirror pfn of this node is 0x084000000000, then zone_movable_pfn 
> >> for this node will be updated to this. This will lead to Mirror Region 
> >>   - 0x084004000000-0x0842bf37ffff
> >>   - 0x0842bf380000-0x0842c21effff 
> >>   - 0x0842c21f0000-0x0847ffffffff
> >> be seen as non-mirror memory since zone_movable_pfn will be the start_pfn of this node
> >> in adjust_zone_range_for_zone_movable().
> > 
> > What do you mean by "seen as non-mirror memory"?
> 
> It mean these memory range will be add to movable zone.
> 
> > 
> > What is the problem with having movable zone on that node start at
> > 0x084000000000?
> > 
> > Can you post the kernel log up to "Memory: nK/mK available" line for more
> > context?
> 
> Memory: nK/mK available can not see be problem here, since there is nothing wrong
> with the total memory. However this problem can be shown via lsmem --output-all

I didn't ask for that particular line but for *up to that line*.
 
> w/o this patch
> [root@localhost ~]# lsmem --output-all
> RANGE                                  SIZE  STATE REMOVABLE         BLOCK NODE   ZONES
> 0x0000084000000000-0x00000847ffffffff   32G online       yes   67584-67839    0 Movable
> 0x0000085000000000-0x0000085fffffffff   64G online       yes   68096-68607    0 Movable
> 
> w/ this patch
> [root@localhost ~]# lsmem --output-all
> RANGE                                  SIZE  STATE REMOVABLE         BLOCK NODE   ZONES
> 0x0000084000000000-0x00000847ffffffff   32G online       yes   8448-8479    0  Normal
> 0x0000085000000000-0x0000085fffffffff   64G online       yes   8512-8575    0 Movable

As I see the problem, you have a problematic firmware that fails to report
memory as mirrored because it reserved for firmware own use. This causes
for non-mirrored memory to appear before mirrored memory. And this breaks
an assumption in find_zone_movable_pfns_for_nodes() that mirrored memory
always has lower addresses than non-mirrored memory and you end up wiht
having all the memory in movable zone.

So to workaround this firmware issue you propose a hack that would skip
NOMAP regions while calculating zone_movable_pfn because your particular
firmware reports the reserved mirrored memory as NOMAP.

Why don't you simply pass "kernelcore=32G" on the command line and you'll
get the same result.

> As shown above, All memory in this node is added to Zone Movable even some range of the memory
> is mirror memory. With this patch, 0x0000084000000000-0x00000847ffffffff will be added to
> zone normal as expected since the MR attribute.

-- 
Sincerely yours,
Mike.


  reply	other threads:[~2025-07-20 12:38 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-07-17  8:57 [PATCH] mm: ignore nomap memory during mirror init Wupeng Ma
2025-07-17 10:29 ` Mike Rapoport
2025-07-17 11:06   ` mawupeng
2025-07-17 13:37     ` Mike Rapoport
2025-07-18  1:37       ` mawupeng
2025-07-20 12:38         ` Mike Rapoport [this message]
2025-07-21  2:11           ` mawupeng
2025-07-22  8:23             ` Mike Rapoport
2025-07-23  2:02               ` mawupeng
2025-07-21  5:08           ` Ard Biesheuvel
2025-07-22  8:17             ` Mike Rapoport
2025-08-05  8:47               ` mawupeng
2025-08-06 10:58                 ` Mike Rapoport
2025-08-10  5:14                   ` Ard Biesheuvel
2025-08-10  8:14                     ` Mike Rapoport
2025-08-29 16:47                       ` Ard Biesheuvel
2025-08-31  9:16                         ` 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=aHzjOxg_oPp06blC@kernel.org \
    --to=rppt@kernel.org \
    --cc=akpm@linux-foundation.org \
    --cc=ardb@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=mawupeng1@huawei.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.