From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.2 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED,USER_AGENT_SANE_1 autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2DAA7C352A9 for ; Thu, 26 Sep 2019 13:06:22 +0000 (UTC) Received: from dpdk.org (dpdk.org [92.243.14.124]) by mail.kernel.org (Postfix) with ESMTP id AF47A222C6 for ; Thu, 26 Sep 2019 13:06:21 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org AF47A222C6 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=intel.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=dev-bounces@dpdk.org Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 9FA7C2C57; Thu, 26 Sep 2019 15:06:20 +0200 (CEST) Received: from mga12.intel.com (mga12.intel.com [192.55.52.136]) by dpdk.org (Postfix) with ESMTP id 50FE32C38 for ; Thu, 26 Sep 2019 15:06:18 +0200 (CEST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga006.jf.intel.com ([10.7.209.51]) by fmsmga106.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 26 Sep 2019 06:06:17 -0700 X-IronPort-AV: E=Sophos;i="5.64,552,1559545200"; d="scan'208";a="194121492" Received: from dhunt5-mobl4.ger.corp.intel.com (HELO [10.237.221.113]) ([10.237.221.113]) by orsmga006-auth.jf.intel.com with ESMTP/TLS/AES256-SHA; 26 Sep 2019 06:06:15 -0700 To: 20190402082121.5472-1-marcinx.hajkowski@intel.com Cc: dev@dpdk.org, Marcin Hajkowski References: <20190405132455.15468-1-marcinx.hajkowski@intel.com> <20190405132455.15468-5-marcinx.hajkowski@intel.com> From: "Hunt, David" Message-ID: <2811a1e6-3eb5-5e0b-1cc8-f683a43c346b@intel.com> Date: Thu, 26 Sep 2019 14:06:13 +0100 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:60.0) Gecko/20100101 Thunderbird/60.7.2 MIME-Version: 1.0 In-Reply-To: <20190405132455.15468-5-marcinx.hajkowski@intel.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Content-Language: en-US Subject: Re: [dpdk-dev] [PATCH v5 4/4] power: send confirmation cmd to vm guest X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" On 05/04/2019 14:24, Hajkowski wrote: > From: Marcin Hajkowski > > Use new guest channel API to send confirmation > message for received power command. > > Signed-off-by: Marcin Hajkowski > --- > 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