|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [xen master] xen/cache-col: Fix initialisation of domain colouring information
commit ce45951cbe17dc01f9e6851e63b231b0acbe0de1
Author: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
AuthorDate: Thu Jul 24 12:05:40 2025 +0100
Commit: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
CommitDate: Tue Jul 29 17:25:54 2025 +0100
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>
Reviewed-by: Jan Beulich <jbeulich@xxxxxxxx>
---
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 9391f5ad7c..5241a1629e 100644
--- a/xen/common/domain.c
+++ b/xen/common/domain.c
@@ -886,6 +886,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 ea3e0ca070..77a54beed1 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 45f250f9f3..94dd22e949 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
--
generated by git-patchbot for /home/xen/git/xen.git#master
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |