diff mbox series

[v2,01/55] x86/mm: defer clearing page in virt_to_xen_lXe

Message ID e16d11bb1dc1dc973476d0ca3b26844ff9d738a4.1569833766.git.hongyax@amazon.com (mailing list archive)
State New, archived
Headers show
Series [v2,01/55] x86/mm: defer clearing page in virt_to_xen_lXe | expand

Commit Message

Xia, Hongyan Sept. 30, 2019, 10:32 a.m. UTC
From: Wei Liu <wei.liu2@citrix.com>

Defer the call to clear_page to the point when we're sure the page is
going to become a page table.

This is a minor optimisation. No functional change.

Signed-off-by: Wei Liu <wei.liu2@citrix.com>
---
 xen/arch/x86/mm.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

Comments

Wei Liu Sept. 30, 2019, 3:05 p.m. UTC | #1
On Mon, Sep 30, 2019 at 11:32:53AM +0100, Hongyan Xia wrote:
> From: Wei Liu <wei.liu2@citrix.com>
> 
> Defer the call to clear_page to the point when we're sure the page is
> going to become a page table.
> 
> This is a minor optimisation. No functional change.
> 
> Signed-off-by: Wei Liu <wei.liu2@citrix.com>

The benefit of this patch was questionable, because it made the lock
held longer. I had decided to drop it.

Wei.
diff mbox series

Patch

diff --git a/xen/arch/x86/mm.c b/xen/arch/x86/mm.c
index 99816fc67c..e90c8a63a6 100644
--- a/xen/arch/x86/mm.c
+++ b/xen/arch/x86/mm.c
@@ -4879,13 +4879,13 @@  static l3_pgentry_t *virt_to_xen_l3e(unsigned long v)
 
         if ( !pl3e )
             return NULL;
-        clear_page(pl3e);
         if ( locking )
             spin_lock(&map_pgdir_lock);
         if ( !(l4e_get_flags(*pl4e) & _PAGE_PRESENT) )
         {
             l4_pgentry_t l4e = l4e_from_paddr(__pa(pl3e), __PAGE_HYPERVISOR);
 
+            clear_page(pl3e);
             l4e_write(pl4e, l4e);
             efi_update_l4_pgtable(l4_table_offset(v), l4e);
             pl3e = NULL;
@@ -4914,11 +4914,11 @@  static l2_pgentry_t *virt_to_xen_l2e(unsigned long v)
 
         if ( !pl2e )
             return NULL;
-        clear_page(pl2e);
         if ( locking )
             spin_lock(&map_pgdir_lock);
         if ( !(l3e_get_flags(*pl3e) & _PAGE_PRESENT) )
         {
+            clear_page(pl2e);
             l3e_write(pl3e, l3e_from_paddr(__pa(pl2e), __PAGE_HYPERVISOR));
             pl2e = NULL;
         }
@@ -4947,11 +4947,11 @@  l1_pgentry_t *virt_to_xen_l1e(unsigned long v)
 
         if ( !pl1e )
             return NULL;
-        clear_page(pl1e);
         if ( locking )
             spin_lock(&map_pgdir_lock);
         if ( !(l2e_get_flags(*pl2e) & _PAGE_PRESENT) )
         {
+            clear_page(pl1e);
             l2e_write(pl2e, l2e_from_paddr(__pa(pl1e), __PAGE_HYPERVISOR));
             pl1e = NULL;
         }