Skip to contentSkip to conversation

x86/p2m: drop second pass looking for shared pages.

PATCH In review Tim Deegan 2 participants 3 messages Dec 18, 2013

lore
Share & tools
lore

Tim Deegan

author
#0 lore raw

PATCH 1/1 x86/p2m: drop second pass looking for shared pages.

We have run relinquish_shared_pages() already by the time this teardown happens, and page_make_sharable() exits early if the owning domain is dying.

Cc Andres Lagar-Cavilla <[email protected]>
---
 xen/arch/x86/mm/p2m.c | 21 +--------------------
 1 file changed, 1 insertion(+), 20 deletions(-)
xen/arch/x86/mm/p2m.c +1 -20
index d7dd480..c0ddef0 100644
@@ -440,9 +440,6 @@ void p2m_teardown(struct p2m_domain *p2m)
 {
     struct page_info *pg;
     struct domain *d;
-    unsigned long gfn;
-    p2m_type_t t;
-    mfn_t mfn;
 
     if (p2m == NULL)
         return;
@@ -450,23 +447,7 @@ void p2m_teardown(struct p2m_domain *p2m)
     d = p2m->domain;
 
     p2m_lock(p2m);
-
-    /* Try to unshare any remaining shared p2m entries. Safeguard
-     * Since relinquish_shared_pages should have done the work. */ 
-    for ( gfn=0; gfn < p2m->max_mapped_pfn; gfn++ )
-    {
-        p2m_access_t a;
-        if ( atomic_read(&d->shr_pages) == 0 )
-            break;
-        mfn = p2m->get_entry(p2m, gfn, &t, &a, 0, NULL);
-        if ( mfn_valid(mfn) && (t == p2m_ram_shared) )
-        {
-            ASSERT(!p2m_is_nestedp2m(p2m));
-            /* Does not fail with ENOMEM given the DESTROY flag */
-            BUG_ON(mem_sharing_unshare_page(d, gfn, MEM_SHARING_DESTROY_GFN));
-        }
-    }
-
+    ASSERT(atomic_read(&d->shr_pages) == 0);
     p2m->phys_table = pagetable_null();
 
     while ( (pg = page_list_remove_head(&p2m->pages)) )
Signature · 1 line
1.8.5.1
author
#1 lore raw
Quoted 6 lines · Tim Deegan

We have run relinquish_shared_pages() already by the time this teardown happens, and page_make_sharable() exits early if the owning domain is dying.

Cc Andres Lagar-Cavilla <[email protected]>

This is also OK to wait until we've branched, just posting now for review.

Tim.

Quoted 46 lines
---
 xen/arch/x86/mm/p2m.c | 21 +--------------------
 1 file changed, 1 insertion(+), 20 deletions(-)
xen/arch/x86/mm/p2m.c +1 -20
index d7dd480..c0ddef0 100644
@@ -440,9 +440,6 @@ void p2m_teardown(struct p2m_domain *p2m)
 {
     struct page_info *pg;
     struct domain *d;
-    unsigned long gfn;
-    p2m_type_t t;
-    mfn_t mfn;
 
     if (p2m == NULL)
         return;
@@ -450,23 +447,7 @@ void p2m_teardown(struct p2m_domain *p2m)
     d = p2m->domain;
 
     p2m_lock(p2m);
-
-    /* Try to unshare any remaining shared p2m entries. Safeguard
-     * Since relinquish_shared_pages should have done the work. */ 
-    for ( gfn=0; gfn < p2m->max_mapped_pfn; gfn++ )
-    {
-        p2m_access_t a;
-        if ( atomic_read(&d->shr_pages) == 0 )
-            break;
-        mfn = p2m->get_entry(p2m, gfn, &t, &a, 0, NULL);
-        if ( mfn_valid(mfn) && (t == p2m_ram_shared) )
-        {
-            ASSERT(!p2m_is_nestedp2m(p2m));
-            /* Does not fail with ENOMEM given the DESTROY flag */
-            BUG_ON(mem_sharing_unshare_page(d, gfn, MEM_SHARING_DESTROY_GFN));
-        }
-    }
-
+    ASSERT(atomic_read(&d->shr_pages) == 0);
     p2m->phys_table = pagetable_null();
 
     while ( (pg = page_list_remove_head(&p2m->pages)) )
Signature · 1 line
1.8.5.1
Acked-by on v1 1/1
#2 lore raw
In reply to Tim Deegan
Quoted 4 lines · Tim Deegan

We have run relinquish_shared_pages() already by the time this teardown happens, and page_make_sharable() exits early if the owning domain is dying.

I'd be absolutely happiest if mem_sharing_enabled(d) were set to false fairly early on the domain destruction sequence. Say in relinquish_resources.

Quoted 47 lines
Cc Andres Lagar-Cavilla <[email protected]>
---
 xen/arch/x86/mm/p2m.c | 21 +--------------------
 1 file changed, 1 insertion(+), 20 deletions(-)
xen/arch/x86/mm/p2m.c +1 -20
index d7dd480..c0ddef0 100644
@@ -440,9 +440,6 @@ void p2m_teardown(struct p2m_domain *p2m)
 {
     struct page_info *pg;
     struct domain *d;
-    unsigned long gfn;
-    p2m_type_t t;
-    mfn_t mfn;
 
     if (p2m == NULL)
         return;
@@ -450,23 +447,7 @@ void p2m_teardown(struct p2m_domain *p2m)
     d = p2m->domain;
 
     p2m_lock(p2m);
-
-    /* Try to unshare any remaining shared p2m entries. Safeguard
-     * Since relinquish_shared_pages should have done the work. */
-    for ( gfn=0; gfn < p2m->max_mapped_pfn; gfn++ )
-    {
-        p2m_access_t a;
-        if ( atomic_read(&d->shr_pages) == 0 )
-            break;
-        mfn = p2m->get_entry(p2m, gfn, &t, &a, 0, NULL);
-        if ( mfn_valid(mfn) && (t == p2m_ram_shared) )
-        {
-            ASSERT(!p2m_is_nestedp2m(p2m));
-            /* Does not fail with ENOMEM given the DESTROY flag */
-            BUG_ON(mem_sharing_unshare_page(d, gfn,
 MEM_SHARING_DESTROY_GFN));
-        }
-    }
-
+    ASSERT(atomic_read(&d->shr_pages) == 0);
     p2m->phys_table = pagetable_null();
 
     while ( (pg = page_list_remove_head(&p2m->pages)) )
Quoted 4 lines

--
1.8.5.1

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel