From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.18]) (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 EDBFE4E66C0 for ; Mon, 28 Sep 2026 15:22:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1790608960; cv=none; b=C5QVbK69nvocbDfAI5UHLTpf54iVlwhsUV3OKiPdcEvURMB46k3Dtb0rx0rruJmiC/7VeHomndgD8vlzngvtqEHOVGTC9VESLkDOiWwG5kalXTbnw2CCv9HYDTKLXtKAKwRJvAeMq58+AV1Vf/7t6r/MRbarOKObk1FYra4NAnc= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1790608960; c=relaxed/simple; bh=epB5TBUW1zB5SEcLjdZT7p/4M1HPpDsRXf3ppGpfiiM=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=tES8/B2xcU3bl3Ig9sVNV9E2xbY3eqgFPOk+OQx1N8gToFkbtvS2+bAFpKNRxrvQM849+/nUH/tVJ7/oqRz3+jO53HWEieFV2UzRywkqchYQyCRVyYpLCJhn32TnG4cYMiPZyVYKksVMh484X/QquUA3B27FFEe/xxVu2HZHuJ8= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com; spf=pass smtp.mailfrom=intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=LbuNsDB6; arc=none smtp.client-ip=198.175.65.18 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="LbuNsDB6" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1790608958; x=1822144958; h=message-id:date:mime-version:subject:to:cc:references: from:in-reply-to:content-transfer-encoding; bh=epB5TBUW1zB5SEcLjdZT7p/4M1HPpDsRXf3ppGpfiiM=; b=LbuNsDB6aVCYyZct4BtlTSbg5A4/fWcwtXS8WvPFiZBoHdsuq63eRwPW l539j32z/SpjnKpiui+z0KWpzhPcbnOZcfMryMPPboglJZaNF0KvEti4J +Z8cp2GDxkJCuYkHte7veW7yiM4e2Ff09O9GG2Y4UXMriWpenND/CXKpG IPGxVSxF3p7gzbua6fPbvcFikNHf5/qd+/qC/ueV97t3MBxdlVZkauSP3 Zin0V72v5BDh9eTvQxagpO/tE2A3DYF5LuZEp7AmWGVoESIUZXgG7LzJa YH7OLAKpQ7tjj7UM27RXmy9fqW9v3QS7kG2Gffh+pLMQKFgEauIso4vOY w==; X-CSE-ConnectionGUID: beNpNmnXRQ2BQE4dKUzQkQ== X-CSE-MsgGUID: WC4WgCk3ROCy7BPp/9i84Q== X-IronPort-AV: E=McAfee;i="6800,10657,11919"; a="90362918" X-IronPort-AV: E=Sophos;i="6.27,128,1787036400"; d="scan'208";a="90362918" Received: from orviesa009.jf.intel.com ([10.64.159.149]) by orvoesa110.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 Sep 2026 08:22:36 -0700 X-CSE-ConnectionGUID: oTF1UL8DSCy7IwbqmmQ4ZA== X-CSE-MsgGUID: jDGLJWVNTrWzC6kZoDSmEw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.27,128,1787036400"; d="scan'208";a="275115684" Received: from sghuge-mobl2.amr.corp.intel.com (HELO [10.125.111.79]) ([10.125.111.79]) by orviesa009-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 Sep 2026 08:22:35 -0700 Message-ID: <82407c03-e208-41b9-a9ca-6a5bbe60f3a7@intel.com> Date: Mon, 28 Sep 2026 08:22:33 -0700 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v2 11/14] NTB: ntb_transport: Prepare remote RX info accesses for MW teardown To: Koichiro Den Cc: Jon Mason , Allen Hubbe , Frank Li , Logan Gunthorpe , fuyuanli , Greg Kroah-Hartman , Nicholas Bellinger , Joey Zhang , ntb@lists.linux.dev, linux-kernel@vger.kernel.org References: <20260910040836.3792333-1-den@valinux.co.jp> <20260910040836.3792333-12-den@valinux.co.jp> <11a47b77-b140-46df-bee6-3484e18ad62e@intel.com> <879429f5-b209-49ef-be1c-184eb7d5783b@intel.com> From: Dave Jiang Content-Language: en-US In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit On 9/28/26 1:51 AM, Koichiro Den wrote: > On Thu, Sep 24, 2026 at 08:57:49AM -0700, Dave Jiang wrote: >> >> >> On 9/24/26 8:56 AM, Dave Jiang wrote: >>> >>> >>> On 9/9/26 9:08 PM, Koichiro Den wrote: >>>> The next patch clears remote_rx_info when freeing its MW. >>>> ntb_transport_tx_free_entry() and debugfs stats reads can run during >>>> link cleanup, so make them handle a NULL pointer. >>>> >>>> The pointer is accessed locklessly. Use READ_ONCE() and WRITE_ONCE() >>>> to prevent compiler-induced tearing, and retain the read value so >>>> the NULL check and dereference use the same pointer. >>>> >>>> Cc: stable@vger.kernel.org >>>> Signed-off-by: Koichiro Den >>> >>> Reviewed-by: Dave Jiang >> >> Probably should take a look at the sashiko raised issue. > > I looked into it and thought we might as well fix the TX/MW teardown race too. > In fact, with patch 14, transport removal stops netdev TX and its timer before > freeing MWs, but ordinary link-down cleanup doesn't wait for them. > I gave this a try locally, but it all ended up being quite a rework.. > > So for this series, I'd just drop WARN_ON_ONCE(!ntb_transport_tx_free_entry(qp)) > from ntb_async_tx(). > > The caller already checks for space. Clean-up can clear remote_rx_info before > this second check, which now returns 0 and trips the WARN. The WARN doesn't stop > TX anyway. > > This won't fix the existing lifetime race, but it does remove the new warning > Sashiko pointed out. I'd leave the broader fix for separate work. Still, > returning 0 when we see a cleared pointer seems at least better than > dereferencing a stale one. > > I'm planning to send v3 with this one-line deletion, but if you have a better > idea, please let me know. Nope, this is fine.