[PATCH v2 2/2] config_tools: add own_pcpu widget


Zhao, Yuanyuan
 

Add "exclusively owns physical CPUs" checkbox to pre-launched VMs
and post-launched VMs. RTVM will not display this checkbox.
If this checkbox is set, the VM will use all the pCPUs assigned to
it alone.

Signed-off-by: Yuanyuan Zhao <yuanyuan.zhao@...>
---
.../ConfigForm/CustomWidget/cpu_affinity.vue | 27 +++++++++++++++++++
.../schema/checks/cpu_assignment.xsd | 7 +++++
misc/config_tools/schema/config.xsd | 5 ++++
.../xforms/vm_configurations.c.xsl | 8 ++++++
4 files changed, 47 insertions(+)

diff --git a/misc/config_tools/configurator/packages/configurator/src/pages/Config/ConfigForm/CustomWidget/cpu_affinity.vue b/misc/config_tools/configurator/packages/configurator/src/pages/Config/ConfigForm/CustomWidget/cpu_affinity.vue
index 7c2fba2bc..58557fdb8 100644
--- a/misc/config_tools/configurator/packages/configurator/src/pages/Config/ConfigForm/CustomWidget/cpu_affinity.vue
+++ b/misc/config_tools/configurator/packages/configurator/src/pages/Config/ConfigForm/CustomWidget/cpu_affinity.vue
@@ -3,6 +3,26 @@
<b>{{ uiOptions.title }}</b>
<div class="p-4">
<div v-if="defaultVal.pcpu && defaultVal.pcpu.length>0">
+ <b-row v-if="!isRTVM">
+ <label>
+ <n-popover trigger="hover" placement="top-start" style="width: 500px">
+ <template #trigger>
+ <IconInfo/>
+ </template>
+ <span> Enable a VM exclusively owns the physical CPUs assigned to it. </span>
+ </n-popover>
+ Exclusively owns physical CPUs: </label>
+ <b-col>own_pcpu</b-col>
+ <b-col>
+ <b-form-checkbox v-model="pcpu_owned" :value="'y'" :uncheckedValue="'n'"
+ @click="click_own_pcpu"
+ >
+ </b-form-checkbox>
+ </b-col>
+ <b-col></b-col>
+ <b-col></b-col>
+ <b-col></b-col>
+ </b-row>
<b-row>
<b-col></b-col>
<b-col></b-col>
@@ -119,6 +139,9 @@ export default {
pcpuid_enum() {
return window.getCurrentFormSchemaData().BasicConfigType.definitions.CPUAffinityConfiguration.properties.pcpu_id.enum
},
+ pcpu_owned() {
+ return vueUtils.getPathVal(this.rootFormData, 'own_pcpu')
+ },
uiOptions() {
return formUtils.getUiOptions({
schema: this.schema,
@@ -148,6 +171,10 @@ export default {
addPCPU(index) {
this.defaultVal.pcpu.splice(index + 1, 0, {pcpu_id: null, real_time_vcpu: "n"})
},
+ click_own_pcpu() {
+ let newValue = this.pcpu_owned === 'y' ? 'n' : 'y';
+ vueUtils.setPathVal(this.rootFormData, 'own_pcpu', newValue)
+ },
removePCPU(index) {
if (this.defaultVal.pcpu.length === 1) {
// prevent delete for the last one
diff --git a/misc/config_tools/schema/checks/cpu_assignment.xsd b/misc/config_tools/schema/checks/cpu_assignment.xsd
index f989f7035..9919a6a54 100644
--- a/misc/config_tools/schema/checks/cpu_assignment.xsd
+++ b/misc/config_tools/schema/checks/cpu_assignment.xsd
@@ -25,6 +25,13 @@
</xs:annotation>
</xs:assert>

+ <xs:assert test="every $pcpu in /acrn-config/vm[own_pcpu = 'y']//cpu_affinity//pcpu_id satisfies
+ count(/acrn-config/vm[@id != $pcpu/ancestor::vm//companion_vmid ]//cpu_affinity[.//pcpu_id = $pcpu]) &lt;= 1">
+ <xs:annotation acrn:severity="error" acrn:report-on="//vm//cpu_affinity[.//pcpu_id = $pcpu]">
+ <xs:documentation>Physical CPU {$pcpu} is assigned to a VM "[{$pcpu/ancestor::vm/name}]" exclusively owns the physical CPUs assigned to it. Look for, and probably remove, any affinity assignments to CPU {$pcpu} in this VM {//vm[cpu_affinity//pcpu_id = $pcpu]/name} settings.</xs:documentation>
+ </xs:annotation>
+ </xs:assert>
+
<xs:assert test="every $vm in /acrn-config/vm[load_order != 'SERVICE_VM'] satisfies
count($vm/cpu_affinity/pcpu[pcpu_id != '']) > 0">
<xs:annotation acrn:severity="error" acrn:report-on="$vm/cpu_affinity">
diff --git a/misc/config_tools/schema/config.xsd b/misc/config_tools/schema/config.xsd
index 3b9fbd186..2c56e451b 100644
--- a/misc/config_tools/schema/config.xsd
+++ b/misc/config_tools/schema/config.xsd
@@ -345,6 +345,11 @@ Refer to :ref:`vuart_config` for detailed vUART settings.</xs:documentation>
<xs:annotation acrn:title="" acrn:views="basic, advanced" acrn:applicable-vms="pre-launched, post-launched">
</xs:annotation>
</xs:element>
+ <xs:element name="own_pcpu" type="Boolean" default="n">
+ <xs:annotation acrn:title="Exclusively owns physical CPUs" acrn:views="">
+ <xs:documentation>Enable a VM exclusively owns the physical CPUs assigned to it.</xs:documentation>
+ </xs:annotation>
+ </xs:element>
<xs:element name="cpu_affinity" type="CPUAffinityConfigurations" minOccurs="0">
<xs:annotation acrn:title="Physical CPU affinity" acrn:views="basic" acrn:applicable-vms="pre-launched, post-launched">
<xs:documentation>Select a subset of physical CPUs that this VM can use. More than one can be selected.</xs:documentation>
diff --git a/misc/config_tools/xforms/vm_configurations.c.xsl b/misc/config_tools/xforms/vm_configurations.c.xsl
index bb2c3e29d..b849d27ab 100644
--- a/misc/config_tools/xforms/vm_configurations.c.xsl
+++ b/misc/config_tools/xforms/vm_configurations.c.xsl
@@ -103,6 +103,14 @@
</xsl:if>
<xsl:value-of select="acrn:initializer('vm_prio', priority)" />
<xsl:value-of select="acrn:initializer('companion_vm_id', concat(companion_vmid, 'U'))" />
+ <xsl:choose>
+ <xsl:when test="(vm_type = 'RTVM') or (own_pcpu = 'y')">
+ <xsl:value-of select="acrn:initializer('own_pcpu', 'true')" />
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:value-of select="acrn:initializer('own_pcpu', 'false')" />
+ </xsl:otherwise>
+ </xsl:choose>
<xsl:call-template name="guest_flags" />

<xsl:if test="acrn:is-rdt-enabled()">
--
2.25.1


Junjie Mao
 

Yuanyuan Zhao <yuanyuan.zhao@...> writes:

Add "exclusively owns physical CPUs" checkbox to pre-launched VMs
and post-launched VMs. RTVM will not display this checkbox.
If this checkbox is set, the VM will use all the pCPUs assigned to
it alone.

Signed-off-by: Yuanyuan Zhao <yuanyuan.zhao@...>
---
.../ConfigForm/CustomWidget/cpu_affinity.vue | 27 +++++++++++++++++++
.../schema/checks/cpu_assignment.xsd | 7 +++++
misc/config_tools/schema/config.xsd | 5 ++++
.../xforms/vm_configurations.c.xsl | 8 ++++++
4 files changed, 47 insertions(+)

diff --git a/misc/config_tools/configurator/packages/configurator/src/pages/Config/ConfigForm/CustomWidget/cpu_affinity.vue b/misc/config_tools/configurator/packages/configurator/src/pages/Config/ConfigForm/CustomWidget/cpu_affinity.vue
index 7c2fba2bc..58557fdb8 100644
--- a/misc/config_tools/configurator/packages/configurator/src/pages/Config/ConfigForm/CustomWidget/cpu_affinity.vue
+++ b/misc/config_tools/configurator/packages/configurator/src/pages/Config/ConfigForm/CustomWidget/cpu_affinity.vue
@@ -3,6 +3,26 @@
<b>{{ uiOptions.title }}</b>
<div class="p-4">
<div v-if="defaultVal.pcpu && defaultVal.pcpu.length>0">
+ <b-row v-if="!isRTVM">
+ <label>
+ <n-popover trigger="hover" placement="top-start" style="width: 500px">
+ <template #trigger>
+ <IconInfo/>
+ </template>
+ <span> Enable a VM exclusively owns the physical CPUs assigned to it. </span>
+ </n-popover>
+ Exclusively owns physical CPUs: </label>
+ <b-col>own_pcpu</b-col>
+ <b-col>
+ <b-form-checkbox v-model="pcpu_owned" :value="'y'" :uncheckedValue="'n'"
+ @click="click_own_pcpu"
+ >
+ </b-form-checkbox>
+ </b-col>
+ <b-col></b-col>
+ <b-col></b-col>
+ <b-col></b-col>
+ </b-row>
<b-row>
<b-col></b-col>
<b-col></b-col>
@@ -119,6 +139,9 @@ export default {
pcpuid_enum() {
return window.getCurrentFormSchemaData().BasicConfigType.definitions.CPUAffinityConfiguration.properties.pcpu_id.enum
},
+ pcpu_owned() {
+ return vueUtils.getPathVal(this.rootFormData, 'own_pcpu')
+ },
uiOptions() {
return formUtils.getUiOptions({
schema: this.schema,
@@ -148,6 +171,10 @@ export default {
addPCPU(index) {
this.defaultVal.pcpu.splice(index + 1, 0, {pcpu_id: null, real_time_vcpu: "n"})
},
+ click_own_pcpu() {
+ let newValue = this.pcpu_owned === 'y' ? 'n' : 'y';
+ vueUtils.setPathVal(this.rootFormData, 'own_pcpu', newValue)
+ },
removePCPU(index) {
if (this.defaultVal.pcpu.length === 1) {
// prevent delete for the last one
diff --git a/misc/config_tools/schema/checks/cpu_assignment.xsd b/misc/config_tools/schema/checks/cpu_assignment.xsd
index f989f7035..9919a6a54 100644
--- a/misc/config_tools/schema/checks/cpu_assignment.xsd
+++ b/misc/config_tools/schema/checks/cpu_assignment.xsd
@@ -25,6 +25,13 @@
</xs:annotation>
</xs:assert>

+ <xs:assert test="every $pcpu in /acrn-config/vm[own_pcpu = 'y']//cpu_affinity//pcpu_id satisfies
+ count(/acrn-config/vm[@id != $pcpu/ancestor::vm//companion_vmid ]//cpu_affinity[.//pcpu_id = $pcpu]) &lt;= 1">
+ <xs:annotation acrn:severity="error" acrn:report-on="//vm//cpu_affinity[.//pcpu_id = $pcpu]">
+ <xs:documentation>Physical CPU {$pcpu} is assigned to a VM "[{$pcpu/ancestor::vm/name}]" exclusively owns the physical CPUs assigned to it. Look for, and probably remove, any affinity assignments to CPU {$pcpu} in this VM {//vm[cpu_affinity//pcpu_id = $pcpu]/name} settings.</xs:documentation>
Since companion VMs are excluded from the `own_pcpu` test, the error
message should also not mention any of them.

And in this case an error always involves multiple VMs. You may want to
say "in these VMs" rather than "in this VM".

Talking about companion VMs, shall we explicitly restrict TEEs from
owning pCPUs?

BTW, we don't add any whitespace at the end of a condition in
XPATH. Please remove the whitespace between `companion_vmid` and `]`

--
Best Regards
Junjie Mao

+ </xs:annotation>
+ </xs:assert>
+
<xs:assert test="every $vm in /acrn-config/vm[load_order != 'SERVICE_VM'] satisfies
count($vm/cpu_affinity/pcpu[pcpu_id != '']) > 0">
<xs:annotation acrn:severity="error" acrn:report-on="$vm/cpu_affinity">
diff --git a/misc/config_tools/schema/config.xsd b/misc/config_tools/schema/config.xsd
index 3b9fbd186..2c56e451b 100644
--- a/misc/config_tools/schema/config.xsd
+++ b/misc/config_tools/schema/config.xsd
@@ -345,6 +345,11 @@ Refer to :ref:`vuart_config` for detailed vUART settings.</xs:documentation>
<xs:annotation acrn:title="" acrn:views="basic, advanced" acrn:applicable-vms="pre-launched, post-launched">
</xs:annotation>
</xs:element>
+ <xs:element name="own_pcpu" type="Boolean" default="n">
+ <xs:annotation acrn:title="Exclusively owns physical CPUs" acrn:views="">
+ <xs:documentation>Enable a VM exclusively owns the physical CPUs assigned to it.</xs:documentation>
+ </xs:annotation>
+ </xs:element>
<xs:element name="cpu_affinity" type="CPUAffinityConfigurations" minOccurs="0">
<xs:annotation acrn:title="Physical CPU affinity" acrn:views="basic" acrn:applicable-vms="pre-launched, post-launched">
<xs:documentation>Select a subset of physical CPUs that this VM can use. More than one can be selected.</xs:documentation>
diff --git a/misc/config_tools/xforms/vm_configurations.c.xsl b/misc/config_tools/xforms/vm_configurations.c.xsl
index bb2c3e29d..b849d27ab 100644
--- a/misc/config_tools/xforms/vm_configurations.c.xsl
+++ b/misc/config_tools/xforms/vm_configurations.c.xsl
@@ -103,6 +103,14 @@
</xsl:if>
<xsl:value-of select="acrn:initializer('vm_prio', priority)" />
<xsl:value-of select="acrn:initializer('companion_vm_id', concat(companion_vmid, 'U'))" />
+ <xsl:choose>
+ <xsl:when test="(vm_type = 'RTVM') or (own_pcpu = 'y')">
+ <xsl:value-of select="acrn:initializer('own_pcpu', 'true')" />
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:value-of select="acrn:initializer('own_pcpu', 'false')" />
+ </xsl:otherwise>
+ </xsl:choose>
<xsl:call-template name="guest_flags" />

<xsl:if test="acrn:is-rdt-enabled()">


Zhao, Yuanyuan
 

On 2022/8/25 16:06, Junjie Mao wrote:
Yuanyuan Zhao <yuanyuan.zhao@...> writes:

Add "exclusively owns physical CPUs" checkbox to pre-launched VMs
and post-launched VMs. RTVM will not display this checkbox.
If this checkbox is set, the VM will use all the pCPUs assigned to
it alone.

Signed-off-by: Yuanyuan Zhao <yuanyuan.zhao@...>
---
.../ConfigForm/CustomWidget/cpu_affinity.vue | 27 +++++++++++++++++++
.../schema/checks/cpu_assignment.xsd | 7 +++++
misc/config_tools/schema/config.xsd | 5 ++++
.../xforms/vm_configurations.c.xsl | 8 ++++++
4 files changed, 47 insertions(+)

diff --git a/misc/config_tools/configurator/packages/configurator/src/pages/Config/ConfigForm/CustomWidget/cpu_affinity.vue b/misc/config_tools/configurator/packages/configurator/src/pages/Config/ConfigForm/CustomWidget/cpu_affinity.vue
index 7c2fba2bc..58557fdb8 100644
--- a/misc/config_tools/configurator/packages/configurator/src/pages/Config/ConfigForm/CustomWidget/cpu_affinity.vue
+++ b/misc/config_tools/configurator/packages/configurator/src/pages/Config/ConfigForm/CustomWidget/cpu_affinity.vue
@@ -3,6 +3,26 @@
<b>{{ uiOptions.title }}</b>
<div class="p-4">
<div v-if="defaultVal.pcpu && defaultVal.pcpu.length>0">
+ <b-row v-if="!isRTVM">
+ <label>
+ <n-popover trigger="hover" placement="top-start" style="width: 500px">
+ <template #trigger>
+ <IconInfo/>
+ </template>
+ <span> Enable a VM exclusively owns the physical CPUs assigned to it. </span>
+ </n-popover>
+ Exclusively owns physical CPUs: </label>
+ <b-col>own_pcpu</b-col>
+ <b-col>
+ <b-form-checkbox v-model="pcpu_owned" :value="'y'" :uncheckedValue="'n'"
+ @click="click_own_pcpu"
+ >
+ </b-form-checkbox>
+ </b-col>
+ <b-col></b-col>
+ <b-col></b-col>
+ <b-col></b-col>
+ </b-row>
<b-row>
<b-col></b-col>
<b-col></b-col>
@@ -119,6 +139,9 @@ export default {
pcpuid_enum() {
return window.getCurrentFormSchemaData().BasicConfigType.definitions.CPUAffinityConfiguration.properties.pcpu_id.enum
},
+ pcpu_owned() {
+ return vueUtils.getPathVal(this.rootFormData, 'own_pcpu')
+ },
uiOptions() {
return formUtils.getUiOptions({
schema: this.schema,
@@ -148,6 +171,10 @@ export default {
addPCPU(index) {
this.defaultVal.pcpu.splice(index + 1, 0, {pcpu_id: null, real_time_vcpu: "n"})
},
+ click_own_pcpu() {
+ let newValue = this.pcpu_owned === 'y' ? 'n' : 'y';
+ vueUtils.setPathVal(this.rootFormData, 'own_pcpu', newValue)
+ },
removePCPU(index) {
if (this.defaultVal.pcpu.length === 1) {
// prevent delete for the last one
diff --git a/misc/config_tools/schema/checks/cpu_assignment.xsd b/misc/config_tools/schema/checks/cpu_assignment.xsd
index f989f7035..9919a6a54 100644
--- a/misc/config_tools/schema/checks/cpu_assignment.xsd
+++ b/misc/config_tools/schema/checks/cpu_assignment.xsd
@@ -25,6 +25,13 @@
</xs:annotation>
</xs:assert>
+ <xs:assert test="every $pcpu in /acrn-config/vm[own_pcpu = 'y']//cpu_affinity//pcpu_id satisfies
+ count(/acrn-config/vm[@id != $pcpu/ancestor::vm//companion_vmid ]//cpu_affinity[.//pcpu_id = $pcpu]) &lt;= 1">
+ <xs:annotation acrn:severity="error" acrn:report-on="//vm//cpu_affinity[.//pcpu_id = $pcpu]">
+ <xs:documentation>Physical CPU {$pcpu} is assigned to a VM "[{$pcpu/ancestor::vm/name}]" exclusively owns the physical CPUs assigned to it. Look for, and probably remove, any affinity assignments to CPU {$pcpu} in this VM {//vm[cpu_affinity//pcpu_id = $pcpu]/name} settings.</xs:documentation>
Since companion VMs are excluded from the `own_pcpu` test, the error
message should also not mention any of them. >
And in this case an error always involves multiple VMs. You may want to
say "in these VMs" rather than "in this VM".
Update in next version.

Talking about companion VMs, shall we explicitly restrict TEEs from
owning pCPUs?
Add TEE_VM and REE_VM.

BTW, we don't add any whitespace at the end of a condition in
XPATH. Please remove the whitespace between `companion_vmid` and `]`
Removed.