Received: by 2002:a05:7412:b10a:b0:f3:1519:9f41 with SMTP id az10csp1350900rdb; Fri, 1 Dec 2023 13:59:44 -0800 (PST) X-Google-Smtp-Source: AGHT+IHRHvw1oK5N45EtkqaqKWS9nh82zqxePdJvpI4SARHxFQNyLDYPtX5OJQiFhXl1Hpiope2Y X-Received: by 2002:a05:6a20:139a:b0:18b:ca68:4e9a with SMTP id hn26-20020a056a20139a00b0018bca684e9amr202880pzc.28.1701467983976; Fri, 01 Dec 2023 13:59:43 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701467983; cv=none; d=google.com; s=arc-20160816; b=oRKhBxhv0k+KlYBEPxl0udscKKcY8o+eg5/iJLr1Gwm29Rcoyb4yA4uNTVjzL7cTsG S7SMG8q5sWG+8mxQMUPblLcjF7flfPoVzXaSTuqI3Itr1MogOf421/sRV5cM7YxZC2x3 fpKpFftG3dcB/GI88xpRJux4aHPByHnu6szLc6HBBsrqlkA4Rip5nHbeN8g9iAQ+1ct4 qJMKlbnzRYCJ/LJprD6EMwRFm/wxz2WNneG29BTT54bNZFRpw5WYB83q3XFfetC4abIX 1VmuiSMt/7lJ73d2yIK2fZVeL+N1oaPCwdzwbJr84vhfeWQt4eYIH9Sy0OmwgfPCsbBc GnwQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=Z+exs5h/ORFFX83E63BLP4xoRIe35RXovt/mscKVvNI=; fh=BonCDYkT2j1VY/AgyhOKqEQ33f4iRxSkOH4YtEHP3pE=; b=r1lEqsV9+2RMhHufc3jB46QGo9E5VZ14kE8hZd6B5muOvumxRVkEHmzA9dMdc2YQlj JzdCg0TD5871vFahwHJUgLFznANpJYfCBdMZNljptO9pWRecoTAX8uCwGrZtjuQcnCwN 8S2pby4ixD5NNH5rWxsSIfGBE37dmzPX9+S9aPepeMc91p2WLz6FvtD0UwI7oqJdnD8Y HUDVq9oYyucw3Yg1yeOrbAqt07kHYBdXaNMokeZ0eTHvVkgoJKodBJYYMrI6PIgQsG8d 5Bk02GqFk1zbEx9Lo3hXF1aNb5eZDiGeLMQDfEFy1LjoED2NWjl8JxWtktCytFhIxmQM maog== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=hX6VTg28; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from fry.vger.email (fry.vger.email. [23.128.96.38]) by mx.google.com with ESMTPS id f22-20020a635116000000b005be007363a4si3831488pgb.669.2023.12.01.13.59.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 Dec 2023 13:59:43 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) client-ip=23.128.96.38; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=hX6VTg28; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by fry.vger.email (Postfix) with ESMTP id 80C0882696D7; Fri, 1 Dec 2023 13:59:39 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at fry.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229552AbjLAV7W (ORCPT + 99 others); Fri, 1 Dec 2023 16:59:22 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58724 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229456AbjLAV7U (ORCPT ); Fri, 1 Dec 2023 16:59:20 -0500 Received: from mail-yw1-x1134.google.com (mail-yw1-x1134.google.com [IPv6:2607:f8b0:4864:20::1134]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B864DFF for ; Fri, 1 Dec 2023 13:59:26 -0800 (PST) Received: by mail-yw1-x1134.google.com with SMTP id 00721157ae682-5d400779f16so10606647b3.0 for ; Fri, 01 Dec 2023 13:59:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1701467966; x=1702072766; darn=vger.kernel.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=Z+exs5h/ORFFX83E63BLP4xoRIe35RXovt/mscKVvNI=; b=hX6VTg28CCxCeP57YZmXo477YSgmH93Dw4fBMR4wa6zhQtrlFGN42dTJW7ffMyR2CE vAl1PUUYT91fOBJfopsUCUmAArwAU/VlXXeMGz5isSl2Of77vITRovW1K3zBV9xyb6x/ KF/Q9DLL8h61WDxD5pTUbV55HXMS1+wiPLdBdZlMrzgejIPbQuH9TyOBSG6+RPX7iyxJ H8lRnSppJWjq8j4vS8hgcP5RY9WmKYYEZv4al4VbPGw/seqJTkfGMlmuoO1bX93eVAb5 nrrvinDEAAMx+dOteVgfbjAyhpSDOX90IBDRwxDtT8COoK3qtagPQW8Pz4x5gnhfgFzM 7Yhg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701467966; x=1702072766; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Z+exs5h/ORFFX83E63BLP4xoRIe35RXovt/mscKVvNI=; b=ZjX4VoQ5DHvUA/gQjBelB9O1CW0c33n3hwj7c9DDtPbMcFMlA4nFDLxUqpnyq089HW oGtYugu9skF/nVSNoTb/+pHjGqNa/tmLhu3w7FZ83dBGuHXzAmRUMGTBMCYoq3bPIY4Z hcN8/iH/JZ/0PN2KWdpF+E34YXS/tdS+pRx2Fixuf3ApOWnrd5GyU/EnB06SM6Ml9cwN Mswc205swSH4kbPyDTAfb4KdyMj7pzqvWbHXecT0BPlNxHNzwYmjfLjOosUHppSxPk7O VHS8GVbA/FqhGltGT9dWxUBkwEGC5BOQZiUmSY2/Xk/QhRCiNat0wrs6acGtYtbqcYfL /XZg== X-Gm-Message-State: AOJu0YzdgmB4+X348fv99OAxCzWcJZfSZUm6IwXJMpb9+P3jccR6atYp lqiVotrrHWIf1neZc4DidDdYDr2KCS02BQ1ftgGx9A== X-Received: by 2002:a0d:e684:0:b0:5d7:1a33:5ad3 with SMTP id p126-20020a0de684000000b005d71a335ad3mr115182ywe.32.1701467965712; Fri, 01 Dec 2023 13:59:25 -0800 (PST) MIME-Version: 1.0 References: <20231121171643.3719880-1-surenb@google.com> <20231121171643.3719880-6-surenb@google.com> In-Reply-To: From: Suren Baghdasaryan Date: Fri, 1 Dec 2023 13:59:14 -0800 Message-ID: Subject: Re: [PATCH v5 5/5] selftests/mm: add UFFDIO_MOVE ioctl test To: David Hildenbrand Cc: Ryan Roberts , 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 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-8.4 required=5.0 tests=DKIMWL_WL_MED,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE, USER_IN_DEF_DKIM_WL autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on fry.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (fry.vger.email [0.0.0.0]); Fri, 01 Dec 2023 13:59:39 -0800 (PST) On Fri, Dec 1, 2023 at 12:47=E2=80=AFPM 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 a= nd > >> unaligned cases because they utilize different code paths in the kerne= l. > >> > >> 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 =3D (unsigned long) area_dst + offset; > >> + uffdio_move.src =3D (unsigned long) area_src + offset; > >> + uffdio_move.len =3D len; > >> + uffdio_move.mode =3D UFFDIO_MOVE_MODE_ALLOW_SRC_HOLES; > >> + uffdio_move.move =3D 0; > >> + if (ioctl(ufd, UFFDIO_MOVE, &uffdio_move)) { > >> + /* real retval in uffdio_move.move */ > >> + if (uffdio_move.move !=3D -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=3D16, > > @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? > > I can spot that uffd_move_pmd_test()/uffd_move_pmd_handle_fault() uses > default_huge_page_size(), which reads the default hugetlb size. > > That, however, does not necessarily correspond to the THP size. That one > can be obtained using read_pmd_pagesize() in vm_util.c Oh, I didn't realize that default_huge_page_size() is not always the actual THP size. Will fix. > > I quickly scanned the code (still want to take a deeper look), but all > PAE checks looked sane to me. > > I think the issue is folio split handling. I replied to the patch. Thanks for your hint! That's very possibly the reason for the test failure. I'm in the process of trying to reproduce this issue on ARM64. If I'm unable to do so then I'll create a patch to split PTE-mapped THP when encountered and will ask Ryan to try that. Thanks, Suren. > > -- > Cheers, > > David / dhildenb >