[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [PATCH 3/4] xen/cache-col: Fix initialisation of domain colouring information
Right now, domains start with no colouring information and depend on a XEN_DOMCTL_set_llc_colors(nr=0) hypercall in order to get default colours. This in turn forces the toolstack to make a hypercall for all VMs even those without colouring configured, and to ignore errors if Xen doesn't have colouring active. Introduce domain_llc_coloring_init(), replacing domain_set_default_colors(), and call it during the trivial initialisation in domain_create(). Leave two comments explaining the positioning. The -EEXISTs condition in domain_set_llc_colors() needs adjusting as a consequence, but that's easy enough to keep working as before. Fixes: 6cdea3444eaf ("xen/arm: add Dom0 cache coloring support") Signed-off-by: Andrew Cooper <andrew.cooper3@xxxxxxxxxx> --- CC: Anthony PERARD <anthony.perard@xxxxxxxxxx> CC: Michal Orzel <michal.orzel@xxxxxxx> CC: Jan Beulich <jbeulich@xxxxxxxx> CC: Julien Grall <julien@xxxxxxx> CC: Roger Pau Monné <roger.pau@xxxxxxxxxx> CC: Stefano Stabellini <sstabellini@xxxxxxxxxx> CC: Carlo Nonato <carlo.nonato@xxxxxxxxxxxxxxx> CC: Marco Solieri <marco.solieri@xxxxxxxxxxxxxxx> --- xen/common/domain.c | 6 ++++++ xen/common/llc-coloring.c | 33 ++++++++++++++------------------- xen/include/xen/llc-coloring.h | 2 ++ 3 files changed, 22 insertions(+), 19 deletions(-) diff --git a/xen/common/domain.c b/xen/common/domain.c index 4f79ba39878c..28c2cc78cd88 100644 --- a/xen/common/domain.c +++ b/xen/common/domain.c @@ -878,6 +878,12 @@ struct domain *domain_create(domid_t domid, rwlock_init(&d->pci_lock); #endif + /* + * Doesn't allocate memory itself, but does set up data relevant for + * memory allocations. + */ + domain_llc_coloring_init(d); + /* All error paths can depend on the above setup. */ /* diff --git a/xen/common/llc-coloring.c b/xen/common/llc-coloring.c index ea3e0ca07017..77a54beed1bf 100644 --- a/xen/common/llc-coloring.c +++ b/xen/common/llc-coloring.c @@ -230,24 +230,12 @@ void domain_dump_llc_colors(const struct domain *d) print_colors(d->llc_colors, d->num_llc_colors); } -static void domain_set_default_colors(struct domain *d) -{ - printk(XENLOG_WARNING - "LLC color config not found for %pd, using all colors\n", d); - - d->llc_colors = default_colors; - d->num_llc_colors = max_nr_colors; -} - int __init dom0_set_llc_colors(struct domain *d) { typeof(*dom0_colors) *colors; if ( !dom0_num_colors ) - { - domain_set_default_colors(d); return 0; - } if ( (dom0_num_colors > max_nr_colors) || !check_colors(dom0_colors, dom0_num_colors) ) @@ -272,14 +260,11 @@ int domain_set_llc_colors(struct domain *d, { unsigned int *colors; - if ( d->num_llc_colors ) + if ( d->llc_colors != default_colors ) return -EEXIST; if ( !config->num_llc_colors ) - { - domain_set_default_colors(d); return 0; - } if ( config->num_llc_colors > max_nr_colors ) return -EINVAL; @@ -307,6 +292,19 @@ int domain_set_llc_colors(struct domain *d, return 0; } +void domain_llc_coloring_init(struct domain *d) +{ + if ( !llc_coloring_enabled ) + return; + + /* + * Any change to this logic needs to consider the position of our call in + * domain_create(). + */ + d->llc_colors = default_colors; + d->num_llc_colors = max_nr_colors; +} + void domain_llc_coloring_free(struct domain *d) { d->num_llc_colors = 0; @@ -321,10 +319,7 @@ int __init domain_set_llc_colors_from_str(struct domain *d, const char *str) unsigned int *colors, num_colors; if ( !str ) - { - domain_set_default_colors(d); return 0; - } colors = xmalloc_array(unsigned int, max_nr_colors); if ( !colors ) diff --git a/xen/include/xen/llc-coloring.h b/xen/include/xen/llc-coloring.h index 45f250f9f39d..94dd22e949e7 100644 --- a/xen/include/xen/llc-coloring.h +++ b/xen/include/xen/llc-coloring.h @@ -21,6 +21,7 @@ extern bool llc_coloring_enabled; void llc_coloring_init(void); void dump_llc_coloring_info(void); void domain_dump_llc_colors(const struct domain *d); +void domain_llc_coloring_init(struct domain *d); void domain_llc_coloring_free(struct domain *d); #else #define llc_coloring_enabled false @@ -28,6 +29,7 @@ void domain_llc_coloring_free(struct domain *d); static inline void llc_coloring_init(void) {} static inline void dump_llc_coloring_info(void) {} static inline void domain_dump_llc_colors(const struct domain *d) {} +static inline void domain_llc_coloring_init(struct domain *d) {} static inline void domain_llc_coloring_free(struct domain *d) {} #endif -- 2.39.5
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |