xen: support per-cpupool scheduling granularity
v4 cover xen: support per-cpupool scheduling granularity
Support scheduling granularity per cpupool. Setting the granularity is done via hypfs, which needed to gain dynamical entries for that purpose.
Apart from the hypfs related additional functionality the main change for cpupools was the support for moving a domain to a new granularity, as this requires to modify the scheduling unit/vcpu relationship.
I have tried to do the hypfs modifications in a rather generic way in order to be able to use the same infrastructure in other cases, too (e.g. for per-domain entries).
The complete series has been tested by creating cpupools with different granularities and moving busy and idle domains between those.
Changes in V4:
- Patches 1-3 of V3 have been committed
- Addressed all comments
Changes in V3:
- Patches 1-6 and 8-11 of V2 have been committed already
- New patch 2
- Addressed all comments
- Added a data pointer to struct hypfs_dyndir
Changes in V2:
- Added several new patches, especially for some further cleanups in cpupool.c.
- Completely reworked the locking scheme with dynamical directories:
locking of resources (cpupools in this series) is now done via new callbacks which are called when traversing the hypfs tree. This removes the need to add locking to each hypfs related cpupool function and it ensures data integrity across multiple callbacks.
- Reordered the first few patches in order to have already acked patches in pure cleanup patches first.
- Addressed several comments.
Juergen Gross (5):
xen/hypfs: support dynamic hypfs nodes
xen/hypfs: add support for id-based dynamic directories xen/cpupool: add cpupool directories
xen/cpupool: add scheduling granularity entry to cpupool entries xen/cpupool: make per-cpupool sched-gran hypfs node writable
docs/misc/hypfs-paths.pandoc | 16 +++ xen/common/hypfs.c | 141 ++++++++++++++++++++ xen/common/sched/cpupool.c | 240 +++++++++++++++++++++++++++++++++-- xen/include/xen/hypfs.h | 47 +++++-- 4 files changed, 422 insertions(+), 22 deletions(-)
Signature · 1 line
2.26.2
PATCH v4 1/5 xen/hypfs: support dynamic hypfs nodes
Add a HYPFS_VARDIR_INIT() macro for initializing such a directory statically, taking a struct hypfs_funcs pointer as parameter additional to those of HYPFS_DIR_INIT().
Modify HYPFS_VARSIZE_INIT() to take the function vector pointer as an additional parameter as this will be needed for dynamical entries.
For being able to let the generic hypfs coding continue to work on normal struct hypfs_entry entities even for dynamical nodes add some infrastructure for allocating a working area for the current hypfs request in order to store needed information for traversing the tree. This area is anchored in a percpu pointer and can be retrieved by any level of the dynamic entries. The normal way to handle allocation and freeing is to allocate the data in the enter() callback of a node and to free it in the related exit() callback.
Add a hypfs_add_dyndir() function for adding a dynamic directory template to the tree, which is needed for having the correct reference to its position in hypfs.
---
V2:
- switch to xzalloc_bytes() in hypfs_alloc_dyndata() (Jan Beulich)
- carved out from previous patch
- use enter() and exit() callbacks for allocating and freeing dyndata memory
- add hypfs_add_dyndir()
V3:
- switch hypfs_alloc_dyndata() to be type safe (Jan Beulich)
- rename HYPFS_VARDIR_INIT() to HYPFS_DIR_INIT_FUNC() (Jan Beulich)
V4:
- use temporary variables for avoiding multiple per_cpu() uses (Jan Beulich)
- add comment (Jan Beulich)
- hide hypfs_alloc_dyndata() type unsafe backing function (Jan Beulich)
--- xen/common/hypfs.c | 43 +++++++++++++++++++++++++++++++++++++++++ xen/include/xen/hypfs.h | 29 +++++++++++++++++---------- 2 files changed, 62 insertions(+), 10 deletions(-)
xen/common/hypfs.c +43 -0
@@ -72,6 +72,7 @@ enum hypfs_lock_state {hypfs_write_locked }; static DEFINE_PER_CPU(enum hypfs_lock_state, hypfs_locked); +static DEFINE_PER_CPU(struct hypfs_dyndata *, hypfs_dyndata); static DEFINE_PER_CPU(const struct hypfs_entry *, hypfs_last_node_entered);
@@ -155,6 +156,36 @@ static void node_exit_all(void)node_exit (*last); } +#undef hypfs_alloc_dyndata +void *hypfs_alloc_dyndata (unsigned long size) +{ +unsigned int cpu =smp_processor_id (); +struct hypfs_dyndata **dyndata = &per_cpu (hypfs_dyndata, cpu); + +ASSERT (per_cpu (hypfs_locked, cpu) != hypfs_unlocked); +ASSERT (*dyndata ==NULL ); + + *dyndata =xzalloc_bytes (size); + +return *dyndata; +} + +void *hypfs_get_dyndata (void ) +{ +struct hypfs_dyndata *dyndata =this_cpu (hypfs_dyndata); + +ASSERT (dyndata); + +return dyndata; +} + +void hypfs_free_dyndata (void ) +{ +struct hypfs_dyndata **dyndata = &this_cpu (hypfs_dyndata); + +XFREE (*dyndata); +} +static int add_entry (struct hypfs_entry_dir *parent,struct hypfs_entry *new) {int ret = -ENOENT ;
@@ -216,6 +247,18 @@ int hypfs_add_dir(struct hypfs_entry_dir *parent,return ret; } +void hypfs_add_dyndir (struct hypfs_entry_dir *parent, +struct hypfs_entry_dir *template) +{ +/* +* As the template is only a placeholder for possibly multiple dynamically +* generated directories, the link up to its parent can be static, while +* the "real" children of the parent are to be found via the parent's +* findentry function only. +*/ + template->e.parent = &parent->e; +} +int hypfs_add_leaf (struct hypfs_entry_dir *parent,struct hypfs_entry_leaf *leaf,bool nofault) {
xen/include/xen/hypfs.h +19 -10
@@ -76,7 +76,7 @@ struct hypfs_entry_dir {struct list_head dirlist; }; -#define HYPFS_DIR_INIT (var, nam) \ +#define HYPFS_DIR_INIT_FUNC (var, nam, fn) \ struct hypfs_entry_dir __read_mostly var = { \ .e.type = XEN_HYPFS_TYPE_DIR, \ .e.encoding = XEN_HYPFS_ENC_PLAIN, \
@@ -84,22 +84,25 @@ struct hypfs_entry_dir { .e.size = 0, \ .e.max_size = 0, \ .e.list = LIST_HEAD_INIT(var.e.list), \ - .e.funcs = &hypfs_dir_funcs, \ + .e.funcs = (fn), \ .dirlist = LIST_HEAD_INIT(var.dirlist), \ } -#define HYPFS_VARSIZE_INIT (var, typ, nam, msz) \ - struct hypfs_entry_leaf __read_mostly var = { \ - .e.type = (typ), \ - .e.encoding = XEN_HYPFS_ENC_PLAIN, \ - .e.name = (nam), \ - .e.max_size = (msz), \ - .e.funcs = &hypfs_leaf_ro_funcs, \ +#define HYPFS_DIR_INIT (var, nam) \ + HYPFS_DIR_INIT_FUNC(var, nam, &hypfs_dir_funcs) + +#define HYPFS_VARSIZE_INIT (var, typ, nam, msz, fn) \ + struct hypfs_entry_leaf __read_mostly var = { \ + .e.type = (typ), \ + .e.encoding = XEN_HYPFS_ENC_PLAIN, \ + .e.name = (nam), \ + .e.max_size = (msz), \ + .e.funcs = (fn), \ }/* Content and size need to be set via hypfs_string_set_reference(). */ #define HYPFS_STRING_INIT (var, nam) \ - HYPFS_VARSIZE_INIT(var, XEN_HYPFS_TYPE_STRING, nam, 0) + HYPFS_VARSIZE_INIT(var, XEN_HYPFS_TYPE_STRING, nam, 0, &hypfs_leaf_ro_funcs)/* * Set content and size of a XEN_HYPFS_TYPE_STRING node. The node will point
@@ -150,6 +153,8 @@ extern struct hypfs_entry_dir hypfs_root;int hypfs_add_dir (struct hypfs_entry_dir *parent,struct hypfs_entry_dir *dir,bool nofault); +void hypfs_add_dyndir (struct hypfs_entry_dir *parent, +struct hypfs_entry_dir *template);int hypfs_add_leaf (struct hypfs_entry_dir *parent,struct hypfs_entry_leaf *leaf,bool nofault);const struct hypfs_entry *hypfs_node_enter (const struct hypfs_entry *entry);
@@ -177,6 +182,10 @@ struct hypfs_entry *hypfs_leaf_findentry(const struct hypfs_entry_dir *dir,struct hypfs_entry *hypfs_dir_findentry (const struct hypfs_entry_dir *dir,const char *name,unsigned int name_len); +void *hypfs_alloc_dyndata (unsigned long size); +#define hypfs_alloc_dyndata (type) ((type *)hypfs_alloc_dyndata(sizeof(type))) +void *hypfs_get_dyndata (void ); +void hypfs_free_dyndata (void );#endif #endif /* __XEN_HYPFS_H__ */
Signature · 1 line
2.26.2
Re: [PATCH v4 1/5] xen/hypfs: support dynamic hypfs nodes
Quoted 16 lines · Juergen Gross
Add a
HYPFS_VARDIR_INIT()macro for initializing such a directory statically, taking a structhypfs_funcspointer as parameter additional to those ofHYPFS_DIR_INIT().Modify
HYPFS_VARSIZE_INIT()to take the function vector pointer as an additional parameter as this will be needed for dynamical entries.For being able to let the generic hypfs coding continue to work on normal struct
hypfs_entryentities even for dynamical nodes add some infrastructure for allocating a working area for the current hypfs request in order to store needed information for traversing the tree. This area is anchored in a percpu pointer and can be retrieved by any level of the dynamic entries. The normal way to handle allocation and freeing is to allocate the data in theenter()callback of a node and to free it in the relatedexit()callback.
Quoted 5 lines
Add a
hypfs_add_dyndir()function for adding a dynamic directory template to the tree, which is needed for having the correct reference to its position in hypfs.Signed-off-by Juergen Gross <[email protected]>
PATCH v4 2/5 xen/hypfs: add support for id-based dynamic directories
In reply to Juergen GrossAdd some helpers to hypfs.c to support dynamic directories with a numerical id as name.
The dynamic directory is based on a template specified by the user allowing to use specific access functions and having a predefined set of entries in the directory.
---
V2:
- use macro for length of entry name (Jan Beulich)
- const attributes (Jan Beulich)
- use template name as format string (Jan Beulich)
- add hypfs_dynid_entry_size() helper (Jan Beulich)
- expect dyndir data having been allocated by enter() callback
V3:
- add a specific enter() callback returning the template pointer
- add data field to struct hypfs_dyndir_id
- rename hypfs_gen_dyndir_entry_id() (Jan Beulich)
- add comments regarding generated names to be kept in sync (Jan Beulich)
V4:
- correct comments (Jan Beulich)
--- xen/common/hypfs.c | 98 +++++++++++++++++++++++++++++++++++++++++ xen/include/xen/hypfs.h | 18 ++++++++ 2 files changed, 116 insertions(+)
xen/common/hypfs.c +98 -0
@@ -365,6 +365,104 @@ unsigned int hypfs_getsize(const struct hypfs_entry *entry)return entry->size; } +/* +* Fill the direntry for a dynamically generated entry. Especially the +* generated name needs to be kept in sync with hypfs_gen_dyndir_id_entry(). +*/ +int hypfs_read_dyndir_id_entry (const struct hypfs_entry_dir *template, +unsigned int id,bool is_last, +XEN_GUEST_HANDLE_PARAM (void ) *uaddr) +{ +struct xen_hypfs_dirlistentry direntry; +char name[HYPFS_DYNDIR_ID_NAMELEN ]; +unsigned int e_namelen, e_len; + + e_namelen =snprintf (name,sizeof (name), template->e.name, id); + e_len =DIRENTRY_SIZE (e_namelen); + direntry.e.pad =0 ; + direntry.e.type = template->e.type; + direntry.e.encoding = template->e.encoding; + direntry.e.content_len = template->e.funcs->getsize (&template->e); + direntry.e.max_write_len = template->e.max_size; + direntry.off_next = is_last ?0 : e_len; +if (copy_to_guest (*uaddr, &direntry,1 ) ) +return -EFAULT ; +if (copy_to_guest_offset (*uaddr,DIRENTRY_NAME_OFF , name, + e_namelen +1 ) ) +return -EFAULT ; + +guest_handle_add_offset (*uaddr, e_len); + +return 0 ; +} + +static const struct hypfs_entry *hypfs_dyndir_enter ( +const struct hypfs_entry *entry) +{ +const struct hypfs_dyndir_id *data; + + data =hypfs_get_dyndata (); + +/* Use template with original enter function. */ +return data->template->e.funcs->enter (&data->template->e); +} + +static struct hypfs_entry *hypfs_dyndir_findentry ( +const struct hypfs_entry_dir *dir,const char *name,unsigned int name_len) +{ +const struct hypfs_dyndir_id *data; + + data =hypfs_get_dyndata (); + +/* Use template with original findentry function. */ +return data->template->e.funcs->findentry (data->template, name, name_len); +} + +static int hypfs_read_dyndir (const struct hypfs_entry *entry, +XEN_GUEST_HANDLE_PARAM (void ) uaddr) +{ +const struct hypfs_dyndir_id *data; + + data =hypfs_get_dyndata (); + +/* Use template with original read function. */ +return data->template->e.funcs->read (&data->template->e, uaddr); +} + +/* +* Fill dyndata with a dynamically generated entry based on a template +* and a numerical id. +* Needs to be kept in sync with hypfs_read_dyndir_id_entry() regarding the +* name generated. +*/ +struct hypfs_entry *hypfs_gen_dyndir_id_entry ( +const struct hypfs_entry_dir *template,unsigned int id,void *data) +{ +struct hypfs_dyndir_id *dyndata; + + dyndata =hypfs_get_dyndata (); + + dyndata->template = template; + dyndata->id = id; + dyndata->data = data; +snprintf (dyndata->name,sizeof (dyndata->name), template->e.name, id); + dyndata->dir = *template; + dyndata->dir.e.name = dyndata->name; + dyndata->dir.e.funcs = &dyndata->funcs; + dyndata->funcs = *template->e.funcs; + dyndata->funcs.enter = hypfs_dyndir_enter; + dyndata->funcs.findentry = hypfs_dyndir_findentry; + dyndata->funcs.read = hypfs_read_dyndir; + +return &dyndata->dir.e; +} + +unsigned int hypfs_dynid_entry_size (const struct hypfs_entry *template, +unsigned int id) +{ +return DIRENTRY_SIZE (snprintf (NULL ,0 , template->name, id)); +} +int hypfs_read_dir (const struct hypfs_entry *entry,XEN_GUEST_HANDLE_PARAM (void ) uaddr) {
xen/include/xen/hypfs.h +18 -0
@@ -76,6 +76,17 @@ struct hypfs_entry_dir {struct list_head dirlist; }; +struct hypfs_dyndir_id { +struct hypfs_entry_dir dir;/* Modified copy of template. */ +struct hypfs_funcs funcs;/* Dynamic functions. */ +const struct hypfs_entry_dir *template;/* Template used. */ +#define HYPFS_DYNDIR_ID_NAMELEN 12 +char name[HYPFS_DYNDIR_ID_NAMELEN ];/* Name of hypfs entry. */ + +unsigned int id;/* Numerical id. */ +void *data;/* Data associated with id. */ +}; +#define HYPFS_DIR_INIT_FUNC (var, nam, fn) \ struct hypfs_entry_dir __read_mostly var = { \ .e.type = XEN_HYPFS_TYPE_DIR, \
@@ -186,6 +197,13 @@ void *hypfs_alloc_dyndata(unsigned long size);#define hypfs_alloc_dyndata (type) ((type *)hypfs_alloc_dyndata(sizeof(type)))void *hypfs_get_dyndata (void );void hypfs_free_dyndata (void ); +int hypfs_read_dyndir_id_entry (const struct hypfs_entry_dir *template, +unsigned int id,bool is_last, +XEN_GUEST_HANDLE_PARAM (void ) *uaddr); +struct hypfs_entry *hypfs_gen_dyndir_id_entry ( +const struct hypfs_entry_dir *template,unsigned int id,void *data); +unsigned int hypfs_dynid_entry_size (const struct hypfs_entry *template, +unsigned int id);#endif #endif /* __XEN_HYPFS_H__ */
Signature · 1 line
2.26.2
Re: [PATCH v4 2/5] xen/hypfs: add support for id-based dynamic directories
Quoted 8 lines · Juergen Gross
Add some helpers to
hypfs.cto support dynamic directories with a numerical id as name.The dynamic directory is based on a template specified by the user allowing to use specific access functions and having a predefined set of entries in the directory.
Signed-off-by Juergen Gross <[email protected]>
PATCH v4 3/5 xen/cpupool: add cpupool directories
In reply to Juergen GrossAdd /cpupool/<cpupool-id> directories to hypfs. Those are completely dynamic, so the related hypfs access functions need to be implemented.
---
V2:
- added const (Jan Beulich)
- call hypfs_add_dir() in helper (Dario Faggioli)
- switch locking to enter/exit callbacks
V3:
- use generic dyndirid enter function
- const for hypfs function vector (Jan Beulich)
- drop size calculation from cpupool_dir_read() (Jan Beulich)
- check cpupool id to not exceed UINT_MAX (Jan Beulich)
- coding style (#if/#else/#endif) (Jan Beulich)
--- docs/misc/hypfs-paths.pandoc | 9 +++ xen/common/sched/cpupool.c | 104 +++++++++++++++++++++++++++++++++++ 2 files changed, 113 insertions(+)
docs/misc/hypfs-paths.pandoc +9 -0
@@ -175,6 +175,15 @@ The major version of Xen. The minor version of Xen. +#### /cpupool/ + +A directory of all current cpupools. + +#### /cpupool/*/ + +The individual cpupools. Each entry is a directory with the name being the +cpupool-id (e.g. /cpupool/0/). + #### /params/ A directory of runtime parameters.
xen/common/sched/cpupool.c +104 -0
128 lines not on this page · raw message
Signature · 1 line
2.26.2
PATCH v4 4/5 xen/cpupool: add scheduling granularity entry to cpupool entries
In reply to Juergen GrossAdd a "sched-gran" entry to the per-cpupool hypfs directories.
For now make this entry read-only and let it contain one of the strings "cpu", "core" or "socket".
---
V2:
- added const (Jan Beulich)
- modify test in cpupool_gran_read() (Jan Beulich)
--- docs/misc/hypfs-paths.pandoc | 4 ++ xen/common/sched/cpupool.c | 72 ++++++++++++++++++++++++++++++++++-- 2 files changed, 72 insertions(+), 4 deletions(-)
docs/misc/hypfs-paths.pandoc +4 -0
@@ -184,6 +184,10 @@ A directory of all current cpupools. The individual cpupools. Each entry is a directory with the name being the cpupool-id (e.g. /cpupool/0/). +#### /cpupool/*/sched-gran = ("cpu" | "core" | "socket") + +The scheduling granularity of a cpupool. + #### /params/ A directory of runtime parameters.
xen/common/sched/cpupool.c +68 -4
114 lines not on this page · raw message
Signature · 1 line
2.26.2
Re: [PATCH v4 4/5] xen/cpupool: add scheduling granularity entry to cpupool entries
Quoted 6 lines · Juergen Gross
Add a "sched-gran" entry to the per-cpupool hypfs directories.
For now make this entry read-only and let it contain one of the strings "cpu", "core" or "socket".
Signed-off-by Juergen Gross <[email protected]>
Re: [PATCH v4 4/5] xen/cpupool: add scheduling granularity entry to cpupool entries
In reply to Juergen GrossQuoted 7 lines · Juergen Gross
Add a "sched-gran" entry to the per-cpupool hypfs directories.
For now make this entry read-only and let it contain one of the strings "cpu", "core" or "socket".
Signed-off-by Juergen Gross <[email protected]>
Regards
Signature · 6 lines
Dario Faggioli, Ph.D http://about.me/dario.faggioli Virtualization Software Engineer SUSE Labs, SUSE https://www.suse.com/ ------------------------------------------------------------------- <<This happens because _I_ choose it to happen!>> (Raistlin Majere)
PATCH v4 5/5 xen/cpupool: make per-cpupool sched-gran hypfs node writable
In reply to Juergen GrossMake /cpupool/<id>/sched-gran in hypfs writable. This will enable per cpupool selectable scheduling granularity.
Writing this node is allowed only with no cpu assigned to the cpupool. Allowed are values "cpu", "core" and "socket".
---
V2:
- test user parameters earlier (Jan Beulich)
V3:
- fix build without CONFIG_HYPFS on Arm (Andrew Cooper)
--- docs/misc/hypfs-paths.pandoc | 5 ++- xen/common/sched/cpupool.c | 70 ++++++++++++++++++++++++++++++------ 2 files changed, 63 insertions(+), 12 deletions(-)
docs/misc/hypfs-paths.pandoc +4 -1
@@ -184,10 +184,13 @@ A directory of all current cpupools. The individual cpupools. Each entry is a directory with the name being the cpupool-id (e.g. /cpupool/0/). -#### /cpupool/*/sched-gran = ("cpu" | "core" | "socket") +#### /cpupool/*/sched-gran = ("cpu" | "core" | "socket") [w] The scheduling granularity of a cpupool. +Writing a value is allowed only for cpupools with no cpu assigned and if the +architecture is supporting different scheduling granularities. + #### /params/ A directory of runtime parameters.
xen/common/sched/cpupool.c +59 -11
132 lines not on this page · raw message
Signature · 1 line
2.26.2
Re: [PATCH v4 5/5] xen/cpupool: make per-cpupool sched-gran hypfs node writable
Quoted 7 lines · Juergen Gross
Make /cpupool/<id>/sched-gran in hypfs writable. This will enable per cpupool selectable scheduling granularity.
Writing this node is allowed only with no cpu assigned to the cpupool. Allowed are values "cpu", "core" and "socket".
Signed-off-by Juergen Gross <[email protected]>
with two small adjustment requests:
Quoted 9 lines
xen/common/sched/cpupool.c +1
-1@@ -85,36 +85,43 @@ static int __init sched_select_granularity(const char *str) {if (strcmp (sg_name[i].name, str) ==0 ) { - opt_sched_granularity = sg_name[i].mode; + *mode = sg_name[i].mode;return 0 ; } }
xen/common/sched/cpupool.c static int __init sched_select_granularity(const char *str) · line 101
Quoted 10 lines
xen/common/sched/cpupool.c +6
-0return -EINVAL; } + +static int __init sched_select_granularity (const char *str) +{ +return sched_gran_get (str, &opt_sched_granularity); +}custom_param ("sched-gran" , sched_select_granularity); +#elif CONFIG_HYPFS
Missing defined().
Quoted 28 lines
xen/common/sched/cpupool.c +24
-0@@ -1126,17 +1136,55 @@ static unsigned int hypfs_gran_getsize(const struct hypfs_entry *entry)return strlen (gran) +1 ; } +static int cpupool_gran_write (struct hypfs_entry_leaf *leaf, +XEN_GUEST_HANDLE_PARAM (const_void) uaddr, +unsigned int ulen) +{ +const struct hypfs_dyndir_id *data; +struct cpupool *cpupool; +enum sched_gran gran; +unsigned int sched_gran =0 ; +char name[SCHED_GRAN_NAME_LEN ]; +int ret =0 ; + +if ( ulen >SCHED_GRAN_NAME_LEN ) +return -ENOSPC ; + +if (copy_from_guest (name, uaddr, ulen) ) +return -EFAULT ; + +if (memchr (name,0 , ulen) == (name + ulen -1 ) ) + sched_gran =sched_gran_get (name, &gran) ? +0 :cpupool_check_granularity (gran); +if ( sched_gran ==0 ) +return -EINVAL ; + + data =hypfs_get_dyndata ();
xen/common/sched/cpupool.c static unsigned int hypfs_gran_getsize(const struct hypfs_entry *entry) · line 1172
Quoted 10 lines
xen/common/sched/cpupool.c +10
-0+ cpupool = data->data; +ASSERT (cpupool); + +if ( !cpumask_empty (cpupool->cpu_valid) ) + ret = -EBUSY ; +else + { + cpupool->gran = gran; + cpupool->sched_gran = sched_gran; + }
I think this could do with a comment clarifying what lock this is protected by, as the function itself has no sign of any locking, not even an assertion that a certain lock is being held. If you were to suggest some text, this as well as the minor issue above could likely be taken care of while committing.
Jan
Re: [PATCH v4 5/5] xen/cpupool: make per-cpupool sched-gran hypfs node writable
Quoted 70 lines · Jan Beulich
Quoted 7 lines · Juergen Gross
Make /cpupool/<id>/sched-gran in hypfs writable. This will enable per cpupool selectable scheduling granularity.
Writing this node is allowed only with no cpu assigned to the cpupool. Allowed are values "cpu", "core" and "socket".
Signed-off-by Juergen Gross <[email protected]>Reviewed-by Jan Beulich <[email protected]>with two small adjustment requests:
Quoted 9 lines
xen/common/sched/cpupool.c +1
-1@@ -85,36 +85,43 @@ static int __init sched_select_granularity(const char *str) {if (strcmp (sg_name[i].name, str) ==0 ) { - opt_sched_granularity = sg_name[i].mode; + *mode = sg_name[i].mode;return 0 ; } }xen/common/sched/cpupool.c static int __init sched_select_granularity(const char *str) · line 101
Quoted 10 lines
xen/common/sched/cpupool.c +6
-0return -EINVAL; } + +static int __init sched_select_granularity (const char *str) +{ +return sched_gran_get (str, &opt_sched_granularity); +}custom_param ("sched-gran" , sched_select_granularity); +#elif CONFIG_HYPFSMissing
defined().Quoted 36 lines
xen/common/sched/cpupool.c +32
-0@@ -1126,17 +1136,55 @@ static unsigned int hypfs_gran_getsize(const struct hypfs_entry *entry)return strlen (gran) +1 ; } +static int cpupool_gran_write (struct hypfs_entry_leaf *leaf, +XEN_GUEST_HANDLE_PARAM (const_void) uaddr, +unsigned int ulen) +{ +const struct hypfs_dyndir_id *data; +struct cpupool *cpupool; +enum sched_gran gran; +unsigned int sched_gran =0 ; +char name[SCHED_GRAN_NAME_LEN ]; +int ret =0 ; + +if ( ulen >SCHED_GRAN_NAME_LEN ) +return -ENOSPC ; + +if (copy_from_guest (name, uaddr, ulen) ) +return -EFAULT ; + +if (memchr (name,0 , ulen) == (name + ulen -1 ) ) + sched_gran =sched_gran_get (name, &gran) ? +0 :cpupool_check_granularity (gran); +if ( sched_gran ==0 ) +return -EINVAL ; + + data =hypfs_get_dyndata (); + cpupool = data->data; +ASSERT (cpupool); + +if ( !cpumask_empty (cpupool->cpu_valid) ) + ret = -EBUSY ; +else + { + cpupool->gran = gran;
Quoted 8 lines
Review static unsigned int hypfs_gran_getsize(const struct hypfs_entry *entry) · line 1172
Quoted 2 lines
(quoted diff) +2
-0+ cpupool->sched_gran = sched_gran; + }I think this could do with a comment clarifying what lock this is protected by, as the function itself has no sign of any locking, not even an assertion that a certain lock is being held. If you were to suggest some text, this as well as the minor issue above could likely be taken care of while committing.
cpupool_gran_[read|write]() are both guarded by the cpupool_lock taken via cpupool_dir_enter().
Juergen
Re: [PATCH v4 5/5] xen/cpupool: make per-cpupool sched-gran hypfs node writable
In reply to Juergen GrossQuoted 9 lines · Juergen Gross
Make /cpupool/<id>/sched-gran in hypfs writable. This will enable per cpupool selectable scheduling granularity.
Writing this node is allowed only with no cpu assigned to the cpupool.
Allowed are values "cpu", "core" and "socket".Signed-off-by Juergen Gross <[email protected]>
This holds with Jan's proposed adjustments.
Regards
Signature · 6 lines
Dario Faggioli, Ph.D http://about.me/dario.faggioli Virtualization Software Engineer SUSE Labs, SUSE https://www.suse.com/ ------------------------------------------------------------------- <<This happens because _I_ choose it to happen!>> (Raistlin Majere)