Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp20343980rwd; Thu, 29 Jun 2023 00:38:26 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4g1TMvLLD+ujgxwfwsFyE1grsnPaMO00fWmwkiJ1hRMXDsjB3xNIhLKVex40YgdM+Sbjn7 X-Received: by 2002:a05:6a20:914d:b0:122:cef6:295 with SMTP id x13-20020a056a20914d00b00122cef60295mr21285357pzc.21.1688024306204; Thu, 29 Jun 2023 00:38:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1688024306; cv=none; d=google.com; s=arc-20160816; b=RqEPMtAwtlcvv+iiA5sjWD4IzNqUVsTSlskRYWTQKNFaCO/gKgrrwkQ8FstIFDo1BJ ozk6mDsgN+47PVhhLP0r2j4qUVfdeX0qnhMRr89qXXdvQQnT4boCNCT1autr7eqTCZku 7jUKlZ/xnqxCpBFHOXd9CUNkB8CA5gi9/vq5Oe7SMEz++CSZLmbUGT+URQ+/WEQHx1Kg u6C1dxrLvYAHPjkZD597fz1x+qw1byY0Vih4F7H/4ltFqtXptxNhS0PfyueeKt6DoFb5 lo5y75JNtj3kScoVQxjrNAV1s7NGtQWv35lALm0zptpLVrgJXRZS9aIrO6+hIZ4NTqra JC4Q== 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:cc:to:content-language:subject:mime-version:date :dkim-signature:dkim-signature:message-id; bh=uYKNMkC/e+EOiXeiis2Yv6NPhSLq1jyIWmFHBR4MTyo=; fh=mKMFL294dH7DELjeOEZnx/qtzgDDVZbGZepvZ8FtclY=; b=LrZM+hJR5A4idzWwclp07gMFf5lRpT+M4tjf96GSm4d57RAg3wyjz6kqNG2CAPrUOS f21L34rGx2rPOPWKO/TL7PoA/GSPUWqb9YnlOFxWBgYw91wLUHDOTu2VdtfELT7lXpm4 yLALI3IwUAXXvKKCtRBmlt4kv15osrDs05bVqb5QJ33NQrgex1FgvE6yGJLu+96oLrnt No7sTc4Ta19WEx26msbqZxagFKWMn5wKL7N1eTNPianUaBsrACArW1L7vuCPeiIOksOW XO+elZu4jJc2OXwRYr6WBH6FDuCw8H95R1dsSIvWD764NBfNq/0zO/ijMzLcxs8wWfjT OD6Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=rCwVstUW; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e; 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=QUARANTINE dis=NONE) header.from=linutronix.de Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id cq21-20020a056a00331500b00677429ef6a0si7246816pfb.217.2023.06.29.00.38.13; Thu, 29 Jun 2023 00:38:26 -0700 (PDT) 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=@linutronix.de header.s=2020 header.b=rCwVstUW; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e; 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=QUARANTINE dis=NONE) header.from=linutronix.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231974AbjF2HHt (ORCPT + 99 others); Thu, 29 Jun 2023 03:07:49 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48448 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231787AbjF2HHp (ORCPT ); Thu, 29 Jun 2023 03:07:45 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 390D52116; Thu, 29 Jun 2023 00:07:43 -0700 (PDT) Message-ID: DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1688022461; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=uYKNMkC/e+EOiXeiis2Yv6NPhSLq1jyIWmFHBR4MTyo=; b=rCwVstUWg5fN/FdCzmGYqSASXpxhRHT+gCl5DHf9/rhTbngXszmfvJwWfcvL1zrCCc2Ejk ZwmVkxUh3PJC0ESM7DWY7IKrcAclzBFMp50cKHsQDF7J53hd4l+fa37ySK71rRuWtBYz2f avwejKEusPI5faNbTQN8FqCTdDO6Jm31WmFhG1+7KJeGQxt6oZJPTo12S6KZeJz71giBB/ eEvAMIi+2vvxFNGEfPlx8Bi0vveNvvE9IQHwp7SZwPnggLf/ahmrY9chZIGFOfWWs5EBYQ q6DiQoOribKDkJKtZbf46MAT+c3QYrsWHRByk6ijYsC0irH+CbiRKiD4nWUDqw== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1688022461; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=uYKNMkC/e+EOiXeiis2Yv6NPhSLq1jyIWmFHBR4MTyo=; b=+Ot956sT7XnMLaiu4aDJD905nJStIalGNQcLZn7ixdjhgopMiyA1f+LMH57VaK5VGYSaBT sXtukp/7Sn7gsSAw== Date: Thu, 29 Jun 2023 09:07:40 +0200 MIME-Version: 1.0 Subject: Re: [Intel-wired-lan] [PATCH net v2] igc: Prevent garbled TX queue with XDP ZEROCOPY Content-Language: en-US To: Vinicius Costa Gomes , Jesse Brandeburg , Tony Nguyen , "David S . Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Vedang Patel , Maciej Fijalkowski , Jithu Joseph , Andre Guedes , Simon Horman Cc: netdev@vger.kernel.org, kurt@linutronix.de, intel-wired-lan@lists.osuosl.org, linux-kernel@vger.kernel.org References: <20230628091148.62256-1-florian.kauer@linutronix.de> <87a5wjqnjk.fsf@intel.com> From: Florian Kauer In-Reply-To: <87a5wjqnjk.fsf@intel.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE 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 Hi Vinicius, On 28.06.23 23:34, Vinicius Costa Gomes wrote: > 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 I am sorry, that was bad timing. I prepared the initial patch on Friday and overlooked the merge. Shall I send a v3 or will someone else take care of the conflict resolution? Greetings, Florian