Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2996931AbdD3XWr (ORCPT ); Sun, 30 Apr 2017 19:22:47 -0400 Received: from a2nlsmtp01-05.prod.iad2.secureserver.net ([198.71.225.49]:55116 "EHLO a2nlsmtp01-05.prod.iad2.secureserver.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S968425AbdD3XWW (ORCPT ); Sun, 30 Apr 2017 19:22:22 -0400 x-originating-ip: 107.180.71.197 From: kys@exchange.microsoft.com To: davem@davemloft.net, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, devel@linuxdriverproject.org, olaf@aepfle.de, apw@canonical.com, jasowang@redhat.com, leann.ogasawara@canonical.comi, marcelo.cerri@canonical.com, sthemmin@microsoft.com Cc: Long Li , "K. Y. Srinivasan" Subject: [PATCH 6/6] HV: properly delay KVP packets when negotiation is in progress Date: Sun, 30 Apr 2017 16:21:19 -0700 Message-Id: <1493594479-25329-6-git-send-email-kys@exchange.microsoft.com> X-Mailer: git-send-email 1.7.1 In-Reply-To: <1493594420-25214-1-git-send-email-kys@exchange.microsoft.com> References: <1493594420-25214-1-git-send-email-kys@exchange.microsoft.com> Reply-To: kys@microsoft.com X-CMAE-Envelope: MS4wfC/+Kkw4obp4d50ijNY37Fc0yOF6BvbMPs0mxBoKPHtidI/WntaQcQmhC58X0FHuOwJQoRFvawoeNB2/TkaRzg6XREaaBvo5npYhRydtcV5ZiSgnlGd8 xpJsibkHwy2VN2E723sRgelgMwEp8BMOGntm7quqd0kP+89Oxh7dz/ikKnMPjHsYuEVAJHMbgdrDk+iNvXojnsZP6UnVaQy6+wqLmHBSOMDedrkGsQN2Ri8g JdTEErQ0QiZroEvXdkcAP0osH8pssK8/5HBPoT4vg+wsfrlvXOiOK9xQUD4wqaea5OHWW2QM1UUz2r9ensvvZSzroW8BxrGCd/ruazcCZPd2PVOxykynpbQW gacw8EzOHLwguAJ00Jv+ncOyE17ZHHdFub6Ye/T0D/dj/ml8M+HKCmj5+UUIZsFf1U/E2cLwI5ALqe5XBSeOI4H6qQXwDnYbiG77K/If6EYVZDiymMOoK5rQ UFKPahIIoFqaxD47l2fSE9+BEWV+duTBLrtyXBYZIp5ZMD8pXXGGMDDRaSNFWnhl8uvnM7xKkZgcwXU6HiaSvkrX83D+pnKxN2Tm1w== Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2645 Lines: 78 From: Long Li The host may send multiple negotiation packets (due to timeout) before the KVP user-mode daemon is connected. KVP user-mode daemon is connected. We need to defer processing those packets until the daemon is negotiated and connected. It's okay for guest to respond to all negotiation packets. In addition, the host may send multiple staged KVP requests as soon as negotiation is done. We need to properly process those packets using one tasklet for exclusive access to ring buffer. This patch is based on the work of Nick Meier . Signed-off-by: Long Li Signed-off-by: K. Y. Srinivasan --- drivers/hv/hv_kvp.c | 14 ++++++++------ 1 files changed, 8 insertions(+), 6 deletions(-) diff --git a/drivers/hv/hv_kvp.c b/drivers/hv/hv_kvp.c index e99ff2d..9a90b91 100644 --- a/drivers/hv/hv_kvp.c +++ b/drivers/hv/hv_kvp.c @@ -112,7 +112,7 @@ static void kvp_poll_wrapper(void *channel) { /* Transaction is finished, reset the state here to avoid races. */ kvp_transaction.state = HVUTIL_READY; - hv_kvp_onchannelcallback(channel); + tasklet_schedule(&((struct vmbus_channel *)channel)->callback_event); } static void kvp_register_done(void) @@ -159,7 +159,7 @@ static void kvp_timeout_func(struct work_struct *dummy) static void kvp_host_handshake_func(struct work_struct *dummy) { - hv_poll_channel(kvp_transaction.recv_channel, hv_kvp_onchannelcallback); + tasklet_schedule(&kvp_transaction.recv_channel->callback_event); } static int kvp_handle_handshake(struct hv_kvp_msg *msg) @@ -625,16 +625,17 @@ void hv_kvp_onchannelcallback(void *context) NEGO_IN_PROGRESS, NEGO_FINISHED} host_negotiatied = NEGO_NOT_STARTED; - if (host_negotiatied == NEGO_NOT_STARTED && - kvp_transaction.state < HVUTIL_READY) { + if (kvp_transaction.state < HVUTIL_READY) { /* * If userspace daemon is not connected and host is asking * us to negotiate we need to delay to not lose messages. * This is important for Failover IP setting. */ - host_negotiatied = NEGO_IN_PROGRESS; - schedule_delayed_work(&kvp_host_handshake_work, + if (host_negotiatied == NEGO_NOT_STARTED) { + host_negotiatied = NEGO_IN_PROGRESS; + schedule_delayed_work(&kvp_host_handshake_work, HV_UTIL_NEGO_TIMEOUT * HZ); + } return; } if (kvp_transaction.state > HVUTIL_READY) @@ -702,6 +703,7 @@ void hv_kvp_onchannelcallback(void *context) VM_PKT_DATA_INBAND, 0); host_negotiatied = NEGO_FINISHED; + hv_poll_channel(kvp_transaction.recv_channel, kvp_poll_wrapper); } } -- 1.7.1