Received: by 2002:a25:d7c1:0:0:0:0:0 with SMTP id o184csp2818554ybg; Thu, 24 Oct 2019 15:59:27 -0700 (PDT) X-Google-Smtp-Source: APXvYqwWmE26+E4rg3RNhOGt2yg/jzy5dmqtKkln6rmB+9wxuk1BkbJhF593J6zYaHSD7DFCsWbE X-Received: by 2002:a17:907:4451:: with SMTP id mw1mr540322ejb.209.1571957967254; Thu, 24 Oct 2019 15:59:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571957967; cv=none; d=google.com; s=arc-20160816; b=Ll7HbJ5qeqMgxPx2UeLUhAoI4+0pYWZm/lTCjY6EC1Urgh1v07FgBZBZKmN7XcUKRH MavfmsdKMm/nYyj8czbXqmovT0XP4UYF9R6kaPeujOd7hBDYbELwPxD5Xnk0kLJa737U QQ/2P10ETDpP8gQ4z7LOptXm7/Vq96WnR8non0QYJlNXwNX0HgXjYCgdY2edUwIp/9Cp P7WOVer+KFcmLP0ZqxGR3HP0xNeZrsdnL5fhGSKbczNJQoKt9JqfIlthBEg1tjSg+A29 VTMChq9v7TD6hdaBF+W40T+3N7KQQ3RefkEU/U1MbRVGVYPV8WA9m56xRA1potc/ak7D DFYw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-language :content-transfer-encoding:mime-version:user-agent:date:message-id :subject:from:to; bh=NmAuHaYr91DOU9qM17J7+kzC3/JnxpWM0zcas3Zg03U=; b=Ry15l8oFdrIxwG0VHxES85eh8y8h6rI/HO6gO74sntXZEo5ExIemtrYATdtipS1cXt kn5oW0HvRBGi+MrvbokT51k2Xlg308iiGMVKiVEHKvaR6/+pNABXpupgkUoBFwjcdPzT zsudYQxyrTiWg/ZL3h1eWOndH5eJ5ywltwXVuTMSmhg58HQ6r21aT6cYRhlMkbjS0i9G 6n+bTOIQD6btwjNnukpfzD3jAnooEud+CJRxQyKvbvoKIwf4q+M3Ilm5fsehQtnBJPrf /1jSWFgfI71Y8ZHS8boiH8NkMTvokJ/DU5jKzL8gYgSRtIHwQBmqaIzgsnYQJ21U69sm 3Xpg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id u2si108925ejr.332.2019.10.24.15.59.03; Thu, 24 Oct 2019 15:59:27 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2408824AbfJXH7h (ORCPT + 99 others); Thu, 24 Oct 2019 03:59:37 -0400 Received: from wp051.webpack.hosteurope.de ([80.237.132.58]:35610 "EHLO wp051.webpack.hosteurope.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2405209AbfJXH7g (ORCPT ); Thu, 24 Oct 2019 03:59:36 -0400 X-Greylist: delayed 1378 seconds by postgrey-1.27 at vger.kernel.org; Thu, 24 Oct 2019 03:59:36 EDT Received: from p200300cd5f0509008cc3eaf0bbac9dd5.dip0.t-ipconnect.de ([2003:cd:5f05:900:8cc3:eaf0:bbac:9dd5]); authenticated by wp051.webpack.hosteurope.de running ExIM with esmtpsa (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) id 1iNXfh-0002uw-UO; Thu, 24 Oct 2019 09:36:37 +0200 To: linux-kernel@vger.kernel.org From: Robert Stupp Subject: mlockall(MCL_CURRENT) blocking infinitely Message-ID: <4576b336-66e6-e2bb-cd6a-51300ed74ab8@snazy.de> Date: Thu, 24 Oct 2019 09:36:37 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.1.2 MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Content-Language: en-US X-bounce-key: webpack.hosteurope.de;snazy@snazy.de;1571903976;f6e34a93; X-HE-SMSGID: 1iNXfh-0002uw-UO Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 #include 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 #include 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 #include #include 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 #include 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 #include 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 -- Robert Stupp @snazy