From: "Burakov, Anatoly" <anatoly.burakov@intel.com>
To: Hajkowski <marcinx.hajkowski@intel.com>, david.hunt@intel.com
Cc: dev@dpdk.org
Subject: Re: [dpdk-dev] [PATCH v3 4/4] power: send confirmation cmd to vm guest
Date: Wed, 27 Mar 2019 14:58:45 +0000 [thread overview]
Message-ID: <91674b9f-41ac-40c6-1043-a25a947917f6@intel.com> (raw)
Message-ID: <20190327145845.o9j8JZPHUjeOuacO24gW_BM9SXzkgqfxo4oywX7d0QQ@z> (raw)
In-Reply-To: <20190321105506.6656-5-marcinx.hajkowski@intel.com>
On 21-Mar-19 10:55 AM, 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 | 67 +++++++++++++++++++--
> 1 file changed, 61 insertions(+), 6 deletions(-)
>
> diff --git a/examples/vm_power_manager/channel_monitor.c b/examples/vm_power_manager/channel_monitor.c
> index 1a3a0fa76..df1dc1205 100644
> --- a/examples/vm_power_manager/channel_monitor.c
> +++ b/examples/vm_power_manager/channel_monitor.c
> @@ -627,6 +627,39 @@ 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) {
Shouldn't this be -1?
> + 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;
Perhaps writing out a debug message with strerror(errno) here?
> + 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)
Too much tabs IMO :)
> +{
> + pkt->command = command;
> + return write_binary_packet(pkt, chan_info);
> +}
> +
> static int
> process_request(struct channel_packet *pkt, struct channel_info *chan_info)
> {
> @@ -645,33 +678,55 @@ process_request(struct channel_packet *pkt, struct channel_info *chan_info)
> else
> core_num = pkt->resource_id;
>
> + 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;
> }
> +
> + int ret = -1;
> + if (valid_unit) {
> + ret = send_ack_for_received_cmd(pkt,
> + chan_info,
> + scale_res > 0 ?
> + CPU_POWER_CMD_ACK
> + : CPU_POWER_CMD_NACK);
I think layout like this looks more readable:
ret = send_ack_for_received_cmd(pkt,
chan_info,
scale_res > 0 ?
CPU_POWER_CMD_ACK :
CPU_POWER_CMD_NACK);
Note the two tabs (not three), extra tab for ternary, and colon on the
first line rather than the second one.
> + 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);
Again, four tabs seems way too much. Two maybe?
> + if (ret < 0)
> + RTE_LOG(DEBUG, CHANNEL_MONITOR, "Error during sending ack command.\n");
> update_policy(pkt);
> policy_is_set = 1;
> }
>
--
Thanks,
Anatoly
next prev parent reply other threads:[~2019-03-27 14:58 UTC|newest]
Thread overview: 40+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-03-21 10:55 [dpdk-dev] [PATCH v3 0/4] bidirect guest channel Hajkowski
2019-03-21 10:55 ` Hajkowski
2019-03-21 10:55 ` [dpdk-dev] [PATCH v3 1/4] power: fix invalid socket indicator value Hajkowski
2019-03-21 10:55 ` Hajkowski
2019-03-22 10:56 ` Maxime Coquelin
2019-03-22 10:56 ` Maxime Coquelin
2019-03-27 14:03 ` Burakov, Anatoly
2019-03-27 14:03 ` Burakov, Anatoly
2019-03-21 10:55 ` [dpdk-dev] [PATCH v3 2/4] power: extend guest channel api for reading Hajkowski
2019-03-21 10:55 ` Hajkowski
2019-03-22 11:00 ` Maxime Coquelin
2019-03-22 11:00 ` Maxime Coquelin
2019-03-22 11:53 ` Ananyev, Konstantin
2019-03-22 11:53 ` Ananyev, Konstantin
2019-03-27 14:23 ` Burakov, Anatoly
2019-03-27 14:23 ` Burakov, Anatoly
2019-03-21 10:55 ` [dpdk-dev] [PATCH v3 3/4] power: process incoming confirmation cmds Hajkowski
2019-03-21 10:55 ` Hajkowski
2019-03-27 14:51 ` Burakov, Anatoly
2019-03-27 14:51 ` Burakov, Anatoly
2019-04-01 14:25 ` Pattan, Reshma
2019-04-01 14:25 ` Pattan, Reshma
2019-03-21 10:55 ` [dpdk-dev] [PATCH v3 4/4] power: send confirmation cmd to vm guest Hajkowski
2019-03-21 10:55 ` Hajkowski
2019-03-27 14:58 ` Burakov, Anatoly [this message]
2019-03-27 14:58 ` Burakov, Anatoly
2019-03-29 14:16 ` [dpdk-dev] [PATCH v3 0/4] bidirect guest channel Thomas Monjalon
2019-03-29 14:16 ` Thomas Monjalon
2019-04-02 8:21 ` [dpdk-dev] [PATCH v4 " Hajkowski
2019-04-02 8:21 ` Hajkowski
2019-04-02 8:21 ` [dpdk-dev] [PATCH v4 1/4] power: fix invalid socket indicator value Hajkowski
2019-04-02 8:21 ` Hajkowski
2019-04-02 8:21 ` [dpdk-dev] [PATCH v4 2/4] power: extend guest channel api for reading Hajkowski
2019-04-02 8:21 ` Hajkowski
2019-04-02 8:21 ` [dpdk-dev] [PATCH v4 3/4] power: process incoming confirmation cmds Hajkowski
2019-04-02 8:21 ` Hajkowski
2019-04-03 9:25 ` Pattan, Reshma
2019-04-03 9:25 ` Pattan, Reshma
2019-04-02 8:21 ` [dpdk-dev] [PATCH v4 4/4] power: send confirmation cmd to vm guest Hajkowski
2019-04-02 8:21 ` Hajkowski
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=91674b9f-41ac-40c6-1043-a25a947917f6@intel.com \
--to=anatoly.burakov@intel.com \
--cc=david.hunt@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).