From: Robert Stupp <snazy@gmx.de>
To: Josef Bacik <josef@toxicpanda.com>, Jan Kara <jack@suse.cz>
Cc: Johannes Weiner <hannes@cmpxchg.org>,
Vlastimil Babka <vbabka@suse.cz>,
Michal Hocko <mhocko@kernel.org>,
"Kirill A. Shutemov" <kirill@shutemov.name>,
Randy Dunlap <rdunlap@infradead.org>,
linux-kernel@vger.kernel.org, Linux MM <linux-mm@kvack.org>,
Andrew Morton <akpm@linux-foundation.org>,
"Potyra, Stefan" <Stefan.Potyra@elektrobit.com>
Subject: Re: mlockall(MCL_CURRENT) blocking infinitely
Date: Wed, 06 Nov 2019 17:39:35 +0100 [thread overview]
Message-ID: <9f6b707c69ceb34e3916b1d47f2e2fa6a4f025ab.camel@gmx.de> (raw)
In-Reply-To: <20191106151429.swqtq2dt4uelhjzn@macbook-pro-91.dhcp.thefacebook.com>
[-- Attachment #1: Type: text/plain, Size: 2880 bytes --]
On Wed, 2019-11-06 at 10:14 -0500, Josef Bacik wrote:
> On Wed, Nov 06, 2019 at 04:05:24PM +0100, Jan Kara wrote:
> > On Wed 06-11-19 09:56:09, Josef Bacik wrote:
> > I don't think this will work. AFAICS faultin_page() just checks
> > whether
> > 'nonblocking' is != NULL but doesn't ever look at its value...
> > Honestly the
> > whole interface is rather weird like lots of things around gup().
> >
>
> Oh what the hell, yeah this is super bonkers. The whole fault path
> probably
> should be cleaned up to handle retry better. This will do the trick
> I think?
I tried the patch, and it seems to fix the `mlockall(MCL_CURRENT)`
issue for "my test.c".
However, shutdown & reboot are still broken - i.e. the console says
"Reached target reboot" and "hangs forever". Shutdown & reboot work
with __get_user_pages_locked(). No clue what the difference there is.
Anyway, I've captured three smaps outputs: from 5.0.21, from
5.3.9+"nonblocking patch", from 5.3.9+"__get_user_pages_locked". All
three look okay to me - although I don't completely understand why some
areas are not locked (-> "Locked: 0kB") - but "Locked" is always equal
to "Pss", so I assume that's fine?
>
> Josef
>
> diff --git a/mm/gup.c b/mm/gup.c
> index 8f236a335ae9..2468789298e6 100644
> --- a/mm/gup.c
> +++ b/mm/gup.c
> @@ -628,7 +628,7 @@ static int faultin_page(struct task_struct *tsk,
> struct vm_area_struct *vma,
> fault_flags |= FAULT_FLAG_WRITE;
> if (*flags & FOLL_REMOTE)
> fault_flags |= FAULT_FLAG_REMOTE;
> - if (nonblocking)
> + if (nonblocking && *nonblocking != 0)
> fault_flags |= FAULT_FLAG_ALLOW_RETRY;
> if (*flags & FOLL_NOWAIT)
> fault_flags |= FAULT_FLAG_ALLOW_RETRY |
> FAULT_FLAG_RETRY_NOWAIT;
> @@ -1237,6 +1237,7 @@ int __mm_populate(unsigned long start, unsigned
> long len, int ignore_errors)
> unsigned long end, nstart, nend;
> struct vm_area_struct *vma = NULL;
> int locked = 0;
> + int nonblocking = 1;
> long ret = 0;
>
> end = start + len;
> @@ -1268,7 +1269,7 @@ int __mm_populate(unsigned long start, unsigned
> long len, int ignore_errors)
> * double checks the vma flags, so that it won't mlock
> pages
> * if the vma was already munlocked.
> */
> - ret = populate_vma_page_range(vma, nstart, nend,
> &locked);
> + ret = populate_vma_page_range(vma, nstart, nend,
> &nonblocking);
> if (ret < 0) {
> if (ignore_errors) {
> ret = 0;
> @@ -1276,6 +1277,14 @@ int __mm_populate(unsigned long start,
> unsigned long len, int ignore_errors)
> }
> break;
> }
> +
> + /*
> + * We dropped the mmap_sem, so we need to re-lock, and
> the next
> + * loop around we won't drop because nonblocking is now
> 0.
> + */
> + if (!nonblocking)
> + locked = 0;
> +
> nend = nstart + ret * PAGE_SIZE;
> ret = 0;
> }
[-- Attachment #2: smaps-5.0.21.txt.gz --]
[-- Type: application/gzip, Size: 1049 bytes --]
[-- Attachment #3: smaps-add-nonblocking.txt.gz --]
[-- Type: application/gzip, Size: 1068 bytes --]
[-- Attachment #4: smaps-get_user_pages_locked.txt.gz --]
[-- Type: application/gzip, Size: 1077 bytes --]
next prev parent reply other threads:[~2019-11-06 16:40 UTC|newest]
Thread overview: 40+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-10-24 7:36 mlockall(MCL_CURRENT) blocking infinitely Robert Stupp
2019-10-24 23:34 ` Randy Dunlap
2019-10-25 9:21 ` Michal Hocko
2019-10-25 11:02 ` Robert Stupp
2019-10-25 11:46 ` Michal Hocko
2019-10-25 11:50 ` Michal Hocko
2019-10-25 11:59 ` Robert Stupp
2019-10-25 13:19 ` Robert Stupp
2019-10-25 11:55 ` Robert Stupp
2019-10-25 12:05 ` Michal Hocko
2019-10-25 12:11 ` Michal Hocko
2019-10-25 13:10 ` Robert Stupp
2019-10-25 13:27 ` Michal Hocko
2019-10-25 13:45 ` Robert Stupp
2019-10-25 13:57 ` Michal Hocko
2019-10-25 14:00 ` Michal Hocko
2019-10-25 15:58 ` Robert Stupp
2019-11-05 13:23 ` Robert Stupp
2019-11-05 15:28 ` Vlastimil Babka
2019-11-05 18:22 ` Johannes Weiner
2019-11-05 20:05 ` Robert Stupp
2019-11-06 10:25 ` Robert Stupp
2019-11-06 11:26 ` Robert Stupp
2019-11-06 12:04 ` Jan Kara
2019-11-06 12:24 ` Robert Stupp
2019-11-06 12:03 ` Jan Kara
2019-11-06 13:45 ` Robert Stupp
2019-11-06 14:35 ` Jan Kara
2019-11-06 15:32 ` Robert Stupp
2019-11-06 14:38 ` Jan Kara
2019-11-06 14:56 ` Josef Bacik
2019-11-06 15:05 ` Jan Kara
2019-11-06 15:14 ` Josef Bacik
2019-11-06 15:25 ` Jan Kara
2019-11-06 16:39 ` Robert Stupp [this message]
2019-11-06 17:03 ` Robert Stupp
2019-11-06 17:25 ` Jan Kara
2019-11-07 8:08 ` Robert Stupp
2019-11-20 12:42 ` Robert Stupp
2019-10-25 13:55 ` Robert Stupp
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=9f6b707c69ceb34e3916b1d47f2e2fa6a4f025ab.camel@gmx.de \
--to=snazy@gmx.de \
--cc=Stefan.Potyra@elektrobit.com \
--cc=akpm@linux-foundation.org \
--cc=hannes@cmpxchg.org \
--cc=jack@suse.cz \
--cc=josef@toxicpanda.com \
--cc=kirill@shutemov.name \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=mhocko@kernel.org \
--cc=rdunlap@infradead.org \
--cc=snazy@snazy.de \
--cc=vbabka@suse.cz \
/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).