Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp331107rwb; Wed, 7 Dec 2022 18:59:11 -0800 (PST) X-Google-Smtp-Source: AA0mqf680LaB59gRrE+xxvPzzJTOqEQorLDtJsgSCP/vgy1IC3o5FXftZ7sJAL1/Cx+EF8ZAug5d X-Received: by 2002:a17:90a:650c:b0:218:f309:53df with SMTP id i12-20020a17090a650c00b00218f30953dfmr71787855pjj.59.1670468351657; Wed, 07 Dec 2022 18:59:11 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1670468351; cv=none; d=google.com; s=arc-20160816; b=UyDJB2uOhhkc7Pw4LTRA8pmsPzwHsl/V2uIQnQ8828JQRVnobuBQX7k+OUP6txn3Bk Jz//28N/nz2J92awJg4+yRttG2g0SE4ly45O5qverf63urdApL6ZnJPu1P5Yaa9feGjD 6kF21APNKueLMsSk7dvTmkJXVy6nB1qj9VtJFioNyKM8CRXMs89xZ5blT4iZsHf+YDqH xiRxGPL4pVU0wsevfhz6N7OzqYncXAziwbMB9vy13wQNciJiOZchR2WxxP7z4OXwvUK5 QMM4P+SX8g5HLM6ig6VF1d8Sk1D1THIWbc2khHM/B9HdW2qXrRzbWCPt0bB2IR6csyPf esQw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:message-id:subject:to:from:date; bh=dSJrt1Dbnoz02EKsiHlxS/ceteXbYC3tDsIS89eV33g=; b=JLjx+oI0+97mv6xuBEUPIcGfA7wcptfs+V7+xpDn08RKoxW81/m06y1FLVtX7fpY81 UJ8p1Ocj/JM1P9Rx24DPDMRuqZh92g17Ccy0BURBB45G/GdjF2NslntpAFTXKJ+V6mzN EYvA/KPilMSnDHRQueVsRUv+GoZyC6Bkhz1M6VT+D1Ajuw7poqKFitHGzbSuiNNV2RLn f3b3w4DstN1RUUbS/8+7OT/FC9AYzCtgENrQTxfyp/WB+jbHiU910Rw/ZvY3r5Xbbmdc Fei2GHA77lYehmMA65bH3E5q8LEGjW00r0hZKBvsuhhcDnMcewGgetFYUybg/WHkj7T0 ZLAg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id iz5-20020a170902ef8500b00189cbf6953dsi11842335plb.300.2022.12.07.18.59.00; Wed, 07 Dec 2022 18:59:11 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229811AbiLHCw6 (ORCPT + 74 others); Wed, 7 Dec 2022 21:52:58 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42014 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229576AbiLHCw5 (ORCPT ); Wed, 7 Dec 2022 21:52:57 -0500 X-Greylist: delayed 1200 seconds by postgrey-1.37 at lindbergh.monkeyblade.net; Wed, 07 Dec 2022 18:52:55 PST Received: from stryx7.localdomain (unknown [12.22.252.226]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id DB8D727CF7; Wed, 7 Dec 2022 18:52:52 -0800 (PST) Received: by stryx7.localdomain (Postfix, from userid 1007) id 5F4EC61241A8; Wed, 7 Dec 2022 18:14:17 -0800 (PST) Date: Wed, 07 Dec 2022 18:14:17 -0800 From: epilmore@gigaio.com To: epilmore@gigaio.com, netdev@vger.kernel.org, dmaengine@vger.kernel.org, linux-kernel@vger.kernel.org, ntb@lists.linux.dev, allenbh@gmail.com, dave.jiang@intel.com, jdmason@kudzu.us Subject: [PATCH] ntb_netdev: Use dev_kfree_skb_irq() in interrupt context Message-ID: <63914879.CJDc0NszG7y0lmQT%epilmore@gigaio.com> User-Agent: Heirloom mailx 12.5 7/5/10 MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-1.1 required=5.0 tests=BAYES_00,RDNS_NONE, SPF_HELO_NONE,T_SPF_PERMERROR autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Eric Pilmore TX/RX callback handlers (ntb_netdev_tx_handler(), ntb_netdev_rx_handler()) can be called in interrupt context via the DMA framework when the respective DMA operations have completed. As such, any calls by these routines to free skb's, should use the interrupt context safe dev_kfree_skb_irq() function. Previously, these callback handlers would call the interrupt unsafe version of dev_kfree_skb(). Although this does not seem to present an issue when the underlying DMA engine being utilized is Intel IOAT, a kernel WARNING message was being encountered when PTDMA DMA engine was utilized on AMD platforms. The WARNING was being issued from skb_release_head_state() due to in_hardirq() being true. Besides the user visible WARNING from the kernel, the other symptom of this bug was that TCP/IP performance across the ntb_netdev interface was very poor, i.e. approximately an order of magnitude below what was expected. With the repair to use dev_kfree_skb_irq(), kernel WARNINGs from skb_release_head_state() ceased and TCP/IP performance, as measured by iperf, was on par with expected results, approximately 20 Gb/s on AMD Milan based server. Note that this performance is comparable with Intel based servers. Fixes: 765ccc7bc3d91 ("ntb_netdev: correct skb leak") Fixes: 548c237c0a997 ("net: Add support for NTB virtual ethernet device") Signed-off-by: Eric Pilmore --- drivers/net/ntb_netdev.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/net/ntb_netdev.c b/drivers/net/ntb_netdev.c index 80bdc07..283e23c 100644 --- a/drivers/net/ntb_netdev.c +++ b/drivers/net/ntb_netdev.c @@ -137,7 +137,7 @@ static void ntb_netdev_rx_handler(struct ntb_transport_qp *qp, void *qp_data, enqueue_again: rc = ntb_transport_rx_enqueue(qp, skb, skb->data, ndev->mtu + ETH_HLEN); if (rc) { - dev_kfree_skb(skb); + dev_kfree_skb_irq(skb); ndev->stats.rx_errors++; ndev->stats.rx_fifo_errors++; } @@ -192,7 +192,7 @@ static void ntb_netdev_tx_handler(struct ntb_transport_qp *qp, void *qp_data, ndev->stats.tx_aborted_errors++; } - dev_kfree_skb(skb); + dev_kfree_skb_irq(skb); if (ntb_transport_tx_free_entry(dev->qp) >= tx_start) { /* Make sure anybody stopping the queue after this sees the new -- 1.8.3.1