From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from smtp2.osuosl.org (smtp2.osuosl.org [140.211.166.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 4B707EB64DA for ; Wed, 28 Jun 2023 21:34:26 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp2.osuosl.org (Postfix) with ESMTP id E331A401C2; Wed, 28 Jun 2023 21:34:25 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp2.osuosl.org E331A401C2 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=osuosl.org; s=default; t=1687988065; bh=6y9NdkWhl6aFw5+QWDDvZSZa4/HBFwPUABv7RHxTifo=; h=From:To:In-Reply-To:References:Date:Subject:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: Cc:From; b=mny6GhKnemtSjeTG9Z/GEgx6r1db6cOiDfEvrWW2WOZQL4utvtBl1a/ZO2Sq1TXpA cyVdJkP/SrAmLYuXF0kGfx/OMlBzP1XX8wHpB2+QYFOnQ2UOps6M4ziLlZNQaExnu2 8VkPXMKZRaU+mUCaVlrul+1XaBplfuHux0Zh7ivFaYAFFHlL7GLvXNjMfeZVzrByul R/awjaTUaVvkmMtdl0zeqT33kWgtY2XLyw08H57i1gkcQ5GlkP9tyc2SXNzklD6Sk4 RUFXOQjru1opDkEetRn7R+DcHi5ITm8zNir/W8Yaw2ZjeHMavDaHT++B94tZm9tATA 36cb+cO+9r1OA== X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp2.osuosl.org ([127.0.0.1]) by localhost (smtp2.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id Wee9tTCHr6d5; Wed, 28 Jun 2023 21:34:25 +0000 (UTC) Received: from ash.osuosl.org (ash.osuosl.org [140.211.166.34]) by smtp2.osuosl.org (Postfix) with ESMTP id DF35B401ED; Wed, 28 Jun 2023 21:34:24 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp2.osuosl.org DF35B401ED Received: from smtp2.osuosl.org (smtp2.osuosl.org [140.211.166.133]) by ash.osuosl.org (Postfix) with ESMTP id 1347B1BF343 for ; Wed, 28 Jun 2023 21:34:24 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp2.osuosl.org (Postfix) with ESMTP id DE56B401ED for ; Wed, 28 Jun 2023 21:34:23 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp2.osuosl.org DE56B401ED X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp2.osuosl.org ([127.0.0.1]) by localhost (smtp2.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id AMmDblRPy7_2 for ; Wed, 28 Jun 2023 21:34:22 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.8.0 DKIM-Filter: OpenDKIM Filter v2.11.0 smtp2.osuosl.org 8C9C840121 Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by smtp2.osuosl.org (Postfix) with ESMTPS id 8C9C840121 for ; Wed, 28 Jun 2023 21:34:22 +0000 (UTC) X-IronPort-AV: E=McAfee;i="6600,9927,10755"; a="351758358" X-IronPort-AV: E=Sophos;i="6.01,166,1684825200"; d="scan'208";a="351758358" Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by orsmga101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 Jun 2023 14:34:08 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10755"; a="787172958" X-IronPort-AV: E=Sophos;i="6.01,166,1684825200"; d="scan'208";a="787172958" Received: from vcostago-desk1.jf.intel.com (HELO vcostago-desk1) ([10.54.70.17]) by fmsmga004-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 Jun 2023 14:34:07 -0700 From: Vinicius Costa Gomes To: Florian Kauer , Jesse Brandeburg , Tony Nguyen , "David S . Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Vedang Patel , Maciej Fijalkowski , Jithu Joseph , Andre Guedes , Simon Horman In-Reply-To: <20230628091148.62256-1-florian.kauer@linutronix.de> References: <20230628091148.62256-1-florian.kauer@linutronix.de> Date: Wed, 28 Jun 2023 14:34:07 -0700 Message-ID: <87a5wjqnjk.fsf@intel.com> MIME-Version: 1.0 X-Mailman-Original-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1687988062; x=1719524062; h=from:to:cc:subject:in-reply-to:references:date: message-id:mime-version; bh=2zFRPcPqSdw/rQupEM6m4agW4/QKfyjYyUa1kit0f1s=; b=nBpV1Q2Rk8IdOarCJCYuvy6ahD1kmWqUJ6Xw7/h82nxCrytvQ4aLvOUs rvtoIN6OCN+RQatl/Pb7Oswk2W3ULW7vm+WlFsAsGQEENKRqWbBq0tgT/ nu6oZeLN3slx0HdVBLnfPIBplcYyDfKmxPY5Q6csNjPJM1g+e/5oPxe7Y iV0KJr2T38rsVghckdxlpSx3k+M6GJ5YutDlWZQ4mQdT7bS17R2KzXx01 ajtAfjH36yzw2X6y1IDhT3rWxcjQZZmWVPqXwih14xouzCOF189oZtHah BeuyZvik11zuOpgwmUFpVJqMr6fQuIIhQv8m4jJ12+CCdAeDCLMJ6K0wM A==; X-Mailman-Original-Authentication-Results: smtp2.osuosl.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.a=rsa-sha256 header.s=Intel header.b=nBpV1Q2R Subject: Re: [Intel-wired-lan] [PATCH net v2] igc: Prevent garbled TX queue with XDP ZEROCOPY X-BeenThere: intel-wired-lan@osuosl.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel Wired Ethernet Linux Kernel Driver Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: netdev@vger.kernel.org, kurt@linutronix.de, intel-wired-lan@lists.osuosl.org, linux-kernel@vger.kernel.org Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: intel-wired-lan-bounces@osuosl.org Sender: "Intel-wired-lan" Florian Kauer writes: > In normal operation, each populated queue item has > next_to_watch pointing to the last TX desc of the packet, > while each cleaned item has it set to 0. In particular, > next_to_use that points to the next (necessarily clean) > item to use has next_to_watch set to 0. > > When the TX queue is used both by an application using > AF_XDP with ZEROCOPY as well as a second non-XDP application > generating high traffic, the queue pointers can get in > an invalid state where next_to_use points to an item > where next_to_watch is NOT set to 0. > > However, the implementation assumes at several places > that this is never the case, so if it does hold, > bad things happen. In particular, within the loop inside > of igc_clean_tx_irq(), next_to_clean can overtake next_to_use. > Finally, this prevents any further transmission via > this queue and it never gets unblocked or signaled. > Secondly, if the queue is in this garbled state, > the inner loop of igc_clean_tx_ring() will never terminate, > completely hogging a CPU core. > > The reason is that igc_xdp_xmit_zc() reads next_to_use > before acquiring the lock, and writing it back > (potentially unmodified) later. If it got modified > before locking, the outdated next_to_use is written > pointing to an item that was already used elsewhere > (and thus next_to_watch got written). > > Fixes: 9acf59a752d4 ("igc: Enable TX via AF_XDP zero-copy") > Signed-off-by: Florian Kauer > Reviewed-by: Kurt Kanzenbach > Tested-by: Kurt Kanzenbach > --- This patch doesn't directly apply because there's a small conflict with commit 95b681485563 ("igc: Avoid transmit queue timeout for XDP"), but really easy to solve. Anyway, good catch: Acked-by: Vinicius Costa Gomes Cheers, -- Vinicius _______________________________________________ Intel-wired-lan mailing list Intel-wired-lan@osuosl.org https://lists.osuosl.org/mailman/listinfo/intel-wired-lan