From patchwork Tue Nov 21 17:16:36 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Suren Baghdasaryan X-Patchwork-Id: 13463395 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1785FC61D85 for ; Tue, 21 Nov 2023 17:16:58 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 580C06B04C6; Tue, 21 Nov 2023 12:16:57 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 50A3F6B04C9; Tue, 21 Nov 2023 12:16:57 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 35CB46B04CB; Tue, 21 Nov 2023 12:16:57 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id 218266B04C6 for ; Tue, 21 Nov 2023 12:16:57 -0500 (EST) Received: from smtpin02.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id EE8CE40A82 for ; Tue, 21 Nov 2023 17:16:56 +0000 (UTC) X-FDA: 81482616432.02.D8E5F3C Received: from mail-yw1-f202.google.com (mail-yw1-f202.google.com [209.85.128.202]) by imf28.hostedemail.com (Postfix) with ESMTP id 33458C0008 for ; Tue, 21 Nov 2023 17:16:54 +0000 (UTC) Authentication-Results: imf28.hostedemail.com; dkim=pass header.d=google.com header.s=20230601 header.b="tx7CD/B2"; dmarc=pass (policy=reject) header.from=google.com; spf=pass (imf28.hostedemail.com: domain of 3BuZcZQYKCHcnpmZiWbjjbgZ.Xjhgdips-hhfqVXf.jmb@flex--surenb.bounces.google.com designates 209.85.128.202 as permitted sender) smtp.mailfrom=3BuZcZQYKCHcnpmZiWbjjbgZ.Xjhgdips-hhfqVXf.jmb@flex--surenb.bounces.google.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1700587015; h=from:from:sender: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: in-reply-to:in-reply-to:references:references:dkim-signature; bh=+oQWC9tOLeE7lomKytBDg6Tp5S7jbgII3AVJArGJfwY=; b=VgWKsG+gyGchBg3fgvdFG/yH1+M1Up74CTr04ue4mBje2sRxcYHMfl3rdKT9i6z+N3ea6B pmBEUG7IEd8rTHvGyq7mcFLneneeW0a3ncV3TvzKPQFzFbmKKrjE6GxLDNQctV7/cBwyj8 jafv9fm8eel3R7QvHxdH7GEobYhIlmI= ARC-Authentication-Results: i=1; imf28.hostedemail.com; dkim=pass header.d=google.com header.s=20230601 header.b="tx7CD/B2"; dmarc=pass (policy=reject) header.from=google.com; spf=pass (imf28.hostedemail.com: domain of 3BuZcZQYKCHcnpmZiWbjjbgZ.Xjhgdips-hhfqVXf.jmb@flex--surenb.bounces.google.com designates 209.85.128.202 as permitted sender) smtp.mailfrom=3BuZcZQYKCHcnpmZiWbjjbgZ.Xjhgdips-hhfqVXf.jmb@flex--surenb.bounces.google.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1700587015; a=rsa-sha256; cv=none; b=fgfnoFIX5ZIhgBJQvCwDmQ6x243G9dfsRoOLkZ1pkNbl8hNAB1nI7H5IEUbzChuk1Rw53C eS1LlnvJoJ8Ve9hSNrzb1LQcC+bQ1W9ecLD8iSqPcps4g03yTPMVDTyfY0qWQNRvPTI50R ZH2nrWjYBhv46jb/WbArAnQnhdbfcc4= Received: by mail-yw1-f202.google.com with SMTP id 00721157ae682-5c9e6c37bc4so39523717b3.2 for ; Tue, 21 Nov 2023 09:16:54 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1700587014; x=1701191814; darn=kvack.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=+oQWC9tOLeE7lomKytBDg6Tp5S7jbgII3AVJArGJfwY=; b=tx7CD/B2/8o773w32XW+kqnTve+6TxR57+fh6+i1YoPSEnsX0i1rCoOdIStk0/DF+N uxZFD5grXn0Wi5UShzDTdrPa0iO903xk64ASpSKiUyMPVEvbVEZraca4b7PFh2sUSI0L EcOCpaK3s4DcrT8G26c9BprLrqSgv9drJNED//s/dcE2HVHndp7nNYPAYhuFqEJUJpQV v45ZNUJoKccxG3OfgWBEQqSVVTSVHmqrb7k0DD08R4NbI4Fy1PlklUgVLcuCR3avtlZc dL8O3EVMqU7fVtdTeHOThz1xNsV9+sGBpPriQlXjYqy18DX8nBqxdmAGRUjwpUfh8Gcw VdFQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1700587014; x=1701191814; 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=+oQWC9tOLeE7lomKytBDg6Tp5S7jbgII3AVJArGJfwY=; b=Dj24SKqaUWbMSoUzhcqwGSPlU/wbX/qjS55MqN8hjkEyld25jaEnObwz3alQD5OYh+ xWTyfWyNt8bk+Anf/xCKJCAvVXjXFG5uuVje+Mt9S04TJFOiAhisX6kO0SjVMRKoYBg2 vuMSx7qaH+YrE+aVdPbEB3h2xis8+0ijDYMpSKsRY8YvfKdN9C98f02beemkBk9o2Ytj URaBxzRVeqTYXUrEMOPYTqxHzaNBXlusKzcyRUOHDeRDV/I5SPq+WG6fvoV1Snv9vexm 1irf4Y2BQPkRUwU1uTWBu0H0XpwlRGDfJNn2N4BZUVUwDqPRHmMAnVjFZ338ENGN+KMl VXzA== X-Gm-Message-State: AOJu0YzYv+ckgv7FVGyM/0MdW8cAH1ve1MZphMQuvybtwgIQJu2Jr9cq RbSR/XrUs72h3uL4sQ7sar+ToGG1v7s= X-Google-Smtp-Source: AGHT+IGt4XeQzmmYh3UGYq1fZSYeCCXt9DvRPaCqVRLnjG7738p7ZSz3vsLWilwzFfU1DtxScxBgR2AWR/c= X-Received: from surenb-desktop.mtv.corp.google.com ([2620:15c:211:201:2045:f6d2:f01d:3fff]) (user=surenb job=sendgmr) by 2002:a05:690c:891:b0:5c9:1c6a:40f with SMTP id cd17-20020a05690c089100b005c91c6a040fmr290590ywb.5.1700587014155; Tue, 21 Nov 2023 09:16:54 -0800 (PST) Date: Tue, 21 Nov 2023 09:16:36 -0800 In-Reply-To: <20231121171643.3719880-1-surenb@google.com> Mime-Version: 1.0 References: <20231121171643.3719880-1-surenb@google.com> X-Mailer: git-send-email 2.43.0.rc1.413.gea7ed67945-goog Message-ID: <20231121171643.3719880-4-surenb@google.com> Subject: [PATCH v5 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 X-Rspam-User: X-Rspamd-Server: rspam12 X-Rspamd-Queue-Id: 33458C0008 X-Stat-Signature: r95ntx6ajcbatyay4ahawjjuqfoxscni X-HE-Tag: 1700587014-563189 X-HE-Meta: U2FsdGVkX19TQSVqjpz3c4WWWfynT8EPp4iesEzF7R76a+xNpnsTUoSlMHcszTEC53jqYK5g4iZ7UiBLLr5cV2L8XNHkZvwvPJe1TKGh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RMO4cUvr0RI3ewwecYHcvarI+qu8DKN1sr9sQEhNYfWbh66VIngBDw0DCCrNlql4Hh5I4staxgoGaBhMvk1yy8BYWyqtvQD4aPOEyHjJJECTbYVUE5S/3FfT/xRdCkT/VInoGbh7ehNEWWNR7QZ8Y0/s2rHgksgYh2pz4a+aXudSLPeGfZFbyqIQEVhDrlPcNRao18nq+uiN7UEQXkvueDgTVxIKJzSZyccG3FEMMPVJ2bCJbT+mL4QPPn7dQ8wynDB8u/cyE2xzPNLmeZ5hwiFFOILSy9slzkvx3fMBRJOd0zJKbmk86LzHDTXDnDfC4d6SCniHVvMOLXfAX9YgUJH/YfR8skKzFnYTNX+ruanOTBQdqlupAsB/9FBu8mFj0s96/odOXQofzQWBMfBaZHnI7sdtCy3NQ5bmMHWV/LFN/101O63uDG1jk2gMzBgoRvlG/VQQE2Vsc8L5N8GSgH1b68ZhhCAIb1EvS3k9usF61MZW+ArmV+6Lq1HzCzDt2TrTLQkLawVc8L5RR465STQaHxSmoqn1A== 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: List-Subscribe: List-Unsubscribe: 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 Reviewed-by: Peter Xu Reviewed-by: Axel Rasmussen --- 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(); } }