From: Catalin Marinas <catalin.marinas@arm.com>
To: David Hildenbrand <david@redhat.com>
Cc: "Anshuman Khandual" <anshuman.khandual@arm.com>,
"Will Deacon" <will@kernel.org>,
"Mark Rutland" <mark.rutland@arm.com>,
linux-kernel@vger.kernel.org,
"Mike Rapoport" <rppt@linux.ibm.com>,
linux-mm@kvack.org, "Jérôme Glisse" <jglisse@redhat.com>,
"James Morse" <james.morse@arm.com>,
"Dan Williams" <dan.j.williams@intel.com>,
"Robin Murphy" <robin.murphy@arm.com>,
"Ard Biesheuvel" <ardb@kernel.org>,
linux-arm-kernel@lists.infradead.org
Subject: Re: [PATCH V2 1/2] arm64/mm: Fix pfn_valid() for ZONE_DEVICE based memory
Date: Wed, 3 Mar 2021 19:04:33 +0000 [thread overview]
Message-ID: <20210303190428.GB24035@arm.com> (raw)
In-Reply-To: <a54d7dcc-8603-6d3d-143f-b09c431b8e32@redhat.com>
On Thu, Feb 11, 2021 at 01:35:56PM +0100, David Hildenbrand wrote:
> On 11.02.21 13:10, Anshuman Khandual wrote:
> > On 2/11/21 5:23 PM, Will Deacon wrote:
> > > ... and dropped. These patches appear to be responsible for a boot
> > > regression reported by CKI:
> >
> > Ahh, boot regression ? These patches only change the behaviour
> > for non boot memory only.
> >
> > > https://lore.kernel.org/r/cki.8D1CB60FEC.K6NJMEFQPV@redhat.com
> >
> > Will look into the logs and see if there is something pointing to
> > the problem.
>
> It's strange. One thing I can imagine is a mis-detection of early sections.
> However, I don't see that happening:
>
> In sparse_init_nid(), we:
> 1. Initialize the memmap
> 2. Set SECTION_IS_EARLY | SECTION_HAS_MEM_MAP via
> sparse_init_one_section()
>
> Only hotplugged sections (DIMMs, dax/kmem) set SECTION_HAS_MEM_MAP without
> SECTION_IS_EARLY - which is correct, because these are not early.
>
> So once we know that we have valid_section() -- SECTION_HAS_MEM_MAP is set
> -- early_section() should be correct.
>
> Even if someone would be doing a pfn_valid() after
> memblocks_present()->memory_present() but before
> sparse_init_nid(), we should be fine (!valid_section() -> return 0).
I couldn't figure out how this could fail with Anshuman's patches.
Will's suspicion is that some invalid/null pointer gets dereferenced
before being initialised but the only case I see is somewhere in
pfn_section_valid() (ms->usage) if valid_section() && !early_section().
Assuming that we do get a valid_section(ms) && !early_section(ms), is
there a case where ms->usage is not initialised? I guess races with
section_deactivate() are not possible this early.
Another situation could be that pfn_valid() returns true when no memory
is mapped for that pfn.
> As it happens early during boot, I doubt that some NVDIMMs that get detected
> and added early during boot as system RAM (via dax/kmem) are the problem.
It is indeed very early, we can't even get the early console output.
Debugging this is even harder as it's only misbehaving on a board we
don't have access to.
On the logic in this patch, is the hot-added memory always covering a
full subsection? The arm64 pfn_valid() currently relies on
memblock_is_map_memory() but the patch changes it to
pfn_section_valid(). So if hot-added memory doesn't cover the full
subsection, it may return true even if the pfn is not mapped.
Regarding the robustness of the pfn_valid for ZONE_DEVICE memory, could
we instead have a SECTION_IS_DEVICE flag and only check for that as not
to disturb the hotplugged memory check via memblock_is_map_memory()?
--
Catalin
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
WARNING: multiple messages have this Message-ID (diff)
From: Catalin Marinas <catalin.marinas@arm.com>
To: David Hildenbrand <david@redhat.com>
Cc: "Anshuman Khandual" <anshuman.khandual@arm.com>,
"Will Deacon" <will@kernel.org>,
"Mark Rutland" <mark.rutland@arm.com>,
linux-kernel@vger.kernel.org,
"Mike Rapoport" <rppt@linux.ibm.com>,
linux-mm@kvack.org, "Jérôme Glisse" <jglisse@redhat.com>,
"James Morse" <james.morse@arm.com>,
"Dan Williams" <dan.j.williams@intel.com>,
"Robin Murphy" <robin.murphy@arm.com>,
"Ard Biesheuvel" <ardb@kernel.org>,
linux-arm-kernel@lists.infradead.org
Subject: Re: [PATCH V2 1/2] arm64/mm: Fix pfn_valid() for ZONE_DEVICE based memory
Date: Wed, 3 Mar 2021 19:04:33 +0000 [thread overview]
Message-ID: <20210303190428.GB24035@arm.com> (raw)
In-Reply-To: <a54d7dcc-8603-6d3d-143f-b09c431b8e32@redhat.com>
On Thu, Feb 11, 2021 at 01:35:56PM +0100, David Hildenbrand wrote:
> On 11.02.21 13:10, Anshuman Khandual wrote:
> > On 2/11/21 5:23 PM, Will Deacon wrote:
> > > ... and dropped. These patches appear to be responsible for a boot
> > > regression reported by CKI:
> >
> > Ahh, boot regression ? These patches only change the behaviour
> > for non boot memory only.
> >
> > > https://lore.kernel.org/r/cki.8D1CB60FEC.K6NJMEFQPV@redhat.com
> >
> > Will look into the logs and see if there is something pointing to
> > the problem.
>
> It's strange. One thing I can imagine is a mis-detection of early sections.
> However, I don't see that happening:
>
> In sparse_init_nid(), we:
> 1. Initialize the memmap
> 2. Set SECTION_IS_EARLY | SECTION_HAS_MEM_MAP via
> sparse_init_one_section()
>
> Only hotplugged sections (DIMMs, dax/kmem) set SECTION_HAS_MEM_MAP without
> SECTION_IS_EARLY - which is correct, because these are not early.
>
> So once we know that we have valid_section() -- SECTION_HAS_MEM_MAP is set
> -- early_section() should be correct.
>
> Even if someone would be doing a pfn_valid() after
> memblocks_present()->memory_present() but before
> sparse_init_nid(), we should be fine (!valid_section() -> return 0).
I couldn't figure out how this could fail with Anshuman's patches.
Will's suspicion is that some invalid/null pointer gets dereferenced
before being initialised but the only case I see is somewhere in
pfn_section_valid() (ms->usage) if valid_section() && !early_section().
Assuming that we do get a valid_section(ms) && !early_section(ms), is
there a case where ms->usage is not initialised? I guess races with
section_deactivate() are not possible this early.
Another situation could be that pfn_valid() returns true when no memory
is mapped for that pfn.
> As it happens early during boot, I doubt that some NVDIMMs that get detected
> and added early during boot as system RAM (via dax/kmem) are the problem.
It is indeed very early, we can't even get the early console output.
Debugging this is even harder as it's only misbehaving on a board we
don't have access to.
On the logic in this patch, is the hot-added memory always covering a
full subsection? The arm64 pfn_valid() currently relies on
memblock_is_map_memory() but the patch changes it to
pfn_section_valid(). So if hot-added memory doesn't cover the full
subsection, it may return true even if the pfn is not mapped.
Regarding the robustness of the pfn_valid for ZONE_DEVICE memory, could
we instead have a SECTION_IS_DEVICE flag and only check for that as not
to disturb the hotplugged memory check via memblock_is_map_memory()?
--
Catalin
next prev parent reply other threads:[~2021-03-04 0:36 UTC|newest]
Thread overview: 46+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-02-02 4:11 [PATCH V2 0/2] arm64/mm: Fix pfn_valid() for ZONE_DEVICE based memory Anshuman Khandual
2021-02-02 4:11 ` Anshuman Khandual
2021-02-02 4:11 ` [PATCH V2 1/2] " Anshuman Khandual
2021-02-02 4:11 ` Anshuman Khandual
2021-02-02 12:32 ` Will Deacon
2021-02-02 12:32 ` Will Deacon
2021-02-02 12:35 ` Will Deacon
2021-02-02 12:35 ` Will Deacon
2021-02-02 12:39 ` David Hildenbrand
2021-02-02 12:39 ` David Hildenbrand
2021-02-02 12:51 ` Will Deacon
2021-02-02 12:51 ` Will Deacon
2021-02-02 12:56 ` David Hildenbrand
2021-02-02 12:56 ` David Hildenbrand
2021-02-03 3:50 ` Anshuman Khandual
2021-02-03 3:50 ` Anshuman Khandual
2021-02-05 18:55 ` Will Deacon
2021-02-05 18:55 ` Will Deacon
2021-02-11 11:53 ` Will Deacon
2021-02-11 11:53 ` Will Deacon
2021-02-11 12:10 ` Anshuman Khandual
2021-02-11 12:10 ` Anshuman Khandual
2021-02-11 12:21 ` Will Deacon
2021-02-11 12:21 ` Will Deacon
2021-02-11 12:35 ` David Hildenbrand
2021-02-11 12:35 ` David Hildenbrand
2021-03-03 19:04 ` Catalin Marinas [this message]
2021-03-03 19:04 ` Catalin Marinas
2021-03-03 19:24 ` David Hildenbrand
2021-03-03 19:24 ` David Hildenbrand
2021-03-03 21:24 ` Will Deacon
2021-03-03 21:24 ` Will Deacon
2021-03-04 3:31 ` Anshuman Khandual
2021-03-04 3:31 ` Anshuman Khandual
2021-03-04 8:12 ` David Hildenbrand
2021-03-04 8:12 ` David Hildenbrand
2021-03-04 9:36 ` Will Deacon
2021-03-04 9:36 ` Will Deacon
2021-03-05 4:22 ` Anshuman Khandual
2021-03-05 4:22 ` Anshuman Khandual
2021-02-02 4:11 ` [PATCH V2 2/2] arm64/mm: Reorganize pfn_valid() Anshuman Khandual
2021-02-02 4:11 ` Anshuman Khandual
2021-02-02 8:26 ` David Hildenbrand
2021-02-02 8:26 ` David Hildenbrand
2021-02-05 18:52 ` [PATCH V2 0/2] arm64/mm: Fix pfn_valid() for ZONE_DEVICE based memory Will Deacon
2021-02-05 18:52 ` Will Deacon
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=20210303190428.GB24035@arm.com \
--to=catalin.marinas@arm.com \
--cc=anshuman.khandual@arm.com \
--cc=ardb@kernel.org \
--cc=dan.j.williams@intel.com \
--cc=david@redhat.com \
--cc=james.morse@arm.com \
--cc=jglisse@redhat.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=mark.rutland@arm.com \
--cc=robin.murphy@arm.com \
--cc=rppt@linux.ibm.com \
--cc=will@kernel.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 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.