From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 40EE0EB64DC for ; Tue, 11 Jul 2023 15:30:53 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id B07DF6B0075; Tue, 11 Jul 2023 11:30:52 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id AB7766B0078; Tue, 11 Jul 2023 11:30:52 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 9A6076B007B; Tue, 11 Jul 2023 11:30:52 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id 8A7AA6B0075 for ; Tue, 11 Jul 2023 11:30:52 -0400 (EDT) Received: from smtpin01.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id A658C160327 for ; Tue, 11 Jul 2023 15:30:51 +0000 (UTC) X-FDA: 80999718702.01.B50A940 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by imf02.hostedemail.com (Postfix) with ESMTP id 90BA280045 for ; Tue, 11 Jul 2023 15:30:47 +0000 (UTC) Authentication-Results: imf02.hostedemail.com; dkim=none; dmarc=pass (policy=none) header.from=arm.com; spf=pass (imf02.hostedemail.com: domain of ryan.roberts@arm.com designates 217.140.110.172 as permitted sender) smtp.mailfrom=ryan.roberts@arm.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1689089448; a=rsa-sha256; cv=none; b=ourCbv+czCz8xlP3yiDbK+3PZWsyxzEIdx9wxePDUb0m4e0vmJUwmJYn8THMXvo5kw2f0V lvpiof+Cps5Oe6BeU7K/VbLWMmUFyP3Ccg3bEPE55qHINOnW9slms2VLKaMKFPT7rpyEtd Avq0zlfTFwPumkmzHU5iYsjAi7F8vXk= ARC-Authentication-Results: i=1; imf02.hostedemail.com; dkim=none; dmarc=pass (policy=none) header.from=arm.com; spf=pass (imf02.hostedemail.com: domain of ryan.roberts@arm.com designates 217.140.110.172 as permitted sender) smtp.mailfrom=ryan.roberts@arm.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1689089448; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=OQ3sxiXtbguqPvv0dof5p8/7OqVLrBCcj3APuphOjZg=; b=mwdZ0Ec15Cx0ctJpL0P7J5LakEBsSHVgEGmhLwToQ1ZiI9TXkexwyrx0jOeufuWAmI9xVq WcHp9JYsYlT9wE+rLO171/eEU1pod0CdKH0fqJ83932vqw5KsplZEkPbjOlyXNiT4hRxD1 YIpVB5DFk1/SaCEHkZBaiSd/PTFashA= Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id D996D1FB; Tue, 11 Jul 2023 08:31:27 -0700 (PDT) Received: from [10.1.37.54] (C02Z41KALVDN.cambridge.arm.com [10.1.37.54]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 341713F740; Tue, 11 Jul 2023 08:30:45 -0700 (PDT) Message-ID: <6fa76b99-24b3-9410-66c4-d765ef8f4c52@arm.com> Date: Tue, 11 Jul 2023 16:30:43 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:102.0) Gecko/20100101 Thunderbird/102.13.0 Subject: Re: [PATCH v4 18/49] mlock: Convert mlock to vma iterator To: "Liam R. Howlett" , linux-mm@kvack.org, linux-kernel@vger.kernel.org, Andrew Morton , maple-tree@lists.infradead.org References: <20230120162650.984577-1-Liam.Howlett@oracle.com> <20230120162650.984577-19-Liam.Howlett@oracle.com> <50341ca1-d582-b33a-e3d0-acb08a65166f@arm.com> <20230711152734.hith252qxjbnz4bt@revolver> From: Ryan Roberts In-Reply-To: <20230711152734.hith252qxjbnz4bt@revolver> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Rspamd-Server: rspam08 X-Rspamd-Queue-Id: 90BA280045 X-Stat-Signature: 1be1nb1s6q63n9f3aggz1jksrt4eqqfc X-Rspam-User: X-HE-Tag: 1689089447-851256 X-HE-Meta: U2FsdGVkX1+QQgEkCv4Mho5qZOGCcIuFoYRBEbk6wuvJvJPGl+RErG66bAOuWkvQgum3oUmfKtzq1LtDnbPvsfurj8Di7/dmBStLL+g5sFVYIBWUvckrN/M1D/AqfP91fGWI1E6gUyjV+dz3LdYrcdQPCSfgNYa+iO48N8RmnXs8ygL9aiaWhLLVLHhaU7M7gt+08QhK+fxNeg2Hp7h8xZ0Dp4n1TdGXUt/uTy6K5XJTyPPUNJ9jCZ9uaa4dvbGfQc8kZRvyh/IhvgkNk3Nu9ljp7AkRK7YE/v6ou9V0BeiQiJCLNFp07ueAvzn1ZUs89PqQV/AiqBRJzEiJ/RgMm4OpkSKaiumadKpUhmwLQvmJg0ibPCEAqRcETIdMpHba3jLoHOHZHLju3KBRLmfCl5cRJtOTqrH4ddGgsE6I7FHxdfhP/j4pGXmcHq4wbkLeJuTtTVbqkmAA1ivX4n8Z1iHEgRLgf1aUex4JdNzF/sicXqXE7B1Sp6QCy04gZA50g4TIk2jKzKIxhH5nfia/f0JNRkA9Zt8YtQiEpq99/lyUf57OUE+BI4kP6d/Tzwwvm+gIUyKc624dHuh5hhsJ8h8LNW8pxjvW2IYN/FkIGy3NG11R7xOXvTORnWOaj6RNHS5Y9OwU+2Pc2XkctAUF8lkN5ud5rECjr2JQSOFPt9KlNbcloPS3SRk6S/V5jzxaWcTsaMoc2sG8iDWxkfB3efTEjCYsd9VP1zer8A7ByYX9k8q6+vxagerptV5ptfj6xpmO1L2MJIMXmHrDWRy1rl2HIJGDlCkg0TbdIP1ZlS0NnjyjLbg4aOudZ1c7R7vf6kQy2Y7lO58iJYpdVgfFqtQg3YxpV7v/SNWCzjs7JwB+t32N28x7Hg9oNWmpGb7/Qk8fhT7wsu561ywMoCIkkGBkOyZR8KvsFo5ab4EVv2wivoQmJuCpRcYGdXBeATYGwy5jWH/RCSB9qAI3mya 26JTUvEk RNHmYQUEB9cPGggsESEeNMW4aRtQD+RqMyL3oFHAJ+EcnG51Ssiy/1gAMQc6ePwzxR+RRqT/c2T/THXK1Rw3q9OMOkHyd8xhUGRcZYnPFtq/ca3D/vutvbt3mAt8UNOayJyoYzcdnAsf8GnCJPuDrIH6G7ExuBRbf1/9GcA83z8XPZ0cSbDLb1btYyA== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On 11/07/2023 16:27, Liam R. Howlett wrote: > * Ryan Roberts [230711 10:09]: >> On 20/01/2023 16:26, Liam R. Howlett wrote: >>> From: "Liam R. Howlett" >>> >>> Use the vma iterator so that the iterator can be invalidated or updated >>> to avoid each caller doing so. >> >> Hi, > > > Hello! > >> >> I've bisected 2 mm selftest regressions back to this patch, so hoping someone can help debug and fix? The failures are reproducible on x86_64 and arm64. > > Thanks! That is a big help. Where did you start your bisection? I > assume 6.4? Yes, I'm working to get all the mm selftests running (and ideally passing!) on arm64. I working on v6.4 and it was broken there. I went arbitrarily back to v5.10 and it was working there, so bisected between them. > >> >> >> mlock-random-test: >> >> $ ./run_kselftest.sh -t mm:mlock-random-test >> TAP version 13 >> 1..1 >> # selftests: mm: mlock-random-test >> mlock() failure at |0xaaaaaaab52d0(131072)| mlock:|0xaaaaaaacc65d(26551)| >> not ok 1 selftests: mm: mlock-random-test # exit=255 >> >> This mallocs a buffer then loops 100 times, trying to mlock random parts of it. After this patch, the test fails after a variable number of iterations; mlock() returns ENOMEM. If I explicitly munlock at the end of each loop, it works. >> >> >> mlock2-tests: >> >> $ ./run_kselftest.sh -t mm:mlock2-tests >> TAP version 13 >> 1..1 >> # selftests: mm: mlock2-tests >> munlock(): Cannot allocate memory >> munlock(): Cannot allocate memory >> not ok 1 selftests: mm: mlock2-tests # exit=2 >> >> Here, a 3 page buffer is mlock2()ed, then the middle page is munlocked. Finally the whole 3 page range is munlocked, and after this patch it fails with ENOMEM. If I modify the test to split the final munlock into 2, one for the first page and one for the last, the test passes. >> >> >> Immediately prior to this patch (2286a6914c77 "mm: change mprotect_fixup to vma iterator"), both tests pass. >> >> From a quick scan of the man page, I don't think it explicitly says that its ok to call mlock/munlock on already locked/unlocked pages, but it's certainly a change of behavior and the tests notice, so I'm guessing this wasn't intentional? >> >> I'm not familiar with this code so it's not obvious to me exactly what the problem is, but I'm hoping someone can help debug? > > I think I see the issue and I'm working on a fix. I appreciate the > analysis and report, it really helps narrow things down. You're welcome! > > Regards, > Liam