Received: by 2002:a05:7412:a9a2:b0:e2:908c:2ebd with SMTP id o34csp1509088rdh; Fri, 27 Oct 2023 17:39:53 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFdhqU7ZEoO3lYfMMLHjiaRwoUmgEt6C1hFkIrexAmTqb7wSNjWlcAzEsxAql/AqieSSGID X-Received: by 2002:a05:6a00:814:b0:6bb:aaf:d7db with SMTP id m20-20020a056a00081400b006bb0aafd7dbmr5631937pfk.29.1698453593316; Fri, 27 Oct 2023 17:39:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698453593; cv=none; d=google.com; s=arc-20160816; b=Qw0Rb3SVjx1XhanFDv9MMlraS0FdL/UFzUnTlqOcAhVF5fgvSrrQeTPTViG7QuEMjM T5GiOJrz+B237auFGPn+kiVYH25gc/WVsPThOh1uAgiaF5wJKm+Xw25TXwSNfbDYen6S jZFX8wqXTDYI1jT+V3OjBltPo5DBwCw2/ROZXczHlI6WrIwMtqyAMG518zHedUWNuebs ahElZkirOFznwTSIWtvmV3RKhVm80Grv1QELaIygGZx8H8vIKnpbHk99m2Zp4K3UHSLF R7ddA+oSn/sivuLbko5yxi400lrTb5Ey2nY/+ypdsMvDlAMC9wo7nKP07kTi5Q6bMcSm kqVw== 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:message-id:references :mime-version:in-reply-to:date:dkim-signature; bh=BD9lPzNt8hnQJcZ/hWgSWD/y67yszl3sQZlzVb4etk8=; fh=vBLx0KH+vftfPuCKolEKY+MKbAkCpwC5WBbaBlSuTXE=; b=OZC1x1bK8OXfTbjpyWdoCnbd/OXmQl9E41VN2GgQtdaVWWN49P/Yb+dGDf/crzfueX GrB3mgwRVOLa25IQllUGK7d+qe2ksV2nMvSzl9kRwHpIgxujJwTMTQW4n2n9RtltixgR ghOzZycgBIpaxI5rje3ze2iZECeFcM68GMGy1uGK9/8taJuNZoftMtcZccYfKHsFuXLC Fq0l3a4OawwEYSH1W3el1a0VJ8B6d0FaWtGYzoR5oPx6VD30+2ze2YhRt0Fq+6UwNx1Z LoR8QCjXSMT/CIlN4aLjzJbzuRzF/bUYGlNNgwRsza5NF+t6rPn4bQiYH4R02Yuzs/MF uJjw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=wRnrNLho; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 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 howler.vger.email (howler.vger.email. [2620:137:e000::3:4]) by mx.google.com with ESMTPS id b9-20020a63d809000000b005ab776a4d4csi1736513pgh.610.2023.10.27.17.39.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 27 Oct 2023 17:39:53 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) client-ip=2620:137:e000::3:4; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=wRnrNLho; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by howler.vger.email (Postfix) with ESMTP id 39DB283F4252; Fri, 27 Oct 2023 17:39:50 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at howler.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235197AbjJ1Aiq (ORCPT + 99 others); Fri, 27 Oct 2023 20:38:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42546 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1346748AbjJ1Aie (ORCPT ); Fri, 27 Oct 2023 20:38:34 -0400 Received: from mail-yw1-x114a.google.com (mail-yw1-x114a.google.com [IPv6:2607:f8b0:4864:20::114a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1E3A71B5 for ; Fri, 27 Oct 2023 17:38:30 -0700 (PDT) Received: by mail-yw1-x114a.google.com with SMTP id 00721157ae682-5a7bbe0a453so23718717b3.0 for ; Fri, 27 Oct 2023 17:38:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1698453509; x=1699058309; darn=vger.kernel.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=BD9lPzNt8hnQJcZ/hWgSWD/y67yszl3sQZlzVb4etk8=; b=wRnrNLhowwwCtiquCs34cdBqrU1JXb5Ss+N2lIWxytefgi1RqBRzji+yXiCNmuI6a2 jC2tjMfyEAVDInZJ0z0offntxZQWshtRnBLUP0WEfWYzyU+Vyu3Qv+ti8qe7KJiHjq2k xrWllxJVKdSZFtgbjOZVMnOzaUBGihOSiVSko2XHXipn1Fgqm/7MujSztMZvQW49CloW nbWtbW+YF1p97INXPGE3MOTKqmpTUXePC+s1NqWDXwB6HU7DYrZ2n7/qAaLDAsm+FmSv sTuKZq+cviYleiA5Gz9RQ7qdALxXER1w2BnldWayez+CiYdXc14Odd0dGwAYxekX4xv7 c2Tw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1698453509; x=1699058309; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=BD9lPzNt8hnQJcZ/hWgSWD/y67yszl3sQZlzVb4etk8=; b=Ab1jtziEZWm19gGvouFWtJrhLtWVmpp6vR8sK04D/1M1nGOu+LRnb3MtMB2+AQ5GMA F7BHtzUpbngFhTZUpwCJLsgUCytpHC6k61H2w+RAvGUfg5WCyrvdQVuaGUac9rkuqrat FjLAO5/mDDC/GOrvkdQvmFVoatl+/CCEBD/SqKnunOGY2Z7sDYdh0IyAt0umyjYb001m WsxbOzBQ/Qsc+fXyD6VCh7EZgrLxmM4VM1MIbbWxgUxPyAHcSm2Cq9fML+4TF64ifoLB WkWi1hytzHvJDBzwAbV3MAVxs+V7VDapDpw3yaDgg3JgusF2lIUD3I/RAn0b0kpHJJu5 YFVA== X-Gm-Message-State: AOJu0YwSW08/VBsTC9vj0UNwGpjLFF8HeLl3AVm4qYgpV4Xfh2tNdyBQ oOC5DB6tW3c8BOxc8boEP9NxwlRE+dI= X-Received: from surenb-desktop.mtv.corp.google.com ([2620:15c:211:201:cba3:7e7f:79e4:fa57]) (user=surenb job=sendgmr) by 2002:a0d:db97:0:b0:5a7:b15a:1a7d with SMTP id d145-20020a0ddb97000000b005a7b15a1a7dmr86233ywe.2.1698453509335; Fri, 27 Oct 2023 17:38:29 -0700 (PDT) Date: Fri, 27 Oct 2023 17:38:13 -0700 In-Reply-To: <20231028003819.652322-1-surenb@google.com> Mime-Version: 1.0 References: <20231028003819.652322-1-surenb@google.com> X-Mailer: git-send-email 2.42.0.820.g83a721a137-goog Message-ID: <20231028003819.652322-4-surenb@google.com> Subject: [PATCH v4 3/5] selftests/mm: call uffd_test_ctx_clear at the end of the test From: Suren Baghdasaryan To: akpm@linux-foundation.org Cc: viro@zeniv.linux.org.uk, brauner@kernel.org, shuah@kernel.org, aarcange@redhat.com, lokeshgidra@google.com, peterx@redhat.com, david@redhat.com, hughd@google.com, mhocko@suse.com, axelrasmussen@google.com, rppt@kernel.org, willy@infradead.org, Liam.Howlett@oracle.com, jannh@google.com, zhangpeng362@huawei.com, bgeffon@google.com, kaleshsingh@google.com, ngeoffray@google.com, jdduke@google.com, surenb@google.com, linux-mm@kvack.org, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, kernel-team@android.com Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-8.4 required=5.0 tests=DKIMWL_WL_MED,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_IN_DEF_DKIM_WL autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on howler.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (howler.vger.email [0.0.0.0]); Fri, 27 Oct 2023 17:39:50 -0700 (PDT) uffd_test_ctx_clear() is being called from uffd_test_ctx_init() to unmap areas used in the previous test run. This approach is problematic because while unmapping areas uffd_test_ctx_clear() uses page_size and nr_pages which might differ from one test run to another. Fix this by calling uffd_test_ctx_clear() after each test is done. Signed-off-by: Suren Baghdasaryan --- tools/testing/selftests/mm/uffd-common.c | 4 +--- tools/testing/selftests/mm/uffd-common.h | 1 + tools/testing/selftests/mm/uffd-stress.c | 5 ++++- tools/testing/selftests/mm/uffd-unit-tests.c | 1 + 4 files changed, 7 insertions(+), 4 deletions(-) diff --git a/tools/testing/selftests/mm/uffd-common.c b/tools/testing/selftests/mm/uffd-common.c index 02b89860e193..583e5a4cc0fd 100644 --- a/tools/testing/selftests/mm/uffd-common.c +++ b/tools/testing/selftests/mm/uffd-common.c @@ -262,7 +262,7 @@ static inline void munmap_area(void **area) *area = NULL; } -static void uffd_test_ctx_clear(void) +void uffd_test_ctx_clear(void) { size_t i; @@ -298,8 +298,6 @@ int uffd_test_ctx_init(uint64_t features, const char **errmsg) unsigned long nr, cpu; int ret; - uffd_test_ctx_clear(); - ret = uffd_test_ops->allocate_area((void **)&area_src, true); ret |= uffd_test_ops->allocate_area((void **)&area_dst, false); if (ret) { diff --git a/tools/testing/selftests/mm/uffd-common.h b/tools/testing/selftests/mm/uffd-common.h index 7c4fa964c3b0..870776b5a323 100644 --- a/tools/testing/selftests/mm/uffd-common.h +++ b/tools/testing/selftests/mm/uffd-common.h @@ -105,6 +105,7 @@ extern uffd_test_ops_t *uffd_test_ops; void uffd_stats_report(struct uffd_args *args, int n_cpus); int uffd_test_ctx_init(uint64_t features, const char **errmsg); +void uffd_test_ctx_clear(void); int userfaultfd_open(uint64_t *features); int uffd_read_msg(int ufd, struct uffd_msg *msg); void wp_range(int ufd, __u64 start, __u64 len, bool wp); diff --git a/tools/testing/selftests/mm/uffd-stress.c b/tools/testing/selftests/mm/uffd-stress.c index 469e0476af26..7e83829bbb33 100644 --- a/tools/testing/selftests/mm/uffd-stress.c +++ b/tools/testing/selftests/mm/uffd-stress.c @@ -323,8 +323,10 @@ static int userfaultfd_stress(void) uffd_stats_reset(args, nr_cpus); /* bounce pass */ - if (stress(args)) + if (stress(args)) { + uffd_test_ctx_clear(); return 1; + } /* Clear all the write protections if there is any */ if (test_uffdio_wp) @@ -354,6 +356,7 @@ static int userfaultfd_stress(void) uffd_stats_report(args, nr_cpus); } + uffd_test_ctx_clear(); return 0; } diff --git a/tools/testing/selftests/mm/uffd-unit-tests.c b/tools/testing/selftests/mm/uffd-unit-tests.c index 2709a34a39c5..e7d43c198041 100644 --- a/tools/testing/selftests/mm/uffd-unit-tests.c +++ b/tools/testing/selftests/mm/uffd-unit-tests.c @@ -1319,6 +1319,7 @@ int main(int argc, char *argv[]) continue; } test->uffd_fn(&args); + uffd_test_ctx_clear(); } } -- 2.42.0.820.g83a721a137-goog