From: Michal Hocko <mhocko@kernel.org>
To: Jens Axboe <axboe@kernel.dk>
Cc: linux-mm <linux-mm@kvack.org>
Subject: Re: schedule/sleep over mmget()
Date: Fri, 19 Jun 2020 13:43:13 +0200 [thread overview]
Message-ID: <20200619114313.GC12177@dhcp22.suse.cz> (raw)
In-Reply-To: <398032e7-7cbf-3a28-75a7-f6586465f0c6@kernel.dk>
On Thu 18-06-20 09:20:40, Jens Axboe wrote:
> Hi,
>
> Got a question that I couldn't immediately find an answer to. io_uring
> currently jumps through a few hoops to avoid holding a process mm over
> schedule, and it doesn't look like that's necessary.
>
> Is it fine for a kthread to do mmget/kthread_use_mm at the start, and
> only put/unuse when it exits? Or is it more prudent to drop/re-acquire
> over schedule for potential longer periods of idleness?
Pinning the address space for a long time is not really ideal. This
would prevent quite a lot of memory to be released when the primary
owner of the address space goes away (willingly or by the OOM killer).
Our documentation says
* Never use this function to pin this address space for an
* unbounded/indefinite amount of time.
If you know the kthread is not going to use the mm for some time just
pin the mm struct itsef by mmgrab() and then mmget_not_zero() to get the
address space for your use again.
--
Michal Hocko
SUSE Labs
next prev parent reply other threads:[~2020-06-19 11:43 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-06-18 15:20 schedule/sleep over mmget() Jens Axboe
2020-06-19 11:43 ` Michal Hocko [this message]
2020-06-19 13:59 ` Jens Axboe
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=20200619114313.GC12177@dhcp22.suse.cz \
--to=mhocko@kernel.org \
--cc=axboe@kernel.dk \
--cc=linux-mm@kvack.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;
as well as URLs for NNTP newsgroup(s).