linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/4] mm: new flag to forbid zero page mappings for a vma
@ 2014-10-17 14:09 Dominik Dingel
  2014-10-17 14:09 ` [PATCH 1/4] s390/mm: recfactor global pgste updates Dominik Dingel
                   ` (3 more replies)
  0 siblings, 4 replies; 15+ messages in thread
From: Dominik Dingel @ 2014-10-17 14:09 UTC (permalink / raw)
  To: Andrew Morton, linux-mm, Mel Gorman, Michal Hocko, Rik van Riel
  Cc: Andrea Arcangeli, Andy Lutomirski, Aneesh Kumar K.V, Bob Liu,
	Christian Borntraeger, Cornelia Huck, Gleb Natapov,
	Heiko Carstens, H. Peter Anvin, Hugh Dickins, Ingo Molnar,
	Jianyu Zhan, Johannes Weiner, Kirill A. Shutemov,
	Konstantin Weitz, kvm, linux390, linux-kernel, linux-s390,
	Martin Schwidefsky, Paolo Bonzini, Peter Zijlstra, Sasha Levin,
	Dominik Dingel

s390 has the special notion of storage keys which are some sort of page flags
associated with physical pages and live outside of direct addressable memory.
These storage keys can be queried and changed with a special set of instructions.
The mentioned instructions behave quite nicely under virtualization, if there is: 
- an invalid pte, then the instructions will work on some memory reserved in the host page table
- a valid pte, then the instructions will work with the real storage key

Thanks to Martin with his software reference and dirty bit tracking, the kernel does not issue any 
storage key instructions as now a software based approach will be taken, on the other hand 
distributions in the wild are currently using them.

However, for virtualized guests we still have a problem with guest pages mapped to zero pages
and the kernel same page merging.  WIth each one multiple guest pages will point to the same 
physical page and share the same storage key.

Let's fix this by introducing a new flag which will forbid new zero page mappings.
If the guest issues a storage key related instruction we flag all vmas and drop existing 
zero page mappings and unmerge the guest memory.

Dominik Dingel (4):
  s390/mm: recfactor global pgste updates
  mm: introduce new VM_NOZEROPAGE flag
  s390/mm: prevent and break zero page mappings in case of storage keys
  s390/mm: disable KSM for storage key enabled pages

 arch/s390/Kconfig               |   3 +
 arch/s390/include/asm/pgalloc.h |   2 -
 arch/s390/include/asm/pgtable.h |   3 +-
 arch/s390/kvm/kvm-s390.c        |   2 +-
 arch/s390/kvm/priv.c            |  17 ++--
 arch/s390/mm/pgtable.c          | 181 ++++++++++++++++++----------------------
 include/linux/mm.h              |  13 ++-
 mm/huge_memory.c                |   2 +-
 mm/memory.c                     |   2 +-
 9 files changed, 112 insertions(+), 113 deletions(-)

-- 
1.8.5.5


^ permalink raw reply	[flat|nested] 15+ messages in thread
* [PATCH v2 0/4] mm: new function to forbid zeropage mappings for a process
@ 2014-10-22  8:30 Dominik Dingel
  2014-10-22  8:30 ` [PATCH 4/4] s390/mm: disable KSM for storage key enabled pages Dominik Dingel
  0 siblings, 1 reply; 15+ messages in thread
From: Dominik Dingel @ 2014-10-22  8:30 UTC (permalink / raw)
  To: Andrew Morton, linux-mm, Mel Gorman, Michal Hocko, Paolo Bonzini,
	Dave Hansen, Rik van Riel
  Cc: Andrea Arcangeli, Andy Lutomirski, Aneesh Kumar K.V, Bob Liu,
	Christian Borntraeger, Cornelia Huck, Gleb Natapov,
	Heiko Carstens, H. Peter Anvin, Hugh Dickins, Ingo Molnar,
	Jianyu Zhan, Johannes Weiner, Kirill A. Shutemov,
	Konstantin Weitz, kvm, linux390, linux-kernel, linux-s390,
	Martin Schwidefsky, Peter Zijlstra, Sasha Levin, Dominik Dingel

s390 has the special notion of storage keys which are some sort of page flags
associated with physical pages and live outside of direct addressable memory.
These storage keys can be queried and changed with a special set of instructions.
The mentioned instructions behave quite nicely under virtualization, if there is: 
- an invalid pte, then the instructions will work on memory in the host page table
- a valid pte, then the instructions will work with the real storage key

Thanks to Martin with his software reference and dirty bit tracking,
the kernel does not issue any storage key instructions as now a 
software based approach will be taken, on the other hand distributions 
in the wild are currently using them.

However, for virtualized guests we still have a problem with guest pages 
mapped to zero pages and the kernel same page merging.  
With each one multiple guest pages will point to the same physical page
and share the same storage key.

Let's fix this by introducing a new function which s390 will define to
forbid new zero page mappings.  If the guest issues a storage key related 
instruction we flag the mm_struct, drop existing zero page mappings
and unmerge the guest memory.

v1 -> v2: 
 - Following Dave and Paolo suggestion removing the vma flag

Dominik Dingel (4):
  s390/mm: recfactor global pgste updates
  mm: introduce mm_forbids_zeropage function
  s390/mm: prevent and break zero page mappings in case of storage keys
  s390/mm: disable KSM for storage key enabled pages

 arch/s390/include/asm/mmu.h     |   2 +
 arch/s390/include/asm/pgalloc.h |   2 -
 arch/s390/include/asm/pgtable.h |  17 +++-
 arch/s390/kvm/kvm-s390.c        |   2 +-
 arch/s390/kvm/priv.c            |  17 ++--
 arch/s390/mm/pgtable.c          | 180 ++++++++++++++++++----------------------
 include/linux/mm.h              |   4 +
 mm/huge_memory.c                |   2 +-
 mm/memory.c                     |   2 +-
 9 files changed, 117 insertions(+), 111 deletions(-)

-- 
1.8.5.5


^ permalink raw reply	[flat|nested] 15+ messages in thread
* [PATCH v3 0/4] mm: new function to forbid zeropage mappings for a process
@ 2014-10-22 11:09 Dominik Dingel
  2014-10-22 11:09 ` [PATCH 4/4] s390/mm: disable KSM for storage key enabled pages Dominik Dingel
  0 siblings, 1 reply; 15+ messages in thread
