[PATCH v2] config_tools: Add core type infomation to pCPU


Zhao, Yuanyuan
 

If a platform has both P-core and E-core,
prompt user if this pCPU is E-core when set the CPU affinity for VMs.

v1->v2
1. Only add hint for E-core.
2. Change the hint style.

Signed-off-by: Yuanyuan Zhao <yuanyuan.zhao@...>
---
.../ConfigForm/CustomWidget/cpu_affinity.vue | 14 ++++++++++----
.../config_tools/configurator/pyodide/loadBoard.py | 12 ++++++++++++
2 files changed, 22 insertions(+), 4 deletions(-)

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 42739290a..91d2355b9 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
@@ -24,8 +24,11 @@
</label>
</b-col>
<b-col>
- <b-form-select :state="validateCPUAffinity(cpu.pcpu_id)" v-model="cpu.pcpu_id"
- :options="pcpuid_enum"></b-form-select>
+ <b-form-select :state="validateCPUAffinity(cpu.pcpu_id)" v-model="cpu.pcpu_id">
+ <option v-for="pcpu in pcpuid_enum.enum" :value="pcpu">
+ {{pcpuid_enum.enumNames[pcpuid_enum.enum.indexOf(pcpu)]}}
+ </option>
+ </b-form-select>
<b-form-invalid-feedback>
pCPU ID is required!
</b-form-invalid-feedback>
@@ -107,7 +110,10 @@ export default {
return vueUtils.getPathVal(this.rootFormData, 'vm_type') === 'RTVM'
},
pcpuid_enum() {
- return window.getCurrentFormSchemaData().BasicConfigType.definitions.CPUAffinityConfiguration.properties.pcpu_id.enum
+ return window.getCurrentFormSchemaData().BasicConfigType.definitions.CPUAffinityConfiguration.properties.pcpu_id
+ },
+ pcpuid_enumNames() {
+ return window.getCurrentFormSchemaData().BasicConfigType.definitions.CPUAffinityConfiguration.properties.pcpu_id.enumNames
},
uiOptions() {
return formUtils.getUiOptions({
@@ -130,7 +136,7 @@ export default {
},
methods: {
validateCPUAffinity(pcpu_id) {
- return _.isNumber(pcpu_id) && this.pcpuid_enum.indexOf(pcpu_id) >= 0
+ return _.isNumber(pcpu_id) && this.pcpuid_enum.enum.indexOf(pcpu_id) >= 0
},
vCPUName(index) {
return `${this.rootFormData.name} vCPU ${index}`
diff --git a/misc/config_tools/configurator/pyodide/loadBoard.py b/misc/config_tools/configurator/pyodide/loadBoard.py
index 9f925915a..4a03e0d56 100644
--- a/misc/config_tools/configurator/pyodide/loadBoard.py
+++ b/misc/config_tools/configurator/pyodide/loadBoard.py
@@ -21,6 +21,7 @@ def get_dynamic_scenario(board):
:param board: board xml text
"""
board_xml = etree.fromstring(board)
+ soup = BeautifulSoup(board, 'xml')

def get_enum(source, options, obj_type):
elements = [str(x) for x in elementpath.select(source, options) if x]
@@ -33,6 +34,15 @@ def get_dynamic_scenario(board):
elements = [enum_type_convert[obj_type](x) for x in elements]
return elements

+ def pcpu_core_type(cores):
+ threads = threads = soup.select('core thread')
+ core = {thread.select_one('cpu_id').text: thread.core_type.string for thread in threads}
+ core_type = [str(core_id) for core_id in cores]
+ for type in core_type:
+ if core[type] == 'Atom':
+ core_type[int(type)] = type + ' (E-core)'
+ return core_type
+
def dynamic_enum(**enum_setting):
# value from env
function, source = [
@@ -57,6 +67,8 @@ def get_dynamic_scenario(board):
enum_setting['type'] = obj.get('type', '')
# replace json schema obj enum field data
obj['enum'] = dynamic_enum(**enum_setting)
+ if 'cpu_id' in enum_setting['selector']:
+ obj['enumNames'] = pcpu_core_type(obj['enum'])
return obj

data = json.loads(scenario_json_schema, object_hook=dynamic_enum_apply)
--
2.25.1


Junjie Mao
 

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

If a platform has both P-core and E-core,
prompt user if this pCPU is E-core when set the CPU affinity for VMs.

v1->v2
1. Only add hint for E-core.
Only adding hints to E-cores can still make the drop-down list looks
strange, as some of the cores are marked as E-cores while the others are
unannotated.

Here's my suggestion:

1. If there are more than one core_type in the board XML (you can
search for the list of distinct core_type using XPATH and count
its length), add hints to both P-cores and E-cores.

2. If there are only one core_type occurred in the board XML, do not
add any hint.

--
Best Regards
Junjie Mao

2. Change the hint style.

Signed-off-by: Yuanyuan Zhao <yuanyuan.zhao@...>
---
.../ConfigForm/CustomWidget/cpu_affinity.vue | 14 ++++++++++----
.../config_tools/configurator/pyodide/loadBoard.py | 12 ++++++++++++
2 files changed, 22 insertions(+), 4 deletions(-)

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 42739290a..91d2355b9 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
@@ -24,8 +24,11 @@
</label>
</b-col>
<b-col>
- <b-form-select :state="validateCPUAffinity(cpu.pcpu_id)" v-model="cpu.pcpu_id"
- :options="pcpuid_enum"></b-form-select>
+ <b-form-select :state="validateCPUAffinity(cpu.pcpu_id)" v-model="cpu.pcpu_id">
+ <option v-for="pcpu in pcpuid_enum.enum" :value="pcpu">
+ {{pcpuid_enum.enumNames[pcpuid_enum.enum.indexOf(pcpu)]}}
+ </option>
+ </b-form-select>
<b-form-invalid-feedback>
pCPU ID is required!
</b-form-invalid-feedback>
@@ -107,7 +110,10 @@ export default {
return vueUtils.getPathVal(this.rootFormData, 'vm_type') === 'RTVM'
},
pcpuid_enum() {
- return window.getCurrentFormSchemaData().BasicConfigType.definitions.CPUAffinityConfiguration.properties.pcpu_id.enum
+ return window.getCurrentFormSchemaData().BasicConfigType.definitions.CPUAffinityConfiguration.properties.pcpu_id
+ },
+ pcpuid_enumNames() {
+ return window.getCurrentFormSchemaData().BasicConfigType.definitions.CPUAffinityConfiguration.properties.pcpu_id.enumNames
},
uiOptions() {
return formUtils.getUiOptions({
@@ -130,7 +136,7 @@ export default {
},
methods: {
validateCPUAffinity(pcpu_id) {
- return _.isNumber(pcpu_id) && this.pcpuid_enum.indexOf(pcpu_id) >= 0
+ return _.isNumber(pcpu_id) && this.pcpuid_enum.enum.indexOf(pcpu_id) >= 0
},
vCPUName(index) {
return `${this.rootFormData.name} vCPU ${index}`
diff --git a/misc/config_tools/configurator/pyodide/loadBoard.py b/misc/config_tools/configurator/pyodide/loadBoard.py
index 9f925915a..4a03e0d56 100644
--- a/misc/config_tools/configurator/pyodide/loadBoard.py
+++ b/misc/config_tools/configurator/pyodide/loadBoard.py
@@ -21,6 +21,7 @@ def get_dynamic_scenario(board):
:param board: board xml text
"""
board_xml = etree.fromstring(board)
+ soup = BeautifulSoup(board, 'xml')

def get_enum(source, options, obj_type):
elements = [str(x) for x in elementpath.select(source, options) if x]
@@ -33,6 +34,15 @@ def get_dynamic_scenario(board):
elements = [enum_type_convert[obj_type](x) for x in elements]
return elements

+ def pcpu_core_type(cores):
+ threads = threads = soup.select('core thread')
+ core = {thread.select_one('cpu_id').text: thread.core_type.string for thread in threads}
+ core_type = [str(core_id) for core_id in cores]
+ for type in core_type:
+ if core[type] == 'Atom':
+ core_type[int(type)] = type + ' (E-core)'
+ return core_type
+
def dynamic_enum(**enum_setting):
# value from env
function, source = [
@@ -57,6 +67,8 @@ def get_dynamic_scenario(board):
enum_setting['type'] = obj.get('type', '')
# replace json schema obj enum field data
obj['enum'] = dynamic_enum(**enum_setting)
+ if 'cpu_id' in enum_setting['selector']:
+ obj['enumNames'] = pcpu_core_type(obj['enum'])
return obj

data = json.loads(scenario_json_schema, object_hook=dynamic_enum_apply)


Zhao, Yuanyuan
 

On 2022/8/12 20:01, Junjie Mao wrote:
Yuanyuan Zhao <yuanyuan.zhao@...> writes:

If a platform has both P-core and E-core,
prompt user if this pCPU is E-core when set the CPU affinity for VMs.

v1->v2
1. Only add hint for E-core.
Only adding hints to E-cores can still make the drop-down list looks
strange, as some of the cores are marked as E-cores while the others are
unannotated.
Here's my suggestion:
1. If there are more than one core_type in the board XML (you can
search for the list of distinct core_type using XPATH and count
its length), add hints to both P-cores and E-cores.
2. If there are only one core_type occurred in the board XML, do not
add any hint.
OK. Update in v3.