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 9E134C4167B for ; Mon, 4 Dec 2023 09:27:55 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 0368C6B0266; Mon, 4 Dec 2023 04:27:55 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id F00846B0269; Mon, 4 Dec 2023 04:27:54 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id DA1706B026A; Mon, 4 Dec 2023 04:27:54 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id C3F016B0266 for ; Mon, 4 Dec 2023 04:27:54 -0500 (EST) Received: from smtpin13.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 95A75C0174 for ; Mon, 4 Dec 2023 09:27:54 +0000 (UTC) X-FDA: 81528608868.13.B185574 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by imf14.hostedemail.com (Postfix) with ESMTP id 7B6BA100004 for ; Mon, 4 Dec 2023 09:27:52 +0000 (UTC) Authentication-Results: imf14.hostedemail.com; dkim=none; dmarc=pass (policy=none) header.from=arm.com; spf=pass (imf14.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=1701682073; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=OEuNTYcd+HKYTOzx1XxSaw/6N75Kl5Qzvg4FVovrJeg=; b=iEqf5Vx67zHmUoAzjfRbYDweOABgGg9DTCISrtqTh0768HR7v+eJ4HVL+M+KT69ISESprB DfsLDIagTakEmzWJdSle1/aZpkZDPsR8xAqHxwwgQd7IAhNucpXuwdNtRidHEz1qDIYB95 d77qgvN9tjgOFrtnfd7c967xxEfqi2I= ARC-Authentication-Results: i=1; imf14.hostedemail.com; dkim=none; dmarc=pass (policy=none) header.from=arm.com; spf=pass (imf14.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=1701682073; a=rsa-sha256; cv=none; b=tnz24xetYws7aLx70tLNnfzzzqAPl6SgIAWZwQuTLHGbwOAy51dgaXzFhdKYUXU6pF3CTD 4286QW8ApC/Ds8KILvJPUd3MSKax1SZTMXSuzbE6r+i1i1ZXxEQ7BjipLj1nShMVMZkdCt fazTe90GNWIoTsj8+v/+Eq8HqWmlI/k= 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 702AA1650; Mon, 4 Dec 2023 01:28:38 -0800 (PST) Received: from [10.57.73.130] (unknown [10.57.73.130]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id A46113F6C4; Mon, 4 Dec 2023 01:27:47 -0800 (PST) Message-ID: <744be4e0-48e0-4c77-825c-711386dd205f@arm.com> Date: Mon, 4 Dec 2023 09:27:45 +0000 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v5 5/5] selftests/mm: add UFFDIO_MOVE ioctl test Content-Language: en-GB To: Suren Baghdasaryan , David Hildenbrand Cc: akpm@linux-foundation.org, viro@zeniv.linux.org.uk, brauner@kernel.org, shuah@kernel.org, aarcange@redhat.com, lokeshgidra@google.com, peterx@redhat.com, hughd@google.com, mhocko@suse.com, axelrasmussen@google.com, rppt@kernel.org, willy@infradead.org, Liam.Howlett@oracle.com, jannh@google.com, zhangpeng362@huawei.com, bgeffon@google.com, kaleshsingh@google.com, ngeoffray@google.com, jdduke@google.com, linux-mm@kvack.org, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, kernel-team@android.com References: <20231121171643.3719880-1-surenb@google.com> <20231121171643.3719880-6-surenb@google.com> From: Ryan Roberts In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspam-User: X-Stat-Signature: rx7x34efqjbri6kzgfsu6atabr47w1y6 X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: 7B6BA100004 X-HE-Tag: 1701682072-419624 X-HE-Meta: U2FsdGVkX182tk/n4lkg9ixI6IgiG2+uuidH3DtqXVQsGfrifunHBurGhSk9XWIeXyARJHHpCa7MRzBwiW5s/zerclzZgan2VGwBFPLxlBcQvcZwt4i3sH97xo9JX6Hfdng3g0g9OZAqVg9MqfvE2cg/ZOTfyKyTL94N9AyROaWFCQu7saCcV4lt8j4yeYD7M1pIt1iMiV059+ana1KYzmfibyFDfSXRChooqlbi86IaiNWC4kipNkvoPRK9Oy/P9kHTxNaPim89Ag9+yNbbBD02inz+Jtf7nqziB6Tzr6TBK5NsbJK4/lFMN82fl6gOxBbCWWMX2carUmCrjGApOVKav65rS2i2QN/Tktm5RDffjAFNwrqnRFgXRkeM4A2eJMY6voAahZtPcMM6SxcMj91P04WpOcCaCT1B3VsF3b9Gn+dLBhstl+oZ7y2hNqNVjkAQPB8L4XJFHoaiskhW6Zlr6a9vtTTxIVF8igZkNDJ3+QEnLfeX00OTGzhwPoyD+CbeKhBAlTV+GRix10s1cMS6q8RSf19+LjGyAMZgpDEvi9ds24VHRr3FE6HVfuBorOm9ZZIOinKCYZfunWDUbvygzMj3DxqQnwkEywx2nE/6KQjk4Ts0FmHv1pEf+aHFq6ea7T7yxbTTAZ/zy9GXwTnecTm2afO10nw+pmW6mq727xeI0Po4b9s6UGh0+YnGmnppq15ddb3Vkum6Vppuh+SCZr9y7B/6YFANKMBZuPB3jMUI1d2VPB3bwjLl79xVZqEZP0mLeNZzRQkmP0sIR+xH243grPBnjE8bej88hD9qrvVex7mHqhn/5GpqeDQULex5+3bG95HVriP+pHIvFm8dOleKn56tZY2y5EqAB9LKnqLhl6enP/SAggVRRcuZJzsnmZ+6vkhKLbB2LzyXXDRDIqVx5tfXr9Kdl0Gq/esn31DDz6fyGM2GDr9MMS43wGoOWRdnoptD40KcXH2 AluvMznb Cw7b7bdXa3K2LuJ5NUeR/6D1oSqFLbdkYP1Y4mTicT5UF9h/R0+uSQf5K8eKhnYoFdnQgaupMPlhRYZBDOMZTKxKxFbKc9XVKEboywarrrhnYK3czyL37lJB4cosEfpCK3JyeeTNUOD1vmiC3wOfo0+Yx1ZEFi0nT9APMmpDp2GtWUq2cir2Ar13Q2GTYkhhKlefwUYfc1OEiEnUJqizzL7it7qGuztWmbTX4qmPGzJORiRfMDmW7tYJTkQ== 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: List-Subscribe: List-Unsubscribe: On 04/12/2023 04:09, Suren Baghdasaryan wrote: > On Sat, Dec 2, 2023 at 2:11 AM David Hildenbrand wrote: >> >> On 02.12.23 09:04, Ryan Roberts wrote: >>> On 01/12/2023 20:47, David Hildenbrand wrote: >>>> On 01.12.23 10:29, Ryan Roberts wrote: >>>>> On 21/11/2023 17:16, Suren Baghdasaryan wrote: >>>>>> Add tests for new UFFDIO_MOVE ioctl which uses uffd to move source >>>>>> into destination buffer while checking the contents of both after >>>>>> the move. After the operation the content of the destination buffer >>>>>> should match the original source buffer's content while the source >>>>>> buffer should be zeroed. Separate tests are designed for PMD aligned and >>>>>> unaligned cases because they utilize different code paths in the kernel. >>>>>> >>>>>> Signed-off-by: Suren Baghdasaryan >>>>>> --- >>>>>> tools/testing/selftests/mm/uffd-common.c | 24 +++ >>>>>> tools/testing/selftests/mm/uffd-common.h | 1 + >>>>>> tools/testing/selftests/mm/uffd-unit-tests.c | 189 +++++++++++++++++++ >>>>>> 3 files changed, 214 insertions(+) >>>>>> >>>>>> diff --git a/tools/testing/selftests/mm/uffd-common.c >>>>>> b/tools/testing/selftests/mm/uffd-common.c >>>>>> index fb3bbc77fd00..b0ac0ec2356d 100644 >>>>>> --- a/tools/testing/selftests/mm/uffd-common.c >>>>>> +++ b/tools/testing/selftests/mm/uffd-common.c >>>>>> @@ -631,6 +631,30 @@ int copy_page(int ufd, unsigned long offset, bool wp) >>>>>> return __copy_page(ufd, offset, false, wp); >>>>>> } >>>>>> +int move_page(int ufd, unsigned long offset, unsigned long len) >>>>>> +{ >>>>>> + struct uffdio_move uffdio_move; >>>>>> + >>>>>> + if (offset + len > nr_pages * page_size) >>>>>> + err("unexpected offset %lu and length %lu\n", offset, len); >>>>>> + uffdio_move.dst = (unsigned long) area_dst + offset; >>>>>> + uffdio_move.src = (unsigned long) area_src + offset; >>>>>> + uffdio_move.len = len; >>>>>> + uffdio_move.mode = UFFDIO_MOVE_MODE_ALLOW_SRC_HOLES; >>>>>> + uffdio_move.move = 0; >>>>>> + if (ioctl(ufd, UFFDIO_MOVE, &uffdio_move)) { >>>>>> + /* real retval in uffdio_move.move */ >>>>>> + if (uffdio_move.move != -EEXIST) >>>>>> + err("UFFDIO_MOVE error: %"PRId64, >>>>>> + (int64_t)uffdio_move.move); >>>>> >>>>> Hi Suren, >>>>> >>>>> FYI this error is triggering in mm-unstable (715b67adf4c8): >>>>> >>>>> Testing move-pmd on anon... ERROR: UFFDIO_MOVE error: -16 (errno=16, >>>>> @uffd-common.c:648) >>>>> >>>>> I'm running in a VM on Apple M2 (arm64). I haven't debugged any further, but >>>>> happy to go deeper if you can direct. >>>> >>>> Does it trigger reliably? Which pagesize is that kernel using? >>> >>> Yep, although very occasionally it fails with EAGAIN. 4K kernel; see other email >>> for full config. >>> >>>> >>>> I can spot that uffd_move_pmd_test()/uffd_move_pmd_handle_fault() uses >>>> default_huge_page_size(), which reads the default hugetlb size. >>> >>> My kernel command line is explicitly seting the default huge page size to 2M. >>> >> >> Okay, so that likely won't affect it. >> >> I can only guess that it has to do with the alignment of the virtual >> area we are testing with, and that we do seem to get more odd patterns >> on arm64. >> >> uffd_move_test_common() is a bit more elaborate, but if we aligned the >> src+start area up, surely "step_count" cannot be left unmodified? >> >> So assuming we get either an unaligned source or an unaligned dst from >> mmap(), I am not convinced that we won't be moving areas that are not >> necessarily fully backed by PMDs and maybe don't even fall into the VMA >> of interest? >> >> Not sure if that could trigger the THP splitting issue, though. >> >> But I just quickly scanned that test setup, could be I am missing >> something. It might make sense to just print the mmap'ed range and the >> actual ranges we are trying to move. Maybe something "obvious" can be >> observed. > > I was able to reproduce the issue on an Android device and after > implementing David's suggestions to split the large folio and after > replacing default_huge_page_size() with read_pmd_pagesize(), the > move-pmd test started working for me. Ryan, could you please apply > attached patches (over mm-unstable) and try the test again? Yep, all fixed with those patches! > Thanks, > Suren. > >> >> -- >> Cheers, >> >> David / dhildenb >>