libxl: memory management patches
v4 cover libxl: memory management patches
Hi,
Here is next version of libxl/xl memory management patches:
- xl: Allow user to configure xl mem-set behavior,
- libxl: Allow a guest to inform a host about its
maximum supported memory size,
- libxl: Some optimizations in libxl_set_memory_target(),
- xl: Improve xl documentation in regards to guest memory management.
Shortly I will send relevent Linux Kernel patches as a reference.
Daniel
PATCH v4 1/4 xl: Allow user to configure xl mem-set behavior
Add mem_set_enforce_limit option to xl.conf file and equivalent xl command line option. Those two things give a chance to align xl mem-set behavior to xm mem-set behavior. Default xl mem-set behavior is not changed.
v4 - suggestions/fixes:
- add limit check for mem_set_enforce_limit=0 case,
- fix some error messages.
v3 - suggestions/fixes:
- add xl command line option
(suggested by Ian Jackson).
--- tools/libxl/libxl.c | 25 ++++++++++++++++++------- tools/libxl/xl.c | 4 ++++ tools/libxl/xl.h | 1 + tools/libxl/xl_cmdimpl.c | 16 ++++++++++------ tools/libxl/xl_cmdtable.c | 3 ++- 5 files changed, 35 insertions(+), 14 deletions(-)
tools/libxl/libxl.c +18 -7
@@ -3517,7 +3517,7 @@ int libxl_domain_setmaxmem(libxl_ctx *ctx, uint32_t domid, uint32_t max_memkb) }if (max_memkb < memorykb) { -LIBXL__LOG_ERRNO (ctx,LIBXL__LOG_ERROR ,"memory_static_max must be greater than or or equal to memory_dynamic_max\n" ); +LIBXL__LOG_ERRNO (ctx,LIBXL__LOG_ERROR ,"memory_xen_max must be greater than or equal to memory_dynamic_max\n" ); goto out; } rc =xc_domain_setmaxmem (ctx->xch, domid, max_memkb +LIBXL_MAXMEM_CONSTANT );
@@ -3678,6 +3678,16 @@ retry_transaction: goto out; } } + + rc =xc_domain_getinfolist (ctx->xch, domid,1 , &info); + +if (rc !=1 || info.domain != domid) { + abort_transaction =1 ; + goto out; + } + +xcinfo2xlinfo (&info, &ptr); + memmax =libxl__xs_read (gc, t,libxl__sprintf (gc,"%s/memory/static-max" , dompath));if (!memmax) {
@@ -3733,6 +3743,12 @@ retry_transaction: abort_transaction =1 ; goto out; } + }else if (new_target_memkb > ptr.max_memkb -LIBXL_MAXMEM_CONSTANT ) { +LIBXL__LOG (ctx,LIBXL__LOG_ERROR , +"memory_dynamic_max must be less than or equal to" +" memory_xen_max\n" ); + abort_transaction =1 ; + goto out; } new_target_memkb -= videoram;
@@ -3749,12 +3765,7 @@ retry_transaction:libxl__xs_write (gc, t,libxl__sprintf (gc,"%s/memory/target" , dompath),"%" PRIu32, new_target_memkb); - rc =xc_domain_getinfolist (ctx->xch, domid,1 , &info); -if (rc !=1 || info.domain != domid) { - abort_transaction =1 ; - goto out; - } -xcinfo2xlinfo (&info, &ptr); + uuid =libxl__uuid2string (gc, ptr.uuid);libxl__xs_write (gc, t,libxl__sprintf (gc,"/vm/%s/memory" , uuid),"%" PRIu32, new_target_memkb /1024 );
tools/libxl/xl.c +4 -0
@@ -39,6 +39,7 @@ xentoollog_logger_stdiostream *logger;int dryrun_only;int force_execution;int autoballoon =-1 ; +int mem_set_enforce_limit =1 ;char *blkdev_start;int run_hotplug_scripts =1 ;char *lockfile;
@@ -107,6 +108,9 @@ static void parse_global_config(const char *configfile,if (autoballoon ==-1 ) autoballoon =auto_autoballoon (); +if (!xlu_cfg_get_long (config,"mem_set_enforce_limit" , &l,0 )) + mem_set_enforce_limit = l; +if (!xlu_cfg_get_long (config,"run_hotplug_scripts" , &l,0 )) run_hotplug_scripts = l;
tools/libxl/xl.h +1 -0
@@ -144,6 +144,7 @@ int xl_child_pid(xlchildnum); /* returns 0 if child struct is not in use *//* global options */ extern int autoballoon; +extern int mem_set_enforce_limit;extern int run_hotplug_scripts;extern int dryrun_only;extern libxl_defbool claim_mode;
tools/libxl/xl_cmdimpl.c +10 -6
@@ -2475,7 +2475,7 @@ int main_memmax(int argc, char **argv)return 0 ; } -static void set_memory_target (uint32_t domid,const char *mem) +static void set_memory_target (uint32_t domid,const char *mem,int enforce_limit) {long long int memorykb;
@@ -2485,23 +2485,27 @@ static void set_memory_target(uint32_t domid, const char *mem)exit (3 ); } -libxl_set_memory_target (ctx, domid, memorykb,0 ,/* enforce */ 1 ); +libxl_set_memory_target (ctx, domid, memorykb,0 , enforce_limit); }int main_memset (int argc,char **argv) {uint32_t domid; -int opt =0 ; +int enforce_limit, opt =0 ;const char *mem; - SWITCH_FOREACH_OPT(opt, "", NULL, "mem-set", 2) { -/* No options */ + enforce_limit = mem_set_enforce_limit; + + SWITCH_FOREACH_OPT(opt, "e:", NULL, "mem-set", 2) { +case 'e' : + enforce_limit =atoi (optarg) ?1 :0 ; +break ; } domid =find_domain (argv[optind]); mem = argv[optind +1 ]; -set_memory_target (domid, mem); +set_memory_target (domid, mem, enforce_limit);return 0 ; }
tools/libxl/xl_cmdtable.c +2 -1
@@ -196,7 +196,8 @@ struct cmd_spec cmd_table[] = { {"mem-set" , &main_memset,0 ,1 ,"Set the current memory usage for a domain" , -"<Domain> <MemMB['b'[bytes]|'k'[KB]|'m'[MB]|'g'[GB]|'t'[TB]]>" , +"[-e <0|1>] <Domain> <MemMB['b'[bytes]|'k'[KB]|'m'[MB]|'g'[GB]|'t'[TB]]>" , +"-e <0|1> (Not)Enforce maximum memory allocation for a domain" }, { "button-press", &main_button_press, 0, 1,
Signature · 1 line
1.7.10.4
PATCH v4 2/4 libxl: Allow a guest to inform a host about its maximum supported memory size
In reply to Daniel KiperAllow a guest to inform a host about its maximum supported memory size. This gives a chance to ignore limit established at boot by maxmem and usage of memory hotplug infrustacture if the guest OS supports it.
--- tools/libxl/libxl.c | 58 +++++++++++++++++++++++++++++++------------- tools/libxl/libxl_create.c | 3 +++ 2 files changed, 44 insertions(+), 17 deletions(-)
tools/libxl/libxl.c +41 -17
@@ -3640,7 +3640,7 @@ int libxl_set_memory_target(libxl_ctx *ctx, uint32_t domid, {GC_INIT (ctx);int rc =1 , abort_transaction =0 ; -uint32_t memorykb =0 , videoram =0 ; +uint32_t guestkb, memorykb =0 , videoram =0 ;uint32_t current_target_memkb =0 , new_target_memkb =0 ;char *memmax, *endptr, *videoram_s =NULL , *target =NULL ;char *dompath =libxl__xs_get_dompath (gc, domid);
@@ -3689,21 +3689,36 @@ retry_transaction:xcinfo2xlinfo (&info, &ptr); memmax =libxl__xs_read (gc, t,libxl__sprintf (gc, -"%s/memory/static-max" , dompath)); -if (!memmax) { -LIBXL__LOG_ERRNO (ctx,LIBXL__LOG_ERROR , -"cannot get memory info from %s/memory/static-max\n" , - dompath); - abort_transaction =1 ; - goto out; - } - memorykb =strtoul (memmax, &endptr,10 ); -if (*endptr !='\0' ) { -LIBXL__LOG_ERRNO (ctx,LIBXL__LOG_ERROR , -"invalid max memory %s from %s/memory/static-max\n" , - memmax, dompath); - abort_transaction =1 ; - goto out; +"%s/memory/guest-max" , dompath)); + +if (memmax) { + guestkb =strtoul (memmax, &endptr,10 ); +if (*endptr !='\0' ) + guestkb =0 ; + }else + guestkb =0 ; + +if (!guestkb) { + memmax =libxl__xs_read (gc, t,libxl__sprintf (gc, +"%s/memory/static-max" , dompath)); + +if (!memmax) { +LIBXL__LOG_ERRNO (ctx,LIBXL__LOG_ERROR , +"cannot get memory info from %s/memory/static-max\n" , + dompath); + abort_transaction =1 ; + goto out; + } + + memorykb =strtoul (memmax, &endptr,10 ); + +if (*endptr !='\0' ) { +LIBXL__LOG_ERRNO (ctx,LIBXL__LOG_ERROR , +"invalid max memory %s from %s/memory/static-max\n" , + memmax, dompath); + abort_transaction =1 ; + goto out; + } }if (relative) {
@@ -3713,7 +3728,16 @@ retry_transaction: new_target_memkb = current_target_memkb + target_memkb; }else new_target_memkb = target_memkb; -if (new_target_memkb > memorykb) { + +if (guestkb) { +if (new_target_memkb > guestkb) { +LIBXL__LOG (ctx,LIBXL__LOG_ERROR , +"memory_dynamic_max must be less than or equal to" +" memory_guest_max\n" ); + abort_transaction =1 ; + goto out; + } + }else if (new_target_memkb > memorykb) {LIBXL__LOG (ctx,LIBXL__LOG_ERROR ,"memory_dynamic_max must be less than or equal to" " memory_static_max\n" );
tools/libxl/libxl_create.c +3 -0
@@ -512,6 +512,9 @@ retry_transaction:libxl__sprintf (gc,"%s/device/suspend/event-channel" , dom_path), rwperm, ARRAY_SIZE(rwperm));libxl__xs_mkdir (gc, t, +libxl__sprintf (gc,"%s/memory/guest-max" , dom_path), + rwperm,ARRAY_SIZE (rwperm)); +libxl__xs_mkdir (gc, t,libxl__sprintf (gc,"%s/data" , dom_path), rwperm,ARRAY_SIZE (rwperm));if (info->type ==LIBXL_DOMAIN_TYPE_HVM )
Signature · 1 line
1.7.10.4
PATCH v4 3/4 libxl: Some optimizations in libxl_set_memory_target()
In reply to Daniel KiperSome optimizations in libxl_set_memory_target().
--- tools/libxl/libxl.c | 48 ++++++++++++++++++++++-------------------------- 1 file changed, 22 insertions(+), 26 deletions(-)
tools/libxl/libxl.c +22 -26
@@ -3640,21 +3640,18 @@ int libxl_set_memory_target(libxl_ctx *ctx, uint32_t domid, {GC_INIT (ctx);int rc =1 , abort_transaction =0 ; -uint32_t guestkb, memorykb =0 , videoram =0 ; -uint32_t current_target_memkb =0 , new_target_memkb =0 ; -char *memmax, *endptr, *videoram_s =NULL , *target =NULL ; -char *dompath =libxl__xs_get_dompath (gc, domid); +uint32_t current_target_memkb, guestkb, memorykb =0 , new_target_memkb; +char *dompath =libxl__xs_get_dompath (gc, domid), *endptr, *s;xc_domaininfo_t info;libxl_dominfo ptr; -char *uuid;xs_transaction_t t; retry_transaction: t =xs_transaction_start (ctx->xsh); - target =libxl__xs_read (gc, t,libxl__sprintf (gc, + s =libxl__xs_read (gc, t,libxl__sprintf (gc,"%s/memory/target" , dompath)); -if (!target && !domid) { +if (!s && !domid) {xs_transaction_end (ctx->xsh, t,1 ); rc =libxl__fill_dom0_memory_info (gc, ¤t_target_memkb);if (rc <0 ) {
@@ -3662,18 +3659,18 @@ retry_transaction: goto out; } goto retry_transaction; - }else if (!target) { + }else if (!s) {LIBXL__LOG_ERRNO (ctx,LIBXL__LOG_ERROR ,"cannot get target memory info from %s/memory/target\n" , dompath); abort_transaction =1 ; goto out; }else { - current_target_memkb =strtoul (target, &endptr,10 ); + current_target_memkb =strtoul (s, &endptr,10 );if (*endptr !='\0' ) {LIBXL__LOG_ERRNO (ctx,LIBXL__LOG_ERROR ,"invalid memory target %s from %s/memory/target\n" , - target, dompath); + s, dompath); abort_transaction =1 ; goto out; }
@@ -3688,21 +3685,21 @@ retry_transaction:xcinfo2xlinfo (&info, &ptr); - memmax =libxl__xs_read (gc, t,libxl__sprintf (gc, + s =libxl__xs_read (gc, t,libxl__sprintf (gc,"%s/memory/guest-max" , dompath)); -if (memmax) { - guestkb =strtoul (memmax, &endptr,10 ); +if (s) { + guestkb =strtoul (s, &endptr,10 );if (*endptr !='\0' ) guestkb =0 ; }else guestkb =0 ;if (!guestkb) { - memmax =libxl__xs_read (gc, t,libxl__sprintf (gc, + s =libxl__xs_read (gc, t,libxl__sprintf (gc,"%s/memory/static-max" , dompath)); -if (!memmax) { +if (!s) {LIBXL__LOG_ERRNO (ctx,LIBXL__LOG_ERROR ,"cannot get memory info from %s/memory/static-max\n" , dompath);
@@ -3710,12 +3707,12 @@ retry_transaction: goto out; } - memorykb =strtoul (memmax, &endptr,10 ); + memorykb =strtoul (s, &endptr,10 );if (*endptr !='\0' ) {LIBXL__LOG_ERRNO (ctx,LIBXL__LOG_ERROR ,"invalid max memory %s from %s/memory/static-max\n" , - memmax, dompath); + s, dompath); abort_transaction =1 ; goto out; }
@@ -3752,18 +3749,14 @@ retry_transaction: abort_transaction =1 ; goto out; } - videoram_s =libxl__xs_read (gc, t,libxl__sprintf (gc, -"%s/memory/videoram" , dompath)); - videoram = videoram_s ?atoi (videoram_s) :0 ;if (enforce) { - memorykb = new_target_memkb; - rc =xc_domain_setmaxmem (ctx->xch, domid, memorykb + + rc =xc_domain_setmaxmem (ctx->xch, domid, new_target_memkb +LIBXL_MAXMEM_CONSTANT );if (rc !=0 ) {LIBXL__LOG_ERRNO (ctx,LIBXL__LOG_ERROR ,"xc_domain_setmaxmem domid=%d memkb=%d failed " -"rc=%d\n" , domid, memorykb +LIBXL_MAXMEM_CONSTANT , rc); +"rc=%d\n" , domid, new_target_memkb +LIBXL_MAXMEM_CONSTANT , rc); abort_transaction =1 ; goto out; }
@@ -3775,7 +3768,10 @@ retry_transaction: goto out; } - new_target_memkb -= videoram; + s =libxl__xs_read (gc, t,libxl__sprintf (gc, +"%s/memory/videoram" , dompath)); + new_target_memkb -= s ?atoi (s) :0 ; + rc =xc_domain_set_pod_target (ctx->xch, domid, new_target_memkb /4 ,NULL ,NULL ,NULL );if (rc !=0 ) {
@@ -3790,8 +3786,8 @@ retry_transaction:libxl__xs_write (gc, t,libxl__sprintf (gc,"%s/memory/target" , dompath),"%" PRIu32, new_target_memkb); - uuid =libxl__uuid2string (gc, ptr.uuid); -libxl__xs_write (gc, t,libxl__sprintf (gc,"/vm/%s/memory" , uuid), + s =libxl__uuid2string (gc, ptr.uuid); +libxl__xs_write (gc, t,libxl__sprintf (gc,"/vm/%s/memory" , s),"%" PRIu32, new_target_memkb /1024 ); out:
Signature · 1 line
1.7.10.4
Re: [PATCH v4 3/4] libxl: Some optimizations in libxl_set_memory_target()
Quoted 1 line · Daniel Kiper
Some optimizations in
libxl_set_memory_target().
Please describe them in the commit message.
At first glance it just looks like you are renaming some variables from "memmax"/"target"/"uuid" to "s", why? Just to reduce the number of local variables?
They seem more meaningful and easier to read with their current names and if you are "optimising" the use of local variable then that seems like a false optimisation to me -- any modern compiler can surely work out that the lifetimes of these various things do not overlap and do the sensible thing WRT register allocation.
At the very least this renaming is hiding what you are actually doing.
Quoted 144 lines
Signed-off-by Daniel Kiper <[email protected]>--- tools/libxl/libxl.c | 48 ++++++++++++++++++++++-------------------------- 1 file changed, 22 insertions(+), 26 deletions(-)tools/libxl/libxl.c +22
-26@@ -3640,21 +3640,18 @@ int libxl_set_memory_target(libxl_ctx *ctx, uint32_t domid, {GC_INIT (ctx);int rc =1 , abort_transaction =0 ; -uint32_t guestkb, memorykb =0 , videoram =0 ; -uint32_t current_target_memkb =0 , new_target_memkb =0 ; -char *memmax, *endptr, *videoram_s =NULL , *target =NULL ; -char *dompath =libxl__xs_get_dompath (gc, domid); +uint32_t current_target_memkb, guestkb, memorykb =0 , new_target_memkb; +char *dompath =libxl__xs_get_dompath (gc, domid), *endptr, *s;xc_domaininfo_t info;libxl_dominfo ptr; -char *uuid;xs_transaction_t t; retry_transaction: t =xs_transaction_start (ctx->xsh); - target =libxl__xs_read (gc, t,libxl__sprintf (gc, + s =libxl__xs_read (gc, t,libxl__sprintf (gc,"%s/memory/target" , dompath)); -if (!target && !domid) { +if (!s && !domid) {xs_transaction_end (ctx->xsh, t,1 ); rc =libxl__fill_dom0_memory_info (gc, ¤t_target_memkb);if (rc <0 ) {@@ -3662,18 +3659,18 @@ retry_transaction: goto out; } goto retry_transaction; - }else if (!target) { + }else if (!s) {LIBXL__LOG_ERRNO (ctx,LIBXL__LOG_ERROR ,"cannot get target memory info from %s/memory/target\n" , dompath); abort_transaction =1 ; goto out; }else { - current_target_memkb =strtoul (target, &endptr,10 ); + current_target_memkb =strtoul (s, &endptr,10 );if (*endptr !='\0' ) {LIBXL__LOG_ERRNO (ctx,LIBXL__LOG_ERROR ,"invalid memory target %s from %s/memory/target\n" , - target, dompath); + s, dompath); abort_transaction =1 ; goto out; }@@ -3688,21 +3685,21 @@ retry_transaction:xcinfo2xlinfo (&info, &ptr); - memmax =libxl__xs_read (gc, t,libxl__sprintf (gc, + s =libxl__xs_read (gc, t,libxl__sprintf (gc,"%s/memory/guest-max" , dompath)); -if (memmax) { - guestkb =strtoul (memmax, &endptr,10 ); +if (s) { + guestkb =strtoul (s, &endptr,10 );if (*endptr !='\0' ) guestkb =0 ; }else guestkb =0 ;if (!guestkb) { - memmax =libxl__xs_read (gc, t,libxl__sprintf (gc, + s =libxl__xs_read (gc, t,libxl__sprintf (gc,"%s/memory/static-max" , dompath)); -if (!memmax) { +if (!s) {LIBXL__LOG_ERRNO (ctx,LIBXL__LOG_ERROR ,"cannot get memory info from %s/memory/static-max\n" , dompath);@@ -3710,12 +3707,12 @@ retry_transaction: goto out; } - memorykb =strtoul (memmax, &endptr,10 ); + memorykb =strtoul (s, &endptr,10 );if (*endptr !='\0' ) {LIBXL__LOG_ERRNO (ctx,LIBXL__LOG_ERROR ,"invalid max memory %s from %s/memory/static-max\n" , - memmax, dompath); + s, dompath); abort_transaction =1 ; goto out; }@@ -3752,18 +3749,14 @@ retry_transaction: abort_transaction =1 ; goto out; } - videoram_s =libxl__xs_read (gc, t,libxl__sprintf (gc, -"%s/memory/videoram" , dompath)); - videoram = videoram_s ?atoi (videoram_s) :0 ;if (enforce) { - memorykb = new_target_memkb; - rc =xc_domain_setmaxmem (ctx->xch, domid, memorykb + + rc =xc_domain_setmaxmem (ctx->xch, domid, new_target_memkb +LIBXL_MAXMEM_CONSTANT );if (rc !=0 ) {LIBXL__LOG_ERRNO (ctx,LIBXL__LOG_ERROR ,"xc_domain_setmaxmem domid=%d memkb=%d failed " -"rc=%d\n" , domid, memorykb +LIBXL_MAXMEM_CONSTANT , rc); +"rc=%d\n" , domid, new_target_memkb +LIBXL_MAXMEM_CONSTANT , rc); abort_transaction =1 ; goto out; }@@ -3775,7 +3768,10 @@ retry_transaction: goto out; } - new_target_memkb -= videoram; + s =libxl__xs_read (gc, t,libxl__sprintf (gc, +"%s/memory/videoram" , dompath)); + new_target_memkb -= s ?atoi (s) :0 ; + rc =xc_domain_set_pod_target (ctx->xch, domid, new_target_memkb /4 ,NULL ,NULL ,NULL );if (rc !=0 ) {@@ -3790,8 +3786,8 @@ retry_transaction:libxl__xs_write (gc, t,libxl__sprintf (gc,"%s/memory/target" , dompath),"%" PRIu32, new_target_memkb); - uuid =libxl__uuid2string (gc, ptr.uuid); -libxl__xs_write (gc, t,libxl__sprintf (gc,"/vm/%s/memory" , uuid), + s =libxl__uuid2string (gc, ptr.uuid); +libxl__xs_write (gc, t,libxl__sprintf (gc,"/vm/%s/memory" , s),"%" PRIu32, new_target_memkb /1024 ); out:
Re: [PATCH v4 3/4] libxl: Some optimizations in libxl_set_memory_target()
Quoted 4 lines · Ian Campbell
Quoted 1 line · Daniel Kiper
Some optimizations in
libxl_set_memory_target().Please describe them in the commit message.
OK.
Quoted 11 lines
At first glance it just looks like you are renaming some variables from "memmax"/"target"/"uuid" to "s", why? Just to reduce the number of local variables?
They seem more meaningful and easier to read with their current names and if you are "optimising" the use of local variable then that seems like a false optimisation to me -- any modern compiler can surely work out that the lifetimes of these various things do not overlap and do the sensible thing WRT register allocation.
At the very least this renaming is hiding what you are actually doing.
Here are four things:
- reduction of number of variables which you found,
- removal of unneeded intialization; probably it was needed some time ago but now it is not,
- removal of memorykb = new_target_memkb assignment with relevant changes in other places,
- merge of video memory size calculation which is currently in two places.
I do not insist on first thing but I think that
other optimizations are worth to do. If you wish
I could do all of them in separate patches.
Daniel
Re: [PATCH v4 3/4] libxl: Some optimizations in libxl_set_memory_target()
Quoted 29 lines · Daniel Kiper
Quoted 4 lines · Ian Campbell
Quoted 1 line · Daniel Kiper
Some optimizations in
libxl_set_memory_target().Please describe them in the commit message.
OK.
Quoted 11 lines
At first glance it just looks like you are renaming some variables from "memmax"/"target"/"uuid" to "s", why? Just to reduce the number of local variables?
They seem more meaningful and easier to read with their current names and if you are "optimising" the use of local variable then that seems like a false optimisation to me -- any modern compiler can surely work out that the lifetimes of these various things do not overlap and do the sensible thing WRT register allocation.
At the very least this renaming is hiding what you are actually doing.
Here are four things:
- reduction of number of variables which you found,
- removal of unneeded intialization; probably it was needed some time ago but now it is not,
- removal of memorykb =new_target_memkbassignment with relevant changes in other places,
- merge of video memory size calculation which is currently in two places.
Quoted 3 lines
I do not insist on first thing but I think that
other optimizations are worth to do. If you wish
I could do all of them in separate patches.
IMHO we should be optimising this code for readability, not for number of variables or even performance (this is hardly a hot path).
With that in mind, #1 -- no, #2 ok, #3 might be ok if it improves readability (but hard to tell with it mixed in with the other fixes), #4 is probably ok on the basis of not repeating the logic.
So separate patches are probably the way to go.
Ian.
PATCH v4 4/4 xl: Improve xl documentation in regards to guest memory management
In reply to Daniel KiperImprove xl documentation in regards to guest memory management.
Some improvements are suggested by Ian Jackson and Konrad Rzeszutek Wilk.
--- docs/man/xl.conf.pod.5 | 15 +++++ docs/misc/libxl_memory.txt | 124 +++++++++++++++++++++---------------- docs/misc/xenstore-paths.markdown | 22 ++++--- tools/examples/xl.conf | 4 ++ 4 files changed, 105 insertions(+), 60 deletions(-)
docs/man/xl.conf.pod.5 +15 -0
@@ -62,6 +62,21 @@ of memory given to domain 0 by default. Default: C<"auto"> +=item B<mem_set_enforce_limit=BOOLEAN> + +If enabled, then C<xl mem-set> by default will set a memory allocation +target and enforce the maximum memory allocation for each domain. +If disabled, then C<xl mem-set> by default will set only a memory allocation +target for each domain. + +The memory allocation target is a suggested amount of memory which +should be allocated by a guest. It is nice when the guest follows this +value but it may have its own idea about memory requirments. However, +it could not allocate more memory than a ceiling known as the maximum +memory allocation. + +Default: C<1> + =item B<run_hotplug_scripts=BOOLEAN> If disabled hotplug scripts will be called from udev, as it used to
docs/misc/libxl_memory.txt +72 -52
142 lines not on this page · raw message
docs/misc/xenstore-paths.markdown +14 -8
@@ -124,18 +124,24 @@ This protocol is not currently well documented. #### ~/memory/static-max = MEMKB [] -Specifies a static maximum amount memory which this domain should -expect to be given. In the absence of in-guest memory hotplug support -this set on domain boot and is usually the maximum amount of RAM which -a guest can make use of. See [docs/misc/libxl_memory.txt][LIBXLMEM] -for a description of how memory is accounted for in toolstacks using -the libxl library. +Specifies a static maximum amount of memory which this domain +should expect to be given. It is usually the maximum amount +of RAM which a guest can make use of. This value is set on the +domain boot. If ~/memory/guest-max is set then static maximum +is ignored by libxl. See [docs/misc/libxl_memory.txt][LIBXLMEM] +for a description of how the memory is accounted for in toolstacks +using the libxl library. + +#### ~/memory/guest-max = ""|MEMKB [w] + +Declared by a guest its maximum supported memory size. Valid if numeric. #### ~/memory/target = MEMKB [] The current balloon target for the domain. The balloon driver within -the guest is expected to make every effort to every effort use no more -than this amount of RAM. +the guest is expected to make every effort to use no more than this +amount of RAM. Guests whose actual allocation exceeds the target may +experience memory allocation failures. #### ~/memory/videoram = MEMKB [HVM,INTERNAL]
tools/examples/xl.conf +4 -0
@@ -5,6 +5,10 @@ # starts with all the host's memory. #autoballoon="auto" +# xl mem-set by default will set a memory allocation target and enforce +# the maximum memory allocation for each domain +#mem_set_enforce_limit=1 + # full path of the lockfile used by xl during domain creation #lockfile="/var/lock/xl"
Signature · 1 line
1.7.10.4
Re: [PATCH v4 4/4] xl: Improve xl documentation in regards to guest memory management
Quoted 1 line · Daniel Kiper
Improve xl documentation in regards to guest memory management.
Thank you for remembering docs!
Could I ask that where you are documenting new options, xenstore paths or xl commands etc you do it in the patch which makes the code change. I'm thinking specifically of the addition of mem_set_enforce_limit and the new xenstore paths. I'm not sure if the libxl_memory.txt changes corresponds to a code change or not.
Quoted 18 lines
Some improvements are suggested by Ian Jackson and Konrad Rzeszutek Wilk.
Signed-off-by Daniel Kiper <[email protected]>--- docs/man/xl.conf.pod.5 | 15 +++++ docs/misc/libxl_memory.txt | 124 +++++++++++++++++++++---------------- docs/misc/xenstore-paths.markdown | 22 ++++--- tools/examples/xl.conf | 4 ++ 4 files changed, 105 insertions(+), 60 deletions(-)docs/man/xl.conf.pod.5 +0
-0@@ -62,6 +62,21 @@ of memory given to domain 0 by default. Default: C<"auto">
docs/man/xl.conf.pod.5 of memory given to domain 0 by default. · line 74
Quoted 10 lines
docs/man/xl.conf.pod.5 +10
-0+=item B<mem_set_enforce_limit=BOOLEAN> + +If enabled, then C<xl mem-set> by default will set a memory allocation +target and enforce the maximum memory allocation for each domain. +If disabled, then C<xl mem-set> by default will set only a memory allocation +target for each domain. + +The memory allocation target is a suggested amount of memory which +should be allocated by a guest. It is nice when the guest follows this +value but it may have its own idea about memory requirments. However,
requirements.
Quoted 63 lines
docs/man/xl.conf.pod.5 +5
-0+it could not allocate more memory than a ceiling known as the maximum +memory allocation. + +Default: C<1> + =item B<run_hotplug_scripts=BOOLEAN> If disabled hotplug scripts will be called from udev, as it used todocs/misc/libxl_memory.txt +23
-26@@ -1,70 +1,90 @@ /* === Domain memory breakdown: HVM guests ================================== - - + +----------+ + - | | shadow | | - | +----------+ | - overhead | | extra | | - | | external | | - | +----------+ + | - | | extra | | | - | | internal | | | - + +----------+ + | | footprint - | | video | | | | - | +----------+ + + | | xen | - | | | | | | actual | maximum | - | | | | | | target | | - | | guest | | | build | | | - | | | | | start | | | - static | | | | | | | | - maximum | +----------+ | + + + + - | | | | - | | | | - | | balloon | | build - | | | | maximum - | | | | - + +----------+ + - - + + + +----------+ + + | | shadow | | + | +----------+ | + overhead | | extra | | + | | external | | + | +----------+ + | + | | extra | | | + | | internal | | | + + +----------+ + + | | footprint + | | video | | | | | + | +----------+ | + + | | xen | + | | | | | | | actual | maximum | + | | | | | | | target | | + | | guest | | | | build | | | + | | | | | | start | | | + | | | | | | | | | + | +----------+ | | + + + + + | | | | | + | | | | | + guest | | | | | build + maximum | | | | | maximum + | | balloon | | |
docs/misc/libxl_memory.txt line 34
Quoted 10 lines
docs/misc/libxl_memory.txt +10
-0+ | | | | | + | | | | static | + | | | | maximum | + | | | | | + | +----------+ + + + | | | + | | memory | + | | hotplug | + | | | + + +----------+
Hard to read a diff of a picture, do I understand correctly that you have just added guest-maximum and moved static maximum over to the other side?
How about, on the left (aligned as appropriate with the existing boxes etc):
overhead +
|
+ +
| |
| static |
| maximum|
| |
guest | +
maximum| |
| memory |
| hotplug|
| |
+ +?
docs/misc/libxl_memory.txt line 43
Quoted 9 lines
docs/misc/libxl_memory.txt +3
-0+ + extra internal = LIBXL_MAXMEM_CONSTANT extra external = LIBXL_HVM_EXTRA_MEMORY shadow = libxl_domain_build_info.shadow_memkb static maximum = libxl_domain_build_info.max_memkb video = libxl_domain_build_info.video_memkb build start = libxl_domain_build_info.target_memkb + guest maximum = declared by a guest its maximum supported memory size
^comma here I think? Or "as"
docs/misc/libxl_memory.txt line 45
Quoted 5 lines
docs/misc/libxl_memory.txt +1
-3libxl_domain_setmaxmem -> xen maximum - libxl_set_memory_target -> actual target - - + libxl_set_memory_target -> actual target & optionaly xen maximum
optionally
Quoted 52 lines
docs/misc/libxl_memory.txt +29
-22+ + === Domain memory breakdown: PV guests ================================== - - - + +----------+ + - overhead | | extra | | - | | external | | - | +----------+ + | - | | extra | | | - | | internal | | | - + +----------+ + + + | | footprint - | | | | | | | xen | - | | | | | | actual | maximum | - | | guest | | | build | target | | - | | | | | start | | | - static | | | | | | | | - maximum | +----------+ | + + + + - | | | | - | | | | - | | balloon | | build - | | | | maximum - | | | | - + +----------+ + - + + + + +----------+ + + overhead | | extra | | + | | external | | + | +----------+ + | + | | extra | | | + | | internal | | | + + +----------+ + + + + | | footprint + | | | | | | | | xen | + | | | | | | | actual | maximum | + | | guest | | | | build | target | | + | | | | | | start | | | + | | | | | | | | | + | +----------+ | | + + + + + | | | | | + | | | | | + | | | | | build + guest | | | | | maximum + maximum | | balloon | | | + | | | | | + | | | | static | + | | | | maximum | + | | | | | + | +----------+ + + + | | | + | | memory |
docs/misc/libxl_memory.txt line 85
Quoted 10 lines
docs/misc/libxl_memory.txt +5
-0+ | | hotplug | + | | | + + +----------+ + extra internal = LIBXL_MAXMEM_CONSTANT extra external = LIBXL_PV_EXTRA_MEMORY static maximum = libxl_domain_build_info.max_memkb build start = libxl_domain_build_info.target_memkb + guest maximum = declared by a guest its maximum supported memory size
Another comma I think.
docs/misc/libxl_memory.txt line 45
Quoted 3 lines
docs/misc/libxl_memory.txt +1
-1libxl_domain_setmaxmem -> xen maximum - libxl_set_memory_target -> actual target + libxl_set_memory_target -> actual target & optionaly xen maximum
optionally again.
Quoted 14 lines
docs/misc/libxl_memory.txt +0
-0========================================================================= */docs/misc/xenstore-paths.markdown +0
-3@@ -124,18 +124,24 @@ This protocol is not currently well documented. #### ~/memory/static-max = MEMKB [] -Specifies a static maximum amount memory which this domain should -expect to be given. In the absence of in-guest memory hotplug support -this set on domain boot and is usually the maximum amount of RAM which
docs/misc/xenstore-paths.markdown This protocol is not currently well documented. · line 133
Quoted 10 lines
docs/misc/xenstore-paths.markdown +7
-3-a guest can make use of. See [docs/misc/libxl_memory.txt][LIBXLMEM] -for a description of how memory is accounted for in toolstacks using -the libxl library. +Specifies a static maximum amount of memory which this domain +should expect to be given. It is usually the maximum amount +of RAM which a guest can make use of. This value is set on the +domain boot. If ~/memory/guest-max is set then static maximum +is ignored by libxl. See [docs/misc/libxl_memory.txt][LIBXLMEM] +for a description of how the memory is accounted for in toolstacks +using the libxl library.
I'd retain the "and in the absence of in-guest..." stuff here but go on to add a sentence lile "If in-guest memory hotplug is supported, then it will write guest-max (see below).
The key point is to describe the behaviour with and without hotplug.
docs/misc/xenstore-paths.markdown This protocol is not currently well documented. · line 137
Quoted 4 lines
docs/misc/xenstore-paths.markdown +4
-0+ +#### ~/memory/guest-max = ""|MEMKB [w] + +Declared by a guest its maximum supported memory size. Valid if numeric.
I think "Valid if numeric" is covered by the specification of MEMKB.
Quoted 29 lines
docs/misc/xenstore-paths.markdown +3
-2#### ~/memory/target = MEMKB [] The current balloon target for the domain. The balloon driver within -the guest is expected to make every effort to every effort use no more -than this amount of RAM. +the guest is expected to make every effort to use no more than this +amount of RAM. Guests whose actual allocation exceeds the target may +experience memory allocation failures. #### ~/memory/videoram = MEMKB [HVM,INTERNAL]tools/examples/xl.conf +4
-1@@ -5,6 +5,10 @@ # starts with all the host's memory. #autoballoon="auto" +# xl mem-set by default will set a memory allocation target and enforce +# the maximum memory allocation for each domain +#mem_set_enforce_limit=1 + # full path of the lockfile used by xl during domain creation #lockfile="/var/lock/xl" --1.7.10.4
Re: [PATCH v4 4/4] xl: Improve xl documentation in regards to guest memory management
Quoted 4 lines · Ian Campbell
Quoted 1 line · Daniel Kiper
Improve xl documentation in regards to guest memory management.
Thank you for remembering docs!
During Document Day it is a must... ;-)))
Quoted 3 lines
Could I ask that where you are documenting new options, xenstore paths or xl commands etc you do it in the patch which makes the code change. I'm thinking specifically of the addition of
mem_set_enforce_limitand
Sure...
Quoted 2 lines
the new xenstore paths. I'm not sure if the libxl_memory.txt changes corresponds to a code change or not.
Yes, it does.
Quoted 100 lines
Quoted 18 lines
Some improvements are suggested by Ian Jackson and Konrad Rzeszutek Wilk.
Signed-off-by Daniel Kiper <[email protected]>--- docs/man/xl.conf.pod.5 | 15 +++++ docs/misc/libxl_memory.txt | 124 +++++++++++++++++++++---------------- docs/misc/xenstore-paths.markdown | 22 ++++--- tools/examples/xl.conf | 4 ++ 4 files changed, 105 insertions(+), 60 deletions(-)docs/man/xl.conf.pod.5 +0
-0@@ -62,6 +62,21 @@ of memory given to domain 0 by default. Default: C<"auto">docs/man/xl.conf.pod.5 of memory given to domain 0 by default. · line 74
Quoted 10 lines
docs/man/xl.conf.pod.5 +10
-0+=item B<mem_set_enforce_limit=BOOLEAN> + +If enabled, then C<xl mem-set> by default will set a memory allocation +target and enforce the maximum memory allocation for each domain. +If disabled, then C<xl mem-set> by default will set only a memory allocation +target for each domain. + +The memory allocation target is a suggested amount of memory which +should be allocated by a guest. It is nice when the guest follows this +value but it may have its own idea about memory requirments. However,requirements.
Quoted 69 lines
docs/man/xl.conf.pod.5 +5
-0+it could not allocate more memory than a ceiling known as the maximum +memory allocation. + +Default: C<1> + =item B<run_hotplug_scripts=BOOLEAN> If disabled hotplug scripts will be called from udev, as it used todocs/misc/libxl_memory.txt +29
-26@@ -1,70 +1,90 @@ /* === Domain memory breakdown: HVM guests ================================== - - + +----------+ + - | | shadow | | - | +----------+ | - overhead | | extra | | - | | external | | - | +----------+ + | - | | extra | | | - | | internal | | | - + +----------+ + | | footprint - | | video | | | | - | +----------+ + + | | xen | - | | | | | | actual | maximum | - | | | | | | target | | - | | guest | | | build | | | - | | | | | start | | | - static | | | | | | | | - maximum | +----------+ | + + + + - | | | | - | | | | - | | balloon | | build - | | | | maximum - | | | | - + +----------+ + - - + + + +----------+ + + | | shadow | | + | +----------+ | + overhead | | extra | | + | | external | | + | +----------+ + | + | | extra | | | + | | internal | | | + + +----------+ + + | | footprint + | | video | | | | | + | +----------+ | + + | | xen | + | | | | | | | actual | maximum | + | | | | | | | target | | + | | guest | | | | build | | | + | | | | | | start | | | + | | | | | | | | | + | +----------+ | | + + + + + | | | | | + | | | | | + guest | | | | | build + maximum | | | | | maximum + | | balloon | | | + | | | | | + | | | | static | + | | | | maximum | + | | | | | + | +----------+ + + + | | |
Quoted 8 lines
docs/misc/libxl_memory.txt line 34
Quoted 4 lines
docs/misc/libxl_memory.txt +4
-0+ | | memory | + | | hotplug | + | | | + + +----------+Hard to read a diff of a picture, do I understand correctly that you have just added guest-maximum and moved static maximum over to the other side?
Right.
Quoted 16 lines
How about, on the left (aligned as appropriate with the existing boxes etc):
overhead + | + + | | | static | | maximum| | | guest | + maximum| | | memory | | hotplug| | | + +
Quoted 1 line
?
OK.
[...]
Quoted 27 lines
Quoted 12 lines
docs/misc/libxl_memory.txt +0
-0========================================================================= */docs/misc/xenstore-paths.markdown +0
-3@@ -124,18 +124,24 @@ This protocol is not currently well documented. #### ~/memory/static-max = MEMKB [] -Specifies a static maximum amount memory which this domain should -expect to be given. In the absence of in-guest memory hotplug support -this set on domain boot and is usually the maximum amount of RAM whichdocs/misc/xenstore-paths.markdown This protocol is not currently well documented. · line 133
Quoted 10 lines
docs/misc/xenstore-paths.markdown +7
-3-a guest can make use of. See [docs/misc/libxl_memory.txt][LIBXLMEM] -for a description of how memory is accounted for in toolstacks using -the libxl library. +Specifies a static maximum amount of memory which this domain +should expect to be given. It is usually the maximum amount +of RAM which a guest can make use of. This value is set on the +domain boot. If ~/memory/guest-max is set then static maximum +is ignored by libxl. See [docs/misc/libxl_memory.txt][LIBXLMEM] +for a description of how the memory is accounted for in toolstacks +using the libxl library.I'd retain the "and in the absence of in-guest..." stuff here but go on to add a sentence lile "If in-guest memory hotplug is supported, then it will write guest-max (see below).
Quoted 1 line
The key point is to describe the behaviour with and without hotplug.
I think that every new polite guest, with or without memory hotplug, should inform about its maximum supported memory size. It means that we should not differentiate both cases here.
Daniel
Re: [PATCH v4 4/4] xl: Improve xl documentation in regards to guest memory management
Quoted 27 lines · Daniel Kiper
Quoted 27 lines
Quoted 12 lines
========================================================================= */
docs/misc/xenstore-paths.markdown +0
-3@@ -124,18 +124,24 @@ This protocol is not currently well documented. #### ~/memory/static-max = MEMKB [] -Specifies a static maximum amount memory which this domain should -expect to be given. In the absence of in-guest memory hotplug support -this set on domain boot and is usually the maximum amount of RAM whichdocs/misc/xenstore-paths.markdown This protocol is not currently well documented. · line 133
Quoted 10 lines
docs/misc/xenstore-paths.markdown +7
-3-a guest can make use of. See [docs/misc/libxl_memory.txt][LIBXLMEM] -for a description of how memory is accounted for in toolstacks using -the libxl library. +Specifies a static maximum amount of memory which this domain +should expect to be given. It is usually the maximum amount +of RAM which a guest can make use of. This value is set on the +domain boot. If ~/memory/guest-max is set then static maximum +is ignored by libxl. See [docs/misc/libxl_memory.txt][LIBXLMEM] +for a description of how the memory is accounted for in toolstacks +using the libxl library.I'd retain the "and in the absence of in-guest..." stuff here but go on to add a sentence lile "If in-guest memory hotplug is supported, then it will write guest-max (see below).
Quoted 5 lines
Quoted 1 line
The key point is to describe the behaviour with and without hotplug.
I think that every new polite guest, with or without memory hotplug, should inform about its maximum supported memory size. It means that we should not differentiate both cases here.
We can say things like "guests should do foo" but we need to account for existing guests which don't and for future guests which still don't, e.g. at the moment all non-Linux guests.
Ian.