From: Randy Dunlap <rdunlap@infradead.org>
To: Robert Stupp <snazy@snazy.de>,
linux-kernel@vger.kernel.org, Linux MM <linux-mm@kvack.org>
Cc: Andrew Morton <akpm@linux-foundation.org>,
"Potyra, Stefan" <Stefan.Potyra@elektrobit.com>
Subject: Re: mlockall(MCL_CURRENT) blocking infinitely
Date: Thu, 24 Oct 2019 16:34:46 -0700 [thread overview]
Message-ID: <b8ff71f5-2d9c-7ebb-d621-017d4b9bc932@infradead.org> (raw)
In-Reply-To: <4576b336-66e6-e2bb-cd6a-51300ed74ab8@snazy.de>
[adding linux-mm + people]
I see only one change in the last 4 years:
commit dedca63504a204dc8410d98883fdc16dffa8cb80
Author: Potyra, Stefan <Stefan.Potyra@elektrobit.com>
Date: Thu Jun 13 15:55:55 2019 -0700
mm/mlock.c: mlockall error for flag MCL_ONFAULT
On 10/24/19 12:36 AM, Robert Stupp wrote:
> Hi guys,
>
> I've got an issue with `mlockall(MCL_CURRENT)` after upgrading Ubuntu 19.04 to 19.10 - i.e. kernel version change from 5.0.x to 5.3.x.
>
> The following simple program hangs forever with one CPU running at 100% (kernel):
>
> #include <stdio.h>
> #include <sys/mman.h>
> int main(char** argv) {
> printf("Before mlockall(MCL_CURRENT)\n");
> // works in 5.0
> // hangs forever w/ 5.1 and newer
> mlockall(MCL_CURRENT);
> printf("After mlockall(MCL_CURRENT)\n");
> }
>
> All kernel versions since 5.1 (tried 5.1.0, 5.1.21, 5.2.21, 5.3.0-19, 5.3.7, 5.4-rc4) show the same symptom (hanging in mlockall(MCL_CURRENT) with 100% kernel-CPU). 5.0 kernel versions (5.0.21) are fine.
>
> First, I thought, that it's something generic, so I tried the above program in a fresh install of Ubuntu eoan (5.3.x) in a VM in virtualbox, but it works fine there. So I suspect, that it has to do with something that's specific to my machine.
>
> My first suspicion was that some library "hijacks" mlockall(), but calling the test program with `LD_DEBUG=all` shows that glibc gets called directly:
> 12248: symbol=mlockall; lookup in file=./test [0]
> 12248: symbol=mlockall; lookup in file=/lib/x86_64-linux-gnu/libc.so.6 [0]
> 12248: binding file ./test [0] to /lib/x86_64-linux-gnu/libc.so.6 [0]: normal symbol `mlockall' [GLIBC_2.2.5]
> An `strace` doesn't show anything meaningful (beside that mlockall's been called but never returns). dmesg and syslog don't show anything obvious (to me) as well.
>
> Some information about the machine:
> - Intel(R) Core(TM) i7-6900K, Intel X99 chipset
> - NVMe 1.1b
> - 64GB RAM (4x 16GB)
>
> I've also reverted all changes for sysctl and ld.conf and checked for other suspicious software without any luck.
>
> I also tried a bunch of variations of the above program, but only `mlockall(MCL_CURRENT)` or `mlockall(MCL_FUTURE | MCL_CURRENT)` hang.
>
> A `git diff v5.0..v5.1 mm/` doesn't show anything obvious (to me).
>
> It seems, there's no debug/trace information that would help to find out what exactly it's doing.
>
> I'm kinda lost at the moment.
>
>
> PS: Variations of the above test program:
>
> #include <stdio.h>
> #include <sys/mman.h>
> char foo[65536];
> int main(char** argv) {
> printf("Before mlock()\n");
> int e = mlock(foo, 8192); // works in 5.0, 5.1, 5.2, 5.3, 5.4
> printf("After mlock()=%d\n", e);
> }
>
>
> #include <stdio.h>
> #include <stdlib.h>
> #include <sys/mman.h>
> int main(char** argv) {
> printf("Before mlockall(MCL_FUTURE)\n");
> int e = mlockall(MCL_FUTURE); // works in 5.0, 5.1, 5.2, 5.3, 5.4
> printf("After mlockall(MCL_FUTURE) = %d\n", e);
> void* mem = malloc(1024 * 1024 * 1024);
> printf("After malloc()\n");
> mem = malloc(1024 * 1024 * 1024);
> printf("After malloc()\n");
> mem = malloc(1024 * 1024 * 1024);
> printf("After malloc()\n");
> // works in 5.0, 5.1, 5.2, 5.3, 5.4
> }
>
>
> #include <stdio.h>
> #include <sys/mman.h>
> int main(char** argv) {
> printf("Before munlockall()\n");
> int e = munlockall(); // works in 5.0, 5.1, 5.2, 5.3, 5.4
> printf("After munlockall() = %d\n", e);
> }
>
>
> #include <stdio.h>
> #include <sys/mman.h>
> int main(char** argv) {
> printf("Before mlockall(MCL_CURRENT|MCL_FUTURE)\n");
> // works in 5.0
> // hangs forever w/ 5.1 and newer
> int e = mlockall(MCL_CURRENT|MCL_FUTURE);
> printf("After mlockall(MCL_CURRENT|MCL_FUTURE) = %d\n", e);
> }
>
> PPS: Kernel version images installed from https://kernel.ubuntu.com/~kernel-ppa/mainline/?C=N;O=D
>
--
~Randy
next parent reply other threads:[~2019-10-24 23:34 UTC|newest]
Thread overview: 39+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <4576b336-66e6-e2bb-cd6a-51300ed74ab8@snazy.de>
2019-10-24 23:34 ` Randy Dunlap [this message]
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
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=b8ff71f5-2d9c-7ebb-d621-017d4b9bc932@infradead.org \
--to=rdunlap@infradead.org \
--cc=Stefan.Potyra@elektrobit.com \
--cc=akpm@linux-foundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=snazy@snazy.de \
/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