From: Dominik Dingel @ 2014-10-22 11:09 UTC (permalink / raw)
  To: Andrew Morton, linux-mm, Mel Gorman, Michal Hocko, Paolo Bonzini,
	Dave Hansen, Rik van Riel
  Cc: Andrea Arcangeli, Andy Lutomirski, Aneesh Kumar K.V, Bob Liu,
	Christian Borntraeger, Cornelia Huck, Gleb Natapov,
	Heiko Carstens, H. Peter Anvin, Hugh Dickins, Ingo Molnar,
	Jianyu Zhan, Johannes Weiner, Kirill A. Shutemov, kvm, linux390,
	linux-kernel, linux-s390, Martin Schwidefsky, Peter Zijlstra,
	Sasha Levin, Dominik Dingel

s390 has the special notion of storage keys which are some sort of page flags
associated with physical pages and live outside of direct addressable memory.
These storage keys can be queried and changed with a special set of instructions.
The mentioned instructions behave quite nicely under virtualization, if there is: 
- an invalid pte, then the instructions will work on memory in the host page table
- a valid pte, then the instructions will work with the real storage key

Thanks to Martin with his software reference and dirty bit tracking,
the kernel does not issue any storage key instructions as now a 
software based approach will be taken, on the other hand distributions 
in the wild are currently using them.

However, for virtualized guests we still have a problem with guest pages 
mapped to zero pages and the kernel same page merging.  
With each one multiple guest pages will point to the same physical page
and share the same storage key.

Let's fix this by introducing a new function which s390 will define to
forbid new zero page mappings.  If the guest issues a storage key related 
instruction we flag the mm_struct, drop existing zero page mappings
and unmerge the guest memory.

v2 -> v3:
 - Clearing up patch description Patch 3/4
 - removing unnecessary flag in mmu_context (Paolo)

v1 -> v2: 
 - Following Dave and Paolo suggestion removing the vma flag

Dominik Dingel (4):
  s390/mm: recfactor global pgste updates
  mm: introduce mm_forbids_zeropage function
  s390/mm: prevent and break zero page mappings in case of storage keys
  s390/mm: disable KSM for storage key enabled pages

 arch/s390/include/asm/pgalloc.h |   2 -
 arch/s390/include/asm/pgtable.h |   8 +-
 arch/s390/kvm/kvm-s390.c        |   2 +-
 arch/s390/kvm/priv.c            |  17 ++--
 arch/s390/mm/pgtable.c          | 180 ++++++++++++++++++----------------------
 include/linux/mm.h              |   4 +
 mm/huge_memory.c                |   2 +-
 mm/memory.c                     |   2 +-
 8 files changed, 106 insertions(+), 111 deletions(-)

-- 
1.8.5.5


^ permalink raw reply	[flat|nested] 15+ messages in thread

end of thread, other threads:[~2014-10-22 14:01 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-10-17 14:09 [PATCH 0/4] mm: new flag to forbid zero page mappings for a vma Dominik Dingel
2014-10-17 14:09 ` [PATCH 1/4] s390/mm: recfactor global pgste updates Dominik Dingel
2014-10-17 14:09 ` [PATCH 2/4] mm: introduce new VM_NOZEROPAGE flag Dominik Dingel
2014-10-17 22:04   ` Dave Hansen
2014-10-18 14:49     ` Dominik Dingel
2014-10-18 16:28       ` Dave Hansen
2014-10-20 18:14         ` Paolo Bonzini
2014-10-21  6:11           ` Martin Schwidefsky
2014-10-21  8:11             ` Paolo Bonzini
2014-10-21 11:20               ` Dominik Dingel
2014-10-17 14:09 ` [PATCH 3/4] s390/mm: prevent and break zero page mappings in case of storage keys Dominik Dingel
2014-10-17 14:09 ` [PATCH 4/4] s390/mm: disable KSM for storage key enabled pages Dominik Dingel
2014-10-22  8:30 [PATCH v2 0/4] mm: new function to forbid zeropage mappings for a process Dominik Dingel
2014-10-22  8:30 ` [PATCH 4/4] s390/mm: disable KSM for storage key enabled pages Dominik Dingel
2014-10-22 11:09 [PATCH v3 0/4] mm: new function to forbid zeropage mappings for a process Dominik Dingel
2014-10-22 11:09 ` [PATCH 4/4] s390/mm: disable KSM for storage key enabled pages Dominik Dingel
2014-10-22 14:00   ` Paolo Bonzini

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).