mbox series

[0/2] kvm: Use huge pages for DAX-backed files

Message ID 20181109203921.178363-1-brho@google.com (mailing list archive)
Headers show
Series kvm: Use huge pages for DAX-backed files | expand

Message

Barret Rhoden Nov. 9, 2018, 8:39 p.m. UTC
This patch series depends on dax pages not being PageReserved.  Once
that is in place, these changes will let KVM use huge pages with
dax-backed files.  Without the PageReserved change, KVM and DAX still
work with these patches, simply without huge pages - which is the
current situation.

RFC/discussion thread:
https://lore.kernel.org/lkml/20181029210716.212159-1-brho@google.com/

Barret Rhoden (2):
  mm: make dev_pagemap_mapping_shift() externally visible
  kvm: Use huge pages for DAX-backed files

 arch/x86/kvm/mmu.c  | 34 ++++++++++++++++++++++++++++++++--
 include/linux/mm.h  |  3 +++
 mm/memory-failure.c | 38 +++-----------------------------------
 mm/util.c           | 34 ++++++++++++++++++++++++++++++++++
 4 files changed, 72 insertions(+), 37 deletions(-)

Comments

Barret Rhoden Nov. 14, 2018, 9:51 p.m. UTC | #1
This patch series depends on dax pages not being PageReserved.  Once
that is in place, these changes will let KVM use huge pages with
dax-backed files.  Without the PageReserved change, KVM and DAX still
work with these patches, simply without huge pages - which is the
current situation.

RFC/discussion thread:
https://lore.kernel.org/lkml/20181029210716.212159-1-brho@google.com/

v1 -> v2:
https://lore.kernel.org/lkml/20181109203921.178363-1-brho@google.com/

- Updated Acks/Reviewed-by
- Minor touchups
- Added patch to remove redundant PageReserved() check
- Rebased onto linux-next


Barret Rhoden (3):
  mm: make dev_pagemap_mapping_shift() externally visible
  kvm: Use huge pages for DAX-backed files
  kvm: remove redundant PageReserved() check

 arch/x86/kvm/mmu.c  | 33 +++++++++++++++++++++++++++++++--
 include/linux/mm.h  |  3 +++
 mm/memory-failure.c | 38 +++-----------------------------------
 mm/util.c           | 34 ++++++++++++++++++++++++++++++++++
 virt/kvm/kvm_main.c |  8 ++------
 5 files changed, 73 insertions(+), 43 deletions(-)
Dan Williams Nov. 15, 2018, 12:55 a.m. UTC | #2
[ add Alex who is looking into removing PageReserved for DAX pages. ]
On Wed, Nov 14, 2018 at 1:53 PM Barret Rhoden <brho@google.com> wrote:
>
> This patch series depends on dax pages not being PageReserved.  Once
> that is in place, these changes will let KVM use huge pages with
> dax-backed files.  Without the PageReserved change, KVM and DAX still
> work with these patches, simply without huge pages - which is the
> current situation.
>
> RFC/discussion thread:
> https://lore.kernel.org/lkml/20181029210716.212159-1-brho@google.com/
>
> v1 -> v2:
> https://lore.kernel.org/lkml/20181109203921.178363-1-brho@google.com/
>
> - Updated Acks/Reviewed-by
> - Minor touchups
> - Added patch to remove redundant PageReserved() check
> - Rebased onto linux-next
>
>
> Barret Rhoden (3):
>   mm: make dev_pagemap_mapping_shift() externally visible
>   kvm: Use huge pages for DAX-backed files
>   kvm: remove redundant PageReserved() check
>
>  arch/x86/kvm/mmu.c  | 33 +++++++++++++++++++++++++++++++--
>  include/linux/mm.h  |  3 +++
>  mm/memory-failure.c | 38 +++-----------------------------------
>  mm/util.c           | 34 ++++++++++++++++++++++++++++++++++
>  virt/kvm/kvm_main.c |  8 ++------
>  5 files changed, 73 insertions(+), 43 deletions(-)
>
> --
> 2.19.1.1215.g8438c0b245-goog
>
Barret Rhoden Dec. 3, 2018, 5:40 p.m. UTC | #3
On 2018-11-14 at 16:55 Dan Williams <dan.j.williams@intel.com> wrote:
> [ add Alex who is looking into removing PageReserved for DAX pages. ]

