From patchwork Tue Feb 7 18:59:01 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vineeth Remanan Pillai X-Patchwork-Id: 725282 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 3vHttH1VjWz9s2s for ; Wed, 8 Feb 2017 05:59:19 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=amazon.com header.i=@amazon.com header.b="ZjC6l1Hk"; dkim-atps=neutral Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755164AbdBGS7L (ORCPT ); Tue, 7 Feb 2017 13:59:11 -0500 Received: from smtp-fw-2101.amazon.com ([72.21.196.25]:7634 "EHLO smtp-fw-2101.amazon.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754530AbdBGS7J (ORCPT ); Tue, 7 Feb 2017 13:59:09 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amazon.com; i=@amazon.com; q=dns/txt; s=amazon201209; t=1486493949; x=1518029949; h=from:to:cc:subject:date:message-id:mime-version; bh=W+7WDze7cvIeUMWfe7AYSVnhvpM9kOK7DneyLSaipkQ=; b=ZjC6l1HkXWiLlIssiFPpzn+8uSab2DwBFezU+ezJWiJlRYA82/6aGEEy 5sA1M5Ac43/8ugeZSTfJU+YE3uzj22YfG4oG/yGf3o5xkddicxs4gKCTr uaPlxFq9f1Pi+PuQzkH9Z1c2ulft6OMCZ/adY2+s2SPLqtzjEhYGUW1f3 k=; X-IronPort-AV: E=Sophos;i="5.33,346,1477958400"; d="scan'208";a="639082281" Received: from iad6-co-svc-p1-lb1-vlan2.amazon.com (HELO email-inbound-relay-60013.pdx1.amazon.com) ([10.124.125.2]) by smtp-border-fw-out-2101.iad2.amazon.com with ESMTP/TLS/DHE-RSA-AES256-SHA; 07 Feb 2017 18:59:07 +0000 Received: from EX13MTAUWB001.ant.amazon.com (pdx1-ws-svc-p6-lb9-vlan3.pdx.amazon.com [10.236.137.198]) by email-inbound-relay-60013.pdx1.amazon.com (8.14.7/8.14.7) with ESMTP id v17Ix6WQ031225 (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=FAIL); Tue, 7 Feb 2017 18:59:07 GMT Received: from EX13D08UWB001.ant.amazon.com (10.43.161.104) by EX13MTAUWB001.ant.amazon.com (10.43.161.249) with Microsoft SMTP Server (TLS) id 15.0.1104.5; Tue, 7 Feb 2017 18:59:06 +0000 Received: from EX13MTAUEE001.ant.amazon.com (10.43.62.200) by EX13D08UWB001.ant.amazon.com (10.43.161.104) with Microsoft SMTP Server (TLS) id 15.0.1104.5; Tue, 7 Feb 2017 18:59:06 +0000 Received: from dev-dsk-vineethp-a-i-1153bf85.us-west-2.amazon.com (172.22.122.237) by mail-relay.amazon.com (10.43.62.226) with Microsoft SMTP Server id 15.0.1104.5 via Frontend Transport; Tue, 7 Feb 2017 18:59:05 +0000 From: Vineeth Remanan Pillai To: , , , , CC: Vineeth Remanan Pillai , , , Subject: [PATCH] xen-netfront: Rework the fix for Rx stall during OOM and network stress Date: Tue, 7 Feb 2017 18:59:01 +0000 Message-ID: <1486493941-15696-1-git-send-email-vineethp@amazon.com> X-Mailer: git-send-email 2.1.2.AMZN MIME-Version: 1.0 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org The commit 90c311b0eeea ("xen-netfront: Fix Rx stall during network stress and OOM") caused the refill timer to be triggerred almost on all invocations of xennet_alloc_rx_buffers for certain workloads. This reworks the fix by reverting to the old behaviour and taking into consideration the skb allocation failure. Refill timer is now triggered on insufficient requests or skb allocation failure. Signed-off-by: Vineeth Remanan Pillai Fixes: 90c311b0eeea (xen-netfront: Fix Rx stall during network stress and OOM) Reported-by: Boris Ostrovsky Reviewed-by: Boris Ostrovsky --- drivers/net/xen-netfront.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/drivers/net/xen-netfront.c b/drivers/net/xen-netfront.c index 8315fe7..9dba697 100644 --- a/drivers/net/xen-netfront.c +++ b/drivers/net/xen-netfront.c @@ -281,6 +281,7 @@ static void xennet_alloc_rx_buffers(struct netfront_queue *queue) { RING_IDX req_prod = queue->rx.req_prod_pvt; int notify; + int err = 0; if (unlikely(!netif_carrier_ok(queue->info->netdev))) return; @@ -295,8 +296,10 @@ static void xennet_alloc_rx_buffers(struct netfront_queue *queue) struct xen_netif_rx_request *req; skb = xennet_alloc_one_rx_buffer(queue); - if (!skb) + if (!skb) { + err = -ENOMEM; break; + } id = xennet_rxidx(req_prod); @@ -320,8 +323,13 @@ static void xennet_alloc_rx_buffers(struct netfront_queue *queue) queue->rx.req_prod_pvt = req_prod; - /* Not enough requests? Try again later. */ - if (req_prod - queue->rx.sring->req_prod < NET_RX_SLOTS_MIN) { + /* Try again later if there are not enough requests or skb allocation + * failed. + * Enough requests is quantified as the sum of newly created slots and + * the unconsumed slots at the backend. + */ + if (req_prod - queue->rx.rsp_cons < NET_RX_SLOTS_MIN || + unlikely(err)) { mod_timer(&queue->rx_refill_timer, jiffies + (HZ/10)); return; }