Skip to contentSkip to conversation

examples/power: fix wrong core_id with JSON cmds

PATCH Applied David Hunt 3 participants 5 messages Jan 7, 2019 – Jan 14, 2019

lore
Share & tools
lore

David Hunt

author
#0 lore raw

PATCH 1/1 examples/power: fix wrong core_id with JSON cmds

This patch fixes a bug introduced in the 64-core limtation enhancement where the core_id is inadvertently converted from virtual to physical even though it may already be a physical core_id.

We should be using the core_type field, and only converting via hypervisor when core_type is set to CORE_TYPE_VIRTUAL

Fixes 5776b7a371d1 ("examples/power: allow VM to use lcores over 63")
---
 examples/vm_power_manager/channel_monitor.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
examples/vm_power_manager/channel_monitor.c +4 -1
index 85622e7cb..1a3a0fa76 100644
@@ -640,7 +640,10 @@ process_request(struct channel_packet *pkt, struct channel_info *chan_info)
 	if (pkt->command == CPU_POWER) {
 		unsigned int core_num;
 
-		core_num = get_pcpu(chan_info, pkt->resource_id);
+		if (pkt->core_type == CORE_TYPE_VIRTUAL)
+			core_num = get_pcpu(chan_info, pkt->resource_id);
+		else
+			core_num = pkt->resource_id;
 
 		switch (pkt->unit) {
 		case(CPU_POWER_SCALE_MIN):
Signature · 1 line
2.17.1
#1 lore raw
Quoted 30 lines

-----Original Message-----
From: Hunt, David
Sent: Monday, January 7, 2019 7:39 PM
To: [email protected]
Cc: Hunt, David <[email protected]>; Yao, Lei A <[email protected]>
Subject: [PATCH] examples/power: fix wrong core_id with JSON cmds

This patch fixes a bug introduced in the 64-core limtation enhancement where the core_id is inadvertently converted from virtual to physical even though it may already be a physical core_id.

We should be using the core_type field, and only converting via hypervisor when core_type is set to CORE_TYPE_VIRTUAL

Fixes 5776b7a371d1 ("examples/power: allow VM to use lcores over 63")
---
 examples/vm_power_manager/channel_monitor.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
examples/vm_power_manager/channel_monitor.c +0 -0
index 85622e7cb..1a3a0fa76 100644

examples/vm_power_manager/channel_monitor.c process_request(struct channel_packet *pkt, struct · line 645

Quoted 7 lines
examples/vm_power_manager/channel_monitor.c +2 -1
@@ -640,7 +640,10 @@ process_request(struct channel_packet *pkt, struct
 channel_info *chan_info)
 	if (pkt->command == CPU_POWER) {
 		unsigned int core_num;
 
-		core_num = get_pcpu(chan_info, pkt->resource_id);
+		if (pkt->core_type == CORE_TYPE_VIRTUAL)
+			core_num = get_pcpu(chan_info, pkt->resource_id);

Hi, Dave

Now in DPDK code, only command send from VM(guest_cli sample) will set the pkt-<core_type to VIRTUAL, if we send JSON command with resource_id, seems we always won't hit this branch. Because parse_json_to_pkt() will always set the core_type to CORE_TYPE_PHYSICAL.
If resource_id in instruction format JSON file will always be treated as Pcpu, it's the same as core_list behavior.

Quoted 7 lines
examples/vm_power_manager/channel_monitor.c +2 -0
+		else
+			core_num = pkt->resource_id;
 
 		switch (pkt->unit) {

case(CPU_POWER_SCALE_MIN):
--
2.17.1

#2 lore raw

Hi Lei,

Quoted 38 lines · Lei A
Quoted 29 lines

-----Original Message-----
From: Hunt, David
Sent: Monday, January 7, 2019 7:39 PM
To: [email protected]
Cc: Hunt, David <[email protected]>; Yao, Lei A <[email protected]>
Subject: [PATCH] examples/power: fix wrong core_id with JSON cmds

This patch fixes a bug introduced in the 64-core limtation enhancement where the core_id is inadvertently converted from virtual to physical even though it may already be a physical core_id.

We should be using the core_type field, and only converting via hypervisor when core_type is set to CORE_TYPE_VIRTUAL

Fixes 5776b7a371d1 ("examples/power: allow VM to use lcores over 63")
---
  examples/vm_power_manager/channel_monitor.c | 5 ++++-
  1 file changed, 4 insertions(+), 1 deletion(-)
examples/vm_power_manager/channel_monitor.c +0 -0
index 85622e7cb..1a3a0fa76 100644

examples/vm_power_manager/channel_monitor.c process_request(struct channel_packet *pkt, struct · line 645

Quoted 7 lines
examples/vm_power_manager/channel_monitor.c +2 -1
@@ -640,7 +640,10 @@ process_request(struct channel_packet *pkt, struct
 channel_info *chan_info)
  	if (pkt->command == CPU_POWER) {
  		unsigned int core_num;
 
-		core_num = get_pcpu(chan_info, pkt->resource_id);
+		if (pkt->core_type == CORE_TYPE_VIRTUAL)
+			core_num = get_pcpu(chan_info, pkt->resource_id);

Hi, Dave

Quoted 6 lines

Now in DPDK code, only command send from VM(guest_cli sample) will set the pkt-<core_type to VIRTUAL, if we send JSON command with resource_id, seems we always won't hit this branch. Because parse_json_to_pkt() will always set the core_type to CORE_TYPE_PHYSICAL.
If resource_id in instruction format JSON file will always be treated as Pcpu, it's the same as core_list behavior.

Yes, that's correct.  But I believe it's OK for the moment.

Currently the only way for the guest app to send commands and policies
to the host is via the virtio-serial interface, which takes a different code path. There is no way currently for the guest app to send a JSON string to the host, so that code path will never be hit. However, now that the JSON functionality is in the host, we plan to add that same functionality to the guest, and when we do that we will ensure that core_type is handled appropriately.

Regards,
Dave.

Quoted 9 lines
Quoted 7 lines
examples/vm_power_manager/channel_monitor.c +2 -0
+		else
+			core_num = pkt->resource_id;
 
  		switch (pkt->unit) {

case(CPU_POWER_SCALE_MIN):
--
2.17.1

Reviewed-by Tested-by
#3 lore raw
Quoted 8 lines

-----Original Message-----
From: Hunt, David
Sent: Tuesday, January 8, 2019 5:20 PM
To: Yao, Lei A <[email protected]>; [email protected]
Subject: Re: [PATCH] examples/power: fix wrong core_id with JSON cmds

Quoted 22 lines

Hi Lei,

Quoted 19 lines · Lei A
Quoted 19 lines

-----Original Message-----
From: Hunt, David
Sent: Monday, January 7, 2019 7:39 PM
To: [email protected]
Cc: Hunt, David <[email protected]>; Yao, Lei A <[email protected]>
Subject: [PATCH] examples/power: fix wrong core_id with JSON cmds

This patch fixes a bug introduced in the 64-core limtation enhancement where the core_id is inadvertently converted from virtual to physical even though it may already be a physical core_id.

We should be using the core_type field, and only converting via hypervisor when core_type is set to CORE_TYPE_VIRTUAL

Fixes 5776b7a371d1 ("examples/power: allow VM to use lcores over 63")
Quoted 57 lines
Quoted 10 lines

examples/vm_power_manager/channel_monitor.c process_request(struct channel_packet *pkt,

Quoted 10 lines
---
  examples/vm_power_manager/channel_monitor.c | 5 ++++-
  1 file changed, 4 insertions(+), 1 deletion(-)
examples/vm_power_manager/channel_monitor.c +0 -0
index 85622e7cb..1a3a0fa76 100644
@@ -640,7 +640,10 @@ process_request(struct channel_packet *pkt,

struct

Quoted 10 lines

examples/vm_power_manager/channel_monitor.c process_request(struct channel_packet *pkt, struct channel_info *chan_info) · line 644

Quoted 7 lines
examples/vm_power_manager/channel_monitor.c +2 -1
 channel_info *chan_info)
  	if (pkt->command == CPU_POWER) {
  		unsigned int core_num;
 
-		core_num = get_pcpu(chan_info, pkt->resource_id);
+		if (pkt->core_type == CORE_TYPE_VIRTUAL)
+			core_num = get_pcpu(chan_info, pkt->resource_id);

Hi, Dave

Now in DPDK code, only command send from VM(guest_cli sample) will set

the

Quoted 1 line

pkt-<core_type to VIRTUAL, if we send JSON command with resource_id,

seems

Quoted 1 line

we always won't hit this branch. Because parse_json_to_pkt() will always

set the

Quoted 2 lines

core_type to CORE_TYPE_PHYSICAL.
If resource_id in instruction format JSON file will always be treated as Pcpu,

it's the

Quoted 1 line

same as core_list behavior.

Yes, that's correct.  But I believe it's OK for the moment.

Currently the only way for the guest app to send commands and policies to the host is via the virtio-serial interface, which takes a different code path. There is no
way currently for the guest app to send a JSON string to the host, so that code path will
never be hit. However, now that the JSON functionality is in the host, we plan to add
that same functionality to the guest, and when we do that we will ensure that core_type
is handled appropriately.

Regards,
Dave.

Quoted 9 lines
Quoted 7 lines
examples/vm_power_manager/channel_monitor.c +2 -0
+		else
+			core_num = pkt->resource_id;
 
  		switch (pkt->unit) {

case(CPU_POWER_SCALE_MIN):
--
2.17.1

#4 lore raw
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines

This patch fixes a bug introduced in the 64-core limtation enhancement where the core_id is inadvertently converted from virtual to physical even though it may already be a physical core_id.

Quoted 8 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines

We should be using the core_type field, and only converting via hypervisor when core_type is set to CORE_TYPE_VIRTUAL

Fixes 5776b7a371d1 ("examples/power: allow VM to use lcores over 63")

Applied, thanks