From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailout1.samsung.com (mailout1.samsung.com [203.254.224.24]) (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 85272419FDC for ; Mon, 27 Jul 2026 13:31:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=203.254.224.24 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785159085; cv=none; b=aqWaOd0PoMRDAx2ioUZz5CjJqjzdgG72PZGZR3sHHUMVWmsMv9d93veqQ80pYQd41Uofk5SlcmGI254Bm6F2goYZ7BgmQtDbGOWlnBp+VJoE901N8gyHY33pAsStth5MZiNa0VJAXGDoiegFCkA2ElOCwbKX6ADL9WxpQ8YaQFk= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785159085; c=relaxed/simple; bh=VRrcKaB4U/LNyUJxhoiAxCDJ/6blMe+yunzCBjfdnGY=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:From:In-Reply-To: Content-Type:References; b=Q3N0Xg78TL1MZrWdUIDQo/JiaxURImsHLxMWvGcBfhEh6y+dAtcxTSAhdwY8gFOqsmwNi+AgZgJVz0JeYiXm/YNGl3oTp5eLtTq4wn65pw1XMlDJOsqIzQL3rsy6bZIirOV/y3VxY1k5+S50IOxJiqCDoufqgkJdV9Kcp8MJz7Y= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=samsung.com; spf=pass smtp.mailfrom=samsung.com; dkim=pass (1024-bit key) header.d=samsung.com header.i=@samsung.com header.b=MlE9GDQg; arc=none smtp.client-ip=203.254.224.24 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=samsung.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=samsung.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=samsung.com header.i=@samsung.com header.b="MlE9GDQg" Received: from epcas5p4.samsung.com (unknown [182.195.41.42]) by mailout1.samsung.com (KnoxPortal) with ESMTP id 20260727133120epoutp01d632c92a93202f893aa017140ed75d16~GKLmxZlvT2366323663epoutp01i for ; Mon, 27 Jul 2026 13:31:20 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout1.samsung.com 20260727133120epoutp01d632c92a93202f893aa017140ed75d16~GKLmxZlvT2366323663epoutp01i DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1785159080; bh=ZheSaNgHeOAB2uoTnWJoErBgw1OSg4botxZ264U/G2U=; h=Date:Subject:To:Cc:From:In-Reply-To:References:From; b=MlE9GDQgPpNECnshKnGVLieC8WlQFhaefk6ZrmLcmOaEbf49k1jNJ4ZKcrlgQb+Dz jB0KR64uFbeV4YgpdkvYHfqK1bNPW1X9BtD5PvACY1Onrha8tG+a8RuuriMVEig7iM 6gmKoTxHFVEA3iqc8IFFJa64XqX6KxKTY0VARZ/A= Received: from epsnrtp02.localdomain (unknown [182.195.42.154]) by epcas5p3.samsung.com (KnoxPortal) with ESMTPS id 20260727133119epcas5p357219960b64ad6df82701504be2b1ff4~GKLmRD8mj2121821218epcas5p32; Mon, 27 Jul 2026 13:31:19 +0000 (GMT) Received: from epcas5p1.samsung.com (unknown [182.195.38.93]) by epsnrtp02.localdomain (Postfix) with ESMTP id 4h7zyG5hbWz2SSKY; Mon, 27 Jul 2026 13:31:18 +0000 (GMT) Received: from epsmtip1.samsung.com (unknown [182.195.34.30]) by epcas5p3.samsung.com (KnoxPortal) with ESMTPA id 20260727133118epcas5p37b42a06ff71c22e769ce7d3c516aa7c1~GKLk7dwu62121821218epcas5p30; Mon, 27 Jul 2026 13:31:18 +0000 (GMT) Received: from [107.122.11.51] (unknown [107.122.11.51]) by epsmtip1.samsung.com (KnoxPortal) with ESMTPA id 20260727133116epsmtip10a0d9d475d5739a337ad81ea59aa4f88~GKLjjIuIf2283822838epsmtip1h; Mon, 27 Jul 2026 13:31:16 +0000 (GMT) Message-ID: <7c3e3243-0c9a-436b-b5c2-e6092e181435@samsung.com> Date: Mon, 27 Jul 2026 19:01:15 +0530 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 1/2] nvme: fix racy access to FDP placement ID array To: Hari Mishal , Keith Busch , Jens Axboe , Christoph Hellwig , Sagi Grimberg Cc: Hannes Reinecke , Nitesh Shetty , Greg Kroah-Hartman , linux-nvme@lists.infradead.org, linux-kernel@vger.kernel.org Content-Language: en-US From: Kanchan Joshi In-Reply-To: <20260725135111.14041-2-harimishal1@gmail.com> Content-Transfer-Encoding: 7bit X-CMS-MailID: 20260727133118epcas5p37b42a06ff71c22e769ce7d3c516aa7c1 X-Msg-Generator: CA Content-Type: text/plain; charset="utf-8" CMS-TYPE: 105P cpgsPolicy: CPGSC10-542,Y X-CFilter-Loop: Reflected X-CMS-RootMailID: 20260725135125epcas5p26801513d440f066295ef2d44035ce3db References: <20260725135111.14041-1-harimishal1@gmail.com> <20260725135111.14041-2-harimishal1@gmail.com> On 7/25/2026 7:21 PM, Hari Mishal wrote: > --- a/drivers/nvme/host/core.c > +++ b/drivers/nvme/host/core.c > @@ -1018,15 +1018,19 @@ static inline blk_status_t nvme_setup_rw(struct nvme_ns *ns, > if (req->cmd_flags & REQ_RAHEAD) > dsmgmt |= NVME_RW_DSM_FREQ_PREFETCH; > > - if (op == nvme_cmd_write && ns->head->nr_plids) { > - u16 write_stream = req->bio->bi_write_stream; > - > - if (WARN_ON_ONCE(write_stream > ns->head->nr_plids)) > - return BLK_STS_INVAL; > - > - if (write_stream) { > - dsmgmt |= ns->head->plids[write_stream - 1] << 16; > - control |= NVME_RW_DTYPE_DPLCMT; > + if (op == nvme_cmd_write) { > + scoped_guard(spinlock, &ns->head->fdp_lock) { > + u16 write_stream = req->bio->bi_write_stream; > + > + if (ns->head->nr_plids) { > + if (WARN_ON_ONCE(write_stream > ns->head->nr_plids)) > + return BLK_STS_INVAL; > + > + if (write_stream) { > + dsmgmt |= ns->head->plids[write_stream - 1] << 16; > + control |= NVME_RW_DTYPE_DPLCMT; > + } > + } It will be nice not to have the impact on the fast-path performance. The spin-lock is being taken for each write, regardless of FDP-enabled config. And for fdp-enabled config also, bi_write_stream may just be 0.