From: sashiko-bot@kernel.org
To: "Li Chen" <me@linux.beauty>
Cc: nvdimm@lists.linux.dev
Subject: Re: [PATCH v7 04/12] nvdimm: virtio_pmem: stop allocating child flush bio
Date: Tue, 30 Jun 2026 10:28:16 +0000 [thread overview]
Message-ID: <20260630102817.24AA31F00A3A@smtp.kernel.org> (raw)
In-Reply-To: <20260630092338.2094628-5-me@linux.beauty>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] Block I/O Forward Progress / Deadlock due to missing mempool backing for flush allocations
--
commit e290d67d3c09c47f258d895e86c79743d39db2c1
Author: Li Chen <me@linux.beauty>
nvdimm: virtio_pmem: stop allocating child flush bio
This commit avoids allocating a child PREFLUSH bio during REQ_FUA
submission by queuing an ordered WQ_MEM_RECLAIM work item. It allows
provider flush callbacks to return NVDIMM_FLUSH_ASYNC after taking
ownership of parent bio completion.
> diff --git a/drivers/nvdimm/nd_virtio.c b/drivers/nvdimm/nd_virtio.c
> index 4176046627beb..8e16b7780be1a 100644
> --- a/drivers/nvdimm/nd_virtio.c
> +++ b/drivers/nvdimm/nd_virtio.c
[ ... ]
> @@ -107,30 +113,46 @@ static int virtio_pmem_flush(struct nd_region *nd_region)
> return err;
> };
>
> +static void virtio_pmem_flush_work(struct work_struct *work)
> +{
> + struct virtio_pmem_flush_work *flush;
> + int err;
> +
> + flush = container_of(work, struct virtio_pmem_flush_work, work);
> + err = virtio_pmem_flush(flush->nd_region);
[ ... ]
> int async_pmem_flush(struct nd_region *nd_region, struct bio *bio)
> {
> - /*
> - * Create child bio for asynchronous flush and chain with
> - * parent bio. Otherwise directly call nd_region flush.
> - */
> - if (bio && bio->bi_iter.bi_sector != -1) {
> - struct bio *child = bio_alloc(bio->bi_bdev, 0,
> - REQ_OP_WRITE | REQ_PREFLUSH,
> - GFP_ATOMIC);
> + struct virtio_device *vdev = nd_region->provider_data;
> + struct virtio_pmem *vpmem = vdev->priv;
> + struct virtio_pmem_flush_work *flush;
> + int err;
>
> - if (!child)
> + if (bio && bio->bi_iter.bi_sector != -1) {
> + flush = kmalloc_obj(*flush, GFP_NOIO);
[Severity: High]
Can this cause a deadlock during memory reclaim?
Order-0 allocations with GFP_NOIO (which includes __GFP_DIRECT_RECLAIM)
can loop indefinitely in the page allocator's slowpath rather than failing.
Since this lacks mempool backing and is directly in the block I/O
submission path, couldn't the block submission thread block waiting
for memory, deadlocking if memory cannot be freed without this block I/O
completing?
> + if (!flush)
> return -ENOMEM;
> - bio_clone_blkg_association(child, bio);
> - child->bi_iter.bi_sector = -1;
> - bio_chain(child, bio);
> - submit_bio(child);
> - return 0;
> +
> + INIT_WORK(&flush->work, virtio_pmem_flush_work);
> + flush->nd_region = nd_region;
> + flush->bio = bio;
> + queue_work(vpmem->flush_wq, &flush->work);
[Severity: High]
Is it safe to queue work on a WQ_MEM_RECLAIM workqueue when the worker
function performs a non-mempool-backed GFP_NOIO allocation?
If the system is under severe memory pressure, the workqueue falls back
to its rescuer thread to ensure forward progress. The rescuer executes
virtio_pmem_flush_work() -> virtio_pmem_flush(), which allocates memory:
drivers/nvdimm/nd_virtio.c:virtio_pmem_flush() {
...
req_data = kmalloc_obj(*req_data, GFP_NOIO);
...
}
Since GFP_NOIO includes __GFP_DIRECT_RECLAIM, the rescuer thread could
block indefinitely in direct reclaim trying to allocate req_data. Doesn't
this stall the rescuer thread and prevent pending flush completions from
making forward progress?
> + return NVDIMM_FLUSH_ASYNC;
> }
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260630092338.2094628-1-me@linux.beauty?part=4
next prev parent reply other threads:[~2026-06-30 10:28 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-30 9:23 [PATCH v7 00/12] nvdimm: virtio_pmem: fix flush/request failure paths Li Chen
2026-06-30 9:23 ` [PATCH v7 01/12] nvdimm: preserve flush callback -ENOMEM Li Chen
2026-06-30 9:23 ` [PATCH v7 02/12] nvdimm: pmem: keep PREFLUSH before data writes Li Chen
2026-06-30 9:23 ` [PATCH v7 03/12] nvdimm: pmem: guard data loop for dataless bios Li Chen
2026-06-30 9:23 ` [PATCH v7 04/12] nvdimm: virtio_pmem: stop allocating child flush bio Li Chen
2026-06-30 10:28 ` sashiko-bot [this message]
2026-06-30 9:23 ` [PATCH v7 05/12] nvdimm: virtio_pmem: use GFP_NOIO for flush requests Li Chen
2026-06-30 10:42 ` sashiko-bot
2026-06-30 9:23 ` [PATCH v7 06/12] nvdimm: virtio_pmem: always wake -ENOSPC waiters Li Chen
2026-06-30 9:23 ` [PATCH v7 07/12] nvdimm: virtio_pmem: use READ_ONCE()/WRITE_ONCE() for wait flags Li Chen
2026-06-30 9:23 ` [PATCH v7 08/12] nvdimm: virtio_pmem: refcount requests for token lifetime Li Chen
2026-06-30 9:23 ` [PATCH v7 09/12] nvdimm: virtio_pmem: publish done with release/acquire Li Chen
2026-06-30 9:23 ` [PATCH v7 10/12] nvdimm: virtio_pmem: isolate DMA request buffers Li Chen
2026-06-30 9:23 ` [PATCH v7 11/12] nvdimm: virtio_pmem: converge broken virtqueue to -EIO Li Chen
2026-06-30 11:50 ` sashiko-bot
2026-06-30 9:23 ` [PATCH v7 12/12] nvdimm: virtio_pmem: drain requests in freeze Li Chen
2026-06-30 9:47 ` [PATCH v7 00/12] nvdimm: virtio_pmem: fix flush/request failure paths Pankaj Gupta
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260630102817.24AA31F00A3A@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=me@linux.beauty \
--cc=nvdimm@lists.linux.dev \
--cc=sashiko-reviews@lists.linux.dev \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox