From patchwork Fri Oct 18 17:17:23 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Edward Liaw X-Patchwork-Id: 13842074 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 BE3CDD3DEA0 for ; Fri, 18 Oct 2024 17:18:12 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 4F57E6B0089; Fri, 18 Oct 2024 13:18:12 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 4A3A06B008A; Fri, 18 Oct 2024 13:18:12 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 346766B008C; Fri, 18 Oct 2024 13:18:12 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id 12A1F6B0089 for ; Fri, 18 Oct 2024 13:18:12 -0400 (EDT) Received: from smtpin02.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id A631C40939 for ; Fri, 18 Oct 2024 17:18:04 +0000 (UTC) X-FDA: 82687381056.02.CD3CA23 Received: from mail-pg1-f202.google.com (mail-pg1-f202.google.com [209.85.215.202]) by imf28.hostedemail.com (Postfix) with ESMTP id D01A5C001E for ; Fri, 18 Oct 2024 17:17:58 +0000 (UTC) Authentication-Results: imf28.hostedemail.com; dkim=pass header.d=google.com header.s=20230601 header.b=SDHAlH2M; spf=pass (imf28.hostedemail.com: domain of 3UJgSZwYKCAspowtl7rzzrwp.nzxwty58-xxv6lnv.z2r@flex--edliaw.bounces.google.com designates 209.85.215.202 as permitted sender) smtp.mailfrom=3UJgSZwYKCAspowtl7rzzrwp.nzxwty58-xxv6lnv.z2r@flex--edliaw.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=1729271743; 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=UFQHSO14/jAsIAlP6YyLD1M4ZuBPXyCrx6oOfYWGU30=; b=RLlDjDAHMqAICKmKToeJ/feTqmkY/xdEK3EkKDEguURDAjPjlaCmeYUVNQB8JPRFADbH0F 2KnLAms37rfCh7776robCQC8ZWOMqkx2vXp3pY9hJB/JEgzBQoTzX6pPtyL1XWCme858ux okUwBHKMoGZZgGYTEkmwTv2SGHXhvlU= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1729271743; a=rsa-sha256; cv=none; b=XmMYn9Af/uj/Hmo5+Ln+gJgeC8HlB1EKRWSnyq1hjsRafJK6dCqKP48AobG5oez0OFu9Jb tSfPudThpO41WboBpSDIfE1/YDJy4ukVzFt0r8tsG62c2rpiDmh7y56u0AWFifpKtZRI27 PhEIFejRD/74I1XHQnd2jaagCZqgvLw= ARC-Authentication-Results: i=1; imf28.hostedemail.com; dkim=pass header.d=google.com header.s=20230601 header.b=SDHAlH2M; spf=pass (imf28.hostedemail.com: domain of 3UJgSZwYKCAspowtl7rzzrwp.nzxwty58-xxv6lnv.z2r@flex--edliaw.bounces.google.com designates 209.85.215.202 as permitted sender) smtp.mailfrom=3UJgSZwYKCAspowtl7rzzrwp.nzxwty58-xxv6lnv.z2r@flex--edliaw.bounces.google.com; dmarc=pass (policy=reject) header.from=google.com Received: by mail-pg1-f202.google.com with SMTP id 41be03b00d2f7-7ea6ebdf5d3so1259807a12.2 for ; Fri, 18 Oct 2024 10:18:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1729271889; x=1729876689; 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=UFQHSO14/jAsIAlP6YyLD1M4ZuBPXyCrx6oOfYWGU30=; b=SDHAlH2M6C2RUBbZm3S3EXynshBaIBrjfcY/3HjO9k8kmEkRWanO/doRkDWVOoGtwc PC9iJewcMBwYngn7L3mLKZqjYWE+/lzvWauF+s+DmxoFCN5b1FmwMs9/5y9dBgn0wK7X t3E72llAl63TSV6yNSUD7s80qyG/1hOqu5pyichGXmmIhD1nO5ltlFHcfyiy/EUaJvVZ ULoyZj45zkiO0eCVGzrpikib5wdy4p3qZFV+6YpMb4VA4bfSCPGCuRtyJGhfvCZjLnxZ L0WjjoCw7SPjVBE32xNz96MJk6NdaDBNkHZi9Wh9ZRRdfum3Uv3s/H9/2UBzyt8QVkNX XbNA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1729271889; x=1729876689; 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=UFQHSO14/jAsIAlP6YyLD1M4ZuBPXyCrx6oOfYWGU30=; b=hfyvw+FnOhj3zF9lr9iaDFKPwYz9acnRBFFcYcpcP2wUH2rfcd9Je0lhXPcoKoLzeZ CKGflSiQBgxXBh7bfqOTwOPs26/NkLPeJnXorHuvQ5aMvxm+IAFUM2OrzNwm0/eb648l fDzc9eniqBTccOqxaX5sjzm5wVnxbhvmF0SmCqdngcj1u144ZjdYScOn0qHbTtqcSdNq 6TFD3llldNId9cosY2fYwKTtKOquDZ/kqQl5u2AWAeen3GKk87T+BbIcij2IOzztpL09 EryJc94IG3Gt8sDhBLD69mugVYGChUh8gZ3unu2liAzGGGEbKT/dEOo3xPc6vln/njq+ AUzg== X-Forwarded-Encrypted: i=1; AJvYcCU6mKLxddgzuN0jiyrofZCY3VU+mCGi/F3rBatW9aIu7n+sl3PdokypA6ea5P6noMXKNxle/Ahd3w==@kvack.org X-Gm-Message-State: AOJu0YyCpQpv8D3Atu9s9WI5Dbizb0PBr3AFZEAOlrigMfaTOn1SxgXW NXoDa7PiiiDkN1nA36Ji/6K0mEX5AOQOhk0gSkd9E5huhjh3EywkBk5WdRKmTAV7WFevi7ad2ir 9AA== X-Google-Smtp-Source: AGHT+IElgKqKmBxxYFR30EicUCVFsCvFx4Ofclcxsw9+z9zau8/mq1g11dMoqL/6qwWZQUMW1ChAG57xdLs= X-Received: from edliaw.c.googlers.com ([fda3:e722:ac3:cc00:24:72f4:c0a8:305d]) (user=edliaw job=sendgmr) by 2002:a63:3858:0:b0:7e9:f93c:22b9 with SMTP id 41be03b00d2f7-7eacc895cf2mr3205a12.10.1729271888448; Fri, 18 Oct 2024 10:18:08 -0700 (PDT) Date: Fri, 18 Oct 2024 17:17:23 +0000 In-Reply-To: <20241018171734.2315053-1-edliaw@google.com> Mime-Version: 1.0 References: <20241018171734.2315053-1-edliaw@google.com> X-Mailer: git-send-email 2.47.0.105.g07ac214952-goog Message-ID: <20241018171734.2315053-3-edliaw@google.com> Subject: [PATCH 2/3] Revert "selftests/mm: replace atomic_bool with pthread_barrier_t" From: Edward Liaw To: linux-kselftest@vger.kernel.org, Andrew Morton , Shuah Khan , Edward Liaw , Peter Xu Cc: linux-kernel@vger.kernel.org, kernel-team@android.com, linux-mm@kvack.org, Ryan Roberts X-Rspam-User: X-Rspamd-Server: rspam04 X-Rspamd-Queue-Id: D01A5C001E X-Stat-Signature: sqmso6kwtox4tq3xqhrjb5ezso7m8ze7 X-HE-Tag: 1729271878-998891 X-HE-Meta: U2FsdGVkX1/xgjDjiV//R/FLvdHcUP/lJbVZNeL3doZbFLGvUu91rohySZulcD9LEVzBl9+AicMWi9LvrJ6r/hyP3wJMl+QScxXOLuvDpvX6iSwtTlCIKoYxZcuLYTAv7hoRQ1PBYFylvb9vQWL1UHMHKZH5mLIofcfVBo274cQ5LpZbciGnylXu8FDlPw7Qi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DEqoF3r3MUQCgxH4eeIqB9dNsexD8ZanEk+loQcD56EyhJ8QyAXvfBBUnrwmpCy9PIX46Qe33gPoT5WfSVUHlHE1XwYTmNhPbmuIoxj0u6KLOmd2iC7gPtGVWc/TuLgLzfroGHs7EriTRLs+DixBHRXyz4X3jrp0GeKyjajm0tbTaVbSQ0RCIYaTdNu0t8baHy/WR4ELpNJCjJpihTVXnE2nSeXSSYiV3UmPdly47XU+1iH2NUNZaTkNkeqFLWiqrkGk5h/OX1jKUmPilJgFWmeGaOmny6cJy+Ud7KWZ6vm47xgAx2PReDyRF7j5ll8SaS7g1UwDm8/W6cU3tE3kZsoS8iblYLR/Sxu5V+o0z95xlbI0yibzVySY= 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: This reverts commit e61ef21e27e8deed8c474e9f47f4aa7bc37e138c. uffd_poll_thread may be called by other tests that do not initialize the pthread_barrier, so this approach is not correct. This will revert to using atomic_bool instead. Fixes: e61ef21e27e8 ("selftests/mm: replace atomic_bool with pthread_barrier_t") CC: Ryan Roberts Signed-off-by: Edward Liaw --- tools/testing/selftests/mm/uffd-common.c | 5 ++--- tools/testing/selftests/mm/uffd-common.h | 3 ++- tools/testing/selftests/mm/uffd-unit-tests.c | 14 ++++++-------- 3 files changed, 10 insertions(+), 12 deletions(-) diff --git a/tools/testing/selftests/mm/uffd-common.c b/tools/testing/selftests/mm/uffd-common.c index 852e7281026e..717539eddf98 100644 --- a/tools/testing/selftests/mm/uffd-common.c +++ b/tools/testing/selftests/mm/uffd-common.c @@ -18,7 +18,7 @@ bool test_uffdio_wp = true; unsigned long long *count_verify; uffd_test_ops_t *uffd_test_ops; uffd_test_case_ops_t *uffd_test_case_ops; -pthread_barrier_t ready_for_fork; +atomic_bool ready_for_fork; static int uffd_mem_fd_create(off_t mem_size, bool hugetlb) { @@ -519,8 +519,7 @@ void *uffd_poll_thread(void *arg) pollfd[1].fd = pipefd[cpu*2]; pollfd[1].events = POLLIN; - /* Ready for parent thread to fork */ - pthread_barrier_wait(&ready_for_fork); + ready_for_fork = true; for (;;) { ret = poll(pollfd, 2, -1); diff --git a/tools/testing/selftests/mm/uffd-common.h b/tools/testing/selftests/mm/uffd-common.h index 3e6228d8e0dc..a70ae10b5f62 100644 --- a/tools/testing/selftests/mm/uffd-common.h +++ b/tools/testing/selftests/mm/uffd-common.h @@ -33,6 +33,7 @@ #include #include #include +#include #include "../kselftest.h" #include "vm_util.h" @@ -104,7 +105,7 @@ extern bool map_shared; extern bool test_uffdio_wp; extern unsigned long long *count_verify; extern volatile bool test_uffdio_copy_eexist; -extern pthread_barrier_t ready_for_fork; +extern atomic_bool ready_for_fork; extern uffd_test_ops_t anon_uffd_test_ops; extern uffd_test_ops_t shmem_uffd_test_ops; diff --git a/tools/testing/selftests/mm/uffd-unit-tests.c b/tools/testing/selftests/mm/uffd-unit-tests.c index 3db2296ac631..b3d21eed203d 100644 --- a/tools/testing/selftests/mm/uffd-unit-tests.c +++ b/tools/testing/selftests/mm/uffd-unit-tests.c @@ -774,7 +774,7 @@ static void uffd_sigbus_test_common(bool wp) char c; struct uffd_args args = { 0 }; - pthread_barrier_init(&ready_for_fork, NULL, 2); + ready_for_fork = false; fcntl(uffd, F_SETFL, uffd_flags | O_NONBLOCK); @@ -791,9 +791,8 @@ static void uffd_sigbus_test_common(bool wp) if (pthread_create(&uffd_mon, NULL, uffd_poll_thread, &args)) err("uffd_poll_thread create"); - /* Wait for child thread to start before forking */ - pthread_barrier_wait(&ready_for_fork); - pthread_barrier_destroy(&ready_for_fork); + while (!ready_for_fork) + ; /* Wait for the poll_thread to start executing before forking */ pid = fork(); if (pid < 0) @@ -834,7 +833,7 @@ static void uffd_events_test_common(bool wp) char c; struct uffd_args args = { 0 }; - pthread_barrier_init(&ready_for_fork, NULL, 2); + ready_for_fork = false; fcntl(uffd, F_SETFL, uffd_flags | O_NONBLOCK); if (uffd_register(uffd, area_dst, nr_pages * page_size, @@ -845,9 +844,8 @@ static void uffd_events_test_common(bool wp) if (pthread_create(&uffd_mon, NULL, uffd_poll_thread, &args)) err("uffd_poll_thread create"); - /* Wait for child thread to start before forking */ - pthread_barrier_wait(&ready_for_fork); - pthread_barrier_destroy(&ready_for_fork); + while (!ready_for_fork) + ; /* Wait for the poll_thread to start executing before forking */ pid = fork(); if (pid < 0)