From: Jens Axboe <axboe@kernel.dk>
To: Kent Overstreet <kent.overstreet@linux.dev>,
linux-bcachefs@vger.kernel.org
Cc: Jann Horn <jannh@google.com>
Subject: Re: [PATCH] bcachefs: dio write: Take ref on mm_struct when using asynchronously
Date: Wed, 27 Nov 2024 14:47:47 -0700 [thread overview]
Message-ID: <09129809-d3b0-43ad-88d5-aee2bc0d04ba@kernel.dk> (raw)
In-Reply-To: <20241127213649.1615078-1-kent.overstreet@linux.dev>
On 11/27/24 2:36 PM, Kent Overstreet wrote:
> When invoked from aio, mm_struct is guaranteed to outlive the request
> since its lifetime is tied to the io_context - but that's not the case
> for io_uring, it's possible that a process could be killed and mm_struct
> goes away while a request is in flight.
>
> So if we're submitting the rest of the io asynchronously, we may need a
> ref on mm_struct.
>
> Per Jens, this is not actually a bug because we're not yet flipping on
> FMODE_NOWAIT, meaning io_uring will do the submission from an io_worker
> kthread - but this patch is necessary for safely flipping on
> FMODE_NOWAIT for more efficient submissions in the future.
This doesn't look right. The mmgrab looks fine, but that should be
paired with mmdrop. And you still need an mmget_not_zero() before doing
kthread_use_mm(), and then the mmput/mmdrop when after unuse done.
--
Jens Axboe
next prev parent reply other threads:[~2024-11-27 21:47 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-11-27 21:36 [PATCH] bcachefs: dio write: Take ref on mm_struct when using asynchronously Kent Overstreet
2024-11-27 21:47 ` Jens Axboe [this message]
2024-11-27 21:48 ` Jann Horn
2024-11-27 22:11 ` Kent Overstreet
2024-11-27 22:21 ` Jens Axboe
2024-11-27 23:11 ` Jann Horn
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=09129809-d3b0-43ad-88d5-aee2bc0d04ba@kernel.dk \
--to=axboe@kernel.dk \
--cc=jannh@google.com \
--cc=kent.overstreet@linux.dev \
--cc=linux-bcachefs@vger.kernel.org \
/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