Received: by 2002:a05:6358:7058:b0:131:369:b2a3 with SMTP id 24csp5247128rwp; Sun, 16 Jul 2023 23:59:24 -0700 (PDT) X-Google-Smtp-Source: APBJJlGESNY1dYXzlq0h2t1dL9JqbupX0CxfTQ24PXOL02Z4sm1NPR1wp0ZjAdB35rA0w5oKT0eP X-Received: by 2002:a17:90a:4a91:b0:258:9621:913f with SMTP id f17-20020a17090a4a9100b002589621913fmr10980943pjh.3.1689577163947; Sun, 16 Jul 2023 23:59:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689577163; cv=none; d=google.com; s=arc-20160816; b=cZmdSJlGDGD4snHZVI0MS9DIVeptdQzx8LI587h5TKcx1fGbbnFcUjGygBdEoZlPEA vEWxjPOx+9BH+438ctVupPqpeknuCHn1+B3egIIpnxC7xOaL9rzw/No8a4OpmkimOBC3 cQhxUY0cS4M3h8/wPpjmEhUKMnHf0Zpfkv235/Wq2aWiJAu+X0oGPJTqg2w5yTmHDHo1 0Bkpp8ghwpSK57waiufz9zPy2q6y6PvbsDEog5+MM1qvu4flqeenPUw+0vCMLISfrdpS 8AstCHtrskOzypP1F+BNiC03sGwwZviHXm06Kn2UPn4OVsnVvDvrUfKBx+JzJfzkwVJ2 BESA== 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:user-agent:mime-version :date:message-id:dkim-signature; bh=yRU5e53zbXxeqV4VwQKiT0aq6yu8pBa9GXm2Ix1WYso=; fh=VHEvO7aoMlDYNWQemCa98DknRdIh6AgE0wOuShUdBMs=; b=yXxaD107H2InBAqZROBoPZ2C8woCn7ByKlmjDIDkxd0oXLGRQe9aEai41Ou5cKS1+l iFAS3vR9WhDcJ+t5tHE3YWeiZEeS3jlnkpGJyFqWxSKATmNKmOo7nrIv25nLrjlz51dK 79bP1D70WLGRZApcmy5pc9ljkxJh3ku4qfx7IvfVw3S85YJVP3mUWHrbL/dhMoo9k05x 0NNUJtsd+MZuTDPOJ1otvPRw7hEvM7BUq4Uv+K1sfTNPltkOPAp8H3lgkJC2Kcibi087 hnxkoiQrP3Y/drUN9eJarCo8LDYNxmZ7XuHbLFMO+veWb8p11/4JGwScYGUvOne1vKtr 3YJw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b="BT/9+IXh"; 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 q8-20020a17090a68c800b0025960d035c6si5396027pjj.138.2023.07.16.23.59.12; Sun, 16 Jul 2023 23:59:23 -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=@intel.com header.s=Intel header.b="BT/9+IXh"; 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 S231194AbjGQGco (ORCPT + 99 others); Mon, 17 Jul 2023 02:32:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36438 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229725AbjGQGcn (ORCPT ); Mon, 17 Jul 2023 02:32:43 -0400 Received: from mga18.intel.com (mga18.intel.com [134.134.136.126]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2AE2CD9; Sun, 16 Jul 2023 23:32:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1689575562; x=1721111562; h=message-id:date:mime-version:subject:to:cc:references: from:in-reply-to:content-transfer-encoding; bh=UIvScjBMq2tJ7obc7FO/ZTmBFLS/+sEbi6AjYJ3oqcc=; b=BT/9+IXhbgKgcCBzQy6mYEkMXdirLWUm5Ya6iv46LOb7zqr7u/8Ow33c k3Fu3ZGWAV0R+uFE5IcNxzKiORB9hXy/40hkOPotLGlb0sZAbnLtUxU9P uVpklhfVZkVfbsgfBIN8srS7by6ZZL50whXKWeNGrfL/FAV+Z6kn/OQTr OzbezQAfpc7A3OFquHML5ZyQt04GqzHOMun7PQ3X3ZWTJcJPMJdrUsU9S BaXYtewzNhqRSyIERskt6VYh3alCGMXSMbTXrBTT4UwOFhZ0iabj/dwof VQiace8CR+dHfvhHo1bm8z+I8dOMCIKZSDWw6nM2al1suKn1UBFPTN9bk Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10773"; a="350721120" X-IronPort-AV: E=Sophos;i="6.01,211,1684825200"; d="scan'208";a="350721120" Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Jul 2023 23:32:41 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10773"; a="788532240" X-IronPort-AV: E=Sophos;i="6.01,211,1684825200"; d="scan'208";a="788532240" Received: from naamamex-mobl.ger.corp.intel.com (HELO [10.13.12.54]) ([10.13.12.54]) by fmsmga008-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Jul 2023 23:32:36 -0700 Message-ID: <68dcdf3c-226c-9a94-0860-68c6d4b8ca0e@linux.intel.com> Date: Mon, 17 Jul 2023 09:32:33 +0300 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101 Thunderbird/102.12.0 Subject: Re: [Intel-wired-lan] [PATCH net v3] igc: Prevent garbled TX queue with XDP ZEROCOPY Content-Language: en-US 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 Cc: netdev@vger.kernel.org, kurt@linutronix.de, linux-kernel@vger.kernel.org, intel-wired-lan@lists.osuosl.org References: <20230630120306.8534-1-florian.kauer@linutronix.de> From: "naamax.meir" In-Reply-To: <20230630120306.8534-1-florian.kauer@linutronix.de> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_EF,NICE_REPLY_A, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_NONE,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 On 6/30/2023 15:03, Florian Kauer wrote: > 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 > Acked-by: Vinicius Costa Gomes > --- > > v2 -> v3: > Resolve merge conflict > > v1 -> v2: > I added some more context for further clarification, > but it is also just how I interpret the code. > Also the typo is fixed and it is reverse christmas again ???? > > --- > drivers/net/ethernet/intel/igc/igc_main.c | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) Tested-by: Naama Meir