Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp160878pxb; Wed, 24 Feb 2021 22:03:59 -0800 (PST) X-Google-Smtp-Source: ABdhPJxwhq8iQ9DTY4FZJRPgFyKhj1aI3FCuBlM2VnDrddxo4rS1ssU/pVY4w8qc9hSmDsP0f8z2 X-Received: by 2002:a17:906:1848:: with SMTP id w8mr1120114eje.3.1614233039158; Wed, 24 Feb 2021 22:03:59 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1614233039; cv=none; d=google.com; s=arc-20160816; b=PCtdfiLyI7oEaw35vv5ylzw6+NrTOQwj0KOv57oI1s2LwyYd5F9fGH/4xIbalHP3Vu ERHA5/SK9asCtAT2OFrdBI2mJjVMrKdE0lJwhh7UdH4JyoKHuW6v2kkWWn8jMn5Oc5bg /G9TlPQHIQk+cyq3lD3LLtnDuAtc27a71OQGRFTsq6rpsCTu2XWON6Rwj11tESxPn1Qa kPGAwwX4z0zG/7/JTYXL2Tg2nIPjJAMuO4wn8k2u3FSt5JLeVxpM6F++4XdEUPAUMKHZ 5LFOc+CLOwNpK6dYCtEViijOEYo4QdKzXb7S1uuB1PRldBh/is82gzVzKAiVoQ963sv/ lk1Q== 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=lQ7mB70IC4ojvTJeDVa366V82dbz54zsKMBfnZVy7Ms=; b=cmkLh0nGUp6bLAhgrRtLq4/naaUgTx/5J4zy3ryfyoDwXy2ZpnaCQdslgAsbg44aYF QsboBeucgMRXOtCinaj6UQhW75RquKnGXaoFTwFm1NdzfpEHXZO1pg2fKKRxD/U11GR1 Cvg2PE1F+x3hQVr7IZfLdlcA88S59aFE8yN63VJOCTZtobArt+BOMfFlS86SB40vG7x7 VF8nCPwruFBL2fnavEQoJduOpuRnWV2oBCikHrUZCtNtqyxgJfRxjdHX3EhznTQCQe2s ecyuyiyNXXIpRaEEPREWUOKgkPqiRErT7fsK9gmQSZBSlmR2jer/i3Xu/IxIqJcu1Gj0 zGzw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=lFJ9b0Yc; 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 dp8si2580562ejc.367.2021.02.24.22.03.34; Wed, 24 Feb 2021 22:03:59 -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=lFJ9b0Yc; 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 S236828AbhBYCQb (ORCPT + 99 others); Wed, 24 Feb 2021 21:16:31 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37742 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236793AbhBYCQW (ORCPT ); Wed, 24 Feb 2021 21:16:22 -0500 Received: from mail-qv1-xf49.google.com (mail-qv1-xf49.google.com [IPv6:2607:f8b0:4864:20::f49]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5C450C061356 for ; Wed, 24 Feb 2021 18:14:51 -0800 (PST) Received: by mail-qv1-xf49.google.com with SMTP id m1so3071451qvp.0 for ; Wed, 24 Feb 2021 18:14:51 -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=lQ7mB70IC4ojvTJeDVa366V82dbz54zsKMBfnZVy7Ms=; b=lFJ9b0YcGKvqVJcJEUWuytLaGKckdM7KmGvm907xlugk9wxeiWjXhPwfymQVBxp9Q2 IstnBZ8+wjO+/QcGj1MgU+rwbm/UiybZgKvq2fglhsfXqANGr3ud+VEau8tVuHe7Zwq0 EOsAWX7/nPq9KEfZpIga28EXZplEa6KRx3g8oLhVyKHm43f/W6MSgPYdJTGREFCUq9Yk L5dgUKAtfUBQ/hnIfNzSPMRRDfmbVO1hBAZlwAZUFV04WBoUr9vtDP9OMlrp9rrLK11H YD7EYLvmCaGZLJ2TPMNI82UfqLI879FX+YDnAJqPFrpxTtbYACU08rJtMWHFZHY/P+nE r0oA== 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=lQ7mB70IC4ojvTJeDVa366V82dbz54zsKMBfnZVy7Ms=; b=XFRj10CxEJ8HjnhspVn7JZG4QTSy0zm+FKUmXFYJfbxuqx7AwnpxVekBRXuiuw59s4 OsbXbXLkLY7lJCLzI6qRm295g69HFBJx7aqfHFc8GXOjUNNy0o+bKnaZsVYO1FpLtYMz CXn01O+/cd0G2UKGylSLbeipXm/nDbRvYl1vSYboRnAkPb9TW+8OvfN7ygV/nE1ZFCaW pbe1oC/T6DWFWonYLdj+zaUfWI8WLMEUAtK6i+kYqorEabLJDxwlmcc4vg0pRrB5bQo1 E8Iu3yBF8EPbVlRishu0yLOPClC4yXr8hHDt98jB3F0QRPtRNUaM0YH3Ie90J0EN1eUo HnNw== X-Gm-Message-State: AOAM5322Out/w3vaR71l30/Z5yNJmfUK5UxqxCTNLHQuvSRg9JM9w82z YSYuRsu54h6EGmYB9rrY0E77+zX10OKMdIiz/46U Sender: "axelrasmussen via sendgmr" X-Received: from ajr0.svl.corp.google.com ([2620:15c:2cd:203:a5fd:f848:2fdf:4651]) (user=axelrasmussen job=sendgmr) by 2002:ad4:5609:: with SMTP id ca9mr615259qvb.58.1614219290463; Wed, 24 Feb 2021 18:14:50 -0800 (PST) Date: Wed, 24 Feb 2021 18:14:20 -0800 In-Reply-To: <20210225021420.2290912-1-axelrasmussen@google.com> Message-Id: <20210225021420.2290912-6-axelrasmussen@google.com> Mime-Version: 1.0 References: <20210225021420.2290912-1-axelrasmussen@google.com> X-Mailer: git-send-email 2.30.0.617.g56c4b15f3c-goog Subject: [PATCH 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 , 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.0.617.g56c4b15f3c-goog