|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] Re: [PATCH v3] xen/dom0less: support for vcpu affinity
On 2/18/25 9:29 PM, Stefano Stabellini
wrote:
I think we want this to add to CHANGELOG. Thanks. ~ Oleksii
Signed-off-by: Xenia Ragiadakou <xenia.ragiadakou@xxxxxxx> Signed-off-by: Stefano Stabellini <stefano.stabellini@xxxxxxx> --- Changes in v3: - improve commit message - improve binding doc - add panic on invalid pCPU - move parsing to a separate function diff --git a/docs/misc/arm/device-tree/booting.txt b/docs/misc/arm/device-tree/booting.txt index 9c881baccc..10e55c825c 100644 --- a/docs/misc/arm/device-tree/booting.txt +++ b/docs/misc/arm/device-tree/booting.txt @@ -324,6 +324,27 @@ The ramdisk sub-node has the following properties: property because it will be created by the UEFI stub on boot. This option is needed only when UEFI boot is used. +Under the "xen,domain" compatible node, it is possible optionally to add +one or more sub-nodes to configure vCPU affinity. The vCPU affinity +sub-node has the following properties: + +- compatible + + "xen,vcpu-affinity" + +- id + + A 32-bit integer that specifies the vCPU id. 0 is the first vCPU. + The last vCPU is cpus-1, where "cpus" is the number of vCPUs + specified with the "cpus" property under the "xen,domain" node. + +- hard-affinity + + Optional. A string specifying the hard affinity configuration for the + vCPU: a comma-separated list of pCPUs or ranges of pCPUs is used. + Ranges are hyphen-separated intervals (such as `0-4`) and are inclusive + on both sides. The numbers refer to pCPU ids. + Example ======= diff --git a/xen/arch/arm/dom0less-build.c b/xen/arch/arm/dom0less-build.c index 49d1f14d65..e364820189 100644 --- a/xen/arch/arm/dom0less-build.c +++ b/xen/arch/arm/dom0less-build.c @@ -810,6 +810,68 @@ static int __init construct_domU(struct domain *d, return rc; } +static void __init domain_vcpu_affinity(struct domain *d, + const struct dt_device_node *node) +{ + const char *hard_affinity_str = NULL; + struct dt_device_node *np; + uint32_t val; + int rc; + + dt_for_each_child_node(node, np) + { + const char *s; + struct vcpu *v; + cpumask_t affinity; + + if ( !dt_device_is_compatible(np, "xen,vcpu-affinity") ) + continue; + + if ( !dt_property_read_u32(np, "id", &val) ) + continue; + + if ( val >= d->max_vcpus ) + panic("Invalid vcpu_id %u for domain %s\n", val, dt_node_name(node)); + + v = d->vcpu[val]; + rc = dt_property_read_string(np, "hard-affinity", &hard_affinity_str); + if ( rc < 0 ) + continue; + + s = hard_affinity_str; + cpumask_clear(&affinity); + while ( *s != '\0' ) + { + unsigned int start, end; + + start = simple_strtoul(s, &s, 0); + + if ( *s == '-' ) /* Range */ + { + s++; + end = simple_strtoul(s, &s, 0); + } + else /* Single value */ + end = start; + + if ( end >= nr_cpu_ids ) + panic("Invalid pCPU %u for domain %s\n", end, dt_node_name(node)); + + for ( ; start <= end; start++ ) + cpumask_set_cpu(start, &affinity); + + if ( *s == ',' ) + s++; + else if ( *s != '\0' ) + break; + } + + rc = vcpu_set_hard_affinity(v, &affinity); + if ( rc ) + panic("vcpu%d: failed to set hard affinity\n", v->vcpu_id); + } +} + void __init create_domUs(void) { struct dt_device_node *node; @@ -992,6 +1054,8 @@ void __init create_domUs(void) if ( rc ) panic("Could not set up domain %s (rc = %d)\n", dt_node_name(node), rc); + + domain_vcpu_affinity(d, node); } }
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |