From patchwork Thu Jul 15 20:16:59 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Xu X-Patchwork-Id: 12380975 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 214BAC636C8 for ; Thu, 15 Jul 2021 20:17:09 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id C4C3D613D0 for ; Thu, 15 Jul 2021 20:17:08 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org C4C3D613D0 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 3251F8D00FE; Thu, 15 Jul 2021 16:17:09 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 2D47D8D00FC; Thu, 15 Jul 2021 16:17:09 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 127ED8D00FE; Thu, 15 Jul 2021 16:17:09 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0194.hostedemail.com [216.40.44.194]) by kanga.kvack.org (Postfix) with ESMTP id DF2588D00FC for ; Thu, 15 Jul 2021 16:17:08 -0400 (EDT) Received: from smtpin34.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id C60C319B13 for ; Thu, 15 Jul 2021 20:17:07 +0000 (UTC) X-FDA: 78365931294.34.582C4B0 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by imf21.hostedemail.com (Postfix) with ESMTP id 67AEED0074B5 for ; Thu, 15 Jul 2021 20:17:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1626380226; 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=Ppx+yKim7jbMz1FK7VXh/FWQcjAZePTvxjo1SRUd7ZOikwqG0dAfxSZeqVYS507DldS9lI dSyaUQPy2UKv4gLLxog5khDbRBr252oqw0PzinDK4ZUSS4fzK/+QqnZE5KGJtYxlv/Pbyd r7GOyrKELRljfk2ZWCreyXdgyL7DrvA= Received: from mail-qv1-f69.google.com (mail-qv1-f69.google.com [209.85.219.69]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-363-fo6RYNhTPxa52o0FNA_R9A-1; Thu, 15 Jul 2021 16:17:03 -0400 X-MC-Unique: fo6RYNhTPxa52o0FNA_R9A-1 Received: by mail-qv1-f69.google.com with SMTP id cw12-20020ad44dcc0000b02902f1474ce8b7so4992590qvb.20 for ; Thu, 15 Jul 2021 13:17:03 -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=E8dI9ZlkgkI/U4LBKkJiCzUhF4Hc1xv+hAaPVvcnyXKPP3dKWxp36EO0S3OA8Zm+R3 O2Cok4fJggdEzBrqlxTK8YTQnJP8RccD6nHjogKoXEg9h/+FbAqEfPL+soqdkK+A943G JMVBwiNQSlfANacCiKFOvzNxc2vUSpuYjgVXRSIX1O37jljt0zQYZRzq+AaITYLXIJ/G SAHeG4ysHuIJQsej5zjnncHKwz01jM9Xvxn4VeLbmkx0+QtZtB6/e5oQilpQfmQriJ88 KhZulbm853zFF8WSLD3+3yGqUxGQBc7OaDk7GaLCmd8gRRzA5JdhNyq2H02p8tNUAmKw IF6w== X-Gm-Message-State: AOAM533EZWG4iz94ypX5t+7uo5JCK1kVw3pBQWzzBvn4eExRL21fzolf DN7KVFbrlbYgfKlXDJwfaxSDn4ix+0VkySYEHol7dgWrnmzPPJW112facIsJabZj/yseZ9VU13S XBesNzkjDyes= X-Received: by 2002:a37:b6c1:: with SMTP id g184mr5710183qkf.270.1626380223274; Thu, 15 Jul 2021 13:17:03 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxbrAZNsiD+WlVjbF9Hym0cG86ASuwEdZaLrSJFs5JIIdeDGCjL1LWLBPqqYUg16c6SiTTW7g== X-Received: by 2002:a37:b6c1:: with SMTP id g184mr5710162qkf.270.1626380223071; Thu, 15 Jul 2021 13:17:03 -0700 (PDT) Received: from localhost.localdomain (bras-base-toroon474qw-grc-65-184-144-111-238.dsl.bell.ca. [184.144.111.238]) by smtp.gmail.com with ESMTPSA id w6sm471188qtt.36.2021.07.15.13.17.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 15 Jul 2021 13:17:02 -0700 (PDT) From: Peter Xu To: linux-kernel@vger.kernel.org, linux-mm@kvack.org Cc: Axel Rasmussen , Nadav Amit , Jerome Glisse , "Kirill A . Shutemov" , Jason Gunthorpe , Alistair Popple , Andrew Morton , David Hildenbrand , peterx@redhat.com, Andrea Arcangeli , Matthew Wilcox , Mike Kravetz , Tiberiu Georgescu , Hugh Dickins , Miaohe Lin , Mike Rapoport Subject: [PATCH v5 26/26] userfaultfd/selftests: Enable uffd-wp for shmem/hugetlbfs Date: Thu, 15 Jul 2021 16:16:59 -0400 Message-Id: <20210715201659.212234-1-peterx@redhat.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210715201422.211004-1-peterx@redhat.com> References: <20210715201422.211004-1-peterx@redhat.com> MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Authentication-Results: imf21.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=Ppx+yKim; spf=none (imf21.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-Stat-Signature: qj1ni14xepj4kxpb1ajsreofwkxz517p X-Rspamd-Queue-Id: 67AEED0074B5 X-Rspamd-Server: rspam01 X-HE-Tag: 1626380227-361697 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 capabilities, while the test may not satisfy them all. E.g., when hugetlb registered without minor mode, then we need to explicitly remove _UFFDIO_CONTINUE. Same thing 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/selftests/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 = true; static volatile bool test_uffdio_zeropage_eexist = true; /* Whether to test uffd write-protection */ -static bool test_uffdio_wp = false; +static bool test_uffdio_wp = true; /* Whether to test uffd minor faults */ static bool test_uffdio_minor = false; @@ -320,6 +320,9 @@ struct uffd_test_ops { (1 << _UFFDIO_ZEROPAGE) | \ (1 << _UFFDIO_WRITEPROTECT)) +#define HUGETLB_EXPECTED_IOCTLS ((1 << _UFFDIO_WAKE) | \ + (1 << _UFFDIO_COPY)) + static struct uffd_test_ops anon_uffd_test_ops = { .expected_ioctls = ANON_EXPECTED_IOCTLS, .allocate_area = anon_allocate_area, @@ -335,7 +338,7 @@ static struct uffd_test_ops shmem_uffd_test_ops = { }; static struct uffd_test_ops hugetlb_uffd_test_ops = { - .expected_ioctls = UFFD_API_RANGE_IOCTLS_BASIC & ~(1 << _UFFDIO_CONTINUE), + .expected_ioctls = HUGETLB_EXPECTED_IOCTLS, .allocate_area = hugetlb_allocate_area, .release_pages = hugetlb_release_pages, .alias_mapping = hugetlb_alias_mapping, @@ -1580,8 +1583,6 @@ static void set_test_type(const char *type) if (!strcmp(type, "anon")) { test_type = TEST_ANON; uffd_test_ops = &anon_uffd_test_ops; - /* Only enable write-protect test for anonymous test */ - test_uffdio_wp = true; } else if (!strcmp(type, "hugetlb")) { test_type = TEST_HUGETLB; uffd_test_ops = &hugetlb_uffd_test_ops;