altp2m: Allow the hostp2m to be shared
PATCH 1/1 altp2m: Allow the hostp2m to be shared
Don't propagate altp2m changes from ept_set_entry for memshare as memshare already has the lock. We call altp2m propagate changes once memshare successfully finishes. Also, allow the hostp2m entries to be of type p2m_ram_shared.
---
Cc: George Dunlap <[email protected]>
Cc: Keir Fraser <[email protected]>
Cc: Jan Beulich <[email protected]>
Cc: Andrew Cooper <[email protected]>
Cc: Jun Nakajima <[email protected]>
Cc: Kevin Tian <[email protected]>
--- xen/arch/x86/mm/mem_sharing.c | 11 +++++++++++ xen/arch/x86/mm/p2m-ept.c | 2 +- xen/arch/x86/mm/p2m.c | 7 +++---- 3 files changed, 15 insertions(+), 5 deletions(-)
xen/arch/x86/mm/mem_sharing.c +11 -0
@@ -35,6 +35,7 @@#include <asm/p2m.h> #include <asm/atomic.h> #include <asm/event.h> +#include <asm/altp2m.h> #include <xsm/xsm.h> #include "mm-locks.h"
@@ -1026,6 +1027,16 @@ int mem_sharing_share_pages(struct domain *sd, unsigned long sgfn, shr_handle_t/* We managed to free a domain page. */ atomic_dec (&nr_shared_mfns);atomic_inc (&nr_saved_mfns); + +if (altp2m_active (cd) ) + { +p2m_access_t a; +struct p2m_domain *p2m =p2m_get_hostp2m (cd); + p2m->get_entry (p2m, cgfn,NULL , &a,0 ,NULL ,NULL ); +p2m_altp2m_propagate_change (cd,_gfn (cgfn), smfn,PAGE_ORDER_4K , + p2m_ram_shared, a); + } + ret =0 ; err_out:
xen/arch/x86/mm/p2m-ept.c +1 -1
@@ -846,7 +846,7 @@ out:if (is_epte_present (&old_entry) )ept_free_entry (p2m, &old_entry, target); -if ( rc ==0 &&p2m_is_hostp2m (p2m) ) +if ( rc ==0 &&p2m_is_hostp2m (p2m) && p2mt != p2m_ram_shared )p2m_altp2m_propagate_change (d,_gfn (gfn), mfn, order, p2mt, p2ma);return rc;
xen/arch/x86/mm/p2m.c +3 -4
@@ -1739,11 +1739,10 @@ int p2m_set_altp2m_mem_access(struct domain *d, struct p2m_domain *hp2m,/* Check host p2m if no valid entry in alternate */ if ( !mfn_valid (mfn) ) { - mfn = hp2m->get_entry (hp2m, gfn_l, &t, &old_a, -P2M_ALLOC |P2M_UNSHARE , &page_order,NULL ); + mfn = hp2m->get_entry (hp2m, gfn_l, &t, &old_a,0 , &page_order,NULL ); rc = -ESRCH ; -if ( !mfn_valid (mfn) || t != p2m_ram_rw ) +if ( !mfn_valid (mfn) || (t != p2m_ram_rw && t != p2m_ram_shared) )return rc;/* If this is a superpage, copy that first */
@@ -1760,7 +1759,7 @@ int p2m_set_altp2m_mem_access(struct domain *d, struct p2m_domain *hp2m, }return ap2m->set_entry (ap2m, gfn_l, mfn,PAGE_ORDER_4K , t, a, - (current->domain != d)); + (current->domain != d)); }/*
Signature · 7 lines
2.1.4 _______________________________________________ Xen-devel mailing list [email protected] http://lists.xen.org/xen-devel
Sadly I only have little nitpicks. Feel free to ignore them.
Quoted 13 lines
xen/arch/x86/mm/mem_sharing.c +1
-0@@ -35,6 +35,7 @@#include <asm/p2m.h> #include <asm/atomic.h> #include <asm/event.h> +#include <asm/altp2m.h> #include <xsm/xsm.h> #include "mm-locks.h"
xen/arch/x86/mm/mem_sharing.c int mem_sharing_share_pages(struct domain *sd, unsigned long sgfn, shr_handle_t · line 1031
Quoted 5 lines
xen/arch/x86/mm/mem_sharing.c +2
-0@@ -1026,6 +1027,16 @@ int mem_sharing_share_pages(struct domain *sd, unsigned long sgfn, shr_handle_t/* We managed to free a domain page. */ atomic_dec (&nr_shared_mfns);atomic_inc (&nr_saved_mfns); + +if (altp2m_active (cd) )
Missing space.
xen/arch/x86/mm/mem_sharing.c int mem_sharing_share_pages(struct domain *sd, unsigned long sgfn, shr_handle_t · line 1033
Quoted 2 lines
xen/arch/x86/mm/mem_sharing.c +2
-0+ { +p2m_access_t a;
Newline.
Quoted 27 lines
xen/arch/x86/mm/mem_sharing.c +6
-0+struct p2m_domain *p2m =p2m_get_hostp2m (cd); + p2m->get_entry (p2m, cgfn,NULL , &a,0 ,NULL ,NULL ); +p2m_altp2m_propagate_change (cd,_gfn (cgfn), smfn,PAGE_ORDER_4K , + p2m_ram_shared, a); + } + ret =0 ; err_out:xen/arch/x86/mm/p2m-ept.c +1
-1@@ -846,7 +846,7 @@ out:if (is_epte_present (&old_entry) )ept_free_entry (p2m, &old_entry, target); -if ( rc ==0 &&p2m_is_hostp2m (p2m) ) +if ( rc ==0 &&p2m_is_hostp2m (p2m) && p2mt != p2m_ram_shared )p2m_altp2m_propagate_change (d,_gfn (gfn), mfn, order, p2mt, p2ma);return rc;xen/arch/x86/mm/p2m.c +0
-0
xen/arch/x86/mm/p2m.c int p2m_set_altp2m_mem_access(struct domain *d, struct p2m_domain *hp2m, · line 1745
Quoted 10 lines
xen/arch/x86/mm/p2m.c +2
-3@@ -1739,11 +1739,10 @@ int p2m_set_altp2m_mem_access(struct domain *d, struct p2m_domain *hp2m,/* Check host p2m if no valid entry in alternate */ if ( !mfn_valid (mfn) ) { - mfn = hp2m->get_entry (hp2m, gfn_l, &t, &old_a, -P2M_ALLOC |P2M_UNSHARE , &page_order,NULL ); + mfn = hp2m->get_entry (hp2m, gfn_l, &t, &old_a,0 , &page_order,NULL ); rc = -ESRCH ; -if ( !mfn_valid (mfn) || t != p2m_ram_rw ) +if ( !mfn_valid (mfn) || (t != p2m_ram_rw && t != p2m_ram_shared) )
Would it be easier to read if there were more of ()?
xen/arch/x86/mm/p2m.c int p2m_set_altp2m_mem_access(struct domain *d, struct p2m_domain *hp2m, · line 1762
Quoted 9 lines
xen/arch/x86/mm/p2m.c +1
-1return rc;/* If this is a superpage, copy that first */ @@ -1760,7 +1759,7 @@ int p2m_set_altp2m_mem_access(struct domain *d, struct p2m_domain *hp2m, }return ap2m->set_entry (ap2m, gfn_l, mfn,PAGE_ORDER_4K , t, a, - (current->domain != d)); + (current->domain != d));
That looks like a cleanup? Perhaps a different patch?
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
Quoted 6 lines · Tamas K Lengyel
Don't propagate altp2m changes from
ept_set_entryfor memshare as memshare already has the lock. We call altp2m propagate changes once memshare successfully finishes. Also, allow the hostp2m entries to be of typep2m_ram_shared.Signed-off-by Tamas K Lengyel <[email protected]>
Sorry for the delay in reviewing -- trying to get my head back around the altp2m code. On the whole looks reasonable, but one question...
Quoted 60 lines
---
Cc: George Dunlap <[email protected]>
Cc: Keir Fraser <[email protected]>
Cc: Jan Beulich <[email protected]>
Cc: Andrew Cooper <[email protected]>
Cc: Jun Nakajima <[email protected]>
Cc: Kevin Tian <[email protected]>--- xen/arch/x86/mm/mem_sharing.c | 11 +++++++++++ xen/arch/x86/mm/p2m-ept.c | 2 +- xen/arch/x86/mm/p2m.c | 7 +++---- 3 files changed, 15 insertions(+), 5 deletions(-)xen/arch/x86/mm/mem_sharing.c +11
-0@@ -35,6 +35,7 @@#include <asm/p2m.h> #include <asm/atomic.h> #include <asm/event.h> +#include <asm/altp2m.h> #include <xsm/xsm.h> #include "mm-locks.h" @@ -1026,6 +1027,16 @@ int mem_sharing_share_pages(struct domain *sd, unsigned long sgfn, shr_handle_t/* We managed to free a domain page. */ atomic_dec (&nr_shared_mfns);atomic_inc (&nr_saved_mfns); + +if (altp2m_active (cd) ) + { +p2m_access_t a; +struct p2m_domain *p2m =p2m_get_hostp2m (cd); + p2m->get_entry (p2m, cgfn,NULL , &a,0 ,NULL ,NULL ); +p2m_altp2m_propagate_change (cd,_gfn (cgfn), smfn,PAGE_ORDER_4K , + p2m_ram_shared, a); + } + ret =0 ; err_out:xen/arch/x86/mm/p2m-ept.c +1
-1@@ -846,7 +846,7 @@ out:if (is_epte_present (&old_entry) )ept_free_entry (p2m, &old_entry, target); -if ( rc ==0 &&p2m_is_hostp2m (p2m) ) +if ( rc ==0 &&p2m_is_hostp2m (p2m) && p2mt != p2m_ram_shared )p2m_altp2m_propagate_change (d,_gfn (gfn), mfn, order, p2mt, p2ma);return rc;xen/arch/x86/mm/p2m.c +0
-0
xen/arch/x86/mm/p2m.c int p2m_set_altp2m_mem_access(struct domain *d, struct p2m_domain *hp2m, · line 1742
Quoted 6 lines
xen/arch/x86/mm/p2m.c +1
-2@@ -1739,11 +1739,10 @@ int p2m_set_altp2m_mem_access(struct domain *d, struct p2m_domain *hp2m,/* Check host p2m if no valid entry in alternate */ if ( !mfn_valid (mfn) ) { - mfn = hp2m->get_entry (hp2m, gfn_l, &t, &old_a, -P2M_ALLOC |P2M_UNSHARE , &page_order,NULL ); + mfn = hp2m->get_entry (hp2m, gfn_l, &t, &old_a,0 , &page_order,NULL );
Why are you getting rid of P2M_ALLOC here? What happens if the hp2m entry is populate-on-demand?
-George
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
Quoted 81 lines · George Dunlap
Quoted 1 line · Tamas K Lengyel
Don't propagate altp2m changes from
ept_set_entryfor memshare asmemshare
Quoted 5 lines
already has the lock. We call altp2m propagate changes once memshare successfully finishes. Also, allow the hostp2m entries to be of type
p2m_ram_shared.Signed-off-by Tamas K Lengyel <[email protected]>Sorry for the delay in reviewing -- trying to get my head back around the altp2m code. On the whole looks reasonable, but one question...
Quoted 7 lines
---
Cc: George Dunlap <[email protected]>
Cc: Keir Fraser <[email protected]>
Cc: Jan Beulich <[email protected]>
Cc: Andrew Cooper <[email protected]>
Cc: Jun Nakajima <[email protected]>
Cc: Kevin Tian <[email protected]>Review
Quoted 7 lines
--- xen/arch/x86/mm/mem_sharing.c | 11 +++++++++++ xen/arch/x86/mm/p2m-ept.c | 2 +- xen/arch/x86/mm/p2m.c | 7 +++---- 3 files changed, 15 insertions(+), 5 deletions(-)(quoted diff) +0
-0
b/xen/arch/x86/mm/mem_sharing.cxen/arch/x86/mm/mem_sharing.c int mem_sharing_share_pages(struct domain *sd,
Quoted 12 lines
index a522423..d5b4b2d 100644
xen/arch/x86/mm/mem_sharing.c +1
-0@@ -35,6 +35,7 @@#include <asm/p2m.h> #include <asm/atomic.h> #include <asm/event.h> +#include <asm/altp2m.h> #include <xsm/xsm.h> #include "mm-locks.h" @@ -1026,6 +1027,16 @@ int mem_sharing_share_pages(struct domain *sd,unsigned long sgfn,
shr_handle_tQuoted 21 lines
xen/arch/x86/mm/mem_sharing.c +10
-0/* We managed to free a domain page. */ atomic_dec (&nr_shared_mfns);atomic_inc (&nr_saved_mfns); + +if (altp2m_active (cd) ) + { +p2m_access_t a; +struct p2m_domain *p2m =p2m_get_hostp2m (cd); + p2m->get_entry (p2m, cgfn,NULL , &a,0 ,NULL ,NULL ); +p2m_altp2m_propagate_change (cd,_gfn (cgfn), smfn,PAGE_ORDER_4K , + p2m_ram_shared, a); + } + ret =0 ; err_out:xen/arch/x86/mm/p2m-ept.c +0
-0xen/arch/x86/mm/p2m-ept.c out: · line 850
Quoted 6 lines
xen/arch/x86/mm/p2m-ept.c +1
-1@@ -846,7 +846,7 @@ out:if (is_epte_present (&old_entry) )ept_free_entry (p2m, &old_entry, target); -if ( rc ==0 &&p2m_is_hostp2m (p2m) ) +if ( rc ==0 &&p2m_is_hostp2m (p2m) && p2mt != p2m_ram_shared ) p2m_altp2m_propagate_change(d, _gfn(gfn), mfn, order, p2mt,p2ma);
xen/arch/x86/mm/p2m.c int p2m_set_altp2m_mem_access(struct domain *d,
Quoted 7 lines
xen/arch/x86/mm/p2m-ept.c +0
-0return rc;xen/arch/x86/mm/p2m.c +0
-0@@ -1739,11 +1739,10 @@ int p2m_set_altp2m_mem_access(struct domain *d,struct
p2m_domain*hp2m,xen/arch/x86/mm/p2m.c int p2m_set_altp2m_mem_access(struct domain *d, struct p2m_domain *hp2m,
Quoted 5 lines
xen/arch/x86/mm/p2m.c +0
-2/* Check host p2m if no valid entry in alternate */ if ( !mfn_valid (mfn) ) { - mfn = hp2m->get_entry(hp2m, gfn_l, &t, &old_a, - P2M_ALLOC | P2M_UNSHARE, &page_order,
Quoted 7 lines
NULL);
xen/arch/x86/mm/p2m.c int p2m_set_altp2m_mem_access(struct domain *d, · line 1742
Quoted 1 line
xen/arch/x86/mm/p2m.c +1
-0+ mfn = hp2m->get_entry(hp2m, gfn_l, &t, &old_a, 0, &page_order,NULL);
Why are you getting rid of
P2M_ALLOChere? What happens if the hp2m entry is populate-on-demand?
There is a check further down here that only allows p2m_ram_rw and p2m_ram_shared. On the non-altp2m path mem_access doesn't request P2M_ALLOC either (but doesn't check the type), so I would say mem_access is not compatible with PoD.
Tamas
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
Quoted 86 lines · Tamas K Lengyel
Quoted 83 lines · George Dunlap
Quoted 1 line · Tamas K Lengyel
Don't propagate altp2m changes from
ept_set_entryfor memshare asmemshare
Quoted 5 lines
already has the lock. We call altp2m propagate changes once memshare successfully finishes. Also, allow the hostp2m entries to be of type
p2m_ram_shared.Signed-off-by Tamas K Lengyel <[email protected]>Sorry for the delay in reviewing -- trying to get my head back around the altp2m code. On the whole looks reasonable, but one question...
Quoted 7 lines
---
Cc: George Dunlap <[email protected]>
Cc: Keir Fraser <[email protected]>
Cc: Jan Beulich <[email protected]>
Cc: Andrew Cooper <[email protected]>
Cc: Jun Nakajima <[email protected]>
Cc: Kevin Tian <[email protected]>Review
Quoted 7 lines
--- xen/arch/x86/mm/mem_sharing.c | 11 +++++++++++ xen/arch/x86/mm/p2m-ept.c | 2 +- xen/arch/x86/mm/p2m.c | 7 +++---- 3 files changed, 15 insertions(+), 5 deletions(-)(quoted diff) +0
-0
b/xen/arch/x86/mm/mem_sharing.cxen/arch/x86/mm/mem_sharing.c int mem_sharing_share_pages(struct domain *sd,
Quoted 12 lines
index a522423..d5b4b2d 100644
xen/arch/x86/mm/mem_sharing.c +1
-0@@ -35,6 +35,7 @@#include <asm/p2m.h> #include <asm/atomic.h> #include <asm/event.h> +#include <asm/altp2m.h> #include <xsm/xsm.h> #include "mm-locks.h" @@ -1026,6 +1027,16 @@ int mem_sharing_share_pages(struct domain *sd,unsigned long sgfn,
shr_handle_tQuoted 21 lines
xen/arch/x86/mm/mem_sharing.c +10
-0/* We managed to free a domain page. */ atomic_dec (&nr_shared_mfns);atomic_inc (&nr_saved_mfns); + +if (altp2m_active (cd) ) + { +p2m_access_t a; +struct p2m_domain *p2m =p2m_get_hostp2m (cd); + p2m->get_entry (p2m, cgfn,NULL , &a,0 ,NULL ,NULL ); +p2m_altp2m_propagate_change (cd,_gfn (cgfn), smfn,PAGE_ORDER_4K , + p2m_ram_shared, a); + } + ret =0 ; err_out:xen/arch/x86/mm/p2m-ept.c +0
-0xen/arch/x86/mm/p2m-ept.c out: · line 850
Quoted 6 lines
xen/arch/x86/mm/p2m-ept.c +1
-1@@ -846,7 +846,7 @@ out:if (is_epte_present (&old_entry) )ept_free_entry (p2m, &old_entry, target); -if ( rc ==0 &&p2m_is_hostp2m (p2m) ) +if ( rc ==0 &&p2m_is_hostp2m (p2m) && p2mt != p2m_ram_shared ) p2m_altp2m_propagate_change(d, _gfn(gfn), mfn, order, p2mt,p2ma);
xen/arch/x86/mm/p2m.c int p2m_set_altp2m_mem_access(struct domain *d,
Quoted 7 lines
xen/arch/x86/mm/p2m-ept.c +0
-0return rc;xen/arch/x86/mm/p2m.c +0
-0@@ -1739,11 +1739,10 @@ int p2m_set_altp2m_mem_access(struct domain *d,struct
p2m_domain*hp2m,xen/arch/x86/mm/p2m.c int p2m_set_altp2m_mem_access(struct domain *d, struct p2m_domain *hp2m,
Quoted 5 lines
xen/arch/x86/mm/p2m.c +0
-2/* Check host p2m if no valid entry in alternate */ if ( !mfn_valid (mfn) ) { - mfn = hp2m->get_entry(hp2m, gfn_l, &t, &old_a, - P2M_ALLOC | P2M_UNSHARE, &page_order,NULL);
Quoted 1 line
xen/arch/x86/mm/p2m.c +1
-0+ mfn = hp2m->get_entry(hp2m, gfn_l, &t, &old_a, 0, &page_order,
Quoted 8 lines
Quoted 5 lines
NULL);
Why are you getting rid of
P2M_ALLOChere? What happens if the hp2m entry is populate-on-demand?There is a check further down here that only allows
p2m_ram_rwandp2m_ram_shared.
So what P2M_ALLOC means is, "If this is entry is PoD, then please populate it so I get a ram page." So the only way you can get a p2m_populate_on_demand type returned is if you remove this flag. Leave it and (assuming there's enough ram to go around), you'll always get p2m_ram_rw. :-)
Quoted 3 lines
On the non-altp2m path
mem_accessdoesn't requestP2M_ALLOCeither (but doesn't check the type), so I would saymem_accessis not compatible with PoD.
Off the top of my head I can't see a reason why they couldn't co-exist in principle, if you added P2M_ALLOC in a few key places.
-George
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
Quoted 104 lines · George Dunlap
Quoted 54 lines · Tamas K Lengyel
On Wed, Apr 27, 2016 at 9:01 AM, George Dunlap <[email protected]
Quoted 50 lines · wrote:
Quoted 1 line · Tamas K Lengyel
Don't propagate altp2m changes from
ept_set_entryfor memshare asmemshare
Quoted 5 lines
already has the lock. We call altp2m propagate changes once memshare successfully finishes. Also, allow the hostp2m entries to be of type
p2m_ram_shared.Signed-off-by Tamas K Lengyel <[email protected]>Sorry for the delay in reviewing -- trying to get my head back around the altp2m code. On the whole looks reasonable, but one question...
Quoted 7 lines
---
Cc: George Dunlap <[email protected]>
Cc: Keir Fraser <[email protected]>
Cc: Jan Beulich <[email protected]>
Cc: Andrew Cooper <[email protected]>
Cc: Jun Nakajima <[email protected]>
Cc: Kevin Tian <[email protected]>Review
Quoted 7 lines
--- xen/arch/x86/mm/mem_sharing.c | 11 +++++++++++ xen/arch/x86/mm/p2m-ept.c | 2 +- xen/arch/x86/mm/p2m.c | 7 +++---- 3 files changed, 15 insertions(+), 5 deletions(-)(quoted diff) +0
-0
b/xen/arch/x86/mm/mem_sharing.cxen/arch/x86/mm/mem_sharing.c int mem_sharing_share_pages(struct domain *sd,
Quoted 12 lines
index a522423..d5b4b2d 100644
xen/arch/x86/mm/mem_sharing.c +1
-0@@ -35,6 +35,7 @@#include <asm/p2m.h> #include <asm/atomic.h> #include <asm/event.h> +#include <asm/altp2m.h> #include <xsm/xsm.h> #include "mm-locks.h" @@ -1026,6 +1027,16 @@ int mem_sharing_share_pages(struct domain *sd,unsigned long sgfn,
shr_handle_tQuoted 10 lines
xen/arch/x86/mm/mem_sharing.c +7
-0/* We managed to free a domain page. */ atomic_dec (&nr_shared_mfns);atomic_inc (&nr_saved_mfns); + +if (altp2m_active (cd) ) + { +p2m_access_t a; +struct p2m_domain *p2m =p2m_get_hostp2m (cd); + p2m->get_entry (p2m, cgfn,NULL , &a,0 ,NULL ,NULL ); + p2m_altp2m_propagate_change(cd, _gfn(cgfn), smfn,
PAGE_ORDER_4K,Quoted 33 lines
Quoted 33 lines
Quoted 11 lines
xen/arch/x86/mm/mem_sharing.c +3
-0+ p2m_ram_shared, a); + } + ret =0 ; err_out:xen/arch/x86/mm/p2m-ept.c +0
-0xen/arch/x86/mm/p2m-ept.c out: · line 850
Quoted 6 lines
xen/arch/x86/mm/p2m-ept.c +1
-1@@ -846,7 +846,7 @@ out:if (is_epte_present (&old_entry) )ept_free_entry (p2m, &old_entry, target); -if ( rc ==0 &&p2m_is_hostp2m (p2m) ) +if ( rc ==0 &&p2m_is_hostp2m (p2m) && p2mt != p2m_ram_shared ) p2m_altp2m_propagate_change(d, _gfn(gfn), mfn, order, p2mt,p2ma);
xen/arch/x86/mm/p2m.c int p2m_set_altp2m_mem_access(struct domain *d,
Quoted 7 lines
xen/arch/x86/mm/p2m-ept.c +0
-0return rc;xen/arch/x86/mm/p2m.c +0
-0@@ -1739,11 +1739,10 @@ int p2m_set_altp2m_mem_access(struct domain *d,struct
p2m_domain*hp2m,xen/arch/x86/mm/p2m.c int p2m_set_altp2m_mem_access(struct domain *d, struct p2m_domain *hp2m,
Quoted 5 lines
xen/arch/x86/mm/p2m.c +0
-2/* Check host p2m if no valid entry in alternate */ if ( !mfn_valid (mfn) ) { - mfn = hp2m->get_entry(hp2m, gfn_l, &t, &old_a, - P2M_ALLOC | P2M_UNSHARE, &page_order,NULL);
Quoted 1 line
xen/arch/x86/mm/p2m.c +1
-0+ mfn = hp2m->get_entry(hp2m, gfn_l, &t, &old_a, 0, &page_order,Quoted 8 lines
Quoted 5 lines
NULL);
Why are you getting rid of
P2M_ALLOChere? What happens if the hp2m entry is populate-on-demand?There is a check further down here that only allows
p2m_ram_rwandp2m_ram_shared.So what
P2M_ALLOCmeans is, "If this is entry is PoD, then please populate it so I get a ram page." So the only way you can get ap2m_populate_on_demandtype returned is if you remove this flag. Leave it and (assuming there's enough ram to go around), you'll always getp2m_ram_rw. :-)
Quoted 7 lines
Quoted 3 lines
On the non-altp2m path
mem_accessdoesn't requestP2M_ALLOCeither (but doesn't check the type), so I would saymem_accessis not compatible with PoD.Off the top of my head I can't see a reason why they couldn't co-exist in principle, if you added
P2M_ALLOCin a few key places.
Sure, I just rather do that in a separate patch and for now have the mem_access paths behaving the same way before doing that adjustment.
Tamas
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
Quoted 111 lines · Tamas K Lengyel
Quoted 108 lines · George Dunlap
Quoted 54 lines · Tamas K Lengyel
On Wed, Apr 27, 2016 at 9:01 AM, George Dunlap <[email protected]
Quoted 50 lines · wrote:
Quoted 1 line · Tamas K Lengyel
Don't propagate altp2m changes from
ept_set_entryfor memshare asmemshare
Quoted 5 lines
already has the lock. We call altp2m propagate changes once memshare successfully finishes. Also, allow the hostp2m entries to be of type
p2m_ram_shared.Signed-off-by Tamas K Lengyel <[email protected]>Sorry for the delay in reviewing -- trying to get my head back around the altp2m code. On the whole looks reasonable, but one question...
Quoted 7 lines
---
Cc: George Dunlap <[email protected]>
Cc: Keir Fraser <[email protected]>
Cc: Jan Beulich <[email protected]>
Cc: Andrew Cooper <[email protected]>
Cc: Jun Nakajima <[email protected]>
Cc: Kevin Tian <[email protected]>Review
Quoted 7 lines
--- xen/arch/x86/mm/mem_sharing.c | 11 +++++++++++ xen/arch/x86/mm/p2m-ept.c | 2 +- xen/arch/x86/mm/p2m.c | 7 +++---- 3 files changed, 15 insertions(+), 5 deletions(-)(quoted diff) +0
-0
b/xen/arch/x86/mm/mem_sharing.cxen/arch/x86/mm/mem_sharing.c int mem_sharing_share_pages(struct domain *sd,
Quoted 12 lines
index a522423..d5b4b2d 100644
xen/arch/x86/mm/mem_sharing.c +1
-0@@ -35,6 +35,7 @@#include <asm/p2m.h> #include <asm/atomic.h> #include <asm/event.h> +#include <asm/altp2m.h> #include <xsm/xsm.h> #include "mm-locks.h" @@ -1026,6 +1027,16 @@ int mem_sharing_share_pages(struct domain *sd,unsigned long sgfn,
shr_handle_tQuoted 10 lines
xen/arch/x86/mm/mem_sharing.c +7
-0/* We managed to free a domain page. */ atomic_dec (&nr_shared_mfns);atomic_inc (&nr_saved_mfns); + +if (altp2m_active (cd) ) + { +p2m_access_t a; +struct p2m_domain *p2m =p2m_get_hostp2m (cd); + p2m->get_entry (p2m, cgfn,NULL , &a,0 ,NULL ,NULL ); + p2m_altp2m_propagate_change(cd, _gfn(cgfn), smfn,
PAGE_ORDER_4K,Quoted 33 lines
Quoted 33 lines
Quoted 11 lines
xen/arch/x86/mm/mem_sharing.c +3
-0+ p2m_ram_shared, a); + } + ret =0 ; err_out:xen/arch/x86/mm/p2m-ept.c +0
-0xen/arch/x86/mm/p2m-ept.c out: · line 850
Quoted 6 lines
xen/arch/x86/mm/p2m-ept.c +1
-1@@ -846,7 +846,7 @@ out:if (is_epte_present (&old_entry) )ept_free_entry (p2m, &old_entry, target); -if ( rc ==0 &&p2m_is_hostp2m (p2m) ) +if ( rc ==0 &&p2m_is_hostp2m (p2m) && p2mt != p2m_ram_shared ) p2m_altp2m_propagate_change(d, _gfn(gfn), mfn, order, p2mt,p2ma);
xen/arch/x86/mm/p2m.c int p2m_set_altp2m_mem_access(struct domain *d,
Quoted 7 lines
xen/arch/x86/mm/p2m-ept.c +0
-0return rc;xen/arch/x86/mm/p2m.c +0
-0@@ -1739,11 +1739,10 @@ int p2m_set_altp2m_mem_access(struct domain *d,struct
p2m_domain*hp2m,xen/arch/x86/mm/p2m.c int p2m_set_altp2m_mem_access(struct domain *d, struct p2m_domain *hp2m,
Quoted 5 lines
xen/arch/x86/mm/p2m.c +0
-2/* Check host p2m if no valid entry in alternate */ if ( !mfn_valid (mfn) ) { - mfn = hp2m->get_entry(hp2m, gfn_l, &t, &old_a, - P2M_ALLOC | P2M_UNSHARE, &page_order,NULL);
Quoted 1 line
xen/arch/x86/mm/p2m.c +1
-0+ mfn = hp2m->get_entry(hp2m, gfn_l, &t, &old_a, 0, &page_order,Quoted 8 lines
Quoted 5 lines
NULL);
Why are you getting rid of
P2M_ALLOChere? What happens if the hp2m entry is populate-on-demand?There is a check further down here that only allows
p2m_ram_rwandp2m_ram_shared.So what
P2M_ALLOCmeans is, "If this is entry is PoD, then please populate it so I get a ram page." So the only way you can get ap2m_populate_on_demandtype returned is if you remove this flag. Leave it and (assuming there's enough ram to go around), you'll always getp2m_ram_rw. :-)Quoted 3 lines
On the non-altp2m path
mem_accessdoesn't requestP2M_ALLOCeither (but doesn't check the type), so I would saymem_accessis not compatible with PoD.
Quoted 6 lines
Quoted 3 lines
Off the top of my head I can't see a reason why they couldn't co-exist in principle, if you added
P2M_ALLOCin a few key places.Sure, I just rather do that in a separate patch and for now have the
mem_accesspaths behaving the same way before doing that adjustment.
Ok, in that case please add a few sentences in the changelog addressing the change.
Thanks,
-George
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel