[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20201029081225.GK1428094@kernel.org>
Date: Thu, 29 Oct 2020 10:12:25 +0200
From: Mike Rapoport <rppt@...nel.org>
To: "Edgecombe, Rick P" <rick.p.edgecombe@...el.com>
Cc: "will@...nel.org" <will@...nel.org>,
"david@...hat.com" <david@...hat.com>,
"cl@...ux.com" <cl@...ux.com>,
"gor@...ux.ibm.com" <gor@...ux.ibm.com>,
"hpa@...or.com" <hpa@...or.com>,
"peterz@...radead.org" <peterz@...radead.org>,
"catalin.marinas@....com" <catalin.marinas@....com>,
"dave.hansen@...ux.intel.com" <dave.hansen@...ux.intel.com>,
"borntraeger@...ibm.com" <borntraeger@...ibm.com>,
"penberg@...nel.org" <penberg@...nel.org>,
"linux-mm@...ck.org" <linux-mm@...ck.org>,
"iamjoonsoo.kim@....com" <iamjoonsoo.kim@....com>,
"aou@...s.berkeley.edu" <aou@...s.berkeley.edu>,
"kirill@...temov.name" <kirill@...temov.name>,
"rientjes@...gle.com" <rientjes@...gle.com>,
"rppt@...ux.ibm.com" <rppt@...ux.ibm.com>,
"paulus@...ba.org" <paulus@...ba.org>,
"hca@...ux.ibm.com" <hca@...ux.ibm.com>,
"bp@...en8.de" <bp@...en8.de>, "pavel@....cz" <pavel@....cz>,
"sparclinux@...r.kernel.org" <sparclinux@...r.kernel.org>,
"akpm@...ux-foundation.org" <akpm@...ux-foundation.org>,
"luto@...nel.org" <luto@...nel.org>,
"davem@...emloft.net" <davem@...emloft.net>,
"mpe@...erman.id.au" <mpe@...erman.id.au>,
"tglx@...utronix.de" <tglx@...utronix.de>,
"linuxppc-dev@...ts.ozlabs.org" <linuxppc-dev@...ts.ozlabs.org>,
"linux-riscv@...ts.infradead.org" <linux-riscv@...ts.infradead.org>,
"x86@...nel.org" <x86@...nel.org>,
"rjw@...ysocki.net" <rjw@...ysocki.net>,
"linux-pm@...r.kernel.org" <linux-pm@...r.kernel.org>,
"benh@...nel.crashing.org" <benh@...nel.crashing.org>,
"linux-arm-kernel@...ts.infradead.org"
<linux-arm-kernel@...ts.infradead.org>,
"palmer@...belt.com" <palmer@...belt.com>,
"Brown, Len" <len.brown@...el.com>,
"mingo@...hat.com" <mingo@...hat.com>,
"linux-s390@...r.kernel.org" <linux-s390@...r.kernel.org>,
"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
"paul.walmsley@...ive.com" <paul.walmsley@...ive.com>
Subject: Re: [PATCH 0/4] arch, mm: improve robustness of direct map
manipulation
On Wed, Oct 28, 2020 at 09:03:31PM +0000, Edgecombe, Rick P wrote:
> > On Wed, Oct 28, 2020 at 11:20:12AM +0000, Will Deacon wrote:
> > > On Tue, Oct 27, 2020 at 10:38:16AM +0200, Mike Rapoport wrote:
> > > >
> > > > This is a theoretical bug, but it is still not nice :)
> > > >
> > >
> > > Just to clarify: this patch series fixes this problem, right?
> >
> > Yes.
> >
>
> Well, now I'm confused again.
>
> As David pointed, __vunmap() should not be executing simultaneously
> with the hibernate operation because hibernate can't snapshot while
> data it needs to save is still updating. If a thread was paused when a
> page was in an "invalid" state, it should be remapped by hibernate
> before the copy.
>
> To level set, before reading this mail, my takeaways from the
> discussions on potential hibernate/debug page alloc problems were:
>
> Potential RISC-V issue:
> Doesn't have hibernate support
>
> Potential ARM issue:
> The logic around when it's cpa determines pages might be unmapped looks
> correct for current callers.
>
> Potential x86 page break issue:
> Seems to be ok for now, but a new set_memory_np() caller could violate
> assumptions in hibernate.
>
> Non-obvious thorny logic:
> General agreement it would be good to separate dependencies.
>
> Behavior of V1 of this patchset:
> No functional change other than addition of a warn in hibernate.
There is a change that adds explicit use of set_direct_map() to
hibernate. Currently, in case of arm64 with DEBUG_PAGEALLOC=n if a
thread was paused when a page was in an "invalid" state hibernate will
access an unmapped data because __kernel_map_pages() will bail out.
After the change set_direct_map_default_noflush() would be used and the
page will get mapped before copy.
> So "does this fix the problem", "yes" leaves me a bit confused... Not
> saying there couldn't be any problems, especially due to the thorniness
> and cross arch stride, but what is it exactly and how does this series
> fix it?
This series goal was primarily to separate dependincies and make it
clearer what DEBUG_PAGEALLOC and what SET_DIRECT_MAP are. As it turned
out, there is also some lack of consistency between architectures that
implement either of this so I tried to improve this as well.
Honestly, I don't know if a thread can be paused at the time __vunmap()
left invalid pages, but it could, there is an issue on arm64 with
DEBUG_PAGEALLOC=n and this set fixes it.
__vunmap()
vm_remove_mappings()
set_direct_map_invalid()
/* thread is frozen */
safe_copy_page()
__kernel_map_pages()
if (!debug_pagealloc())
return
do_copy_page() -> fault
--
Sincerely yours,
Mike.
Powered by blists - more mailing lists