xen: better grant v2 support
cover xen: better grant v2 support
Currently Linux has no support for grant v2 as this would reduce the maximum number of active grants by a factor of 2 compared to v1, because the number of possible grants are limited by the allowed number of grant frames and grant entries of v2 need twice as much bytes as those of v1.
Unfortunately grant v2 is the only way to support either guests with more than 16TB memory size or PV guests with memory above the 16TB border, as grant v1 limits the frame number to be 32 bits wide.
In order to remove the disadvantage of grant v2 this patch series enables configuring different maximum grant frame numbers for v1 and v2. In order to let the guest know about the actual numbers an interface for probing the v1 and v2 limits is added.
Juergen Gross (5):
xen: remove deprecated boot parameter gnttab_max_nr_frames
xen: move XENMAPSPACE_grant_table code into grant_table.c
xen: clean up grant_table.h
xen: support different gnttab_max_frames for grant v1 and v2
xen: add new hypercall to get grant table limits
xen/arch/arm/domain.c | 2 +- xen/arch/arm/domain_build.c | 2 +- xen/arch/arm/mm.c | 34 +---- xen/arch/x86/mm.c | 41 ++---- xen/common/compat/grant_table.c | 9 +- xen/common/grant_table.c | 267 ++++++++++++++++++++++++++++++-------- xen/include/asm-arm/grant_table.h | 9 +- xen/include/asm-x86/grant_table.h | 5 + xen/include/public/grant_table.h | 14 ++ xen/include/xen/grant_table.h | 92 +------------ xen/include/xen/sched.h | 1 + 11 files changed, 269 insertions(+), 207 deletions(-)
Signature · 7 lines
2.12.3 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xen.org/xen-devel
PATCH 1/5 xen: remove deprecated boot parameter gnttab_max_nr_frames
The boot parameter gnttab_max_nr_frames has been deprecated in Xen 4.5. Remove it now.
--- xen/common/grant_table.c | 19 +------------------ 1 file changed, 1 insertion(+), 18 deletions(-)
xen/common/grant_table.c +1 -18
@@ -40,13 +40,6 @@#include <xsm/xsm.h> #include <asm/flushtlb.h> -/* -* This option is deprecated, use gnttab_max_frames and -* gnttab_max_maptrack_frames instead. -*/ -static unsigned int __initdata max_nr_grant_frames; -integer_param ("gnttab_max_nr_frames" , max_nr_grant_frames); -unsigned int __read_mostly max_grant_frames;integer_param ("gnttab_max_frames" , max_grant_frames);
@@ -3684,17 +3677,7 @@ static void gnttab_usage_print_all(unsigned char key)static int __init gnttab_usage_init (void ) { -if ( max_nr_grant_frames ) - { -printk (XENLOG_WARNING -"gnttab_max_nr_frames is deprecated, use gnttab_max_frames instead\n" ); -if ( !max_grant_frames ) - max_grant_frames = max_nr_grant_frames; -BUILD_BUG_ON (DEFAULT_MAX_MAPTRACK_FRAMES <DEFAULT_MAX_NR_GRANT_FRAMES ); -if ( !max_maptrack_frames ) - max_maptrack_frames = max_nr_grant_frames * - (DEFAULT_MAX_MAPTRACK_FRAMES /DEFAULT_MAX_NR_GRANT_FRAMES ); - } +BUILD_BUG_ON (DEFAULT_MAX_MAPTRACK_FRAMES <DEFAULT_MAX_NR_GRANT_FRAMES );if ( !max_grant_frames ) max_grant_frames =DEFAULT_MAX_NR_GRANT_FRAMES ;
Signature · 7 lines
2.12.3 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xen.org/xen-devel
Re: [PATCH 1/5] xen: remove deprecated boot parameter gnttab_max_nr_frames
Quoted 5 lines
Quoted 1 line
Quoted 1 line · On 21.08.17 at 20:05, <[email protected]> wrote:
The boot parameter
gnttab_max_nr_frameshas been deprecated in Xen 4.5. Remove it now.Signed-off-by Juergen Gross <[email protected]>
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
PATCH 2/5 xen: move XENMAPSPACE_grant_table code into grant_table.c
In reply to Juergen GrossThe x86 and arm versions of XENMAPSPACE_grant_table handling are nearly identical. Move the code into a function in grant_table.c and add an architecture dependant hook to handle the differences.
This at once fixes a bug in the arm code which didn't unlock the grant table in error case.
--- xen/arch/arm/mm.c | 34 ++++---------------------------- xen/arch/x86/mm.c | 41 ++++++++++----------------------------- xen/common/grant_table.c | 38 ++++++++++++++++++++++++++++++++++++ xen/include/asm-arm/grant_table.h | 6 ++++++ xen/include/asm-x86/grant_table.h | 5 +++++ xen/include/xen/grant_table.h | 3 +++ 6 files changed, 66 insertions(+), 61 deletions(-)
xen/arch/arm/mm.c +4 -30
@@ -24,6 +24,7 @@#include <xen/mm.h> #include <xen/preempt.h> #include <xen/errno.h> +#include <xen/sched.h> #include <xen/grant_table.h> #include <xen/softirq.h> #include <xen/event.h>
@@ -34,7 +35,6 @@#include <asm/current.h> #include <asm/flushtlb.h> #include <public/memory.h> -#include <xen/sched.h> #include <xen/vmap.h> #include <xsm/xsm.h> #include <xen/pfn.h>
@@ -1229,37 +1229,11 @@ int xenmem_add_to_physmap_one(switch ( space ) {case XENMAPSPACE_grant_table: -grant_write_lock (d->grant_table); - -if ( d->grant_table->gt_version ==0 ) - d->grant_table->gt_version =1 ; - -if ( d->grant_table->gt_version ==2 && - (idx & XENMAPIDX_grant_table_status) ) - { - idx &= ~XENMAPIDX_grant_table_status; -if ( idx <nr_status_frames (d->grant_table) ) - mfn =virt_to_mfn (d->grant_table->status[idx]); -else -return -EINVAL ; - } -else - { -if ( (idx >=nr_grant_frames (d->grant_table)) && - (idx < max_grant_frames) ) -gnttab_grow_table (d, idx +1 ); - -if ( idx <nr_grant_frames (d->grant_table) ) - mfn =virt_to_mfn (d->grant_table->shared_raw[idx]); -else -return -EINVAL ; - } - - d->arch.grant_table_gfn[idx] = gfn; + rc =gnttab_map_frame (d, idx, gfn, &mfn); +if ( rc ) +return rc; t = p2m_ram_rw; - -grant_write_unlock (d->grant_table);break ;case XENMAPSPACE_shared_info:if ( idx !=0 )
xen/arch/x86/mm.c +10 -31
81 lines not on this page · raw message
xen/common/grant_table.c +38 -0
@@ -3607,6 +3607,44 @@ int mem_sharing_gref_to_gfn(struct grant_table *gt, grant_ref_t ref, }#endif +int gnttab_map_frame (struct domain *d,unsigned long idx,gfn_t gfn, +mfn_t *mfn) +{ +int rc =0 ; + +grant_write_lock (d->grant_table); + +if ( d->grant_table->gt_version ==0 ) + d->grant_table->gt_version =1 ; + +if ( d->grant_table->gt_version ==2 && + (idx & XENMAPIDX_grant_table_status) ) + { + idx &= ~XENMAPIDX_grant_table_status; +if ( idx <nr_status_frames (d->grant_table) ) + *mfn =_mfn (virt_to_mfn (d->grant_table->status[idx])); +else + rc = -EINVAL ; + } +else + { +if ( (idx >=nr_grant_frames (d->grant_table)) && + (idx < max_grant_frames) ) +gnttab_grow_table (d, idx +1 ); + +if ( idx <nr_grant_frames (d->grant_table) ) + *mfn =_mfn (virt_to_mfn (d->grant_table->shared_raw[idx])); +else + rc = -EINVAL ; + } + +gnttab_set_frame_gfn (d, idx, gfn); + +grant_write_unlock (d->grant_table); + +return rc; +} +static void gnttab_usage_print (struct domain *rd) {int first =1 ;
xen/include/asm-arm/grant_table.h +6 -0
@@ -21,6 +21,12 @@ static inline int replace_grant_supported(void)return 1 ; } +static inline void gnttab_set_frame_gfn (struct domain *d,unsigned long idx, +gfn_t gfn) +{ + d->arch.grant_table_gfn[idx] = gfn; +} +#define gnttab_create_shared_page (d, t, i) \ do { \ share_xen_page_with_guest( \
xen/include/asm-x86/grant_table.h +5 -0
@@ -75,6 +75,11 @@ static inline void gnttab_clear_flag(unsigned int nr, uint16_t *st) asmvolatile ("lock btrw %w1,%0" :"=m" (*st) :"Ir" (nr),"m" (*st)); } +static inline void gnttab_set_frame_gfn (struct domain *d,unsigned long idx, +gfn_t gfn) +{ +} +/* Foreign mappings of HHVM-guest pages do not modify the type count. */ #define gnttab_host_mapping_get_page_type (ro, ld, rd) \ (!(ro) && (((ld) == (rd)) || !paging_mode_external(rd)))
xen/include/xen/grant_table.h +3 -0
@@ -136,4 +136,7 @@ static inline unsigned int grant_to_status_frames(int grant_frames)int mem_sharing_gref_to_gfn (struct grant_table *gt,grant_ref_t ref,gfn_t *gfn,uint16_t *status); +int gnttab_map_frame (struct domain *d,unsigned long idx,gfn_t gfn, +mfn_t *mfn); +#endif /* __XEN_GRANT_TABLE_H__ */
Signature · 7 lines
2.12.3 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xen.org/xen-devel
Re: [PATCH 2/5] xen: move XENMAPSPACE_grant_table code into grant_table.c
Quoted 9 lines
Quoted 1 line
Quoted 1 line · On 21.08.17 at 20:05, <[email protected]> wrote:
The x86 and arm versions of
XENMAPSPACE_grant_tablehandling are nearly identical. Move the code into a function ingrant_table.cand add an architecture dependant hook to handle the differences.This at once fixes a bug in the arm code which didn't unlock the grant table in error case.
Signed-off-by Juergen Gross <[email protected]>
This will need re-basing over the XSA-235 fix which went in yesterday. Perhaps worth having a local variable for d->grant_table in gnttab_map_frame(), but apart from that the change looks fine.
Jan
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Re: [PATCH 2/5] xen: move XENMAPSPACE_grant_table code into grant_table.c
In reply to Juergen GrossHello,
I was expecting to be CCed on this patch.
Quoted 22 lines · Juergen Gross
The x86 and arm versions of
XENMAPSPACE_grant_tablehandling are nearly identical. Move the code into a function ingrant_table.cand add an architecture dependant hook to handle the differences.This at once fixes a bug in the arm code which didn't unlock the grant table in error case.
Signed-off-by Juergen Gross <[email protected]>--- xen/arch/arm/mm.c | 34 ++++---------------------------- xen/arch/x86/mm.c | 41 ++++++++++----------------------------- xen/common/grant_table.c | 38 ++++++++++++++++++++++++++++++++++++ xen/include/asm-arm/grant_table.h | 6 ++++++ xen/include/asm-x86/grant_table.h | 5 +++++ xen/include/xen/grant_table.h | 3 +++ 6 files changed, 66 insertions(+), 61 deletions(-)xen/arch/arm/mm.c +0
-0
xen/arch/arm/mm.c line 27
Quoted 4 lines
xen/arch/arm/mm.c +1
-0@@ -24,6 +24,7 @@#include <xen/mm.h> #include <xen/preempt.h> #include <xen/errno.h> +#include <xen/sched.h>
Why sched.h has been moved earlier? Likely it means one of the header doesn't include all its dependency.
Cheers,
Signature · 6 lines
Julien Grall _______________________________________________ Xen-devel mailing list [email protected] https://lists.xen.org/xen-devel
Re: [PATCH 2/5] xen: move XENMAPSPACE_grant_table code into grant_table.c
Quoted 3 lines · Julien Grall
Hello,
I was expecting to be CCed on this patch.
Oops, sorry for that.
Quoted 21 lines · Juergen Gross
Quoted 19 lines
The x86 and arm versions of
XENMAPSPACE_grant_tablehandling are nearly identical. Move the code into a function ingrant_table.cand add an architecture dependant hook to handle the differences.This at once fixes a bug in the arm code which didn't unlock the grant table in error case.
Signed-off-by Juergen Gross <[email protected]>--- xen/arch/arm/mm.c | 34 ++++---------------------------- xen/arch/x86/mm.c | 41 ++++++++++----------------------------- xen/common/grant_table.c | 38 ++++++++++++++++++++++++++++++++++++ xen/include/asm-arm/grant_table.h | 6 ++++++ xen/include/asm-x86/grant_table.h | 5 +++++ xen/include/xen/grant_table.h | 3 +++ 6 files changed, 66 insertions(+), 61 deletions(-)
Quoted 12 lines
xen/arch/arm/mm.c line 27
Quoted 9 lines
xen/arch/arm/mm.c +1
-0@@ -24,6 +24,7 @@#include <xen/mm.h> #include <xen/preempt.h> #include <xen/errno.h> +#include <xen/sched.h> Why
sched.hhas been moved earlier? Likely it means one of the header doesn't include all its dependency.
I'll have a look.
Juergen
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
PATCH 3/5 xen: clean up grant_table.h
In reply to Juergen GrossMany definitions can be moved from xen/grant_table.h to common/grant_table.c now, as they are no longer used in other sources.
--- xen/common/grant_table.c | 81 +++++++++++++++++++++++++++++++++++++++- xen/include/xen/grant_table.h | 86 +------------------------------------------ xen/include/xen/sched.h | 1 + 3 files changed, 81 insertions(+), 87 deletions(-)
xen/common/grant_table.c +79 -2
@@ -40,6 +40,42 @@#include <xsm/xsm.h> #include <asm/flushtlb.h> +/* Per-domain grant information. */ +struct grant_table { +/* +* Lock protecting updates to grant table state (version, active +* entry list, etc.) +*/ +percpu_rwlock_t lock; +/* Table size. Number of frames shared with guest */ +unsigned int nr_grant_frames; +/* Shared grant table (see include/public/grant_table.h). */ +union { +void **shared_raw; +struct grant_entry_v1 **shared_v1; +union grant_entry_v2 **shared_v2; + }; +/* Number of grant status frames shared with guest (for version 2) */ +unsigned int nr_status_frames; +/* State grant table (see include/public/grant_table.h). */ +grant_status_t **status; +/* Active grant table. */ +struct active_grant_entry **active; +/* Mapping tracking table per vcpu. */ +struct grant_mapping **maptrack; +unsigned int maptrack_limit; +/* Lock protecting the maptrack limit */ +spinlock_t maptrack_lock; +/* The defined versions are 1 and 2. Set to 0 if we don't know +what version to use yet. */ +unsigned gt_version; +}; + +#ifndef DEFAULT_MAX_NR_GRANT_FRAMES /* to allow arch to override */ +/* Default maximum size of a grant table. [POLICY] */ +#define DEFAULT_MAX_NR_GRANT_FRAMES 32 +#endif +unsigned int __read_mostly max_grant_frames;integer_param ("gnttab_max_frames" , max_grant_frames);
@@ -118,6 +154,18 @@ struct grant_mapping {uint32_t pad;/* round size to a power of 2 */ }; +/* Number of grant table frames. Caller must hold d's grant table lock. */ +static inline unsigned int nr_grant_frames (struct grant_table *gt) +{ +return gt->nr_grant_frames; +} + +/* Number of status grant table frames. Caller must hold d's gr. table lock.*/ +static inline unsigned int nr_status_frames (struct grant_table *gt) +{ +return gt->nr_status_frames; +} +#define MAPTRACK_PER_PAGE (PAGE_SIZE / sizeof(struct grant_mapping))#define maptrack_entry (t, e) \ ((t)->maptrack[(e)/MAPTRACK_PER_PAGE][(e)%MAPTRACK_PER_PAGE])
@@ -197,7 +245,27 @@ static inline void act_set_gfn(struct active_grant_entry *act, gfn_t gfn)#endif } -DEFINE_PERCPU_RWLOCK_GLOBAL (grant_rwlock); +static DEFINE_PERCPU_RWLOCK_GLOBAL (grant_rwlock); + +static inline void grant_read_lock (struct grant_table *gt) +{ +percpu_read_lock (grant_rwlock, >->lock); +} + +static inline void grant_read_unlock (struct grant_table *gt) +{ +percpu_read_unlock (grant_rwlock, >->lock); +} + +static inline void grant_write_lock (struct grant_table *gt) +{ +percpu_write_lock (grant_rwlock, >->lock); +} + +static inline void grant_write_unlock (struct grant_table *gt) +{ +percpu_write_unlock (grant_rwlock, >->lock); +}static inline void gnttab_flush_tlb (const struct domain *d) {
@@ -250,6 +318,15 @@ static inline void active_entry_release(struct active_grant_entry *act)spin_unlock (&act->lock); } +#define GRANT_STATUS_PER_PAGE (PAGE_SIZE / sizeof(grant_status_t)) +#define GRANT_PER_PAGE (PAGE_SIZE / sizeof(grant_entry_v2_t)) +/* Number of grant table status entries. Caller must hold d's gr. table lock.*/ +static inline unsigned int grant_to_status_frames (int grant_frames) +{ +return (grant_frames *GRANT_PER_PAGE +GRANT_STATUS_PER_PAGE -1 ) / +GRANT_STATUS_PER_PAGE ; +} +/* Check if the page has been paged out, or needs unsharing. If rc == GNTST_okay, *page contains the page struct with a ref taken. Caller must do put_page(*page).
@@ -1580,7 +1657,7 @@ gnttab_unpopulate_status_frames(struct domain *d, struct grant_table *gt)* Grow the grant table. The caller must hold the grant table's * write lock before calling this function. */ -int +static int gnttab_grow_table (struct domain *d,unsigned int req_nr_frames) {struct grant_table *gt = d->grant_table;
xen/include/xen/grant_table.h +1 -85
99 lines not on this page · raw message
xen/include/xen/sched.h +1 -0
@@ -307,6 +307,7 @@ struct vm_event_per_domain };struct evtchn_port_ops ; +struct grant_table ;enum guest_type { guest_type_pv, guest_type_hvm
Signature · 7 lines
2.12.3 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xen.org/xen-devel
Re: [PATCH 3/5] xen: clean up grant_table.h
Quoted 6 lines
Quoted 1 line
Quoted 1 line · On 21.08.17 at 20:05, <[email protected]> wrote:
xen/common/grant_table.c +1
-0@@ -118,6 +154,18 @@ struct grant_mapping {uint32_t pad;/* round size to a power of 2 */ }; +/* Number of grant table frames. Caller must hold d's grant table lock. */
xen/common/grant_table.c struct grant_mapping { · line 167
Quoted 10 lines
xen/common/grant_table.c +10
-0+static inline unsigned int nr_grant_frames (struct grant_table *gt) +{ +return gt->nr_grant_frames; +} + +/* Number of status grant table frames. Caller must hold d's gr. table lock.*/ +static inline unsigned int nr_status_frames (struct grant_table *gt) +{ +return gt->nr_status_frames; +}
For both the parameters want to be constified.
xen/common/grant_table.c static inline void active_entry_release(struct active_grant_entry *act) · line 324
Quoted 8 lines
xen/common/grant_table.c +4
-0@@ -250,6 +318,15 @@ static inline void active_entry_release(struct active_grant_entry *act)spin_unlock (&act->lock); } +#define GRANT_STATUS_PER_PAGE (PAGE_SIZE / sizeof(grant_status_t)) +#define GRANT_PER_PAGE (PAGE_SIZE / sizeof(grant_entry_v2_t)) +/* Number of grant table status entries. Caller must hold d's gr. table lock.*/ +static inline unsigned int grant_to_status_frames (int grant_frames)
unsigned int also for the parameter.
Quoted 56 lines
xen/include/xen/grant_table.h +0
-49@@ -29,65 +29,8 @@#include <asm/page.h> #include <asm/grant_table.h> -#ifndef DEFAULT_MAX_NR_GRANT_FRAMES /* to allow arch to override */ -/* Default maximum size of a grant table. [POLICY] */ -#define DEFAULT_MAX_NR_GRANT_FRAMES 32 -#endif /* The maximum size of a grant table. */ -extern unsigned int max_grant_frames; - -DECLARE_PERCPU_RWLOCK_GLOBAL (grant_rwlock); - -/* Per-domain grant information. */ -struct grant_table { -/* -* Lock protecting updates to grant table state (version, active -* entry list, etc.) -*/ -percpu_rwlock_t lock; -/* Table size. Number of frames shared with guest */ -unsigned int nr_grant_frames; -/* Shared grant table (see include/public/grant_table.h). */ -union { -void **shared_raw; -struct grant_entry_v1 **shared_v1; -union grant_entry_v2 **shared_v2; - }; -/* Number of grant status frames shared with guest (for version 2) */ -unsigned int nr_status_frames; -/* State grant table (see include/public/grant_table.h). */ -grant_status_t **status; -/* Active grant table. */ -struct active_grant_entry **active; -/* Mapping tracking table per vcpu. */ -struct grant_mapping **maptrack; -unsigned int maptrack_limit; -/* Lock protecting the maptrack limit */ -spinlock_t maptrack_lock; -/* The defined versions are 1 and 2. Set to 0 if we don't know -what version to use yet. */ -unsigned gt_version; -}; - -static inline void grant_read_lock (struct grant_table *gt) -{ -percpu_read_lock (grant_rwlock, >->lock); -} - -static inline void grant_read_unlock (struct grant_table *gt) -{ -percpu_read_unlock (grant_rwlock, >->lock); -} -
xen/include/xen/grant_table.h line 33
Quoted 10 lines
xen/include/xen/grant_table.h +1
-9-static inline void grant_write_lock (struct grant_table *gt) -{ -percpu_write_lock (grant_rwlock, >->lock); -} - -static inline void grant_write_unlock (struct grant_table *gt) -{ -percpu_write_unlock (grant_rwlock, >->lock); -} +extern unsigned int __read_mostly max_grant_frames;
Why are you adding __read_mostly here? Like all section placement annotations it belongs on definitions only, not declarations.
xen/include/xen/sched.h struct vm_event_per_domain · line 310
Quoted 7 lines
xen/include/xen/sched.h +1
-0@@ -307,6 +307,7 @@ struct vm_event_per_domain };struct evtchn_port_ops ; +struct grant_table ;
Why is this needed? There's no function with a respective parameter in the header here.
Jan
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
A message that is not in the archive (sent off-list or not yet received): [email protected]
Re: [PATCH 3/5] xen: clean up grant_table.h
Quoted 5 lines · Jan Beulich
Quoted 5 lines
Quoted 1 line
Quoted 1 line · On 21.08.17 at 20:05, <[email protected]> wrote:
xen/common/grant_table.c +0
-0@@ -118,6 +154,18 @@ struct grant_mapping {uint32_t pad;/* round size to a power of 2 */ };
Quoted 13 lines
xen/common/grant_table.c struct grant_mapping { · line 167
Quoted 11 lines
xen/common/grant_table.c +11
-0+/* Number of grant table frames. Caller must hold d's grant table lock. */ +static inline unsigned int nr_grant_frames (struct grant_table *gt) +{ +return gt->nr_grant_frames; +} + +/* Number of status grant table frames. Caller must hold d's gr. table lock.*/ +static inline unsigned int nr_status_frames (struct grant_table *gt) +{ +return gt->nr_status_frames; +}For both the parameters want to be constified.
Okay.
Quoted 11 lines
xen/common/grant_table.c static inline void active_entry_release(struct active_grant_entry *act) · line 324
Quoted 9 lines
xen/common/grant_table.c +4
-0@@ -250,6 +318,15 @@ static inline void active_entry_release(struct active_grant_entry *act)spin_unlock (&act->lock); } +#define GRANT_STATUS_PER_PAGE (PAGE_SIZE / sizeof(grant_status_t)) +#define GRANT_PER_PAGE (PAGE_SIZE / sizeof(grant_entry_v2_t)) +/* Number of grant table status entries. Caller must hold d's gr. table lock.*/ +static inline unsigned int grant_to_status_frames (int grant_frames)unsigned int also for the parameter.
Okay.
Quoted 62 lines
Quoted 62 lines
xen/include/xen/grant_table.h +0
-54@@ -29,65 +29,8 @@#include <asm/page.h> #include <asm/grant_table.h> -#ifndef DEFAULT_MAX_NR_GRANT_FRAMES /* to allow arch to override */ -/* Default maximum size of a grant table. [POLICY] */ -#define DEFAULT_MAX_NR_GRANT_FRAMES 32 -#endif /* The maximum size of a grant table. */ -extern unsigned int max_grant_frames; - -DECLARE_PERCPU_RWLOCK_GLOBAL (grant_rwlock); - -/* Per-domain grant information. */ -struct grant_table { -/* -* Lock protecting updates to grant table state (version, active -* entry list, etc.) -*/ -percpu_rwlock_t lock; -/* Table size. Number of frames shared with guest */ -unsigned int nr_grant_frames; -/* Shared grant table (see include/public/grant_table.h). */ -union { -void **shared_raw; -struct grant_entry_v1 **shared_v1; -union grant_entry_v2 **shared_v2; - }; -/* Number of grant status frames shared with guest (for version 2) */ -unsigned int nr_status_frames; -/* State grant table (see include/public/grant_table.h). */ -grant_status_t **status; -/* Active grant table. */ -struct active_grant_entry **active; -/* Mapping tracking table per vcpu. */ -struct grant_mapping **maptrack; -unsigned int maptrack_limit; -/* Lock protecting the maptrack limit */ -spinlock_t maptrack_lock; -/* The defined versions are 1 and 2. Set to 0 if we don't know -what version to use yet. */ -unsigned gt_version; -}; - -static inline void grant_read_lock (struct grant_table *gt) -{ -percpu_read_lock (grant_rwlock, >->lock); -} - -static inline void grant_read_unlock (struct grant_table *gt) -{ -percpu_read_unlock (grant_rwlock, >->lock); -} - -static inline void grant_write_lock (struct grant_table *gt) -{ -percpu_write_lock (grant_rwlock, >->lock); -} -
Quoted 8 lines
xen/include/xen/grant_table.h line 33
Quoted 5 lines
xen/include/xen/grant_table.h +1
-4-static inline void grant_write_unlock (struct grant_table *gt) -{ -percpu_write_unlock (grant_rwlock, >->lock); -} +extern unsigned int __read_mostly max_grant_frames;Why are you adding
__read_mostlyhere? Like all section placement annotations it belongs on definitions only, not declarations.
Oops, sorry.
Quoted 11 lines
xen/include/xen/sched.h struct vm_event_per_domain · line 310
Quoted 8 lines
xen/include/xen/sched.h +1
-0@@ -307,6 +307,7 @@ struct vm_event_per_domain };struct evtchn_port_ops ; +struct grant_table ;Why is this needed? There's no function with a respective parameter in the header here.
You are right, of course. Will remove it again.
Juergen
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
PATCH 4/5 xen: support different gnttab_max_frames for grant v1 and v2
In reply to Juergen GrossThe number of grants a domain can setup is limited by the maximum number of grant frames it is allowed to use. Today the limit is the same regardless whether the domain uses grant v1 or v2. Using v2 will therefor be a disadvantage for the domain as only half the number of grants compared to v1 can be used, because a grant v2 entry is twice as large as the v1 entry. This is the reason for the lack of grant v2 support in the Linux kernel (in fact grant v2 support has been removed from Linux for this reason).
OTOH using only grant v1 will limit a pv domain to the low 16TB of memory of the host, as grant v1 entries only use a 32 bit mfn. So if we want to support more than 16TB of memory and be able to use that memory in pv domains, we have to remove the disadvantage of using grant v2 by being able to setup the same number of grants as with v1.
In order to achieve this add support for limiting the number of grant frames for v1 and v2 independently from each other. Per default let the v2 number be twice the value of the v1 number. Modify the boot parameter gnttab_max_frames to accept either a single value which will set the v1 limit to that value and the v2 limit to 2*value, or two values separated by a comma to set both limits to dedicated values.
Add some sanity checks to make sure the maximum number of frames isn't lower than the initial number, as this leads to rather strange crashes.
--- xen/arch/arm/domain.c | 2 +- xen/arch/arm/domain_build.c | 2 +- xen/common/compat/grant_table.c | 9 ++-- xen/common/grant_table.c | 107 ++++++++++++++++++++++++++------------ xen/include/asm-arm/grant_table.h | 3 +- xen/include/xen/grant_table.h | 5 +- 6 files changed, 84 insertions(+), 44 deletions(-)
xen/arch/arm/domain.c +1 -1
@@ -469,7 +469,7 @@ struct domain *alloc_domain_struct(void)return NULL ;clear_page (d); - d->arch.grant_table_gfn =xzalloc_array (gfn_t, max_grant_frames); + d->arch.grant_table_gfn =xzalloc_array (gfn_t,max_grant_frames ());return d; }
xen/arch/arm/domain_build.c +1 -1
@@ -2095,7 +2095,7 @@ static void __init find_gnttab_region(struct domain *d, kinfo->gnttab_size = (_etext - _stext) &PAGE_MASK ;/* Make sure the grant table will fit in the region */ -if ( (kinfo->gnttab_size >>PAGE_SHIFT ) < max_grant_frames ) +if ( (kinfo->gnttab_size >>PAGE_SHIFT ) <max_grant_frames () )panic ("Cannot find a space for the grant table region\n" );#ifdef CONFIG_ARM_32
xen/common/compat/grant_table.c +5 -4
@@ -157,11 +157,12 @@ int compat_grant_table_op(unsigned int cmd,unsigned int max_frame_list_size_in_page = (COMPAT_ARG_XLAT_SIZE -sizeof (*nat.setup)) /sizeof (*nat.setup->frame_list.p); -if ( max_frame_list_size_in_page < max_grant_frames ) + +if ( max_frame_list_size_in_page <max_grant_frames () ) {gdprintk (XENLOG_WARNING ,"max_grant_frames is too large (%u,%u)\n" , - max_grant_frames, max_frame_list_size_in_page); +max_grant_frames (), max_frame_list_size_in_page); rc = -EINVAL ; }else
@@ -295,11 +296,11 @@ int compat_grant_table_op(unsigned int cmd,break ; }if ( max_frame_list_size_in_pages < -grant_to_status_frames (max_grant_frames) ) +grant_to_status_frames (max_grant_frames_v2) ) {gdprintk (XENLOG_WARNING ,"grant_to_status_frames(max_grant_frames) is too large (%u,%u)\n" , -grant_to_status_frames (max_grant_frames), +grant_to_status_frames (max_grant_frames_v2), max_frame_list_size_in_pages); rc = -EINVAL ;break ;
xen/common/grant_table.c +73 -34
218 lines not on this page · raw message
xen/include/asm-arm/grant_table.h +2 -1
@@ -36,7 +36,8 @@ static inline void gnttab_set_frame_gfn(struct domain *d, unsigned long idx,#define gnttab_shared_gmfn (d, t, i) \ ( ((i >= nr_grant_frames(d->grant_table)) && \ - (i < max_grant_frames)) ? 0 : gfn_x(d->arch.grant_table_gfn[i])) + (i < max_grant_frames_v(d->grant_table))) \ + ? 0 : gfn_x(d->arch.grant_table_gfn[i]))#define gnttab_need_iommu_mapping (d) \ (is_domain_direct_mapped(d) && need_iommu(d))
xen/include/xen/grant_table.h +2 -3
@@ -29,9 +29,6 @@#include <asm/page.h> #include <asm/grant_table.h> -/* The maximum size of a grant table. */ -extern unsigned int __read_mostly max_grant_frames; -/* Create/destroy per-domain grant table context. */ int grant_table_create (struct domain *d);
@@ -55,4 +52,6 @@ int mem_sharing_gref_to_gfn(struct grant_table *gt, grant_ref_t ref,int gnttab_map_frame (struct domain *d,unsigned long idx,gfn_t gfn,mfn_t *mfn); +unsigned int max_grant_frames (void ); +#endif /* __XEN_GRANT_TABLE_H__ */
Signature · 7 lines
2.12.3 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xen.org/xen-devel
Re: [PATCH 4/5] xen: support different gnttab_max_frames for grant v1 and v2
Quoted 25 lines
Quoted 1 line
Quoted 1 line · On 21.08.17 at 20:05, <[email protected]> wrote:
The number of grants a domain can setup is limited by the maximum number of grant frames it is allowed to use. Today the limit is the same regardless whether the domain uses grant v1 or v2. Using v2 will therefor be a disadvantage for the domain as only half the number of grants compared to v1 can be used, because a grant v2 entry is twice as large as the v1 entry. This is the reason for the lack of grant v2 support in the Linux kernel (in fact grant v2 support has been removed from Linux for this reason).
OTOH using only grant v1 will limit a pv domain to the low 16TB of memory of the host, as grant v1 entries only use a 32 bit mfn. So if we want to support more than 16TB of memory and be able to use that memory in pv domains, we have to remove the disadvantage of using grant v2 by being able to setup the same number of grants as with v1.
In order to achieve this add support for limiting the number of grant frames for v1 and v2 independently from each other. Per default let the v2 number be twice the value of the v1 number. Modify the boot parameter
gnttab_max_framesto accept either a single value which will set the v1 limit to that value and the v2 limit to 2*value, or two values separated by a comma to set both limits to dedicated values.
Quoted 4 lines
Add some sanity checks to make sure the maximum number of frames isn't lower than the initial number, as this leads to rather strange crashes.
Signed-off-by Juergen Gross <[email protected]>
As discussed elsewhere, this probably rather wants to become a per-domain setting then. Looking also at what patch 5 adds, I additionally wonder whether we shouldn't allow Dom0 to know whether it needs to use v2 at all (or maybe it can derive that already).
Jan
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
A message that is not in the archive (sent off-list or not yet received): [email protected]
Re: [PATCH 4/5] xen: support different gnttab_max_frames for grant v1 and v2
Quoted 28 lines · Jan Beulich
Quoted 28 lines
Quoted 1 line
Quoted 1 line · On 21.08.17 at 20:05, <[email protected]> wrote:
The number of grants a domain can setup is limited by the maximum number of grant frames it is allowed to use. Today the limit is the same regardless whether the domain uses grant v1 or v2. Using v2 will therefor be a disadvantage for the domain as only half the number of grants compared to v1 can be used, because a grant v2 entry is twice as large as the v1 entry. This is the reason for the lack of grant v2 support in the Linux kernel (in fact grant v2 support has been removed from Linux for this reason).
OTOH using only grant v1 will limit a pv domain to the low 16TB of memory of the host, as grant v1 entries only use a 32 bit mfn. So if we want to support more than 16TB of memory and be able to use that memory in pv domains, we have to remove the disadvantage of using grant v2 by being able to setup the same number of grants as with v1.
In order to achieve this add support for limiting the number of grant frames for v1 and v2 independently from each other. Per default let the v2 number be twice the value of the v1 number. Modify the boot parameter
gnttab_max_framesto accept either a single value which will set the v1 limit to that value and the v2 limit to 2*value, or two values separated by a comma to set both limits to dedicated values.Add some sanity checks to make sure the maximum number of frames isn't lower than the initial number, as this leads to rather strange crashes.
Quoted 7 lines
Quoted 1 line
Signed-off-by Juergen Gross <[email protected]>As discussed elsewhere, this probably rather wants to become a per-domain setting then. Looking also at what patch 5 adds, I additionally wonder whether we shouldn't allow Dom0 to know whether it needs to use v2 at all (or maybe it can derive that already).
I'm absolutely in favor of adding a way to make this a per-domain setting.
OTOH I think there should be a default especially on huge hosts allowing to use v2 grants without reducing the number of allowed grants, which doesn't need adding another parameter to the domain config. Or do you want the tools to always set the per-domain value possibly based on a xl.conf value? Then we could remove the gnttab_max_frames command line parameter completely.
Juergen
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Re: [PATCH 4/5] xen: support different gnttab_max_frames for grant v1 and v2
Quoted 7 lines
Quoted 1 line
Quoted 1 line · On 24.08.17 at 16:54, <[email protected]> wrote:
OTOH I think there should be a default especially on huge hosts allowing to use v2 grants without reducing the number of allowed grants, which doesn't need adding another parameter to the domain config. Or do you want the tools to always set the per-domain value possibly based on a xl.conf value? Then we could remove the
gnttab_max_framescommand line parameter completely.
Yes, obsoleting that command line option would seem quite desirable to me.
Jan
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
A message that is not in the archive (sent off-list or not yet received): [email protected]
Re: [PATCH 4/5] xen: support different gnttab_max_frames for grant v1 and v2
Quoted 10 lines · Jan Beulich
Quoted 7 lines
Quoted 1 line
Quoted 1 line · On 24.08.17 at 16:54, <[email protected]> wrote:
OTOH I think there should be a default especially on huge hosts allowing to use v2 grants without reducing the number of allowed grants, which doesn't need adding another parameter to the domain config. Or do you want the tools to always set the per-domain value possibly based on a xl.conf value? Then we could remove the
gnttab_max_framescommand line parameter completely.Yes, obsoleting that command line option would seem quite desirable to me.
Okay, I can modify my patches in that regard.
Juergen
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
PATCH 5/5 xen: add new hypercall to get grant table limits
In reply to Juergen GrossToday a guest can get the maximum grant table frame number for the currently selected grant table interface version (1 or 2) only. Add a new grant table operation to get the limits of both variants in order to give the guest an opportunity to select the version serving its needs best.
Background for the need for this new hypercall is that e.g. the Linux kernel won't use v2 as long as this will allow less active grants as v1. As soon as the kernel can detect it can create as many v2 entries as for v1, it will have no reason not to use v2. And this will allow Xen placing a pv-domain with such a kernel above the current 16TB RAM limit.
For setting up the grant table a kernel needs the following information:
- current version (kexec case)
- current size (kexec case)
- max size v1
- max size v2
In order not to have to issue 3 hypercalls (GNTTABOP_query_size, GNTTABOP_get_version, GNTTABOP_get_v1_and_v2_max), let the new hypercall return all the needed information.
--- xen/common/grant_table.c | 26 ++++++++++++++++++++++++++ xen/include/public/grant_table.h | 14 ++++++++++++++ 2 files changed, 40 insertions(+)
xen/common/grant_table.c +26 -0
@@ -3041,6 +3041,28 @@ gnttab_get_version(XEN_GUEST_HANDLE_PARAM(gnttab_get_version_t) uop)return 0 ; } +static long +gnttab_get_setup_info (XEN_GUEST_HANDLE_PARAM (gnttab_setup_info_t) uop) +{ +gnttab_setup_info_t op; +struct domain *d =rcu_lock_current_domain (); +struct grant_table *gt = d->grant_table; + +grant_write_lock (gt); + op.version = gt->gt_version; + op.nr_frames =nr_grant_frames (gt); +grant_write_unlock (gt); + op.max_nr_frames_v1 = max_grant_frames_v1; + op.max_nr_frames_v2 = max_grant_frames_v2; + +rcu_unlock_domain (d); + +if (__copy_to_guest (uop, &op,1 ) ) +return -EFAULT ; + +return 0 ; +} +static s16 swap_grant_ref (grant_ref_t ref_a,grant_ref_t ref_b) {
@@ -3389,6 +3411,10 @@ do_grant_table_op(break ; } +case GNTTABOP_get_setup_info: + rc =gnttab_get_setup_info (guest_handle_cast (uop, gnttab_setup_info_t)); +break ; +default : rc = -ENOSYS ;break ;
xen/include/public/grant_table.h +14 -0
@@ -312,6 +312,7 @@ typedef uint16_t grant_status_t;#define GNTTABOP_get_version 10#define GNTTABOP_swap_grant_ref 11#define GNTTABOP_cache_flush 12 +#define GNTTABOP_get_setup_info 13#endif /* __XEN_INTERFACE_VERSION__ */ /* ` } */
@@ -597,6 +598,19 @@ struct gnttab_cache_flush {typedef struct gnttab_cache_flush gnttab_cache_flush_t ;DEFINE_XEN_GUEST_HANDLE (gnttab_cache_flush_t); +/* +* GNTTABOP_get_setup_info: Get information needed for grant table setup +* of the calling domain. +*/ +struct gnttab_setup_info { +uint32_t version; +uint32_t nr_frames; +uint32_t max_nr_frames_v1; +uint32_t max_nr_frames_v2; +}; +typedef struct gnttab_setup_info gnttab_setup_info_t ; +DEFINE_XEN_GUEST_HANDLE (gnttab_setup_info_t); +#endif /* __XEN_INTERFACE_VERSION__ */ /*
Signature · 7 lines
2.12.3 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xen.org/xen-devel
Re: [PATCH 5/5] xen: add new hypercall to get grant table limits
Quoted 14 lines
Quoted 1 line
Quoted 1 line · On 21.08.17 at 20:05, <[email protected]> wrote:
Today a guest can get the maximum grant table frame number for the currently selected grant table interface version (1 or 2) only. Add a new grant table operation to get the limits of both variants in order to give the guest an opportunity to select the version serving its needs best.
Background for the need for this new hypercall is that e.g. the Linux kernel won't use v2 as long as this will allow less active grants as v1. As soon as the kernel can detect it can create as many v2 entries as for v1, it will have no reason not to use v2. And this will allow Xen placing a pv-domain with such a kernel above the current 16TB RAM limit.
Quoted 9 lines
For setting up the grant table a kernel needs the following information:
- current version (kexec case)
- current size (kexec case)
- max size v1
- max size v2
In order not to have to issue 3 hypercalls (GNTTABOP_query_size,GNTTABOP_get_version,GNTTABOP_get_v1_and_v2_max), let the new hypercall return all the needed information.
I'm not sure I follow: v2 is always going to allow less active grants than v1, as the limit is always derived from the number of frames allowed for a domain. I also don't see a problem with issuing multiple calls - none of this ought to be performance critical. I would, however, agree that rather than adding a new hypercall to just return the max sizes adding one like you suggest would be preferable. I'm simply not convinced yet that returning the max sizes is actually necessary.
Jan
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
A message that is not in the archive (sent off-list or not yet received): [email protected]
Re: [PATCH 5/5] xen: add new hypercall to get grant table limits
Quoted 24 lines · Jan Beulich
Quoted 14 lines
Quoted 1 line
Quoted 1 line · On 21.08.17 at 20:05, <[email protected]> wrote:
Today a guest can get the maximum grant table frame number for the currently selected grant table interface version (1 or 2) only. Add a new grant table operation to get the limits of both variants in order to give the guest an opportunity to select the version serving its needs best.
Background for the need for this new hypercall is that e.g. the Linux kernel won't use v2 as long as this will allow less active grants as v1. As soon as the kernel can detect it can create as many v2 entries as for v1, it will have no reason not to use v2. And this will allow Xen placing a pv-domain with such a kernel above the current 16TB RAM limit.
Quoted 9 lines
For setting up the grant table a kernel needs the following information:
- current version (kexec case)
- current size (kexec case)
- max size v1
- max size v2
In order not to have to issue 3 hypercalls (GNTTABOP_query_size,GNTTABOP_get_version,GNTTABOP_get_v1_and_v2_max), let the new hypercall return all the needed information.
Quoted 3 lines
I'm not sure I follow: v2 is always going to allow less active grants than v1, as the limit is always derived from the number of frames allowed for a domain.
Right. Patch 3 adds support for different number of allowed frames for v1 and v2. So the system can be configured to allow the same max. number of grants for v1 and v2, or even more v2 grants than v1.
Quoted 6 lines
I also don't see a problem with issuing multiple calls - none of this ought to be performance critical. I would, however, agree that rather than adding a new hypercall to just return the max sizes adding one like you suggest would be preferable. I'm simply not convinced yet that returning the max sizes is actually necessary.
How would the guest know whether using v2 grants is no disadvantage?
Juergen
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Re: [PATCH 5/5] xen: add new hypercall to get grant table limits
Quoted 25 lines · Juergen Gross
Quoted 24 lines · Jan Beulich
Quoted 23 lines
Quoted 1 line
Quoted 1 line · On 21.08.17 at 20:05, <[email protected]> wrote:
Today a guest can get the maximum grant table frame number for the currently selected grant table interface version (1 or 2) only. Add a new grant table operation to get the limits of both variants in order to give the guest an opportunity to select the version serving its needs best.
Background for the need for this new hypercall is that e.g. the Linux kernel won't use v2 as long as this will allow less active grants as v1. As soon as the kernel can detect it can create as many v2 entries as for v1, it will have no reason not to use v2. And this will allow Xen placing a pv-domain with such a kernel above the current 16TB RAM limit.
For setting up the grant table a kernel needs the following information:
- current version (kexec case)
- current size (kexec case)
- max size v1
- max size v2
In order not to have to issue 3 hypercalls (GNTTABOP_query_size,GNTTABOP_get_version,GNTTABOP_get_v1_and_v2_max), let the new hypercall return all the needed information.
Quoted 5 lines
Quoted 3 lines
I'm not sure I follow: v2 is always going to allow less active grants than v1, as the limit is always derived from the number of frames allowed for a domain.
Right. Patch 3 adds support for different number of allowed frames for
This should read "Patch 4", of course
Quoted 13 lines
v1 and v2. So the system can be configured to allow the same max. number of grants for v1 and v2, or even more v2 grants than v1.
Quoted 6 lines
I also don't see a problem with issuing multiple calls - none of this ought to be performance critical. I would, however, agree that rather than adding a new hypercall to just return the max sizes adding one like you suggest would be preferable. I'm simply not convinced yet that returning the max sizes is actually necessary.
How would the guest know whether using v2 grants is no disadvantage?
Quoted 7 lines
Juergen
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Re: [PATCH 5/5] xen: add new hypercall to get grant table limits
In reply to Juergen GrossQuoted 34 lines
Quoted 1 line
Quoted 1 line · On 24.08.17 at 16:48, <[email protected]> wrote:
Quoted 24 lines · Jan Beulich
Quoted 14 lines
Quoted 1 line
Quoted 1 line · On 21.08.17 at 20:05, <[email protected]> wrote:
Today a guest can get the maximum grant table frame number for the currently selected grant table interface version (1 or 2) only. Add a new grant table operation to get the limits of both variants in order to give the guest an opportunity to select the version serving its needs best.
Background for the need for this new hypercall is that e.g. the Linux kernel won't use v2 as long as this will allow less active grants as v1. As soon as the kernel can detect it can create as many v2 entries as for v1, it will have no reason not to use v2. And this will allow Xen placing a pv-domain with such a kernel above the current 16TB RAM limit.
Quoted 9 lines
For setting up the grant table a kernel needs the following information:
- current version (kexec case)
- current size (kexec case)
- max size v1
- max size v2
In order not to have to issue 3 hypercalls (GNTTABOP_query_size,GNTTABOP_get_version,GNTTABOP_get_v1_and_v2_max), let the new hypercall return all the needed information.Quoted 3 lines
I'm not sure I follow: v2 is always going to allow less active grants than v1, as the limit is always derived from the number of frames allowed for a domain.
Right. Patch 3 adds support for different number of allowed frames for v1 and v2. So the system can be configured to allow the same max. number of grants for v1 and v2, or even more v2 grants than v1.
Quoted 8 lines
Quoted 6 lines
I also don't see a problem with issuing multiple calls - none of this ought to be performance critical. I would, however, agree that rather than adding a new hypercall to just return the max sizes adding one like you suggest would be preferable. I'm simply not convinced yet that returning the max sizes is actually necessary.
How would the guest know whether using v2 grants is no disadvantage?
As said - it's always going to be a disadvantage. Even if controlling the number of frames per-domain, that same number of frames will always fit more v1 than v2 entries. I don't think the config setting should directly control the number of active grants. Or if we did it that way, then the answer to your question would be "based on hypervisor version".
Jan
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
A message that is not in the archive (sent off-list or not yet received): [email protected]
Re: [PATCH 5/5] xen: add new hypercall to get grant table limits
Quoted 41 lines · Jan Beulich
Quoted 41 lines
Quoted 1 line
Quoted 1 line · On 24.08.17 at 16:48, <[email protected]> wrote:
Quoted 24 lines · Jan Beulich
Quoted 14 lines
Quoted 1 line
Quoted 1 line · On 21.08.17 at 20:05, <[email protected]> wrote:
Today a guest can get the maximum grant table frame number for the currently selected grant table interface version (1 or 2) only. Add a new grant table operation to get the limits of both variants in order to give the guest an opportunity to select the version serving its needs best.
Background for the need for this new hypercall is that e.g. the Linux kernel won't use v2 as long as this will allow less active grants as v1. As soon as the kernel can detect it can create as many v2 entries as for v1, it will have no reason not to use v2. And this will allow Xen placing a pv-domain with such a kernel above the current 16TB RAM limit.
Quoted 9 lines
For setting up the grant table a kernel needs the following information:
- current version (kexec case)
- current size (kexec case)
- max size v1
- max size v2
In order not to have to issue 3 hypercalls (GNTTABOP_query_size,GNTTABOP_get_version,GNTTABOP_get_v1_and_v2_max), let the new hypercall return all the needed information.Quoted 3 lines
I'm not sure I follow: v2 is always going to allow less active grants than v1, as the limit is always derived from the number of frames allowed for a domain.
Right. Patch 3 adds support for different number of allowed frames for v1 and v2. So the system can be configured to allow the same max. number of grants for v1 and v2, or even more v2 grants than v1.
Quoted 6 lines
I also don't see a problem with issuing multiple calls - none of this ought to be performance critical. I would, however, agree that rather than adding a new hypercall to just return the max sizes adding one like you suggest would be preferable. I'm simply not convinced yet that returning the max sizes is actually necessary.
Quoted 5 lines
Quoted 1 line
How would the guest know whether using v2 grants is no disadvantage?
As said - it's always going to be a disadvantage. Even if controlling the number of frames per-domain, that same number of frames will always fit more v1 than v2 entries.
And my patches break the assumption "same number of frames".
Quoted 2 lines
I don't think the config
setting should directly control the number of active grants.
Why not? In the end that number is the one the guest is interested in.
BTW: the number of needed maptrack frames is depending on the number of grants only, not on v1 or v2. And the default for the max. number of maptrack frames is much higher than the one of the grant frames (1024 vs 32).
Quoted 2 lines
Or if we did it that way, then the answer to your question would be "based on hypervisor version".
Yeah, or based on the answer from the hypervisor regarding my new info call (if the answer is "-ENOSYS" the guest probably would choose v1 as today).
Juergen
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Re: [PATCH 5/5] xen: add new hypercall to get grant table limits
Quoted 9 lines
Quoted 1 line
Quoted 1 line · On 24.08.17 at 17:13, <[email protected]> wrote:
Quoted 6 lines · Jan Beulich
Quoted 2 lines
Quoted 1 line
Quoted 1 line · On 24.08.17 at 16:48, <[email protected]> wrote:
How would the guest know whether using v2 grants is no disadvantage?
As said - it's always going to be a disadvantage. Even if controlling the number of frames per-domain, that same number of frames will always fit more v1 than v2 entries.
Quoted 6 lines
And my patches break the assumption "same number of frames".
Quoted 2 lines
I don't think the config
setting should directly control the number of active grants.Why not? In the end that number is the one the guest is interested in.
And the resource use is what the admin is interested in.
Quoted 4 lines
BTW: the number of needed maptrack frames is depending on the number of grants only, not on v1 or v2. And the default for the max. number of maptrack frames is much higher than the one of the grant frames (1024 vs 32).
Of course.
Jan
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
A message that is not in the archive (sent off-list or not yet received): [email protected]
Re: [PATCH 5/5] xen: add new hypercall to get grant table limits
Quoted 16 lines · Jan Beulich
Quoted 9 lines
Quoted 1 line
Quoted 1 line · On 24.08.17 at 17:13, <[email protected]> wrote:
Quoted 6 lines · Jan Beulich
Quoted 2 lines
Quoted 1 line
Quoted 1 line · On 24.08.17 at 16:48, <[email protected]> wrote:
How would the guest know whether using v2 grants is no disadvantage?
As said - it's always going to be a disadvantage. Even if controlling the number of frames per-domain, that same number of frames will always fit more v1 than v2 entries.
Quoted 6 lines
And my patches break the assumption "same number of frames".
Quoted 2 lines
I don't think the config
setting should directly control the number of active grants.Why not? In the end that number is the one the guest is interested in.
Quoted 8 lines
And the resource use is what the admin is interested in.
Quoted 4 lines
BTW: the number of needed maptrack frames is depending on the number of grants only, not on v1 or v2. And the default for the max. number of maptrack frames is much higher than the one of the grant frames (1024 vs 32).
Of course.
So what about the following idea:
- Set the default max number of grant frames to 32 on "small" hosts (max. physical memory address below 16TB) and to 64 on "large" hosts
- Add a per-domain parameter for the max number of grant frames
In the Linux kernel I would then:
- Re-add grant v2 support
- Add boot parameter for selecting grant v1 or v2
- Use grant v2 if selected via boot parameter, or (pv only:) max. host address is above 16TB
Juergen
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Re: [PATCH 5/5] xen: add new hypercall to get grant table limits
Quoted 6 lines
Quoted 1 line
Quoted 1 line · On 25.08.17 at 13:40, <[email protected]> wrote:
So what about the following idea:
- Set the default max number of grant frames to 32 on "small" hosts (max. physical memory address below 16TB) and to 64 on "large" hosts
This looks reasonable to me as long as it's properly documented.
Quoted 8 lines
- Add a per-domain parameter for the max number of grant frames
In the Linux kernel I would then:
- Re-add grant v2 support
- Add boot parameter for selecting grant v1 or v2
- Use grant v2 if selected via boot parameter, or (pv only:) max. host address is above 16TB
Can a PV DomU know? Plus can you easily switch between versions after having been migrated? And wouldn't HVM or ARM guests need to judge by max guest address?
Jan
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
A message that is not in the archive (sent off-list or not yet received): [email protected]
Re: [PATCH 5/5] xen: add new hypercall to get grant table limits
Quoted 11 lines · Jan Beulich
Quoted 6 lines
Quoted 1 line
Quoted 1 line · On 25.08.17 at 13:40, <[email protected]> wrote:
So what about the following idea:
- Set the default max number of grant frames to 32 on "small" hosts (max. physical memory address below 16TB) and to 64 on "large" hosts
This looks reasonable to me as long as it's properly documented.
Quoted 2 lines
- Add a per-domain parameter for the max number of grant frames
Quoted 8 lines
Quoted 6 lines
In the Linux kernel I would then:
- Re-add grant v2 support
- Add boot parameter for selecting grant v1 or v2
- Use grant v2 if selected via boot parameter, or (pv only:) max. host address is above 16TBCan a PV DomU know?
XENMEM_maximum_ram_page
Quoted 2 lines
Plus can you easily switch between
versions after having been migrated?
Other than console and xenbus there should be no active grant after migration. So yes, I'm planning to support both, v1->v2 and v2->v1.
Quoted 2 lines
And wouldn't HVM or ARM
guests need to judge by max guest address?
Yes.
Juergen
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Re: [PATCH 5/5] xen: add new hypercall to get grant table limits
Quoted 5 lines
Quoted 1 line
Quoted 1 line · On 25.08.17 at 14:03, <[email protected]> wrote:
Quoted 3 lines · Jan Beulich
Quoted 3 lines
Quoted 1 line
Quoted 1 line · On 25.08.17 at 13:40, <[email protected]> wrote:
In the Linux kernel I would then:
Quoted 8 lines
Quoted 6 lines
Quoted 4 lines
- Re-add grant v2 support
- Add boot parameter for selecting grant v1 or v2
- Use grant v2 if selected via boot parameter, or (pv only:) max. host address is above 16TBCan a PV DomU know?
XENMEM_maximum_ram_page
Oh, I always forget that we bogusly expose a machine property here.
Jan
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Quoted 7 lines
Quoted 1 line
Quoted 1 line · On 21.08.17 at 20:05, <[email protected]> wrote:
Currently Linux has no support for grant v2 as this would reduce the maximum number of active grants by a factor of 2 compared to v1, because the number of possible grants are limited by the allowed number of grant frames and grant entries of v2 need twice as much bytes as those of v1.
Quoted 7 lines
Unfortunately grant v2 is the only way to support either guests with more than 16TB memory size or PV guests with memory above the 16TB border, as grant v1 limits the frame number to be 32 bits wide.
In order to remove the disadvantage of grant v2 this patch series enables configuring different maximum grant frame numbers for v1 and v2.
But that does imply higher memory footprint of such a guest in Xen, doesn't it? The limit, after all, is there to bound resource use of DomU-s. I wonder whether we shouldn't make any such increase dependent on first putting in place proper accounting of the memory used for individual domains.
Jan
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
A message that is not in the archive (sent off-list or not yet received): [email protected]
Quoted 11 lines · Jan Beulich
Quoted 11 lines
Quoted 1 line
Quoted 1 line · On 21.08.17 at 20:05, <[email protected]> wrote:
Currently Linux has no support for grant v2 as this would reduce the maximum number of active grants by a factor of 2 compared to v1, because the number of possible grants are limited by the allowed number of grant frames and grant entries of v2 need twice as much bytes as those of v1.
Unfortunately grant v2 is the only way to support either guests with more than 16TB memory size or PV guests with memory above the 16TB border, as grant v1 limits the frame number to be 32 bits wide.
Quoted 6 lines
Quoted 3 lines
In order to remove the disadvantage of grant v2 this patch series enables configuring different maximum grant frame numbers for v1 and v2.
But that does imply higher memory footprint of such a guest in Xen, doesn't it?
With current defaults this would need up to 128kB more for a guest using v2 grants.
Quoted 4 lines
The limit, after all, is there to bound resource use of DomU-s. I wonder whether we shouldn't make any such increase dependent on first putting in place proper accounting of the memory used for individual domains.
So you would want to have a way to count pages (or bytes?) allocated for hypervisor internal needs on a per-domain basis, right?
Would that be additional to struct domain -> xenheap_pages or would you want to merge the new counter into it? I guess a new field would be required in order to avoid counting some data twice.
Do you have an idea what to do with that value? Do you want to expose it to the user (dom0 admin), or should it be used just inside the hypervisor and e.g. printed by a debug key handler?
Do you want an additional set of allocating functions doing the accounting, or should the existing functions be used with an additional domain pointer, or should the caller be responsible doing the additional accounting?
Do you want an all-or-nothing approach or a gradual move to add the new accounting step by step?
Juergen
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Quoted 17 lines
Quoted 1 line
Quoted 1 line · On 23.08.17 at 09:49, <[email protected]> wrote:
Quoted 15 lines · Jan Beulich
Quoted 14 lines
Quoted 1 line
Quoted 1 line · On 21.08.17 at 20:05, <[email protected]> wrote:
Currently Linux has no support for grant v2 as this would reduce the maximum number of active grants by a factor of 2 compared to v1, because the number of possible grants are limited by the allowed number of grant frames and grant entries of v2 need twice as much bytes as those of v1.
Unfortunately grant v2 is the only way to support either guests with more than 16TB memory size or PV guests with memory above the 16TB border, as grant v1 limits the frame number to be 32 bits wide.
In order to remove the disadvantage of grant v2 this patch series enables configuring different maximum grant frame numbers for v1 and v2.
Quoted 5 lines
Quoted 2 lines
But that does imply higher memory footprint of such a guest in Xen, doesn't it?
With current defaults this would need up to 128kB more for a guest using v2 grants.
At least in an auto-ballooned setup this may make the difference between a guest being able or failing to start.
Quoted 16 lines
Quoted 4 lines
The limit, after all, is there to bound resource use of DomU-s. I wonder whether we shouldn't make any such increase dependent on first putting in place proper accounting of the memory used for individual domains.
So you would want to have a way to count pages (or bytes?) allocated for hypervisor internal needs on a per-domain basis, right?
Would that be additional to struct domain ->
xenheap_pagesor would you want to merge the new counter into it? I guess a new field would be required in order to avoid counting some data twice.Do you have an idea what to do with that value? Do you want to expose it to the user (dom0 admin), or should it be used just inside the hypervisor and e.g. printed by a debug key handler?
Quoted 7 lines
Do you want an additional set of allocating functions doing the accounting, or should the existing functions be used with an additional domain pointer, or should the caller be responsible doing the additional accounting?
Do you want an all-or-nothing approach or a gradual move to add the new accounting step by step?
We've been vaguely discussing this in the past on a few occasions. My personal thinking is that the "memory=" setting in a guest config really ought to express all the memory associated with a guest. But of course there'll be problems with us starting to do so, and that's beyond people observing less memory in their guests. Switching to such a full accounting model will require some careful thought (and discussion up front). Hence I've only said "I wonder whether", i.e. I don't mean to make this a strict prerequisite to the proposed changes here. I'd be in particular interested to hear opinions of a few other people.
Jan
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Quoted 62 lines
-----Original Message-----
From: Xen-devel [mailto:[email protected]] On Behalf Of Jan Beulich
Sent: 23 August 2017 09:36
To: Juergen Gross <[email protected]>
Cc: Tim (Xen.org) <[email protected]>; [email protected]; Wei Liu <[email protected]>; George Dunlap <[email protected]>; Andrew Cooper <[email protected]>; Ian Jackson <[email protected]>; [email protected]
Subject: Re: [Xen-devel] [PATCH 0/5] xen: better grant v2 supportQuoted 6 lines
Quoted 1 line
Quoted 1 line · On 23.08.17 at 09:49, <[email protected]> wrote:
Quoted 4 lines · Jan Beulich
Quoted 4 lines
Quoted 1 line
Quoted 1 line · On 21.08.17 at 20:05, <[email protected]> wrote:
Currently Linux has no support for grant v2 as this would reduce the maximum number of active grants by a factor of 2 compared to v1, because the number of possible grants are limited by the allowed
number
Quoted 11 lines
Quoted 11 lines
Quoted 10 lines
of grant frames and grant entries of v2 need twice as much bytes as those of v1.
Unfortunately grant v2 is the only way to support either guests with more than 16TB memory size or PV guests with memory above the 16TB border, as grant v1 limits the frame number to be 32 bits wide.
In order to remove the disadvantage of grant v2 this patch series enables configuring different maximum grant frame numbers for v1 and v2.
Quoted 5 lines
Quoted 2 lines
But that does imply higher memory footprint of such a guest in Xen, doesn't it?
With current defaults this would need up to 128kB more for a guest using v2 grants.
At least in an auto-ballooned setup this may make the difference between a guest being able or failing to start.
Quoted 16 lines
Quoted 4 lines
The limit, after all, is there to bound resource use of DomU-s. I wonder whether we shouldn't make any such increase dependent on first putting in place proper accounting of the memory used for individual domains.
So you would want to have a way to count pages (or bytes?) allocated for hypervisor internal needs on a per-domain basis, right?
Would that be additional to struct domain ->
xenheap_pagesor would you want to merge the new counter into it? I guess a new field would be required in order to avoid counting some data twice.Do you have an idea what to do with that value? Do you want to expose it to the user (dom0 admin), or should it be used just inside the hypervisor and e.g. printed by a debug key handler?
Quoted 7 lines
Do you want an additional set of allocating functions doing the accounting, or should the existing functions be used with an additional domain pointer, or should the caller be responsible doing the additional accounting?
Do you want an all-or-nothing approach or a gradual move to add the new accounting step by step?
Quoted 11 lines
We've been vaguely discussing this in the past on a few occasions. My personal thinking is that the "memory=" setting in a guest config really ought to express all the memory associated with a guest. But of course there'll be problems with us starting to do so, and that's beyond people observing less memory in their guests. Switching to such a full accounting model will require some careful thought (and discussion up front). Hence I've only said "I wonder whether", i.e. I don't mean to make this a strict prerequisite to the proposed changes here. I'd be in particular interested to hear opinions of a few other people.
Making a the number of grant frames a per-vm-configurable quantity would seem like a reasonable first step. I'm not convinced of the need for separate v1 and v2 limits if this were the case.
Paul
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Quoted 74 lines · Paul Durrant
Quoted 62 lines
-----Original Message-----
From: Xen-devel [mailto:[email protected]] On Behalf Of Jan Beulich
Sent: 23 August 2017 09:36
To: Juergen Gross <[email protected]>
Cc: Tim (Xen.org) <[email protected]>; [email protected]; Wei Liu <[email protected]>; George Dunlap <[email protected]>; Andrew Cooper <[email protected]>; Ian Jackson <[email protected]>; [email protected]
Subject: Re: [Xen-devel] [PATCH 0/5] xen: better grant v2 supportQuoted 6 lines
Quoted 1 line
Quoted 1 line · On 23.08.17 at 09:49, <[email protected]> wrote:
Quoted 4 lines · Jan Beulich
Quoted 4 lines
Quoted 1 line
Quoted 1 line · On 21.08.17 at 20:05, <[email protected]> wrote:
Currently Linux has no support for grant v2 as this would reduce the maximum number of active grants by a factor of 2 compared to v1, because the number of possible grants are limited by the allowed
number
Quoted 11 lines
Quoted 11 lines
Quoted 10 lines
of grant frames and grant entries of v2 need twice as much bytes as those of v1.
Unfortunately grant v2 is the only way to support either guests with more than 16TB memory size or PV guests with memory above the 16TB border, as grant v1 limits the frame number to be 32 bits wide.
In order to remove the disadvantage of grant v2 this patch series enables configuring different maximum grant frame numbers for v1 and v2.
Quoted 5 lines
Quoted 2 lines
But that does imply higher memory footprint of such a guest in Xen, doesn't it?
With current defaults this would need up to 128kB more for a guest using v2 grants.
At least in an auto-ballooned setup this may make the difference between a guest being able or failing to start.
Quoted 16 lines
Quoted 4 lines
The limit, after all, is there to bound resource use of DomU-s. I wonder whether we shouldn't make any such increase dependent on first putting in place proper accounting of the memory used for individual domains.
So you would want to have a way to count pages (or bytes?) allocated for hypervisor internal needs on a per-domain basis, right?
Would that be additional to struct domain ->
xenheap_pagesor would you want to merge the new counter into it? I guess a new field would be required in order to avoid counting some data twice.Do you have an idea what to do with that value? Do you want to expose it to the user (dom0 admin), or should it be used just inside the hypervisor and e.g. printed by a debug key handler?
Quoted 7 lines
Do you want an additional set of allocating functions doing the accounting, or should the existing functions be used with an additional domain pointer, or should the caller be responsible doing the additional accounting?
Do you want an all-or-nothing approach or a gradual move to add the new accounting step by step?
Quoted 11 lines
We've been vaguely discussing this in the past on a few occasions. My personal thinking is that the "memory=" setting in a guest config really ought to express all the memory associated with a guest. But of course there'll be problems with us starting to do so, and that's beyond people observing less memory in their guests. Switching to such a full accounting model will require some careful thought (and discussion up front). Hence I've only said "I wonder whether", i.e. I don't mean to make this a strict prerequisite to the proposed changes here. I'd be in particular interested to hear opinions of a few other people.
Quoted 1 line
Making a the number of grant frames a per-vm-configurable quantity would seem like a reasonable first step. I'm not convinced of the need for separate v1 and v2 limits if this were the case.
Really? I don't think so. I believe the default should be to allow the same number of grants regardless whether they are v1 or v2. Having to modify the guest config to achieve this isn't good practice IMO.
Juergen
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Quoted 94 lines
-----Original Message-----
From: Juergen Gross [mailto:[email protected]]
Sent: 23 August 2017 10:23
To: Paul Durrant <[email protected]>; 'Jan Beulich' <[email protected]>
Cc: Tim (Xen.org) <[email protected]>; [email protected]; Wei Liu <[email protected]>; George Dunlap <[email protected]>; Andrew Cooper <[email protected]>; Ian Jackson <[email protected]>; [email protected]
Subject: Re: [Xen-devel] [PATCH 0/5] xen: better grant v2 supportQuoted 2 lines · Paul Durrant
Quoted 2 lines
-----Original Message-----
From: Xen-devel [mailto:[email protected]] On Behalf OfJan
Quoted 15 lines
Quoted 15 lines
Beulich
Sent: 23 August 2017 09:36
To: Juergen Gross <[email protected]>
Cc: Tim (Xen.org) <[email protected]>; [email protected]; Wei Liu <[email protected]>; George Dunlap <[email protected]>; Andrew Cooper <[email protected]>; Ian Jackson <[email protected]>; [email protected]
Subject: Re: [Xen-devel] [PATCH 0/5] xen: better grant v2 supportQuoted 6 lines
Quoted 1 line
Quoted 1 line · On 23.08.17 at 09:49, <[email protected]> wrote:
Quoted 4 lines · Jan Beulich
Quoted 4 lines
Quoted 1 line
Quoted 1 line · On 21.08.17 at 20:05, <[email protected]> wrote:
Currently Linux has no support for grant v2 as this would reduce the maximum number of active grants by a factor of 2 compared to v1, because the number of possible grants are limited by the allowed
Quoted 6 lines
Quoted 6 lines
number
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
of grant frames and grant entries of v2 need twice as much bytes as those of v1.
Unfortunately grant v2 is the only way to support either guests with more than 16TB memory size or PV guests with memory above the
16TB
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
border, as grant v1 limits the frame number to be 32 bits wide.
In order to remove the disadvantage of grant v2 this patch series enables configuring different maximum grant frame numbers for v1
and
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 4 lines
Quoted 1 line
v2.
But that does imply higher memory footprint of such a guest in Xen, doesn't it?
With current defaults this would need up to 128kB more for a guest
using
Quoted 11 lines
Quoted 11 lines
Quoted 1 line
v2 grants.
At least in an auto-ballooned setup this may make the difference between a guest being able or failing to start.
Quoted 6 lines
Quoted 4 lines
The limit, after all, is there to bound resource use of DomU-s. I wonder whether we shouldn't make any such increase dependent on first putting in place proper accounting of the memory used for individual domains.
So you would want to have a way to count pages (or bytes?) allocated
for
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
hypervisor internal needs on a per-domain basis, right?
Would that be additional to struct domain ->
xenheap_pagesor wouldyou
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
want to merge the new counter into it? I guess a new field would be required in order to avoid counting some data twice.
Do you have an idea what to do with that value? Do you want to expose
it
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
to the user (dom0 admin), or should it be used just inside the hypervisor and e.g. printed by a debug key handler?
Do you want an additional set of allocating functions doing the accounting, or should the existing functions be used with an additional domain pointer, or should the caller be responsible doing the additional accounting?
Do you want an all-or-nothing approach or a gradual move to add the
new
Quoted 14 lines
Quoted 13 lines
Quoted 1 line
accounting step by step?
We've been vaguely discussing this in the past on a few occasions. My personal thinking is that the "memory=" setting in a guest config really ought to express all the memory associated with a guest. But of course there'll be problems with us starting to do so, and that's beyond people observing less memory in their guests. Switching to such a full accounting model will require some careful thought (and discussion up front). Hence I've only said "I wonder whether", i.e. I don't mean to make this a strict prerequisite to the proposed changes here. I'd be in particular interested to hear opinions of a few other people.
Quoted 8 lines
Quoted 1 line
Making a the number of grant frames a per-vm-configurable quantity
would seem like a reasonable first step. I'm not convinced of the need for separate v1 and v2 limits if this were the case.
Really? I don't think so. I believe the default should be to allow the same number of grants regardless whether they are v1 or v2. Having to modify the guest config to achieve this isn't good practice IMO.
In that case I guess we should have per-vm config for the number of grants that the guest is allowed (since the admin should not really have to know about then nature of v1 or v2) and we'd always need to reserve sufficient pages to cover v2 even if v1 is being used (unless we also have a way to disallow use of v2 on a per-guest basis).
Paul
Quoted 2 lines
Juergen
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Quoted 98 lines · Paul Durrant
Quoted 98 lines
-----Original Message-----
From: Juergen Gross [mailto:[email protected]]
Sent: 23 August 2017 10:23
To: Paul Durrant <[email protected]>; 'Jan Beulich' <[email protected]>
Cc: Tim (Xen.org) <[email protected]>; [email protected]; Wei Liu <[email protected]>; George Dunlap <[email protected]>; Andrew Cooper <[email protected]>; Ian Jackson <[email protected]>; [email protected]
Subject: Re: [Xen-devel] [PATCH 0/5] xen: better grant v2 supportQuoted 2 lines · Paul Durrant
Quoted 2 lines
-----Original Message-----
From: Xen-devel [mailto:[email protected]] On Behalf OfJan
Quoted 15 lines
Quoted 15 lines
Beulich
Sent: 23 August 2017 09:36
To: Juergen Gross <[email protected]>
Cc: Tim (Xen.org) <[email protected]>; [email protected]; Wei Liu <[email protected]>; George Dunlap <[email protected]>; Andrew Cooper <[email protected]>; Ian Jackson <[email protected]>; [email protected]
Subject: Re: [Xen-devel] [PATCH 0/5] xen: better grant v2 supportQuoted 6 lines
Quoted 1 line
Quoted 1 line · On 23.08.17 at 09:49, <[email protected]> wrote:
Quoted 4 lines · Jan Beulich
Quoted 4 lines
Quoted 1 line
Quoted 1 line · On 21.08.17 at 20:05, <[email protected]> wrote:
Currently Linux has no support for grant v2 as this would reduce the maximum number of active grants by a factor of 2 compared to v1, because the number of possible grants are limited by the allowed
Quoted 6 lines
Quoted 6 lines
number
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
of grant frames and grant entries of v2 need twice as much bytes as those of v1.
Unfortunately grant v2 is the only way to support either guests with more than 16TB memory size or PV guests with memory above the
16TB
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
border, as grant v1 limits the frame number to be 32 bits wide.
In order to remove the disadvantage of grant v2 this patch series enables configuring different maximum grant frame numbers for v1
and
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 4 lines
Quoted 1 line
v2.
But that does imply higher memory footprint of such a guest in Xen, doesn't it?
With current defaults this would need up to 128kB more for a guest
using
Quoted 11 lines
Quoted 11 lines
Quoted 1 line
v2 grants.
At least in an auto-ballooned setup this may make the difference between a guest being able or failing to start.
Quoted 6 lines
Quoted 4 lines
The limit, after all, is there to bound resource use of DomU-s. I wonder whether we shouldn't make any such increase dependent on first putting in place proper accounting of the memory used for individual domains.
So you would want to have a way to count pages (or bytes?) allocated
for
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
hypervisor internal needs on a per-domain basis, right?
Would that be additional to struct domain ->
xenheap_pagesor wouldyou
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
want to merge the new counter into it? I guess a new field would be required in order to avoid counting some data twice.
Do you have an idea what to do with that value? Do you want to expose
it
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
to the user (dom0 admin), or should it be used just inside the hypervisor and e.g. printed by a debug key handler?
Do you want an additional set of allocating functions doing the accounting, or should the existing functions be used with an additional domain pointer, or should the caller be responsible doing the additional accounting?
Do you want an all-or-nothing approach or a gradual move to add the
new
Quoted 14 lines
Quoted 13 lines
Quoted 1 line
accounting step by step?
We've been vaguely discussing this in the past on a few occasions. My personal thinking is that the "memory=" setting in a guest config really ought to express all the memory associated with a guest. But of course there'll be problems with us starting to do so, and that's beyond people observing less memory in their guests. Switching to such a full accounting model will require some careful thought (and discussion up front). Hence I've only said "I wonder whether", i.e. I don't mean to make this a strict prerequisite to the proposed changes here. I'd be in particular interested to hear opinions of a few other people.
Quoted 1 line
Making a the number of grant frames a per-vm-configurable quantity
would seem like a reasonable first step. I'm not convinced of the need for separate v1 and v2 limits if this were the case.
Quoted 6 lines
Quoted 4 lines
Really? I don't think so. I believe the default should be to allow the same number of grants regardless whether they are v1 or v2. Having to modify the guest config to achieve this isn't good practice IMO.
In that case I guess we should have per-vm config for the number of grants that the guest is allowed (since the admin should not really have to know about then nature of v1 or v2) and we'd always need to reserve sufficient pages to cover v2 even if v1 is being used (unless we also have a way to disallow use of v2 on a per-guest basis).
Its not about reserving pages or disallowing v2 IMO.
A guest needs to know whether it can use v2 without having disadvantages due to that usage. With hosts having more than 16TB of memory v2 isn't just a nice to have, but a mandatory feature to be able to run above the 16TB limit as a PV guest.
And I think this should be possible without any special command line settings or guest config.
Juergen
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Quoted 9 lines
Quoted 1 line
Quoted 1 line · On 23.08.17 at 11:23, <[email protected]> wrote:
Quoted 1 line · Paul Durrant
Making a the number of grant frames a per-vm-configurable quantity would
seem like a reasonable first step. I'm not convinced of the need for separate v1 and v2 limits if this were the case.
Really? I don't think so. I believe the default should be to allow the same number of grants regardless whether they are v1 or v2. Having to modify the guest config to achieve this isn't good practice IMO.
I'm not convinced one is significantly better than the other. Both have their upsides and downsides.
Jan
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
A message that is not in the archive (sent off-list or not yet received): [email protected]
Quoted 6 lines · Jan Beulich
Quoted 6 lines
Quoted 1 line
Quoted 1 line · On 23.08.17 at 11:23, <[email protected]> wrote:
Quoted 1 line · Paul Durrant
Making a the number of grant frames a per-vm-configurable quantity would
seem like a reasonable first step. I'm not convinced of the need for separate v1 and v2 limits if this were the case.
Quoted 6 lines
Quoted 3 lines
Really? I don't think so. I believe the default should be to allow the same number of grants regardless whether they are v1 or v2. Having to modify the guest config to achieve this isn't good practice IMO.
I'm not convinced one is significantly better than the other. Both have their upsides and downsides.
Again: the whole series is meant to not make a guest having to choose whether it can either use the amount of grants it is needing or it can run on a host with more than 16TB of memory.
And I believe the default should be not having to use special command line parameters or guest config settings to achieve this.
Juergen
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
A message that is not in the archive (sent off-list or not yet received): [email protected]
Quoted 50 lines · Jan Beulich
Quoted 17 lines
Quoted 1 line
Quoted 1 line · On 23.08.17 at 09:49, <[email protected]> wrote:
Quoted 15 lines · Jan Beulich
Quoted 14 lines
Quoted 1 line
Quoted 1 line · On 21.08.17 at 20:05, <[email protected]> wrote:
Currently Linux has no support for grant v2 as this would reduce the maximum number of active grants by a factor of 2 compared to v1, because the number of possible grants are limited by the allowed number of grant frames and grant entries of v2 need twice as much bytes as those of v1.
Unfortunately grant v2 is the only way to support either guests with more than 16TB memory size or PV guests with memory above the 16TB border, as grant v1 limits the frame number to be 32 bits wide.
In order to remove the disadvantage of grant v2 this patch series enables configuring different maximum grant frame numbers for v1 and v2.
Quoted 5 lines
Quoted 2 lines
But that does imply higher memory footprint of such a guest in Xen, doesn't it?
With current defaults this would need up to 128kB more for a guest using v2 grants.
At least in an auto-ballooned setup this may make the difference between a guest being able or failing to start.
Quoted 16 lines
Quoted 4 lines
The limit, after all, is there to bound resource use of DomU-s. I wonder whether we shouldn't make any such increase dependent on first putting in place proper accounting of the memory used for individual domains.
So you would want to have a way to count pages (or bytes?) allocated for hypervisor internal needs on a per-domain basis, right?
Would that be additional to struct domain ->
xenheap_pagesor would you want to merge the new counter into it? I guess a new field would be required in order to avoid counting some data twice.Do you have an idea what to do with that value? Do you want to expose it to the user (dom0 admin), or should it be used just inside the hypervisor and e.g. printed by a debug key handler?
Quoted 7 lines
Do you want an additional set of allocating functions doing the accounting, or should the existing functions be used with an additional domain pointer, or should the caller be responsible doing the additional accounting?
Do you want an all-or-nothing approach or a gradual move to add the new accounting step by step?
Quoted 10 lines
We've been vaguely discussing this in the past on a few occasions. My personal thinking is that the "memory=" setting in a guest config really ought to express all the memory associated with a guest. But of course there'll be problems with us starting to do so, and that's beyond people observing less memory in their guests. Switching to such a full accounting model will require some careful thought (and discussion up front). Hence I've only said "I wonder whether", i.e. I don't mean to make this a strict prerequisite to the proposed changes here. I'd be in particular interested to hear opinions of a few other people.
Fair enough.
Just some thoughts on that topic from my side:
This approach should be fine IMO for memory allocated while creating a domain. This is basically the same as a bare metal system where the BIOS needs some memory.
Memory allocated during the lifetime of a domain is a different problem:
either you allow the domain to claim more memory as configured, or you have to reserve a more or less arbitrary amount of memory to be allocated later and eventually fail such allocations. I don't think this approach is acceptable.
Juergen
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Quoted 7 lines
Quoted 1 line
Quoted 1 line · On 23.08.17 at 11:19, <[email protected]> wrote:
Just some thoughts on that topic from my side:
This approach should be fine IMO for memory allocated while creating a domain. This is basically the same as a bare metal system where the BIOS needs some memory.
Quoted 5 lines
Memory allocated during the lifetime of a domain is a different problem:
either you allow the domain to claim more memory as configured, or you have to reserve a more or less arbitrary amount of memory to be allocated later and eventually fail such allocations. I don't think this approach is acceptable.
Or an interrupt gets sent to the guest telling it that it should nominate (balloon out or something similar) a page in order for another of its operations to succeed. Of course that would be limited to paravirtual operations (i.e. mostly hypercalls); allocations done while emulating something could not be handled this way.
Jan
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
A message that is not in the archive (sent off-list or not yet received): [email protected]
Quoted 13 lines · Jan Beulich
Quoted 7 lines
Quoted 1 line
Quoted 1 line · On 23.08.17 at 11:19, <[email protected]> wrote:
Just some thoughts on that topic from my side:
This approach should be fine IMO for memory allocated while creating a domain. This is basically the same as a bare metal system where the BIOS needs some memory.
Quoted 5 lines
Memory allocated during the lifetime of a domain is a different problem:
either you allow the domain to claim more memory as configured, or you have to reserve a more or less arbitrary amount of memory to be allocated later and eventually fail such allocations. I don't think this approach is acceptable.
Quoted 6 lines
Or an interrupt gets sent to the guest telling it that it should nominate (balloon out or something similar) a page in order for another of its operations to succeed. Of course that would be limited to paravirtual operations (i.e. mostly hypercalls); allocations done while emulating something could not be handled this way.
As this would probably break existing pv guests I don't think this is an option we should consider.
Juergen
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel