From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from sender4-pp-f112.zoho.com (sender4-pp-f112.zoho.com [136.143.188.112]) (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 CBFFF748F for ; Sun, 1 Feb 2026 04:40:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=pass smtp.client-ip=136.143.188.112 ARC-Seal:i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769920845; cv=pass; b=jr98z00R2sSavNSFyFAybRX2euWUP3zw4I46uM6o7GYbcJj2j8s6c5sgzJ34XhTK2Q/WCu25PqxsUp5rB0ESYTEvJyHs0VuIakchkveMELkcnTEHnmBqc7xtaAWy5hJUohhEWeoaXIzyhsqdzvrz36PUPYeeaBbgO0CBzm9FGYg= ARC-Message-Signature:i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769920845; c=relaxed/simple; bh=zx3uK6OUyhKOc8SgSfvJ1t/xjxISwq/GyLbRzxjb8fM=; h=Date:Message-ID:From:To:Cc:Subject:In-Reply-To:References: MIME-Version:Content-Type; b=k4y/A1OJwxqTA7WlSLQellT4WFDB3DrL04sk2nELY+U8N/iq0YdTDA6XwJGIrlf+W4N6LCOKSxm4l9eLiirLyD/MmL3g3JPLTXkHQrA/vFJGNC8Qnevm0VIEzRFAxTvHFfRGUGhxxlJZukPFttp1skSw1jBDvIwjpMCmJ+lszjg= ARC-Authentication-Results:i=2; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=linux.beauty; spf=pass smtp.mailfrom=linux.beauty; dkim=pass (1024-bit key) header.d=linux.beauty header.i=me@linux.beauty header.b=J7MGQwVO; arc=pass smtp.client-ip=136.143.188.112 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=linux.beauty Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.beauty Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.beauty header.i=me@linux.beauty header.b="J7MGQwVO" ARC-Seal: i=1; a=rsa-sha256; t=1769920830; cv=none; d=zohomail.com; s=zohoarc; b=OCH0Bjxk+SCfTxm05bjBFgq9f4ZE/N9hSg5558ja2++fFUBUJVddhSJVFMopSXsyz36NCv8nDboU6ZYev+V9zt/0a3ipmEkipRi8sQOkx+Jk65FemvM7rIcenhKn4dAMmQ7zixo6PSvwBcN3Cu/JrTNNPoMk/aazJ1GBO/b9B5I= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1769920830; h=Content-Type:Cc:Cc:Date:Date:From:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:Subject:To:To:Message-Id:Reply-To; bh=Mg0/vv+N2TY3Mun8A569+YtuS6aKPFTWr3H+LYPY9rA=; b=hKRbiSy8FhZRqq9u0R4HLDG7GR+Vw+Dp7a4GsFnO3w3Kl/k36QlPTVgbh7cXpMaaqhm3cPi9R4io6obN+zVzWVkiFOPutHf1xqKzZkmK/1pRCeoUrbbilLUD2v2jhmd8wzN6SQAzLkuxcrOZ+wwSj+mbUH4NxmCGsqAlNCeHSF8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=linux.beauty; spf=pass smtp.mailfrom=me@linux.beauty; dmarc=pass header.from= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; t=1769920830; s=zmail; d=linux.beauty; i=me@linux.beauty; h=Date:Date:Message-ID:From:From:To:To:Cc:Cc:Subject:Subject:In-Reply-To:References:MIME-Version:Content-Type:Message-Id:Reply-To; bh=Mg0/vv+N2TY3Mun8A569+YtuS6aKPFTWr3H+LYPY9rA=; b=J7MGQwVOA5DBFqc9nmvyy3MYqMbV+CoXlv2LnLe6vejfbudQTIYQ2Ao3r615K5zV r3Zim2UkXrKk2wWEJ5phFZPA85Iphyo6HTOTZnCS+bRIv0xZndDuE00820g63WiTSQE Kec0u5krxFiTAHzQauA3oO+Ad26XuIoGlU5YEPwA= Received: by mx.zohomail.com with SMTPS id 1769920828747568.2122837823392; Sat, 31 Jan 2026 20:40:28 -0800 (PST) Date: Sun, 01 Feb 2026 12:40:15 +0800 Message-ID: <877bsxoz4g.wl-me@linux.beauty> From: Li Chen To: "Michael S. Tsirkin" Cc: Ira Weiny , Dan Williams , Vishal Verma , Dave Jiang , Pankaj Gupta , Cornelia Huck , Jakub Staron , nvdimm@lists.linux.dev, virtualization@lists.linux.dev, linux-kernel@vger.kernel.org Subject: Re: [PATCH] nvdimm: virtio_pmem: serialize flush requests In-Reply-To: <20260131124554-mutt-send-email-mst@kernel.org> References: <20260113034552.62805-1-me@linux.beauty> <697d19fc772ad_f6311008@iweiny-mobl.notmuch> <20260131124554-mutt-send-email-mst@kernel.org> User-Agent: Wanderlust/2.15.9 (Almost Unreal) SEMI-EPG/1.14.7 (Harue) FLIM-LB/1.14.9 (=?ISO-8859-4?Q?Goj=F2?=) APEL-LB/10.8 EasyPG/1.0.0 Emacs/30.2 (x86_64-pc-linux-gnu) MULE/6.0 (HANACHIRUSATO) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 (generated by SEMI-EPG 1.14.7 - "Harue") Content-Type: text/plain; charset=US-ASCII X-ZohoMailClient: External Hi Michael, On Sun, 01 Feb 2026 01:46:19 +0800, Michael S. Tsirkin wrote: > > On Fri, Jan 30, 2026 at 02:52:12PM -0600, Ira Weiny wrote: > > Li Chen wrote: > > > Under heavy concurrent flush traffic, virtio-pmem can overflow its request > > > virtqueue (req_vq): virtqueue_add_sgs() starts returning -ENOSPC and the > > > driver logs "no free slots in the virtqueue". Shortly after that the > > > device enters VIRTIO_CONFIG_S_NEEDS_RESET and flush requests fail with > > > "virtio pmem device needs a reset". > > > > > > Serialize virtio_pmem_flush() with a per-device mutex so only one flush > > > request is in-flight at a time. This prevents req_vq descriptor overflow > > > under high concurrency. > > > > > > Reproducer (guest with virtio-pmem): > > > - mkfs.ext4 -F /dev/pmem0 > > > - mount -t ext4 -o dax,noatime /dev/pmem0 /mnt/bench > > > - fio: ioengine=io_uring rw=randwrite bs=4k iodepth=64 numjobs=64 > > > direct=1 fsync=1 runtime=30s time_based=1 > > > > I don't see this error. > > > > > > 13:28:50 > cat foo.fio > > # test http://lore.kernel.org/20260113034552.62805-1-me@linux.beauty > > > > [global] > > filename=/mnt/bench/foo > > ioengine=io_uring > > size=1G > > bs=4K > > iodepth=64 > > numjobs=64 > > direct=1 > > fsync=1 > > runtime=30s > > time_based=1 > > > > [rand-write] > > rw=randwrite > > > > > > It's possible I'm doing something wrong. Can you share your qemu cmdline > > or more details on the bug yall see. > > > > > - dmesg: "no free slots in the virtqueue" > > > "virtio pmem device needs a reset" > > > > > > Fixes: 6e84200c0a29 ("virtio-pmem: Add virtio pmem driver") > > > Signed-off-by: Li Chen > > > --- > > > drivers/nvdimm/nd_virtio.c | 15 +++++++++++---- > > > drivers/nvdimm/virtio_pmem.c | 1 + > > > drivers/nvdimm/virtio_pmem.h | 4 ++++ > > > 3 files changed, 16 insertions(+), 4 deletions(-) > > > > > > diff --git a/drivers/nvdimm/nd_virtio.c b/drivers/nvdimm/nd_virtio.c > > > index c3f07be4aa22..827a17fe7c71 100644 > > > --- a/drivers/nvdimm/nd_virtio.c > > > +++ b/drivers/nvdimm/nd_virtio.c > > > @@ -44,19 +44,24 @@ static int virtio_pmem_flush(struct nd_region *nd_region) > > > unsigned long flags; > > > int err, err1; > > > > > > + might_sleep(); > > > for that matter might_sleep not really needed near mutex_lock. > > > > > + mutex_lock(&vpmem->flush_lock); Good point. mutex_lock() already does might_sleep(), so the explicit might_sleep() next to the lock is redundant. I'll drop it in v2 (which also switches to guard(mutex) as Ira suggested). Regards, Li