From: Dmitry Bogdanov <d.bogdanov@yadro.com>
To: Chris Leech <cleech@redhat.com>
Cc: Keith Busch <kbusch@kernel.org>, Jens Axboe <axboe@kernel.dk>,
"Christoph Hellwig" <hch@lst.de>,
Sagi Grimberg <sagi@grimberg.me>,
Stuart Hayes <stuart.w.hayes@gmail.com>,
<linux-nvme@lists.infradead.org>, <linux-kernel@vger.kernel.org>,
<linux@yadro.com>, <stable@vger.kernel.org>
Subject: Re: [PATCH] nvme-tcp: fix usage of page_frag_cache
Date: Wed, 1 Oct 2025 19:41:52 +0300 [thread overview]
Message-ID: <20251001164152.GB4234@yadro.com> (raw)
In-Reply-To: <20250930-feminine-dry-42d2705c778a@redhat.com>
On Tue, Sep 30, 2025 at 11:31:26PM -0700, Chris Leech wrote:
>
> On Mon, Sep 29, 2025 at 02:19:51PM +0300, Dmitry Bogdanov wrote:
> > nvme uses page_frag_cache to preallocate PDU for each preallocated request
> > of block device. Block devices are created in parallel threads,
> > consequently page_frag_cache is used in not thread-safe manner.
> > That leads to incorrect refcounting of backstore pages and premature free.
> >
> > That can be catched by !sendpage_ok inside network stack:
> >
> > WARNING: CPU: 7 PID: 467 at ../net/core/skbuff.c:6931 skb_splice_from_iter+0xfa/0x310.
> > tcp_sendmsg_locked+0x782/0xce0
> > tcp_sendmsg+0x27/0x40
> > sock_sendmsg+0x8b/0xa0
> > nvme_tcp_try_send_cmd_pdu+0x149/0x2a0
> > Then random panic may occur.
> >
> > Fix that by serializing the usage of page_frag_cache.
>
> Thank you for reporting this. I think we can fix it without blocking the
> async namespace scanning with a mutex, by switching from a per-queue
> page_frag_cache to per-cpu. There shouldn't be a need to keep the
> page_frag allocations isolated by queue anyway.
>
> It would be great if you could test the patch which I'll send after
> this.
>
As I commented on your patch, a naive per-cpu cache solution is
error-prone. The complete solution will be unnecessaryly difficult.
Block device creation is not a data plane, it is a control plane, so
there is no sense to use there lockless algorithms.
My patch is a simple and error-proof already.
So, I insist on this solution.
BR,
Dmitry
next prev parent reply other threads:[~2025-10-01 16:42 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-09-29 11:19 [PATCH] nvme-tcp: fix usage of page_frag_cache Dmitry Bogdanov
2025-10-01 6:31 ` Chris Leech
2025-10-01 16:41 ` Dmitry Bogdanov [this message]
2025-10-01 6:34 ` [PATCH] nvme-tcp: switch to per-cpu page_frag_cache Chris Leech
2025-10-01 16:24 ` Dmitry Bogdanov
-- strict thread matches above, loose matches on Subject: below --
2026-07-16 14:42 [PATCH] nvme-tcp: fix usage of page_frag_cache Daniel Wagner
2026-08-06 12:46 ` Daniel Wagner
2026-08-10 23:40 ` Keith Busch
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=20251001164152.GB4234@yadro.com \
--to=d.bogdanov@yadro.com \
--cc=axboe@kernel.dk \
--cc=cleech@redhat.com \
--cc=hch@lst.de \
--cc=kbusch@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-nvme@lists.infradead.org \
--cc=linux@yadro.com \
--cc=sagi@grimberg.me \
--cc=stable@vger.kernel.org \
--cc=stuart.w.hayes@gmail.com \
/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