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 X-Spam-Level: X-Spam-Status: No, score=-16.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id EEF0EC47089 for ; Thu, 27 May 2021 20:23:59 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 9411361360 for ; Thu, 27 May 2021 20:23:59 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 9411361360 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 2D8686B006C; Thu, 27 May 2021 16:23:59 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 2AEAE6B0093; Thu, 27 May 2021 16:23:59 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 129516B0095; Thu, 27 May 2021 16:23:59 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0228.hostedemail.com [216.40.44.228]) by kanga.kvack.org (Postfix) with ESMTP id D86CE6B006C for ; Thu, 27 May 2021 16:23:58 -0400 (EDT) Received: from smtpin39.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id 7C5471803D420 for ; Thu, 27 May 2021 20:23:58 +0000 (UTC) X-FDA: 78188137356.39.6D1488B Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by imf02.hostedemail.com (Postfix) with ESMTP id 9FDB94142C51 for ; Thu, 27 May 2021 20:23:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1622147037; h=from:from: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=Uq4QT2ZrcVHt/byJv1ujYeldpYEbg+Q7RaFfi3UPyeE=; b=K9DbR+DrQxDgcJd6+X33FseF6NeKGreCjA0f4HVk+ulpYFgCCQGG6UioC7L8P9zZWk88SV i0uVoijRabQvNhH1iLWJgxZzx4lbce1NBq5H3kUtZh6mgTSWMhWvotCZibL6xH3ABFCclk vNOekWNoLhkCLeE8L4jfF1LjmGOvEpw= Received: from mail-qt1-f197.google.com (mail-qt1-f197.google.com [209.85.160.197]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-123-Y12DBMgWNza1g9CcPv5-8w-1; Thu, 27 May 2021 16:23:53 -0400 X-MC-Unique: Y12DBMgWNza1g9CcPv5-8w-1 Received: by mail-qt1-f197.google.com with SMTP id h12-20020ac8776c0000b02901f1228fdb1bso876243qtu.6 for ; Thu, 27 May 2021 13:23:53 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Uq4QT2ZrcVHt/byJv1ujYeldpYEbg+Q7RaFfi3UPyeE=; b=ETsA8dF/iUL+DMsCibSVwN1HN1xSVhCbNhGrO70pw5sKRbtjTe1GZFFCKIvz1PvNRy fyBrPJoOoHwv0SoisExDcJw2ovLT2ifbduVfMuX1exuIEqmR4zV6cfF6elE3NK710Aa2 vBYHShSRMLM9ZfcSo/Wa+Z74Bk26928S7Qi9tiaKV0iQW9ykaxTL+SygC/nYoOvelCGf qkoX26KehSNPU0Hwjrbam9DgMK91OzbiPD7oYbQOzBlbnlhl3of5a9XcB6yxLlMVK1VI XvUKdND9s8BbXzrrVYlgEVVnGoEtQZ71SyfN6tMhw/4HtbWoizx9y2bOAoGs8soBcUab Y8sg== X-Gm-Message-State: AOAM533/qGGgECG3qSp1bTvmS/kyWmGS5Al4UkUYROTXQfmABDSuYuPg Pya3FzU8SFsxxmcWTcmkylnIGZxnBZwpjBusnzcJhwnO3v2AG5ba2O4OfFtGDkZiN87EcFnV5GN svdzkjDEsMwc= X-Received: by 2002:ac8:5484:: with SMTP id h4mr360837qtq.338.1622147032999; Thu, 27 May 2021 13:23:52 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz3zi5PoIwHGhlPFnbYVnDOeLkXM0Dn9r4qegg3oaBy1B1xbjvo3TJ2sVyd9Gu8IcG8naBLlA== X-Received: by 2002:ac8:5484:: with SMTP id h4mr360813qtq.338.1622147032703; Thu, 27 May 2021 13:23:52 -0700 (PDT) Received: from localhost.localdomain (bras-base-toroon474qw-grc-72-184-145-4-219.dsl.bell.ca. [184.145.4.219]) by smtp.gmail.com with ESMTPSA id w4sm1981299qki.57.2021.05.27.13.23.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 27 May 2021 13:23:52 -0700 (PDT) From: Peter Xu To: linux-kernel@vger.kernel.org, linux-mm@kvack.org Cc: Mike Rapoport , peterx@redhat.com, Andrew Morton , Mike Kravetz , Jerome Glisse , Miaohe Lin , Nadav Amit , Hugh Dickins , Matthew Wilcox , Jason Gunthorpe , "Kirill A . Shutemov" , Andrea Arcangeli , Axel Rasmussen Subject: [PATCH v3 27/27] userfaultfd/selftests: Enable uffd-wp for shmem/hugetlbfs Date: Thu, 27 May 2021 16:23:48 -0400 Message-Id: <20210527202348.32406-1-peterx@redhat.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210527201927.29586-1-peterx@redhat.com> References: <20210527201927.29586-1-peterx@redhat.com> MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="US-ASCII" X-Rspamd-Queue-Id: 9FDB94142C51 Authentication-Results: imf02.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=K9DbR+Dr; spf=none (imf02.hostedemail.com: domain of peterx@redhat.com has no SPF policy when checking 216.205.24.124) smtp.mailfrom=peterx@redhat.com; dmarc=pass (policy=none) header.from=redhat.com X-Rspamd-Server: rspam04 X-Stat-Signature: hs5kzt5endyqn4hheofoa3qci9gfzcq7 X-HE-Tag: 1622147033-195623 Content-Transfer-Encoding: quoted-printable 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: After we added support for shmem and hugetlbfs, we can turn uffd-wp test = on always now. Define HUGETLB_EXPECTED_IOCTLS to avoid using UFFD_API_RANGE_IOCTLS_BASIC= , because UFFD_API_RANGE_IOCTLS_BASIC is normally a superset of capabilitie= s, while the test may not satisfy them all. E.g., when hugetlb registered w= ithout minor mode, then we need to explicitly remove _UFFDIO_CONTINUE. Same thi= ng to uffd-wp, as we'll need to explicitly remove _UFFDIO_WRITEPROTECT if not registered with uffd-wp. For the long term, we may consider dropping UFFD_API_* macros completely = from uapi/linux/userfaultfd.h header files, because it may cause kernel header update to easily break userspace. Signed-off-by: Peter Xu --- tools/testing/selftests/vm/userfaultfd.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/tools/testing/selftests/vm/userfaultfd.c b/tools/testing/sel= ftests/vm/userfaultfd.c index e363bdaff59d..015f2df8ece4 100644 --- a/tools/testing/selftests/vm/userfaultfd.c +++ b/tools/testing/selftests/vm/userfaultfd.c @@ -80,7 +80,7 @@ static int test_type; static volatile bool test_uffdio_copy_eexist =3D true; static volatile bool test_uffdio_zeropage_eexist =3D true; /* Whether to test uffd write-protection */ -static bool test_uffdio_wp =3D false; +static bool test_uffdio_wp =3D true; /* Whether to test uffd minor faults */ static bool test_uffdio_minor =3D false; =20 @@ -320,6 +320,9 @@ struct uffd_test_ops { (1 << _UFFDIO_ZEROPAGE) | \ (1 << _UFFDIO_WRITEPROTECT)) =20 +#define HUGETLB_EXPECTED_IOCTLS ((1 << _UFFDIO_WAKE) | \ + (1 << _UFFDIO_COPY)) + static struct uffd_test_ops anon_uffd_test_ops =3D { .expected_ioctls =3D ANON_EXPECTED_IOCTLS, .allocate_area =3D anon_allocate_area, @@ -335,7 +338,7 @@ static struct uffd_test_ops shmem_uffd_test_ops =3D { }; =20 static struct uffd_test_ops hugetlb_uffd_test_ops =3D { - .expected_ioctls =3D UFFD_API_RANGE_IOCTLS_BASIC & ~(1 << _UFFDIO_CONTI= NUE), + .expected_ioctls =3D HUGETLB_EXPECTED_IOCTLS, .allocate_area =3D hugetlb_allocate_area, .release_pages =3D hugetlb_release_pages, .alias_mapping =3D hugetlb_alias_mapping, @@ -1580,8 +1583,6 @@ static void set_test_type(const char *type) if (!strcmp(type, "anon")) { test_type =3D TEST_ANON; uffd_test_ops =3D &anon_uffd_test_ops; - /* Only enable write-protect test for anonymous test */ - test_uffdio_wp =3D true; } else if (!strcmp(type, "hugetlb")) { test_type =3D TEST_HUGETLB; uffd_test_ops =3D &hugetlb_uffd_test_ops; --=20 2.31.1