From patchwork Wed Dec 6 10:36:57 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Suren Baghdasaryan X-Patchwork-Id: 13481429 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 30523C10F07 for ; Wed, 6 Dec 2023 10:37:16 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 2EBB86B00A5; Wed, 6 Dec 2023 05:37:15 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 29B246B00A6; Wed, 6 Dec 2023 05:37:15 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 116806B00A7; Wed, 6 Dec 2023 05:37:15 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id F24FB6B00A5 for ; Wed, 6 Dec 2023 05:37:14 -0500 (EST) Received: from smtpin04.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id C8EFFA0174 for ; Wed, 6 Dec 2023 10:37:14 +0000 (UTC) X-FDA: 81536041188.04.1F59178 Received: from mail-yb1-f202.google.com (mail-yb1-f202.google.com [209.85.219.202]) by imf30.hostedemail.com (Postfix) with ESMTP id 1370B80002 for ; Wed, 6 Dec 2023 10:37:12 +0000 (UTC) Authentication-Results: imf30.hostedemail.com; dkim=pass header.d=google.com header.s=20230601 header.b=IxgfOk0j; spf=pass (imf30.hostedemail.com: domain of 32E5wZQYKCGkZbYLUINVVNSL.JVTSPUbe-TTRcHJR.VYN@flex--surenb.bounces.google.com designates 209.85.219.202 as permitted sender) smtp.mailfrom=32E5wZQYKCGkZbYLUINVVNSL.JVTSPUbe-TTRcHJR.VYN@flex--surenb.bounces.google.com; dmarc=pass (policy=reject) header.from=google.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1701859033; 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=Puo0/IOkGZzeDNo6LANVKcztB/uZ2FwQ4rTVo9jmukU=; b=0ie1EihS030vLh6qoyqh121UzfKl10vl8aMedaMsu3QUYm5oBLK8usULdXgvOskdYIe9We TvQCd7Xxn+/8TUIUB2jaNvLz5OuzKXVyBioNyjCC+70a7H+DyDFCXhuS7kRJeGACTuujgU F3otIU7MMvo9HDzD8QoWc0sT/omIFMo= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1701859033; a=rsa-sha256; cv=none; b=y9hJtlie9D/wgy3YfmtBvXNj9eIMgDFac3A0Z9ebUA+5oZix8ugoxfGrNf/pH2huTixBqS k8A6OOL+4QeextPOQII6I4y3luQDx4T7uY04/7u32e4o5XfyC/2HYLN2C9tMCR+fbwzQRX XssYtfStyu7DtlrE9ZmaLVmjRtz/5T4= ARC-Authentication-Results: i=1; imf30.hostedemail.com; dkim=pass header.d=google.com header.s=20230601 header.b=IxgfOk0j; spf=pass (imf30.hostedemail.com: domain of 32E5wZQYKCGkZbYLUINVVNSL.JVTSPUbe-TTRcHJR.VYN@flex--surenb.bounces.google.com designates 209.85.219.202 as permitted sender) smtp.mailfrom=32E5wZQYKCGkZbYLUINVVNSL.JVTSPUbe-TTRcHJR.VYN@flex--surenb.bounces.google.com; dmarc=pass (policy=reject) header.from=google.com Received: by mail-yb1-f202.google.com with SMTP id 3f1490d57ef6-db54a19c7d6so5703555276.3 for ; Wed, 06 Dec 2023 02:37:12 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1701859032; x=1702463832; 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=Puo0/IOkGZzeDNo6LANVKcztB/uZ2FwQ4rTVo9jmukU=; b=IxgfOk0jZs5V0JXdxIsdkEpFEqcFAxngELMcJBxwrY/dyBLiHANpbD5BEJ7SgB5F5u bBet5VaJ5f8xgRpB094yPpGN7wEnPwqWacmsO5LQ//9zCCtdxBV6Kc0cS7CFcxq3DCrI baj+nrHDmxzeJdsezETAWPOuVwwm7G+cjW9MwfUyz2Ddw1ob0SNAiAlyExqcQjCsncqC k+jGrgPQKfIYUkFgt8BSuOAWSplz3oc/+Rdrxj8Fj4diKyIKUvyVJRrRiVCNkf+vuw6R v3Zhld2yQTQ9ey1KKFR2irIIVuZ2wMTzcL+L7hKQ32mcpfge/5TT8jlffhre00T6pvw8 EtLA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701859032; x=1702463832; 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=Puo0/IOkGZzeDNo6LANVKcztB/uZ2FwQ4rTVo9jmukU=; b=nXHrdwRNbL7vn+G81zHqAsKYbqCmJjILPCWU9LtnwYQrWUn3Ks6WZWw5c+GePICvMc 4GDFE2Uwz2oZl2abWfneiueJRCSLY2dQuU3S1XJSI3whbxcYaBgEVKwOXzo55sqIdpuZ B6YconlsdL/5T74JBYbQhlNOOG72EOZ8OeCvyIPlxLnHzcCHAekrkPmXaODsG7SWCJhB WgMOgWmcUQWRmUkOwYphtrCVrxOOObkITy7bCJFnWP+MHH2wuxt/hc+ccClwgLGg73dl IHMolFTKlQOaL4ECQiFWbJ4uw+eXk9+VoECGCkCDY5gyK47ybQHyHvSG8XU33dqlcS33 tDTw== X-Gm-Message-State: AOJu0YzaNdlLR90GDhsxAj23PB1ZE+bf6rpiKqiT4E29aMcApxZ3DK/5 t91o9nSe9i4k4j6pvXRjBa9ULbS1E/g= X-Google-Smtp-Source: AGHT+IHA1Y29L+NkSe0tx6k2aoEfMY/lNB6ALySjHtUB1ExXnuX9TN8ZY2Jn+/kFOMbKEKZSCPu3KGAmWc0= X-Received: from surenb-desktop.mtv.corp.google.com ([2620:15c:211:201:73f6:b5e2:415:6ba5]) (user=surenb job=sendgmr) by 2002:a25:3144:0:b0:da0:5452:29e4 with SMTP id x65-20020a253144000000b00da0545229e4mr5930ybx.0.1701859032195; Wed, 06 Dec 2023 02:37:12 -0800 (PST) Date: Wed, 6 Dec 2023 02:36:57 -0800 In-Reply-To: <20231206103702.3873743-1-surenb@google.com> Mime-Version: 1.0 References: <20231206103702.3873743-1-surenb@google.com> X-Mailer: git-send-email 2.43.0.rc2.451.g8631bc7472-goog Message-ID: <20231206103702.3873743-4-surenb@google.com> Subject: [PATCH v6 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, ryan.roberts@arm.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-Rspamd-Queue-Id: 1370B80002 X-Rspam-User: X-Rspamd-Server: rspam11 X-Stat-Signature: 95b95awhcuz33c57wqqrptzs76jk4ro7 X-HE-Tag: 1701859032-49558 X-HE-Meta: U2FsdGVkX1+17DcXXBZVrCGyM+rtYjGmQFauvmLHZm3gnqwnFYFvGmmAJGbfdorS09Z2XAHR2zYq8rYeFOiMPY67cOrT0mwQtZeBioEU30GZD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3iOUZicx8zEGcvHmwQqky1DMY8W88fhoCAv5jJR2M6rEwrYnFCkUi0/VXqtuEyhvQrl6PBjX0SZqyl62i/6mbBU1JV6n3x81M4ISl47Yo1PNtC0gfh/jsMfnqy9NURdQeyKYDvEsD81s1JUt8QdwQRZ79gXfT/LJjXBJPUU7IANFtvDKifpEOCqi5a+Q822yjstCWShCFooayc8k2aYUpFnXRr4GkUJgfacQdODN0oi0C8vEq57RjeT6l1cp7UImezPw6SQRot3R8CiTnmZKUJ2zs1XjTpOhssSNNhItgj25o6qUmzoMWGgtkdMuBMFrLRSv6RvmwidiZwGfecfRtwRuC7W8mkBiISi95K1equkxe+LGsY8GloNfwk+g5alzCZzg45lgFQtFSR5zqhuHgQnDBLJpTWXBJvRPB0Ck55wDWdspcmV5v7kvE6R6+PxUjdgjg+tuzHus4N5A3Ky72zk/S3TPpjiTMawa8Z/evBrAHcm8hWrBkcBQ4OULTnxtMzasjVzDCcIqG8yFGa5qKnoCAg== 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(); } }