Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp19815558rwd; Wed, 28 Jun 2023 14:58:29 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7tO7fmgyRnGIOSchWGSKzVqk9Q7AeHWZJeGJxEMUw0EBKo/b8yxEy/zV4eO9H3gQiOOA1q X-Received: by 2002:a50:ee96:0:b0:518:82c4:cc7e with SMTP id f22-20020a50ee96000000b0051882c4cc7emr23750304edr.17.1687989509269; Wed, 28 Jun 2023 14:58:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687989509; cv=none; d=google.com; s=arc-20160816; b=UMF6QDw2CK3dhuZaweYcxGfhYV5r42mQyIvCrdAiocE9oc8kOq7QfVr0zVd99V7GVj cwj5Zvb+PDG+kEFKv/URUqchKeUX+pY1Ba5lHK/PTnVFDs+xys56GkF64n+wa/1GZqA1 23IiGpvYc0r4hpNF5xmsZdRzXQxTveKCCCXhjmtS8GGxZ1TwhrnSQCZUzY1spr0FeBCi hqFk5i3mjFHKvUM/idtrdUh+OvZgHkBgTs3V4gMyllIeDbdTa+vmVrFmnNisVGzcXIoA nixknjwkGNZbZFPZC+rzE25MFKr2HdC2OkqDyfKlgy6gyjQeKGAZftHDtUC6fR/TrjkT AtGw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:message-id:date:references :in-reply-to:subject:cc:to:from:dkim-signature; bh=piVAlc5JvzIuynwZ71Af6Gg3lfmNmDbrfIX7m+zReeY=; fh=N4kc64bOtURJlK2XSY/0iiUo8AMhPTaiYWBoNu3c4Zo=; b=n6oCKQhtaWbibWNn4F0jkxyNNQWe6TmRVHNXKWSdUNeNZxeAPkZYnZmdjKC13WH3AH aabKriyG+FK5AIfi6QzpQPaHEX4d7usXSLmW4a+LxD9L5RB7sRP9iFqcENMf4MTwrm8n vkAP2QWNMH+061W8FsjhKicsIjJzIFIQUGQL7gNaD5Y7TzudoAe3oapDGy0GpOIrKdtW A7qrkYXFMsmngIg+gOLX7kWb1loCiRKZ5t2KBKlYj0yAASxOpQQYgRQKsrgrs7sqZifn zppQHSnL3SPWL15Hc5MoJ02B65oXz9UQuq7+/BYjj6ObqfNaa/FMHZp9U9jZFaA9m0rT rIhQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=UIa1fHs2; 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 b2-20020aa7dc02000000b0051a595dc64bsi5372188edu.105.2023.06.28.14.58.04; Wed, 28 Jun 2023 14:58:29 -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=UIa1fHs2; 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 S232046AbjF1VeL (ORCPT + 99 others); Wed, 28 Jun 2023 17:34:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34914 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230014AbjF1VeK (ORCPT ); Wed, 28 Jun 2023 17:34:10 -0400 Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 78B671FE4; Wed, 28 Jun 2023 14:34:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1687988049; x=1719524049; h=from:to:cc:subject:in-reply-to:references:date: message-id:mime-version; bh=2zFRPcPqSdw/rQupEM6m4agW4/QKfyjYyUa1kit0f1s=; b=UIa1fHs2Zs9fdB87YCNRFAuxiWbmg/365ZNADpyUTOAtzHvLgfO5lBUK wxw67CFmygXg+ogUUMNSmnnNLywwAJ0Au4bjzmidC/nbeyA6beV653ui/ lSYP1SiJBy5+Qb4mDjF7U7L2U0i/tqr98wyd7l0MXuKC+xLb3kZz6wVk/ 4nCnAFdauRuLIoNlwLs9RgXmrPzHLU9plxZuBFcUBTmly0A3B2lUc86t9 D2mOHA42J2FRRrzQU0rztrUyjmIDZ8kycv95abvSgM7JDW6P8UmVR+wzU xTd3Fit49RtYOAk49V48l7GcxjvapcCmElyyuz4oLkqLm/WUSy1+cpXET g==; X-IronPort-AV: E=McAfee;i="6600,9927,10755"; a="351758361" X-IronPort-AV: E=Sophos;i="6.01,166,1684825200"; d="scan'208";a="351758361" 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 Cc: netdev@vger.kernel.org, kurt@linutronix.de, intel-wired-lan@lists.osuosl.org, linux-kernel@vger.kernel.org Subject: Re: [Intel-wired-lan] [PATCH net v2] igc: Prevent garbled TX queue with XDP ZEROCOPY 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 Content-Type: text/plain X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE, T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED 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 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