* THP handling with driver compound page on fault
@ 2021-01-30 0:13 Minchan Kim
2021-01-30 1:00 ` Matthew Wilcox
0 siblings, 1 reply; 7+ messages in thread
From: Minchan Kim @ 2021-01-30 0:13 UTC (permalink / raw)
To: willy, hughd, kirill; +Cc: linux-mm
Hi Folks,
A custom driver overrides (vm_operations_struct.fault) and map their
compound page(__GFP_COMP) to page table on userprocess on demand.
Here problem is
page fault occur:
__do_fault
vma->vm_ops->fault <- driver returns their compould page
finish_fault
alloc_set_pte
PageTransCompound(page)
do_set_pmd
map the page as THP page
Since it's not a THP page, system goes random crash after a while due to
conflict of VM THP handling with the driver compound page handling.
Even though it happens in old kernel with backporting THP pagecache,
I think it's still valid on recent kernel.
What's the best way to fix it? Driver don't do that or VM need to
deal with it?
Thank you.
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: THP handling with driver compound page on fault
2021-01-30 0:13 THP handling with driver compound page on fault Minchan Kim
@ 2021-01-30 1:00 ` Matthew Wilcox
2021-01-30 1:22 ` Minchan Kim
0 siblings, 1 reply; 7+ messages in thread
From: Matthew Wilcox @ 2021-01-30 1:00 UTC (permalink / raw)
To: Minchan Kim; +Cc: hughd, kirill, linux-mm
On Fri, Jan 29, 2021 at 04:13:07PM -0800, Minchan Kim wrote:
> A custom driver overrides (vm_operations_struct.fault) and map their
> compound page(__GFP_COMP) to page table on userprocess on demand.
You're looking to backport:
commit d01ac3c35214ce362f50cada37cb7bab8c801896
Author: Matthew Wilcox (Oracle) <willy@infradead.org>
Date: Thu Oct 15 20:05:26 2020 -0700
mm/memory: remove page fault assumption of compound page size
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: THP handling with driver compound page on fault
2021-01-30 1:00 ` Matthew Wilcox
@ 2021-01-30 1:22 ` Minchan Kim
2021-01-30 1:28 ` Matthew Wilcox
0 siblings, 1 reply; 7+ messages in thread
From: Minchan Kim @ 2021-01-30 1:22 UTC (permalink / raw)
To: Matthew Wilcox; +Cc: hughd, kirill, linux-mm
Hi Mattew,
On Sat, Jan 30, 2021 at 01:00:02AM +0000, Matthew Wilcox wrote:
> On Fri, Jan 29, 2021 at 04:13:07PM -0800, Minchan Kim wrote:
> > A custom driver overrides (vm_operations_struct.fault) and map their
> > compound page(__GFP_COMP) to page table on userprocess on demand.
>
> You're looking to backport:
>
> commit d01ac3c35214ce362f50cada37cb7bab8c801896
> Author: Matthew Wilcox (Oracle) <willy@infradead.org>
> Date: Thu Oct 15 20:05:26 2020 -0700
>
> mm/memory: remove page fault assumption of compound page size
>
I guess you meant the check below.
if (compound_order(page) != HPAGE_PMD_ORDER)
What happens if driver allcoated HPAGE_PMD_ORDER size?
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: THP handling with driver compound page on fault
2021-01-30 1:22 ` Minchan Kim
@ 2021-01-30 1:28 ` Matthew Wilcox
2021-01-30 1:49 ` Minchan Kim
0 siblings, 1 reply; 7+ messages in thread
From: Matthew Wilcox @ 2021-01-30 1:28 UTC (permalink / raw)
To: Minchan Kim; +Cc: hughd, kirill, linux-mm
On Fri, Jan 29, 2021 at 05:22:24PM -0800, Minchan Kim wrote:
> Hi Mattew,
>
> On Sat, Jan 30, 2021 at 01:00:02AM +0000, Matthew Wilcox wrote:
> > On Fri, Jan 29, 2021 at 04:13:07PM -0800, Minchan Kim wrote:
> > > A custom driver overrides (vm_operations_struct.fault) and map their
> > > compound page(__GFP_COMP) to page table on userprocess on demand.
> >
> > You're looking to backport:
> >
> > commit d01ac3c35214ce362f50cada37cb7bab8c801896
> > Author: Matthew Wilcox (Oracle) <willy@infradead.org>
> > Date: Thu Oct 15 20:05:26 2020 -0700
> >
> > mm/memory: remove page fault assumption of compound page size
> >
>
> I guess you meant the check below.
>
> if (compound_order(page) != HPAGE_PMD_ORDER)
>
> What happens if driver allcoated HPAGE_PMD_ORDER size?
... then it should be fine to map it with a PMD entry?
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: THP handling with driver compound page on fault
2021-01-30 1:28 ` Matthew Wilcox
@ 2021-01-30 1:49 ` Minchan Kim
2021-01-30 2:09 ` Matthew Wilcox
0 siblings, 1 reply; 7+ messages in thread
From: Minchan Kim @ 2021-01-30 1:49 UTC (permalink / raw)
To: Matthew Wilcox; +Cc: hughd, kirill, linux-mm
On Sat, Jan 30, 2021 at 01:28:44AM +0000, Matthew Wilcox wrote:
> On Fri, Jan 29, 2021 at 05:22:24PM -0800, Minchan Kim wrote:
> > Hi Mattew,
> >
> > On Sat, Jan 30, 2021 at 01:00:02AM +0000, Matthew Wilcox wrote:
> > > On Fri, Jan 29, 2021 at 04:13:07PM -0800, Minchan Kim wrote:
> > > > A custom driver overrides (vm_operations_struct.fault) and map their
> > > > compound page(__GFP_COMP) to page table on userprocess on demand.
> > >
> > > You're looking to backport:
> > >
> > > commit d01ac3c35214ce362f50cada37cb7bab8c801896
> > > Author: Matthew Wilcox (Oracle) <willy@infradead.org>
> > > Date: Thu Oct 15 20:05:26 2020 -0700
> > >
> > > mm/memory: remove page fault assumption of compound page size
> > >
> >
> > I guess you meant the check below.
> >
> > if (compound_order(page) != HPAGE_PMD_ORDER)
> >
> > What happens if driver allcoated HPAGE_PMD_ORDER size?
>
> ... then it should be fine to map it with a PMD entry?
I don't think so because following logic assumes it's THP page,
for example, page_add_file_rmap, count_vm_event(THP_FILE_MAPPED)
in do_set_pmd.
Isn't it bug?
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: THP handling with driver compound page on fault
2021-01-30 1:49 ` Minchan Kim
@ 2021-01-30 2:09 ` Matthew Wilcox
2021-01-30 2:40 ` Minchan Kim
0 siblings, 1 reply; 7+ messages in thread
From: Matthew Wilcox @ 2021-01-30 2:09 UTC (permalink / raw)
To: Minchan Kim; +Cc: hughd, kirill, linux-mm
On Fri, Jan 29, 2021 at 05:49:11PM -0800, Minchan Kim wrote:
> On Sat, Jan 30, 2021 at 01:28:44AM +0000, Matthew Wilcox wrote:
> > On Fri, Jan 29, 2021 at 05:22:24PM -0800, Minchan Kim wrote:
> > > Hi Mattew,
> > >
> > > On Sat, Jan 30, 2021 at 01:00:02AM +0000, Matthew Wilcox wrote:
> > > > On Fri, Jan 29, 2021 at 04:13:07PM -0800, Minchan Kim wrote:
> > > > > A custom driver overrides (vm_operations_struct.fault) and map their
> > > > > compound page(__GFP_COMP) to page table on userprocess on demand.
> > > >
> > > > You're looking to backport:
> > > >
> > > > commit d01ac3c35214ce362f50cada37cb7bab8c801896
> > > > Author: Matthew Wilcox (Oracle) <willy@infradead.org>
> > > > Date: Thu Oct 15 20:05:26 2020 -0700
> > > >
> > > > mm/memory: remove page fault assumption of compound page size
> > > >
> > >
> > > I guess you meant the check below.
> > >
> > > if (compound_order(page) != HPAGE_PMD_ORDER)
> > >
> > > What happens if driver allcoated HPAGE_PMD_ORDER size?
> >
> > ... then it should be fine to map it with a PMD entry?
>
> I don't think so because following logic assumes it's THP page,
> for example, page_add_file_rmap, count_vm_event(THP_FILE_MAPPED)
> in do_set_pmd.
>
> Isn't it bug?
Clearly nobody's actually tested it, but I think in principle, if a
device driver returns a PMD sized page (and it's appropriately aligned),
it should be mapped with a PMD entry.
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: THP handling with driver compound page on fault
2021-01-30 2:09 ` Matthew Wilcox
@ 2021-01-30 2:40 ` Minchan Kim
0 siblings, 0 replies; 7+ messages in thread
From: Minchan Kim @ 2021-01-30 2:40 UTC (permalink / raw)
To: Matthew Wilcox; +Cc: hughd, kirill, linux-mm
On Sat, Jan 30, 2021 at 02:09:11AM +0000, Matthew Wilcox wrote:
> On Fri, Jan 29, 2021 at 05:49:11PM -0800, Minchan Kim wrote:
> > On Sat, Jan 30, 2021 at 01:28:44AM +0000, Matthew Wilcox wrote:
> > > On Fri, Jan 29, 2021 at 05:22:24PM -0800, Minchan Kim wrote:
> > > > Hi Mattew,
> > > >
> > > > On Sat, Jan 30, 2021 at 01:00:02AM +0000, Matthew Wilcox wrote:
> > > > > On Fri, Jan 29, 2021 at 04:13:07PM -0800, Minchan Kim wrote:
> > > > > > A custom driver overrides (vm_operations_struct.fault) and map their
> > > > > > compound page(__GFP_COMP) to page table on userprocess on demand.
> > > > >
> > > > > You're looking to backport:
> > > > >
> > > > > commit d01ac3c35214ce362f50cada37cb7bab8c801896
> > > > > Author: Matthew Wilcox (Oracle) <willy@infradead.org>
> > > > > Date: Thu Oct 15 20:05:26 2020 -0700
> > > > >
> > > > > mm/memory: remove page fault assumption of compound page size
> > > > >
> > > >
> > > > I guess you meant the check below.
> > > >
> > > > if (compound_order(page) != HPAGE_PMD_ORDER)
> > > >
> > > > What happens if driver allcoated HPAGE_PMD_ORDER size?
> > >
> > > ... then it should be fine to map it with a PMD entry?
> >
> > I don't think so because following logic assumes it's THP page,
> > for example, page_add_file_rmap, count_vm_event(THP_FILE_MAPPED)
> > in do_set_pmd.
> >
> > Isn't it bug?
>
> Clearly nobody's actually tested it, but I think in principle, if a
> device driver returns a PMD sized page (and it's appropriately aligned),
> it should be mapped with a PMD entry.
Okay, then you mean d01ac3c35214ce362f50cada37cb7bab8c801896 will
fix the corruption for every-order driver compound page mapping.
I have no idea it's worth to solve THP_FILE_MAPPED misaccounting
problem but it doesn't matter for my case, at least.
Thanks for the quick answer, Matthew.
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2021-01-30 2:40 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-01-30 0:13 THP handling with driver compound page on fault Minchan Kim
2021-01-30 1:00 ` Matthew Wilcox
2021-01-30 1:22 ` Minchan Kim
2021-01-30 1:28 ` Matthew Wilcox
2021-01-30 1:49 ` Minchan Kim
2021-01-30 2:09 ` Matthew Wilcox
2021-01-30 2:40 ` Minchan Kim
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).