Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751723AbdFYTcb (ORCPT ); Sun, 25 Jun 2017 15:32:31 -0400 Received: from a2nlsmtp01-02.prod.iad2.secureserver.net ([198.71.225.36]:58994 "EHLO a2nlsmtp01-02.prod.iad2.secureserver.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751373AbdFYTbc (ORCPT ); Sun, 25 Jun 2017 15:31:32 -0400 x-originating-ip: 107.180.71.197 From: kys@exchange.microsoft.com To: gregkh@linuxfoundation.org, linux-kernel@vger.kernel.org, devel@linuxdriverproject.org, olaf@aepfle.de, apw@canonical.com, vkuznets@redhat.com, jasowang@redhat.com, leann.ogasawara@canonical.com, marcelo.cerri@canonical.com, sthemmin@microsoft.com Cc: Stephen Hemminger , "K. Y. Srinivasan" Subject: [PATCH 5/6] vmbus: more host signalling avoidance Date: Sun, 25 Jun 2017 12:30:28 -0700 Message-Id: <1498419029-4127-5-git-send-email-kys@exchange.microsoft.com> X-Mailer: git-send-email 1.7.1 In-Reply-To: <1498418991-4071-1-git-send-email-kys@exchange.microsoft.com> References: <1498418991-4071-1-git-send-email-kys@exchange.microsoft.com> Reply-To: kys@microsoft.com X-CMAE-Envelope: MS4wfM1a/nLFzYWAWEHMTngceUPm/r+RgkwFWd+gXCU2cfYcxNZ/U2LfpFWdlaKR37zbLVzK7hQ59qnrOasdMqYNR8Saypq/boVzdk0pWFWTFehmWlOFDu4n AYRSaFNwg65Bqjr+YM+O9MFWwZTC4aXhE1gMqao92gB22pyyoYEPOX50ebTWaiWF7Fxre2kTu7RZVewCHtolxo28m9g2CpDWRF896qbjGsRgGg4CZc40LKVR EVG2m1pqvURb5Fv+PoTsm5N+W7QbeFTueQVYkzP7aKUSeWYUth7s/XCyiB1na2neivtaFClSEubyvvCOTh+JHjePbgTFOG7v7W+6IYwuR6zT18RIKgRDhwSs 7hgV4Gbh9YFOs+CXGU6nCe81i51jTlDwtTTLLvJhHdD7bWsROseACQwOXaPMQhPy7GKih1UyQK05fNhU3B6fyUtOOj1D4H51eSd2/4SlKF3NIV7Kpq9mzGqf 7ozKuqd9GK6sgrN167Oz2skokjwqU5I0FqLA0znH+npn72kGrE/ym20qm04b2rNBBCKFRbrdYNJYe6ASCWmmyYpgoEYyyJRv6MaQHA== Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1931 Lines: 61 From: Stephen Hemminger Don't signal host if it has disabled interrupts for that ring buffer. Check the feature bit to see if host supports pending send size flag. Signed-off-by: Stephen Hemminger Signed-off-by: K. Y. Srinivasan --- drivers/hv/ring_buffer.c | 27 +++++++++++++++++++-------- 1 files changed, 19 insertions(+), 8 deletions(-) diff --git a/drivers/hv/ring_buffer.c b/drivers/hv/ring_buffer.c index b0f7952..741daa6 100644 --- a/drivers/hv/ring_buffer.c +++ b/drivers/hv/ring_buffer.c @@ -396,7 +396,6 @@ void hv_pkt_iter_close(struct vmbus_channel *channel) { struct hv_ring_buffer_info *rbi = &channel->inbound; u32 orig_write_sz = hv_get_bytes_to_write(rbi); - u32 pending_sz; /* * Make sure all reads are done before we update the read index since @@ -419,15 +418,27 @@ void hv_pkt_iter_close(struct vmbus_channel *channel) */ virt_mb(); - pending_sz = READ_ONCE(rbi->ring_buffer->pending_send_sz); - /* If the other end is not blocked on write don't bother. */ - if (pending_sz == 0) + /* If host has disabled notifications then skip */ + if (rbi->ring_buffer->interrupt_mask) return; - if (hv_get_bytes_to_write(rbi) < pending_sz) - return; + if (rbi->ring_buffer->feature_bits.feat_pending_send_sz) { + u32 pending_sz = READ_ONCE(rbi->ring_buffer->pending_send_sz); - if (orig_write_sz < pending_sz) - vmbus_setevent(channel); + /* + * If there was space before we began iteration, + * then host was not blocked. Also handles case where + * pending_sz is zero then host has nothing pending + * and does not need to be signaled. + */ + if (orig_write_sz > pending_sz) + return; + + /* If pending write will not fit, don't give false hope. */ + if (hv_get_bytes_to_write(rbi) < pending_sz) + return; + } + + vmbus_setevent(channel); } EXPORT_SYMBOL_GPL(hv_pkt_iter_close); -- 1.7.1