Thanks.  I can keep my eye out for his patches and repost once that's
done.  

Alternatively, if you all want to merge this before the PageReserved /
DAX changes, then I can repost - just Ack/Review tags.  It's harmless
with the existing PageReserved behavior.

Thanks,

Barret


> On Wed, Nov 14, 2018 at 1:53 PM Barret Rhoden <brho@google.com> wrote:
> >
> > This patch series depends on dax pages not being PageReserved.  Once
> > that is in place, these changes will let KVM use huge pages with
> > dax-backed files.  Without the PageReserved change, KVM and DAX still
> > work with these patches, simply without huge pages - which is the
> > current situation.
> >
> > RFC/discussion thread:
> > https://lore.kernel.org/lkml/20181029210716.212159-1-brho@google.com/
> >
> > v1 -> v2:
> > https://lore.kernel.org/lkml/20181109203921.178363-1-brho@google.com/
> >
> > - Updated Acks/Reviewed-by
> > - Minor touchups
> > - Added patch to remove redundant PageReserved() check
> > - Rebased onto linux-next
> >
> >
> > Barret Rhoden (3):
> >   mm: make dev_pagemap_mapping_shift() externally visible
> >   kvm: Use huge pages for DAX-backed files
> >   kvm: remove redundant PageReserved() check
> >
> >  arch/x86/kvm/mmu.c  | 33 +++++++++++++++++++++++++++++++--
> >  include/linux/mm.h  |  3 +++
> >  mm/memory-failure.c | 38 +++-----------------------------------
> >  mm/util.c           | 34 ++++++++++++++++++++++++++++++++++
> >  virt/kvm/kvm_main.c |  8 ++------
> >  5 files changed, 73 insertions(+), 43 deletions(-)
> >
> > --
> > 2.19.1.1215.g8438c0b245-goog
> >
Alexander Duyck Dec. 3, 2018, 6:32 p.m. UTC | #4
On Mon, 2018-12-03 at 12:40 -0500, Barret Rhoden wrote:
> On 2018-11-14 at 16:55 Dan Williams <dan.j.williams@intel.com> wrote:
> > [ add Alex who is looking into removing PageReserved for DAX pages. ]
> 
> Thanks.  I can keep my eye out for his patches and repost once that's
> done.  
> 
> Alternatively, if you all want to merge this before the PageReserved /
> DAX changes, then I can repost - just Ack/Review tags.  It's harmless
> with the existing PageReserved behavior.
> 
> Thanks,
> 
> Barret

So the latest version of my generic memory init patches are up at:

https://lore.kernel.org/lkml/154361452447.7497.1348692079883153517.stgit@ahduyck-desk1.amr.corp.intel.com/

To be honest I am not entirely convinced that dropping PageReserved is
the right thing to do for DAX pages. I've been trying to work out a few
different issues but not having much luck. It seems like the main issue
is that the PageReserved bit is being used to indicate 2 different
things in a few spots throughout the kernel.

The definition of the PG_reserved flag reads like it should apply to
DAX pages:
  PG_reserved is set for special pages, which can never be swapped out.
  Some of them might not even exist...

PageReserved essentially means you aren't supposed to be migrating or
swapping the page. The problem here is that I believe this logic should
apply to DAX pages and so in many cases it makes sense to leave the
flag set for DAX pages. Otherwise you have to go through and start
special casing all the spots where normal memory falls through and add
a check to see if we have a DAX page.

The second use for the PG_reserved flag is to test for if you can pin
the page or not. This I think is the reason why many are just assuming
PageReserved == MMIO like KVM does. However this is a bad assumption to
be making since the introduction of DAX, HMM, and P2PDMA allows MMIO
memory to start doing different things like supporting pinning. I also
believe it would be a bad reason to clear the flag for DAX pages.

Thanks.

- Alex