Re: [PATCH 2/4] mm: introduce mm_forbids_zeropage function

2014-10-22 Thread Paolo Bonzini
Reviewed-by: Paolo Bonzini pbonz...@redhat.com

On 10/22/2014 01:09 PM, Dominik Dingel wrote:
 Add a new function stub to allow architectures to disable for
 an mm_structthe backing of non-present, anonymous pages with
 read-only empty zero pages.
 
 Signed-off-by: Dominik Dingel din...@linux.vnet.ibm.com
 ---
  include/linux/mm.h | 4 
  mm/huge_memory.c   | 2 +-
  mm/memory.c| 2 +-
  3 files changed, 6 insertions(+), 2 deletions(-)
 
 diff --git a/include/linux/mm.h b/include/linux/mm.h
 index cd33ae2..0a2022e 100644
 --- a/include/linux/mm.h
 +++ b/include/linux/mm.h
 @@ -56,6 +56,10 @@ extern int sysctl_legacy_va_layout;
  #define __pa_symbol(x)  __pa(RELOC_HIDE((unsigned long)(x), 0))
  #endif
  
 +#ifndef mm_forbids_zeropage
 +#define mm_forbids_zeropage(X)  (0)
 +#endif
 +
  extern unsigned long sysctl_user_reserve_kbytes;
  extern unsigned long sysctl_admin_reserve_kbytes;
  
 diff --git a/mm/huge_memory.c b/mm/huge_memory.c
 index de98415..357a381 100644
 --- a/mm/huge_memory.c
 +++ b/mm/huge_memory.c
 @@ -805,7 +805,7 @@ int do_huge_pmd_anonymous_page(struct mm_struct *mm, 
 struct vm_area_struct *vma,
   return VM_FAULT_OOM;
   if (unlikely(khugepaged_enter(vma, vma-vm_flags)))
   return VM_FAULT_OOM;
 - if (!(flags  FAULT_FLAG_WRITE) 
 + if (!(flags  FAULT_FLAG_WRITE)  !mm_forbids_zeropage(mm) 
   transparent_hugepage_use_zero_page()) {
   spinlock_t *ptl;
   pgtable_t pgtable;
 diff --git a/mm/memory.c b/mm/memory.c
 index 64f82aa..f275a9d 100644
 --- a/mm/memory.c
 +++ b/mm/memory.c
 @@ -2640,7 +2640,7 @@ static int do_anonymous_page(struct mm_struct *mm, 
 struct vm_area_struct *vma,
   return VM_FAULT_SIGBUS;
  
   /* Use the zero-page for reads */
 - if (!(flags  FAULT_FLAG_WRITE)) {
 + if (!(flags  FAULT_FLAG_WRITE)  !mm_forbids_zeropage(mm)) {
   entry = pte_mkspecial(pfn_pte(my_zero_pfn(address),
   vma-vm_page_prot));
   page_table = pte_offset_map_lock(mm, pmd, address, ptl);
 
--
To unsubscribe from this list: send the line unsubscribe kvm in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 2/4] mm: introduce mm_forbids_zeropage function

2014-10-22 Thread Andrew Morton
On Wed, 22 Oct 2014 13:09:28 +0200 Dominik Dingel din...@linux.vnet.ibm.com 
wrote:

 Add a new function stub to allow architectures to disable for
 an mm_structthe backing of non-present, anonymous pages with
 read-only empty zero pages.
 
 ...

 --- a/include/linux/mm.h
 +++ b/include/linux/mm.h
 @@ -56,6 +56,10 @@ extern int sysctl_legacy_va_layout;
  #define __pa_symbol(x)  __pa(RELOC_HIDE((unsigned long)(x), 0))
  #endif
  
 +#ifndef mm_forbids_zeropage
 +#define mm_forbids_zeropage(X)  (0)
 +#endif

Can we document this please?  What it does, why it does it.  We should
also specify precisely which arch header file is responsible for
defining mm_forbids_zeropage.


--
To unsubscribe from this list: send the line unsubscribe kvm in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 2/4] mm: introduce mm_forbids_zeropage function

2014-10-22 Thread Dominik Dingel
On Wed, 22 Oct 2014 12:22:23 -0700
Andrew Morton a...@linux-foundation.org wrote:

 On Wed, 22 Oct 2014 13:09:28 +0200 Dominik Dingel din...@linux.vnet.ibm.com 
 wrote:
 
  Add a new function stub to allow architectures to disable for
  an mm_structthe backing of non-present, anonymous pages with
  read-only empty zero pages.
  
  ...
 
  --- a/include/linux/mm.h
  +++ b/include/linux/mm.h
  @@ -56,6 +56,10 @@ extern int sysctl_legacy_va_layout;
   #define __pa_symbol(x)  __pa(RELOC_HIDE((unsigned long)(x), 0))
   #endif
   
  +#ifndef mm_forbids_zeropage
  +#define mm_forbids_zeropage(X)  (0)
  +#endif
 
 Can we document this please?  What it does, why it does it.  We should
 also specify precisely which arch header file is responsible for
 defining mm_forbids_zeropage.
 

I will add a comment like:

/*
 * To prevent common memory management code establishing
 * a zero page mapping on a read fault.
 * This function should be implemented within asm/pgtable.h.
 * s390 does this to prevent multiplexing of hardware bits
 * related to the physical page in case of virtualization.
 */

Okay?


 --
 To unsubscribe, send a message with 'unsubscribe linux-mm' in
 the body to majord...@kvack.org.  For more info on Linux MM,
 see: http://www.linux-mm.org/ .
 Don't email: a href=mailto:d...@kvack.org; em...@kvack.org /a
 

--
To unsubscribe from this list: send the line unsubscribe kvm in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 2/4] mm: introduce mm_forbids_zeropage function

2014-10-22 Thread Andrew Morton
On Wed, 22 Oct 2014 21:45:52 +0200 Dominik Dingel din...@linux.vnet.ibm.com 
wrote:

   +#ifndef mm_forbids_zeropage
   +#define mm_forbids_zeropage(X)  (0)
   +#endif
  
  Can we document this please?  What it does, why it does it.  We should
  also specify precisely which arch header file is responsible for
  defining mm_forbids_zeropage.
  
 
 I will add a comment like:
 
 /*
  * To prevent common memory management code establishing
  * a zero page mapping on a read fault.
  * This function should be implemented within asm/pgtable.h.

s/function should be implemented/macro should be defined/

  * s390 does this to prevent multiplexing of hardware bits
  * related to the physical page in case of virtualization.
  */
 
 Okay?

Looks great, thanks.
--
To unsubscribe from this list: send the line unsubscribe kvm in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html