From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753295AbdJSNjg (ORCPT ); Thu, 19 Oct 2017 09:39:36 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:44432 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753252AbdJSNjc (ORCPT ); Thu, 19 Oct 2017 09:39:32 -0400 From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Stephen Hemminger , "K. Y. Srinivasan" Subject: [PATCH 4.13 11/11] vmbus: more host signalling avoidance Date: Thu, 19 Oct 2017 15:39:06 +0200 Message-Id: <20171019131700.965593955@linuxfoundation.org> X-Mailer: git-send-email 2.14.2 In-Reply-To: <20171019131659.388456140@linuxfoundation.org> References: <20171019131659.388456140@linuxfoundation.org> User-Agent: quilt/0.65 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.13-stable review patch. If anyone has any objections, please let me know. ------------------ From: Stephen Hemminger commit 03bad714a1619c0074eb44d6f217c505fe27030f upstream. 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 Signed-off-by: Greg Kroah-Hartman --- drivers/hv/ring_buffer.c | 27 +++++++++++++++++++-------- 1 file changed, 19 insertions(+), 8 deletions(-) --- a/drivers/hv/ring_buffer.c +++ b/drivers/hv/ring_buffer.c @@ -396,7 +396,6 @@ void hv_pkt_iter_close(struct vmbus_chan { 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_chan */ 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 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; + } - if (orig_write_sz < pending_sz) - vmbus_setevent(channel); + vmbus_setevent(channel); } EXPORT_SYMBOL_GPL(hv_pkt_iter_close);