Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp932180pxb; Wed, 3 Mar 2021 21:33:24 -0800 (PST) X-Google-Smtp-Source: ABdhPJz2uAEHRfAaU/JHhISb3bachDYnQXmxfZhiKelNI1HaXdq9oeOSbnjI7D9Vl//w36+ojyqC X-Received: by 2002:a17:906:6558:: with SMTP id u24mr2406675ejn.185.1614836004572; Wed, 03 Mar 2021 21:33:24 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1614836004; cv=none; d=google.com; s=arc-20160816; b=AwZzfBiRS6sBGkFIGEURVbHAria1eBDUJyz/nMP7LimYxHeMzDUyBNBeuIaqRiYyDV wTF2pU6BCc5DZxVQIJbtflEHZOoMyAUaIxBRYf7lE3m48BGbmh/CMNfv4LQfm/IXHrWw 9d5YGchiO7Nh78Y/OUQysC7DC/xrvmS78za+gRRnIQn8QFTnqydQwQ+oNKvZVquTkz6W LIBHqsxWliMmEWDHx8/9AO4okfD2r9iut0BXosheqPGpcTkmlolh1LBLq0mw5BTjOKUb HQh+mxG5sDgxIF44hXUHkljvNGxhr013X5TGmXFTUWBOoIAFrbMZdXTfmpiRLTUFDFkz yhfg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:from:subject:references:mime-version :message-id:in-reply-to:date:sender:dkim-signature; bh=Ykwv7UPOg2gnv7U6N4+XsXv4MVQdTbl3lFORivTI5qU=; b=PVH818KqH7uWHtNX9RJbtIz79XGDkAJPYFBIu5MKxYZU7vagyEp7kvD5bwZZU154uH FbH4PperBrruZhFjTobSZE9c/QM7UmOseKM2VkZCUTQB5mBisR7R/XS83NwEXaC4jQKJ 8MRBrdRe68Rw6X3rBCKnwyq+vl0w1apw6W5ZPnj0MCLz+nRmP5vV1Sk5Yz71oRFE6YRy ddzRQCQIurq50jK5P+fVptOg5r0yN1UoW+8M4EpHUAlFojkiO49mH5VoFdICqhU8TxTg HMkOfEcqfXROc4zklih6SXl1Njoe78DUYTuCbdZiYjJPAHKv8avcOeMJ2Za2zjU6VH10 FuxA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=Ike7yisT; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id h18si10206701ejd.89.2021.03.03.21.33.02; Wed, 03 Mar 2021 21:33:24 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=Ike7yisT; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1381085AbhCBEUo (ORCPT + 99 others); Mon, 1 Mar 2021 23:20:44 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49780 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235441AbhCBAEb (ORCPT ); Mon, 1 Mar 2021 19:04:31 -0500 Received: from mail-yb1-xb49.google.com (mail-yb1-xb49.google.com [IPv6:2607:f8b0:4864:20::b49]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B351EC061222 for ; Mon, 1 Mar 2021 16:01:47 -0800 (PST) Received: by mail-yb1-xb49.google.com with SMTP id p136so20822291ybc.21 for ; Mon, 01 Mar 2021 16:01:47 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=sender:date:in-reply-to:message-id:mime-version:references:subject :from:to:cc; bh=Ykwv7UPOg2gnv7U6N4+XsXv4MVQdTbl3lFORivTI5qU=; b=Ike7yisTth4MPXILsDu/yWLMoEt9B+Ui8PttQAbq3inRV2gVHSVxandNIzZpd5ZqDG yTzLI6fh7QLGqwwBZzvml3GG4wf8k4furX6FEBBT5/pscBRVuCf1bHOjj+18ezm3sO+y BqRXkF6w+rmlczom6l9qwgJloIYYoBPtB+krv83i3eij0jETbsJDKTVGUQeLmEL5wt41 BC0zJ/5ipdyI68rlqEtHjblDSX6sLqucKcS4j7LGMiDOnL1HVnDJUqvRC6T/VQT5h+wZ A+ezDf0lPKYbc4quZ5oy3GxsVg2cbSZh6nVcGeYr6UNw8HpPCKw+Bx8wrOWJfFoAyFTA 7Dlw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=Ykwv7UPOg2gnv7U6N4+XsXv4MVQdTbl3lFORivTI5qU=; b=RjvqxZsJiPv1dgUhVbqJ1f4pyqUk6FSJmwFWTKrD/yyu2RAaYo0KPxsCaVH8QbamDP arw9m/oE86ILl7uIYr44Yc/k46c7VOFkO/57dTzAjGrBEfBfKHOUd/+xJYOsi7srhK9K ObZTPvvyqq2T40d7C3E6AgqaiFPATlo1uGJG4susFh3tNmOGKLFQNzXL32B++NCC5O0N p+CVcLq3LZ6lxax8ZZT+Q0bHtm5OEpCRgbpfoQFLQTX1F48BDvV+Yc/leeodja8LK+XF mSw9EYBWojWlpbUBvy6NGyuYmtmEGWNTiQOFye1J0L6Lr1B6dFYnK1zPwCNUR74U4oYK PVkw== X-Gm-Message-State: AOAM533vLqJ4zKWELAFrf+NA9ez0uTD2BFPiSWVt9zp9iOzFMljzNymD lkw7wWBCX8hg1200lvmsryLLlwFVv8oiAHw3Hpik Sender: "axelrasmussen via sendgmr" X-Received: from ajr0.svl.corp.google.com ([2620:15c:2cd:203:1998:8165:ca50:ab8d]) (user=axelrasmussen job=sendgmr) by 2002:a25:e08b:: with SMTP id x133mr26514883ybg.138.1614643306922; Mon, 01 Mar 2021 16:01:46 -0800 (PST) Date: Mon, 1 Mar 2021 16:01:33 -0800 In-Reply-To: <20210302000133.272579-1-axelrasmussen@google.com> Message-Id: <20210302000133.272579-6-axelrasmussen@google.com> Mime-Version: 1.0 References: <20210302000133.272579-1-axelrasmussen@google.com> X-Mailer: git-send-email 2.30.1.766.gb4fecdf3b7-goog Subject: [PATCH v2 5/5] userfaultfd/selftests: exercise minor fault handling shmem support From: Axel Rasmussen To: Alexander Viro , Andrea Arcangeli , Andrew Morton , Hugh Dickins , Jerome Glisse , Joe Perches , Lokesh Gidra , Mike Rapoport , Peter Xu , Shaohua Li , Shuah Khan , Wang Qing Cc: linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, linux-kselftest@vger.kernel.org, Axel Rasmussen , Brian Geffon , Cannon Matthews , "Dr . David Alan Gilbert" , David Rientjes , Michel Lespinasse , Mina Almasry , Oliver Upton Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Enable test_uffdio_minor for test_type == TEST_SHMEM, and modify the test slightly to pass in / check for the right feature flags. Signed-off-by: Axel Rasmussen --- tools/testing/selftests/vm/userfaultfd.c | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/tools/testing/selftests/vm/userfaultfd.c b/tools/testing/selftests/vm/userfaultfd.c index 5183ddb3080d..f31e9a4edc55 100644 --- a/tools/testing/selftests/vm/userfaultfd.c +++ b/tools/testing/selftests/vm/userfaultfd.c @@ -1410,7 +1410,7 @@ static int userfaultfd_minor_test(void) void *expected_page; char c; struct uffd_stats stats = { 0 }; - uint64_t features = UFFD_FEATURE_MINOR_HUGETLBFS; + uint64_t req_features, features_out; if (!test_uffdio_minor) return 0; @@ -1418,10 +1418,18 @@ static int userfaultfd_minor_test(void) printf("testing minor faults: "); fflush(stdout); - if (uffd_test_ctx_clear() || uffd_test_ctx_init_ext(&features)) + if (test_type == TEST_HUGETLB) + req_features = UFFD_FEATURE_MINOR_HUGETLBFS; + else if (test_type == TEST_SHMEM) + req_features = UFFD_FEATURE_MINOR_SHMEM; + else + return 1; + + features_out = req_features; + if (uffd_test_ctx_clear() || uffd_test_ctx_init_ext(&features_out)) return 1; - /* If kernel reports the feature isn't supported, skip the test. */ - if (!(features & UFFD_FEATURE_MINOR_HUGETLBFS)) { + /* If kernel reports required features aren't supported, skip test. */ + if ((features_out & req_features) != req_features) { printf("skipping test due to lack of feature support\n"); fflush(stdout); return 0; @@ -1431,7 +1439,7 @@ static int userfaultfd_minor_test(void) uffdio_register.range.len = nr_pages * page_size; uffdio_register.mode = UFFDIO_REGISTER_MODE_MINOR; if (ioctl(uffd, UFFDIO_REGISTER, &uffdio_register)) { - fprintf(stderr, "register failure\n"); + perror("register failure"); exit(1); } @@ -1695,6 +1703,7 @@ static void set_test_type(const char *type) map_shared = true; test_type = TEST_SHMEM; uffd_test_ops = &shmem_uffd_test_ops; + test_uffdio_minor = true; } else { fprintf(stderr, "Unknown test type: %s\n", type); exit(1); } -- 2.30.1.766.gb4fecdf3b7-goog