From patchwork Fri Jan 15 17:12:26 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Xu X-Patchwork-Id: 12023373 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 423C8C433DB for ; Fri, 15 Jan 2021 17:12:35 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id E87F2238EE for ; Fri, 15 Jan 2021 17:12:34 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org E87F2238EE 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 836F78D01B8; Fri, 15 Jan 2021 12:12:34 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 7E65F8D01B2; Fri, 15 Jan 2021 12:12:34 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 6FCD78D01B8; Fri, 15 Jan 2021 12:12:34 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0018.hostedemail.com [216.40.44.18]) by kanga.kvack.org (Postfix) with ESMTP id 57BF58D01B2 for ; Fri, 15 Jan 2021 12:12:34 -0500 (EST) Received: from smtpin23.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id 1DD1D1812A458 for ; Fri, 15 Jan 2021 17:12:34 +0000 (UTC) X-FDA: 77708653428.23.patch36_161369627531 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin23.hostedemail.com (Postfix) with ESMTP id F3C4C37621 for ; Fri, 15 Jan 2021 17:12:33 +0000 (UTC) X-HE-Tag: patch36_161369627531 X-Filterd-Recvd-Size: 6238 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf10.hostedemail.com (Postfix) with ESMTP for ; Fri, 15 Jan 2021 17:12:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1610730752; 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=tEf8T0Go1KzAUeqBOwWH7qIZostwBrdc7d1MGMOL0rE=; b=ZVE/vkW++mCOaQhNFu9LM94wasXr17KLClYBCKAUTFy+p5mz5rFT/1Es/PBs9Fl9URV4vu gWIa9oatG4WvV7HcQUXsRPgK+ZX12hBPq6ok1qRVBrE2Y/zGmDTaDYXjebNX8gykSg/RXr 3YSeGZtsa3BLyPgPfX9CtIhelglxuqA= Received: from mail-qt1-f200.google.com (mail-qt1-f200.google.com [209.85.160.200]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-8-Y7UHIcxQPbuLq-TYfUc6Jg-1; Fri, 15 Jan 2021 12:12:31 -0500 X-MC-Unique: Y7UHIcxQPbuLq-TYfUc6Jg-1 Received: by mail-qt1-f200.google.com with SMTP id c14so7889367qtn.5 for ; Fri, 15 Jan 2021 09:12:30 -0800 (PST) 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=tEf8T0Go1KzAUeqBOwWH7qIZostwBrdc7d1MGMOL0rE=; b=VsALxTAKjwDuxwJjnV3eISCP/NTBiLIGWJbHQ12020KYjN5WM3gfiyBJw0BappY8Ur PI6UxYnDDiQMFGmqxxkiJS4O4AG043S5ZNYJn+L6hitTzlzBhjcCbphXqukaih1Hg7GF DjwV1zp/i3gaOgdW6wsi2wlYKq+VSBR6toNiEvdLV+ESMn6XHTcxe55tyGhp1XQP1QPG nXMf20VxcSj3+58QDyCGVGS/2XnqEm4gBUF/lPtTyJEgrYv4boDs07RvkKxDqpUYSOOT k6OoWuaFM+D4De6R6+kwxkBPsktQ/sdez/vqDK+4Ms7yjU5kMOtwiC4xx7rpmZcZ0Rdr /K5g== X-Gm-Message-State: AOAM531O4LqQdrryOOYoJjH2ClqP46kOlbyaNlGrg8DazChniOJjYoeV ViqnQ0n5r4oRfrElA479PO/uvlM+Qq4ztHO3qqguiifk3J9YQlkAYn78WCw21vEXIdCG7qNoQeN xhJYFXvwxye8= X-Received: by 2002:ad4:4c03:: with SMTP id bz3mr12717675qvb.18.1610730748366; Fri, 15 Jan 2021 09:12:28 -0800 (PST) X-Google-Smtp-Source: ABdhPJyrBIMScW0Akbh1tP53btOa7oiIiWgBQH32e/IJAnpRq/urGVjQU2YQNcHoeHxeMdk+kjiB3w== X-Received: by 2002:ad4:4c03:: with SMTP id bz3mr12717658qvb.18.1610730748161; Fri, 15 Jan 2021 09:12:28 -0800 (PST) Received: from localhost.localdomain ([142.126.83.202]) by smtp.gmail.com with ESMTPSA id x134sm5418843qka.1.2021.01.15.09.12.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Jan 2021 09:12:27 -0800 (PST) From: Peter Xu To: linux-kernel@vger.kernel.org, linux-mm@kvack.org Cc: Andrea Arcangeli , Hugh Dickins , Jerome Glisse , "Kirill A . Shutemov" , Mike Rapoport , Matthew Wilcox , peterx@redhat.com, Nadav Amit , Axel Rasmussen , Mike Kravetz , Andrew Morton Subject: [PATCH RFC 30/30] userfaultfd/selftests: Enable uffd-wp for shmem/hugetlbfs Date: Fri, 15 Jan 2021 12:12:26 -0500 Message-Id: <20210115171226.25127-1-peterx@redhat.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20210115170907.24498-1-peterx@redhat.com> References: <20210115170907.24498-1-peterx@redhat.com> MIME-Version: 1.0 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=peterx@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com 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. Signed-off-by: Peter Xu --- tools/testing/selftests/vm/userfaultfd.c | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/tools/testing/selftests/vm/userfaultfd.c b/tools/testing/selftests/vm/userfaultfd.c index c4425597769a..219251c194da 100644 --- a/tools/testing/selftests/vm/userfaultfd.c +++ b/tools/testing/selftests/vm/userfaultfd.c @@ -77,8 +77,8 @@ static int test_type; #define ALARM_INTERVAL_SECS 10 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; +/* Whether to test uffd write-protection. Default is to test uffd-wp always */ +static bool test_uffdio_wp = true; static bool map_shared; static int huge_fd; @@ -295,9 +295,9 @@ struct uffd_test_ops { void (*alias_mapping)(__u64 *start, size_t len, unsigned long offset); }; -#define SHMEM_EXPECTED_IOCTLS ((1 << _UFFDIO_WAKE) | \ +#define HUGETLB_EXPECTED_IOCTLS ((1 << _UFFDIO_WAKE) | \ (1 << _UFFDIO_COPY) | \ - (1 << _UFFDIO_ZEROPAGE)) + (1 << _UFFDIO_WRITEPROTECT)) #define ANON_EXPECTED_IOCTLS ((1 << _UFFDIO_WAKE) | \ (1 << _UFFDIO_COPY) | \ @@ -312,14 +312,14 @@ static struct uffd_test_ops anon_uffd_test_ops = { }; static struct uffd_test_ops shmem_uffd_test_ops = { - .expected_ioctls = SHMEM_EXPECTED_IOCTLS, + .expected_ioctls = ANON_EXPECTED_IOCTLS, .allocate_area = shmem_allocate_area, .release_pages = shmem_release_pages, .alias_mapping = noop_alias_mapping, }; static struct uffd_test_ops hugetlb_uffd_test_ops = { - .expected_ioctls = UFFD_API_RANGE_IOCTLS_BASIC, + .expected_ioctls = HUGETLB_EXPECTED_IOCTLS, .allocate_area = hugetlb_allocate_area, .release_pages = hugetlb_release_pages, .alias_mapping = hugetlb_alias_mapping, @@ -1453,8 +1453,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;