From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752051AbcCKS7m (ORCPT ); Fri, 11 Mar 2016 13:59:42 -0500 Received: from p3plsmtps2ded01.prod.phx3.secureserver.net ([208.109.80.58]:55537 "EHLO p3plsmtps2ded01.prod.phx3.secureserver.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751379AbcCKS7j (ORCPT ); Fri, 11 Mar 2016 13:59:39 -0500 x-originating-ip: 72.167.245.219 From: "K. Y. Srinivasan" To: gregkh@linuxfoundation.org, linux-kernel@vger.kernel.org, devel@linuxdriverproject.org, olaf@aepfle.de, apw@canonical.com, vkuznets@redhat.com, jasowang@redhat.com Cc: "K. Y. Srinivasan" , Subject: [PATCH 1/1] Drivers: hv: vmbus: Fix a bug in hv_need_to_signal_on_read() Date: Fri, 11 Mar 2016 12:38:39 -0800 Message-Id: <1457728720-29172-1-git-send-email-kys@microsoft.com> X-Mailer: git-send-email 1.7.4.1 X-CMAE-Envelope: MS4wfCmU1iVXLpibfBgZENG2LEXPXjRZVjWeneIq77GdeyHbQ2UK95+fffgnf8IqGTZJfvMHmmYeTIrX6mCyv50bGOImDxGnfwgUP47azc+h4A2Sn8WesEHs D0n/uWhNKpaj/fVTZb/1Sk/BF3b7T6jZfgMtcSDIG0hu3zde9xWSIONL1OyWtZ22aYYZSjHK4LFAPhoTqfPlCKMDtRLd2Aw+HKv4FDFfrMwGRBG2ohOm67Mt 0F08sb+D+lV5/cW0naW+TXo3gfl79SehvWlmuUosmz8ohNHQjIkRy0H8dGJ3WsUzsUlyikAAi5QF1jPdADwEGWr8KCnBvOgO9RAteObnYhsG/IsGTUTU9x3w GdmexGtF3KBoO56CTVtCjjqq7y2smKVs8ax9y/gWNZTU0OIwIplTi0ihjEPcYOmFdSg0PStZtmKziReXzGZwzUP3EnRlqw== Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On the consumer side, we have interrupt driven flow management of the producer. It is sufficient to base the signalling decision on the amount of space that is available to write after the read is complete. The current code samples the previous available space and uses this in making the signalling decision. This state can be stale and is unnecessary. Since the state can be stale, we end up not signalling the host (when we should) and this can result in a hang. Fix this problem by removing the unnecessary check. I would like to thank Arseney Romanenko for pointing out this bug. Signed-off-by: K. Y. Srinivasan Tested-by: Dexuan Cui Cc: --- drivers/hv/ring_buffer.c | 7 +++---- 1 files changed, 3 insertions(+), 4 deletions(-) diff --git a/drivers/hv/ring_buffer.c b/drivers/hv/ring_buffer.c index 5613e2b..085003a 100644 --- a/drivers/hv/ring_buffer.c +++ b/drivers/hv/ring_buffer.c @@ -103,8 +103,7 @@ static bool hv_need_to_signal(u32 old_write, struct hv_ring_buffer_info *rbi) * there is room for the producer to send the pending packet. */ -static bool hv_need_to_signal_on_read(u32 prev_write_sz, - struct hv_ring_buffer_info *rbi) +static bool hv_need_to_signal_on_read(struct hv_ring_buffer_info *rbi) { u32 cur_write_sz; u32 r_size; @@ -120,7 +119,7 @@ static bool hv_need_to_signal_on_read(u32 prev_write_sz, cur_write_sz = write_loc >= read_loc ? r_size - (write_loc - read_loc) : read_loc - write_loc; - if ((prev_write_sz < pending_sz) && (cur_write_sz >= pending_sz)) + if (cur_write_sz >= pending_sz) return true; return false; @@ -455,7 +454,7 @@ int hv_ringbuffer_read(struct hv_ring_buffer_info *inring_info, /* Update the read index */ hv_set_next_read_location(inring_info, next_read_location); - *signal = hv_need_to_signal_on_read(bytes_avail_towrite, inring_info); + *signal = hv_need_to_signal_on_read(inring_info); return ret; } -- 1.7.4.1