From patchwork Tue Aug 4 12:50:58 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ross Lagerwall X-Patchwork-Id: 503582 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 2435F1402D0 for ; Tue, 4 Aug 2015 22:51:25 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756134AbbHDMvO (ORCPT ); Tue, 4 Aug 2015 08:51:14 -0400 Received: from smtp02.citrix.com ([66.165.176.63]:45569 "EHLO SMTP02.CITRIX.COM" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755867AbbHDMvN (ORCPT ); Tue, 4 Aug 2015 08:51:13 -0400 X-IronPort-AV: E=Sophos;i="5.15,608,1432598400"; d="scan'208";a="291071722" From: Ross Lagerwall To: CC: , Wei Liu , "Ian Campbell" , Ross Lagerwall Subject: [PATCH] xen/netback: Wake dealloc thread after completing zerocopy work Date: Tue, 4 Aug 2015 13:50:58 +0100 Message-ID: <1438692658-22311-1-git-send-email-ross.lagerwall@citrix.com> X-Mailer: git-send-email 2.1.0 MIME-Version: 1.0 X-DLP: MIA1 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Waking the dealloc thread before decrementing inflight_packets is racy because it means the thread may go to sleep before inflight_packets is decremented. If kthread_stop() has already been called, the dealloc thread may wait forever with nothing to wake it. Instead, wake the thread only after decrementing inflight_packets. Signed-off-by: Ross Lagerwall --- drivers/net/xen-netback/netback.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/xen-netback/netback.c b/drivers/net/xen-netback/netback.c index 7d50711..e95ee20 100644 --- a/drivers/net/xen-netback/netback.c +++ b/drivers/net/xen-netback/netback.c @@ -1536,7 +1536,6 @@ void xenvif_zerocopy_callback(struct ubuf_info *ubuf, bool zerocopy_success) smp_wmb(); queue->dealloc_prod++; } while (ubuf); - wake_up(&queue->dealloc_wq); spin_unlock_irqrestore(&queue->callback_lock, flags); if (likely(zerocopy_success)) @@ -1544,6 +1543,7 @@ void xenvif_zerocopy_callback(struct ubuf_info *ubuf, bool zerocopy_success) else queue->stats.tx_zerocopy_fail++; xenvif_skb_zerocopy_complete(queue); + wake_up(&queue->dealloc_wq); } static inline void xenvif_tx_dealloc_action(struct xenvif_queue *queue)