From: "Hunt, David" <david.hunt@intel.com>
To: 20190402082121.5472-1-marcinx.hajkowski@intel.com
Cc: dev@dpdk.org, Marcin Hajkowski <marcinx.hajkowski@intel.com>
Subject: Re: [dpdk-dev] [PATCH v5 4/4] power: send confirmation cmd to vm guest
Date: Thu, 26 Sep 2019 14:06:13 +0100 [thread overview]
Message-ID: <2811a1e6-3eb5-5e0b-1cc8-f683a43c346b@intel.com> (raw)
In-Reply-To: <20190405132455.15468-5-marcinx.hajkowski@intel.com>
On 05/04/2019 14:24, Hajkowski wrote:
> From: Marcin Hajkowski <marcinx.hajkowski@intel.com>
>
> Use new guest channel API to send confirmation
> message for received power command.
>
> Signed-off-by: Marcin Hajkowski <marcinx.hajkowski@intel.com>
> ---
> examples/vm_power_manager/channel_monitor.c | 68 +++++++++++++++++++--
> 1 file changed, 62 insertions(+), 6 deletions(-)
>
> diff --git a/examples/vm_power_manager/channel_monitor.c b/examples/vm_power_manager/channel_monitor.c
> index 7892d75de..ed580b36a 100644
> --- a/examples/vm_power_manager/channel_monitor.c
> +++ b/examples/vm_power_manager/channel_monitor.c
> @@ -627,6 +627,41 @@ apply_policy(struct policy *pol)
> apply_workload_profile(pol);
> }
>
> +static int
> +write_binary_packet(struct channel_packet *pkt, struct channel_info *chan_info)
> +{
> + int ret, buffer_len = sizeof(*pkt);
> + void *buffer = pkt;
> +
> + if (chan_info->fd < 0) {
> + RTE_LOG(ERR, CHANNEL_MONITOR, "Channel is not connected\n");
> + return -1;
> + }
> +
> + while (buffer_len > 0) {
> + ret = write(chan_info->fd, buffer, buffer_len);
> + if (ret == -1) {
> + if (errno == EINTR)
> + continue;
> + RTE_LOG(ERR, CHANNEL_MONITOR, "Write function failed due to %s.\n",
> + strerror(errno));
> + return -1;
> + }
> + buffer = (char *)buffer + ret;
> + buffer_len -= ret;
> + }
> + return 0;
> +}
> +
> +static int
> +send_ack_for_received_cmd(struct channel_packet *pkt,
> + struct channel_info *chan_info,
> + uint32_t command)
> +{
> + pkt->command = command;
> + return write_binary_packet(pkt, chan_info);
> +}
> +
> static int
> process_request(struct channel_packet *pkt, struct channel_info *chan_info)
> {
> @@ -650,33 +685,54 @@ process_request(struct channel_packet *pkt, struct channel_info *chan_info)
> RTE_LOG(DEBUG, CHANNEL_MONITOR, "Processing requested cmd for cpu:%d\n",
> core_num);
>
> + bool valid_unit = true;
> + int scale_res;
> +
> switch (pkt->unit) {
> case(CPU_POWER_SCALE_MIN):
> - power_manager_scale_core_min(core_num);
> + scale_res = power_manager_scale_core_min(core_num);
> break;
> case(CPU_POWER_SCALE_MAX):
> - power_manager_scale_core_max(core_num);
> + scale_res = power_manager_scale_core_max(core_num);
> break;
> case(CPU_POWER_SCALE_DOWN):
> - power_manager_scale_core_down(core_num);
> + scale_res = power_manager_scale_core_down(core_num);
> break;
> case(CPU_POWER_SCALE_UP):
> - power_manager_scale_core_up(core_num);
> + scale_res = power_manager_scale_core_up(core_num);
> break;
> case(CPU_POWER_ENABLE_TURBO):
> - power_manager_enable_turbo_core(core_num);
> + scale_res = power_manager_enable_turbo_core(core_num);
> break;
> case(CPU_POWER_DISABLE_TURBO):
> - power_manager_disable_turbo_core(core_num);
> + scale_res = power_manager_disable_turbo_core(core_num);
> break;
> default:
> + valid_unit = false;
> break;
> }
> +
> + if (valid_unit) {
> + ret = send_ack_for_received_cmd(pkt,
> + chan_info,
> + scale_res > 0 ?
> + CPU_POWER_CMD_ACK :
> + CPU_POWER_CMD_NACK);
> + if (ret < 0)
> + RTE_LOG(DEBUG, CHANNEL_MONITOR, "Error during sending ack command.\n");
> + } else
> + RTE_LOG(DEBUG, CHANNEL_MONITOR, "Unexpected unit type.\n");
> +
> }
>
> if (pkt->command == PKT_POLICY) {
> RTE_LOG(INFO, CHANNEL_MONITOR, "Processing policy request %s\n",
> pkt->vm_name);
> + int ret = send_ack_for_received_cmd(pkt,
> + chan_info,
> + CPU_POWER_CMD_ACK);
> + if (ret < 0)
> + RTE_LOG(DEBUG, CHANNEL_MONITOR, "Error during sending ack command.\n");
> update_policy(pkt);
> policy_is_set = 1;
> }
Using the guest_cli sample app in a VM, sending commands to the
vm_power_manager app on the host, we now have Acks and Nacks coming from
the host to the VM to conform the execution of the guest requests.
vmpower(guest)> set_cpu_freq 3 down
ACK received for message sent to host.
vmpower(guest)> set_cpu_freq 3 up
ACK received for message sent to host.
vmpower(guest)> set_cpu_freq 3 up
NACK received for message sent to host.
(NACK because we're already at the maxumum frequency)
And in the host vm_power_manager command line, we can see when a guest
request cannot be processed:
POWER: Turbo is off, frequency can't be scaled up more 31
Patchset looks good functionally.
Tested-by: David Hunt <david.hunt@intel.com>
next prev parent reply other threads:[~2019-09-26 13:06 UTC|newest]
Thread overview: 29+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-04-05 13:24 [dpdk-dev] [PATCH v5 0/4] bidirect guest channel Hajkowski
2019-04-05 13:24 ` Hajkowski
2019-04-05 13:24 ` [dpdk-dev] [PATCH v5 1/4] power: fix invalid socket indicator value Hajkowski
2019-04-05 13:24 ` Hajkowski
2019-09-27 8:42 ` [dpdk-dev] [PATCH v6 0/4] bidirectional guest channel Marcin Hajkowski
2019-09-27 8:42 ` [dpdk-dev] [PATCH v6 1/4] power: fix invalid socket indicator value Marcin Hajkowski
2019-09-27 8:42 ` [dpdk-dev] [PATCH v6 2/4] power: extend guest channel API for reading Marcin Hajkowski
2019-09-27 8:42 ` [dpdk-dev] [PATCH v6 3/4] power: process incoming confirmation cmds Marcin Hajkowski
2019-09-27 8:42 ` [dpdk-dev] [PATCH v6 4/4] power: send confirmation cmd to vm guest Marcin Hajkowski
2019-10-27 18:29 ` [dpdk-dev] [PATCH v6 0/4] bidirectional guest channel Thomas Monjalon
2019-04-05 13:24 ` [dpdk-dev] [PATCH v5 2/4] power: extend guest channel API for reading Hajkowski
2019-04-05 13:24 ` Hajkowski
2019-09-26 13:00 ` Hunt, David
2019-09-26 15:53 ` Daly, Lee
2019-04-05 13:24 ` [dpdk-dev] [PATCH v5 3/4] power: process incoming confirmation cmds Hajkowski
2019-04-05 13:24 ` Hajkowski
2019-09-26 13:01 ` Hunt, David
2019-09-26 15:49 ` Daly, Lee
2019-04-05 13:24 ` [dpdk-dev] [PATCH v5 4/4] power: send confirmation cmd to vm guest Hajkowski
2019-04-05 13:24 ` Hajkowski
2019-09-26 13:06 ` Hunt, David [this message]
2019-09-26 15:47 ` Daly, Lee
2019-04-22 20:36 ` [dpdk-dev] [PATCH v5 0/4] bidirect guest channel Thomas Monjalon
2019-04-22 20:36 ` Thomas Monjalon
2019-04-24 8:38 ` Hunt, David
2019-04-24 8:38 ` Hunt, David
2019-04-24 8:44 ` Thomas Monjalon
2019-04-24 8:44 ` Thomas Monjalon
2019-07-04 19:55 ` Thomas Monjalon
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=2811a1e6-3eb5-5e0b-1cc8-f683a43c346b@intel.com \
--to=david.hunt@intel.com \
--cc=20190402082121.5472-1-marcinx.hajkowski@intel.com \
--cc=dev@dpdk.org \
--cc=marcinx.hajkowski@intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).