Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp1208990rwb; Thu, 8 Dec 2022 07:57:53 -0800 (PST) X-Google-Smtp-Source: AA0mqf75+/2EV2pZ9oyVjJalOR2v3PyAg0/VHnnGmLgxJAGJzedsICijW2TJvwiWWulIqhvRsmM9 X-Received: by 2002:a05:6a02:46:b0:478:ec72:5227 with SMTP id az6-20020a056a02004600b00478ec725227mr7493711pgb.93.1670515073441; Thu, 08 Dec 2022 07:57:53 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1670515073; cv=none; d=google.com; s=arc-20160816; b=pZOteZZmi5yC0ZzoDhqG+8qhcZQ3qDnfrjuSkY8O1Fo111sVEdmzLoA8n1SAUXOeJw d+fbaupgeFAZYdIoVvSpP8aYjOLybB+hZQB5X2sRCaWHnron2Idp/WGtl4WBBo7c4O0Q KjtULmddIrggm40hVv52/VlAQ/l91ixf7OHh/SfNfn64ElPyoiXhgUnQsvJ/nwsSW72I iTrCUGIfp9wTVTbSVt3FXgRR46SdS9rrewwvPFtAkwoeynRXa8/EbZOcxD2oMh0Agl2u v63Y86417zUOUKTXJ7GkvILIO2bVtqPbA3DtG5R6REDJMK82AaQK9BMegKWeT6CNxNxh O3QA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:to:content-language:subject:user-agent:mime-version:date :message-id:dkim-signature; bh=t8OUXZa8An7lFkXiM/MQGOrvy2ESxcMFrN3gbvi8D0U=; b=X/yrp2fDa99W4g/4mZra3mwEqPG7Sc9SJ7eRWPGaD3uSltdHWgneM1/YtzSknoFQt9 0d67+u+sLTjiH0tdlLltdA5z6owU41iGbql3ASjCEySM7x4z4s+GPjl0s3AXBAiG+OTs urqSwgi9fdkIC7zITH1S67dcwITf8+JRtaNe89Efp3XshPWdz9n9DxAMNujt4UWxq2W/ LdnifdsLUPYjITKxekoA030o0RP6E8+BVIpIjHUF8hk+mhKnsb0lNmIdf5p7/6xEAxX2 92RGi3rvM2sGipfpceLEujBNqLtmHwMpKtZodxIvcS16ygURDwgjtfJRXhDya7Y8Bgmg 8nnA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=dRhyirQy; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id b5-20020a170902e94500b00189907c6b9asi10823027pll.302.2022.12.08.07.57.43; Thu, 08 Dec 2022 07:57:53 -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; dkim=pass header.i=@intel.com header.s=Intel header.b=dRhyirQy; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230199AbiLHPg1 (ORCPT + 73 others); Thu, 8 Dec 2022 10:36:27 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54346 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229879AbiLHPgL (ORCPT ); Thu, 8 Dec 2022 10:36:11 -0500 Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 21F591F2EE; Thu, 8 Dec 2022 07:35:10 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1670513711; x=1702049711; h=message-id:date:mime-version:subject:to:references:from: in-reply-to:content-transfer-encoding; bh=tx6WgOOXVLV5hrV1QwuXZAr3B29JWv8/BeADXXKDTck=; b=dRhyirQyWt23uSSGMCegry6skCJklVhP/lrr1D0eocUUWZkpHCrmdb8v 99AdAucRp13IyJXNk5tb25FyOAjeS4ZFCBy2SrEV7aKt24RXLti9WiQ13 4H8ep7QDIe/l2Alej+KuckhoIhVjReF8+DzgQ12ZFIb/RBjgv4NrwyvLX YiA8oxtdwraTXN54gw5lLNAFoF9I4fbEns39mY1b/1bRSomXR/hJ6CwrL 95eQK4P07nLljvtcaKgRKllvbh4iDFHe9LJtUBvoUjxzkwitvySJQj9bI aJftQzg3dO5wJEBTqIDyQzo1umM4frA/WROOmzp6e/YLNDtz8W5j30Pe5 w==; X-IronPort-AV: E=McAfee;i="6500,9779,10555"; a="317206948" X-IronPort-AV: E=Sophos;i="5.96,227,1665471600"; d="scan'208";a="317206948" Received: from orsmga006.jf.intel.com ([10.7.209.51]) by fmsmga103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 08 Dec 2022 07:35:10 -0800 X-IronPort-AV: E=McAfee;i="6500,9779,10555"; a="624745533" X-IronPort-AV: E=Sophos;i="5.96,227,1665471600"; d="scan'208";a="624745533" Received: from rganeshm-mobl.amr.corp.intel.com (HELO [10.212.107.194]) ([10.212.107.194]) by orsmga006-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 08 Dec 2022 07:35:09 -0800 Message-ID: Date: Thu, 8 Dec 2022 08:35:08 -0700 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101 Firefox/102.0 Thunderbird/102.5.1 Subject: Re: [PATCH] ntb_netdev: Use dev_kfree_skb_irq() in interrupt context Content-Language: en-US To: epilmore@gigaio.com, netdev@vger.kernel.org, dmaengine@vger.kernel.org, linux-kernel@vger.kernel.org, ntb@lists.linux.dev, allenbh@gmail.com, jdmason@kudzu.us References: <63914879.CJDc0NszG7y0lmQT%epilmore@gigaio.com> From: Dave Jiang In-Reply-To: <63914879.CJDc0NszG7y0lmQT%epilmore@gigaio.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-7.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A, RCVD_IN_DNSWL_HI,SPF_HELO_NONE,SPF_NONE autolearn=ham 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 On 12/7/2022 7:14 PM, epilmore@gigaio.com wrote: > 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 Hi Eric, Thanks for submitting this. I think the reason is ptdma runs everything in the hard interrupt handler while ioatdma runs interrupt handling in a tasklet. I just took a look at the function definitions in netdevice.h, and I think the call you want to use is dev_kfree_skb_any(). It handles being freed depending on the context for you. > --- > 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