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 smtp4.osuosl.org (smtp4.osuosl.org [140.211.166.137]) (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 5BA07C3ABA3 for ; Fri, 2 May 2025 09:36:24 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp4.osuosl.org (Postfix) with ESMTP id 0492741514; Fri, 2 May 2025 09:36:24 +0000 (UTC) X-Virus-Scanned: amavis at osuosl.org Received: from smtp4.osuosl.org ([127.0.0.1]) by localhost (smtp4.osuosl.org [127.0.0.1]) (amavis, port 10024) with ESMTP id CiHnQSutc3bF; Fri, 2 May 2025 09:36:20 +0000 (UTC) X-Comment: SPF check N/A for local connections - client-ip=140.211.166.142; helo=lists1.osuosl.org; envelope-from=intel-wired-lan-bounces@osuosl.org; receiver= DKIM-Filter: OpenDKIM Filter v2.11.0 smtp4.osuosl.org 77F034154C DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=osuosl.org; s=default; t=1746178580; bh=wqgy53IKHmPNpHADK7KRC8FETh3ffBRz4E6RtpaLAbA=; h=Date:From:To:Cc:References:In-Reply-To:Subject:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=36LVTAhLDVMMCcoOVB8MzWBwOHO70z5uMW0bL/MoxQR2NElbiwI47E/QyeVsrJ56y AO/lbmehHBNSyG+KE2K+mEbSjHvO77+KQJBxAOXkjrb+FF2tHIYo83Ls5YTwNGAr2e zp8hn94IFc2OgDZEPhrJYp2vmdo0pJ6CL316+P5XNk6ynPFHPoDWMMmAjKaCQtR45s qmAJzz4xuYorIDoYmUuDiB+JmQcu8TCge5AZybBbVnVs7kvYv92jyHtd3JEim/+ltv gVN69lSkH/dfJ5KTt0Ga9rmviS5oVNG3ZLSLdcLAL4GwxMj32KQ0bmGTEGf9pPYU/P dRThS77p8x8tg== Received: from lists1.osuosl.org (lists1.osuosl.org [140.211.166.142]) by smtp4.osuosl.org (Postfix) with ESMTP id 77F034154C; Fri, 2 May 2025 09:36:20 +0000 (UTC) Received: from smtp1.osuosl.org (smtp1.osuosl.org [IPv6:2605:bc80:3010::138]) by lists1.osuosl.org (Postfix) with ESMTP id E25B11A4 for ; Fri, 2 May 2025 09:36:18 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp1.osuosl.org (Postfix) with ESMTP id CCF9983BE6 for ; Fri, 2 May 2025 09:36:18 +0000 (UTC) X-Virus-Scanned: amavis at osuosl.org Received: from smtp1.osuosl.org ([127.0.0.1]) by localhost (smtp1.osuosl.org [127.0.0.1]) (amavis, port 10024) with ESMTP id A6ro9PhXbzKc for ; Fri, 2 May 2025 09:36:18 +0000 (UTC) Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.234.252.31; helo=sea.source.kernel.org; envelope-from=horms@kernel.org; receiver= DMARC-Filter: OpenDMARC Filter v1.4.2 smtp1.osuosl.org 3DBC683BF4 DKIM-Filter: OpenDKIM Filter v2.11.0 smtp1.osuosl.org 3DBC683BF4 Received: from sea.source.kernel.org (sea.source.kernel.org [172.234.252.31]) by smtp1.osuosl.org (Postfix) with ESMTPS id 3DBC683BF4 for ; Fri, 2 May 2025 09:36:18 +0000 (UTC) Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by sea.source.kernel.org (Postfix) with ESMTP id 5055D4A83C; Fri, 2 May 2025 09:36:15 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9BF07C4CEE4; Fri, 2 May 2025 09:36:13 +0000 (UTC) Date: Fri, 2 May 2025 10:36:10 +0100 From: Simon Horman To: Brian Vazquez Cc: Brian Vazquez , Tony Nguyen , Przemek Kitszel , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , intel-wired-lan@lists.osuosl.org, David Decotigny , Anjali Singhai , Sridhar Samudrala , linux-kernel@vger.kernel.org, netdev@vger.kernel.org, emil.s.tantilov@intel.com, Josh Hay , Luigi Rizzo Message-ID: <20250502093610.GE3339421@horms.kernel.org> References: <20250428195532.1590892-1-brianvv@google.com> <20250501151616.GA3339421@horms.kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: X-Mailman-Original-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1746178577; bh=nNsPW6XIz1dfXDGedIBWReECqLV2gSOT1oJoe6xzPy0=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=CkWn2BuLyal3lMk+03qVPnGB4YzEZb/iTNj8WHzyeTeRjRaQY6H1mgAM8Vy+fKaQ6 PGnuHlP7uy5OJqhnBE919YK/fkOdJEfdWOymkh/J2ToOIFTk2tVfhJnzK5hOmlGbpG SLH8uG4SnafT8Ys0wGFYUTcq8fiOWNsLyghLw92N6l+bQkzQA6RqZAsV1r9S+Fbsa5 t1VUXX656s3deliP0xdGbc2ISD29RUesIuAn/hm6LoXnQ+sCwwAyTks99Pliwd9nv5 IIpJJW1qtkRZsC906bV5eoWzbTkhdk8ORB9DmrF2kzI+mf/f13RqCXE3B+koh80/OC i17ZgFJitjoqQ== X-Mailman-Original-Authentication-Results: smtp1.osuosl.org; dmarc=pass (p=quarantine dis=none) header.from=kernel.org X-Mailman-Original-Authentication-Results: smtp1.osuosl.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20201202 header.b=CkWn2BuL Subject: Re: [Intel-wired-lan] [iwl-net PATCH v2] idpf: fix a race in txq wakeup X-BeenThere: intel-wired-lan@osuosl.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Intel Wired Ethernet Linux Kernel Driver Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: intel-wired-lan-bounces@osuosl.org Sender: "Intel-wired-lan" On Thu, May 01, 2025 at 12:51:48PM -0400, Brian Vazquez wrote: > On Thu, May 1, 2025 at 11:16 AM Simon Horman wrote: > > > > On Mon, Apr 28, 2025 at 07:55:32PM +0000, Brian Vazquez wrote: > > > Add a helper function to correctly handle the lockless > > > synchronization when the sender needs to block. The paradigm is > > > > > > if (no_resources()) { > > > stop_queue(); > > > barrier(); > > > if (!no_resources()) > > > restart_queue(); > > > } > > > > > > netif_subqueue_maybe_stop already handles the paradigm correctly, but > > > the code split the check for resources in three parts, the first one > > > (descriptors) followed the protocol, but the other two (completions and > > > tx_buf) were only doing the first part and so race prone. > > > > > > Luckily netif_subqueue_maybe_stop macro already allows you to use a > > > function to evaluate the start/stop conditions so the fix only requires > > > the right helper function to evaluate all the conditions at once. > > > > > > The patch removes idpf_tx_maybe_stop_common since it's no longer needed > > > and instead adjusts separately the conditions for singleq and splitq. > > > > > > Note that idpf_rx_buf_hw_update doesn't need to check for resources > > > since that will be covered in idpf_tx_splitq_frame. > > > > Should the above read idpf_tx_buf_hw_update() rather than > > idpf_rx_buf_hw_update()? > > Nice catch, that's a typo indeed. Thanks. I only noticed because on reading the above I was looking at idpf_rx_buf_hw_update(). Which turned out to not be very useful in the context of reviewing this patch. > > If so, I see that this is true when idpf_tx_buf_hw_update() is called from > > idpf_tx_singleq_frame(). But is a check required in the case where > > idpf_rx_buf_hw_update() is called by idpf_tx_singleq_map()? > > No, the check is not required. The call is at the end of > idpf_tx_singleq_map at that point you already checked for resources > and you're about to send the pkt. Thanks for the clarification. In that case this patch looks good to me. (But please do fix the typo.) Reviewed-by: Simon Horman From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 30362230BF0; Fri, 2 May 2025 09:36:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1746178579; cv=none; b=ai7MH7/rhu98Uls+lscjWkwwqtJmidbaHFzo7o8H7AbQwR6krgUE3pyUIk8RMhOMhzgVRRESu9KNUjKrHpYBARnSz6fUHugEh5zaJhNHF8z+t+xGO1iTa5XiAjqP7LP6QevPegllFWfEPL/TgrYiQd9q+tA84PXNLCD0EPmRr68= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1746178579; c=relaxed/simple; bh=nNsPW6XIz1dfXDGedIBWReECqLV2gSOT1oJoe6xzPy0=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=r8TeDDX1Pxquwroazs3lwjA3GLHg6m2gLNhIxY37rc2ChD+JrMZZ8a1Nean9i8ms3WogU9WsQEgAEZHi/j42bTtG8LkYlp9H9tOGRgvo54XWVwdKAMILQNGm2KlZ7G3/nbkzGD/vTF9P3dYKCJoURlyPp9uLyHuqFaOG0D5Lbo4= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=CkWn2BuL; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="CkWn2BuL" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9BF07C4CEE4; Fri, 2 May 2025 09:36:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1746178577; bh=nNsPW6XIz1dfXDGedIBWReECqLV2gSOT1oJoe6xzPy0=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=CkWn2BuLyal3lMk+03qVPnGB4YzEZb/iTNj8WHzyeTeRjRaQY6H1mgAM8Vy+fKaQ6 PGnuHlP7uy5OJqhnBE919YK/fkOdJEfdWOymkh/J2ToOIFTk2tVfhJnzK5hOmlGbpG SLH8uG4SnafT8Ys0wGFYUTcq8fiOWNsLyghLw92N6l+bQkzQA6RqZAsV1r9S+Fbsa5 t1VUXX656s3deliP0xdGbc2ISD29RUesIuAn/hm6LoXnQ+sCwwAyTks99Pliwd9nv5 IIpJJW1qtkRZsC906bV5eoWzbTkhdk8ORB9DmrF2kzI+mf/f13RqCXE3B+koh80/OC i17ZgFJitjoqQ== Date: Fri, 2 May 2025 10:36:10 +0100 From: Simon Horman To: Brian Vazquez Cc: Brian Vazquez , Tony Nguyen , Przemek Kitszel , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , intel-wired-lan@lists.osuosl.org, David Decotigny , Anjali Singhai , Sridhar Samudrala , linux-kernel@vger.kernel.org, netdev@vger.kernel.org, emil.s.tantilov@intel.com, Josh Hay , Luigi Rizzo Subject: Re: [iwl-net PATCH v2] idpf: fix a race in txq wakeup Message-ID: <20250502093610.GE3339421@horms.kernel.org> References: <20250428195532.1590892-1-brianvv@google.com> <20250501151616.GA3339421@horms.kernel.org> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: On Thu, May 01, 2025 at 12:51:48PM -0400, Brian Vazquez wrote: > On Thu, May 1, 2025 at 11:16 AM Simon Horman wrote: > > > > On Mon, Apr 28, 2025 at 07:55:32PM +0000, Brian Vazquez wrote: > > > Add a helper function to correctly handle the lockless > > > synchronization when the sender needs to block. The paradigm is > > > > > > if (no_resources()) { > > > stop_queue(); > > > barrier(); > > > if (!no_resources()) > > > restart_queue(); > > > } > > > > > > netif_subqueue_maybe_stop already handles the paradigm correctly, but > > > the code split the check for resources in three parts, the first one > > > (descriptors) followed the protocol, but the other two (completions and > > > tx_buf) were only doing the first part and so race prone. > > > > > > Luckily netif_subqueue_maybe_stop macro already allows you to use a > > > function to evaluate the start/stop conditions so the fix only requires > > > the right helper function to evaluate all the conditions at once. > > > > > > The patch removes idpf_tx_maybe_stop_common since it's no longer needed > > > and instead adjusts separately the conditions for singleq and splitq. > > > > > > Note that idpf_rx_buf_hw_update doesn't need to check for resources > > > since that will be covered in idpf_tx_splitq_frame. > > > > Should the above read idpf_tx_buf_hw_update() rather than > > idpf_rx_buf_hw_update()? > > Nice catch, that's a typo indeed. Thanks. I only noticed because on reading the above I was looking at idpf_rx_buf_hw_update(). Which turned out to not be very useful in the context of reviewing this patch. > > If so, I see that this is true when idpf_tx_buf_hw_update() is called from > > idpf_tx_singleq_frame(). But is a check required in the case where > > idpf_rx_buf_hw_update() is called by idpf_tx_singleq_map()? > > No, the check is not required. The call is at the end of > idpf_tx_singleq_map at that point you already checked for resources > and you're about to send the pkt. Thanks for the clarification. In that case this patch looks good to me. (But please do fix the typo.) Reviewed-by: Simon Horman