From patchwork Fri Oct 18 17:17:22 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Edward Liaw X-Patchwork-Id: 13842073 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 59598D3DEA0 for ; Fri, 18 Oct 2024 17:18:09 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id DA7396B0083; Fri, 18 Oct 2024 13:18:08 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id D56226B0088; Fri, 18 Oct 2024 13:18:08 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id C1DDF6B0089; Fri, 18 Oct 2024 13:18:08 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id 9EBB56B0083 for ; Fri, 18 Oct 2024 13:18:08 -0400 (EDT) Received: from smtpin24.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id EA421ACE40 for ; Fri, 18 Oct 2024 17:17:43 +0000 (UTC) X-FDA: 82687380720.24.4D2B598 Received: from mail-pj1-f73.google.com (mail-pj1-f73.google.com [209.85.216.73]) by imf05.hostedemail.com (Postfix) with ESMTP id E2323100005 for ; Fri, 18 Oct 2024 17:17:44 +0000 (UTC) Authentication-Results: imf05.hostedemail.com; dkim=pass header.d=google.com header.s=20230601 header.b=ltsVJowU; spf=pass (imf05.hostedemail.com: domain of 3TJgSZwYKCAclksph3nvvnsl.jvtspu14-ttr2hjr.vyn@flex--edliaw.bounces.google.com designates 209.85.216.73 as permitted sender) smtp.mailfrom=3TJgSZwYKCAclksph3nvvnsl.jvtspu14-ttr2hjr.vyn@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=1729271812; 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=09rqkYzv1mj2i541CG3quDs2Oto4Z5t/2Gr1EPh2MJY=; b=dqBbm6dqryT05qMA3k236hBa3r07a+WPgF6zm5HuW7SOPr/8eMAuI0c3yJ4MQ35UG5BAU0 92RL9SguImthRkFUy15YDzTksibSZBbQ6hObzZ23uu6rkOhG9ZP5JpQHqMzwYOIBCgaXvL SjKlfemygMN1E+BPYNr9JJgQWspssdk= ARC-Authentication-Results: i=1; imf05.hostedemail.com; dkim=pass header.d=google.com header.s=20230601 header.b=ltsVJowU; spf=pass (imf05.hostedemail.com: domain of 3TJgSZwYKCAclksph3nvvnsl.jvtspu14-ttr2hjr.vyn@flex--edliaw.bounces.google.com designates 209.85.216.73 as permitted sender) smtp.mailfrom=3TJgSZwYKCAclksph3nvvnsl.jvtspu14-ttr2hjr.vyn@flex--edliaw.bounces.google.com; dmarc=pass (policy=reject) header.from=google.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1729271812; a=rsa-sha256; cv=none; b=c9XZbz+GwDwpGmlffXkLZFs7hjOUFqdnuUD9qvgJb6bTA4efWezeBjAfHATlzpKwrh8zVZ bdlDlbBQMkV4JzTr+lfatSI3S5F9XuMbaDybiuw56y0CEuCt8aFzj/R42KuCo1suxY/Wi6 aunE8gdaAe35Of56QrtLekbe5u19HQA= Received: by mail-pj1-f73.google.com with SMTP id 98e67ed59e1d1-2e3ce03a701so2655779a91.0 for ; Fri, 18 Oct 2024 10:18:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1729271885; x=1729876685; 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=09rqkYzv1mj2i541CG3quDs2Oto4Z5t/2Gr1EPh2MJY=; b=ltsVJowUgqHKsB0QeqX55pU1OrrHvdDAjDOPywMrVcglMBbw5fkRZwkho26RA1hePN i52nq3/D3qS28bkDB1U68AmkxlkR5zPbzQuQNmn5WeurCpxzoCKweUEPZgIiEnzmyzG0 enUvaTBdo/gdawZlrJBebY9lamaRc8xu7Y1JfN5VKf5f/G7VqsVLT3wJIdqWcdcHW1bj WULFSX4E8SB9zbzB/fVh0EivtN0FQnob9cy2LwmmjQGiJcWvMhccoOeif1aw6FlROlJZ am7NRpa5w0P4u9XH5FwoDmKq8EragBvwRhq3OWkEcols7P1epV3kmlDRv42v0CIf5S54 Bv/A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1729271885; x=1729876685; 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=09rqkYzv1mj2i541CG3quDs2Oto4Z5t/2Gr1EPh2MJY=; b=WfyQ6svCj2HZNHCo16lvB4u7cIQHrrMXPUNK/y/wRpSBDoSWMiituqJ835KD+ZLgEc zc+CoQuoH8wFKi1MhxhfniytRHnEEHxmLP9ONnHBSLhXXpeQMwLQbDMh0RERZD5GNFNp lwV50ls1fjm47iqlZlOugxxA3WqzMj6q7/QAFlB8rnU08jvBJJYpQIfFAUPOr2k7p6Ui vgr2b/huu8evR4GjQnTN3HE/lnafMEgAZuG+jZuepCVwQG5SaxZAtD7/gLQn9694ypyt RmaMRLKOk6YVKzoM++XVoTDY4o9weJbVMRSH4zUwi+xLmcljm5Do7w9yVEtdR3//3SKv ZlQQ== X-Forwarded-Encrypted: i=1; AJvYcCVANGxrlzs4EonfG9i70g/aAYomZVh7pOL398oH1DHdXwBhO1WXv8S9GPiDgoXjIsuDzYCiSYQl1A==@kvack.org X-Gm-Message-State: AOJu0YyoS53KtIby/HHgW82bHD7UzETS8VLRP/90W6xSwt4hdmXJDLW0 DR8ikwcgfGJtUFuKl0I+Kra73thQN2Sa3fFm/raTKf1+YQU9kxQvA6u/vEEjl6JzY1nFeBRiYpc daw== X-Google-Smtp-Source: AGHT+IFCzoFKtcQsGl5HORvI+qdsZRNBp3NS1MD2ovvhIYOdGqZKLlvaQri87EIXebpvo+p31wOY+8NUM+A= X-Received: from edliaw.c.googlers.com ([fda3:e722:ac3:cc00:24:72f4:c0a8:305d]) (user=edliaw job=sendgmr) by 2002:a17:90a:dc02:b0:2e0:72ab:98e9 with SMTP id 98e67ed59e1d1-2e561511115mr9463a91.0.1729271884764; Fri, 18 Oct 2024 10:18:04 -0700 (PDT) Date: Fri, 18 Oct 2024 17:17:22 +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-2-edliaw@google.com> Subject: [PATCH 1/3] Revert "selftests/mm: fix deadlock for fork after pthread_create on ARM" 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-Rspamd-Server: rspam03 X-Rspam-User: X-Rspamd-Queue-Id: E2323100005 X-Stat-Signature: qo1zsw96nt1finh7j3uhfyr7d14mmmj8 X-HE-Tag: 1729271864-274404 X-HE-Meta: U2FsdGVkX187XjcMaZUFwzlSR+jaH9OMs91KZpLrZmPbw0ue/lv+4lF8R5jRVnatJKphwIxa0qT1/YuYoSiK96uipv/5cSVk8lwoWiuqnEA6vD2VNdsIUlo1VWhmIV2BVjvps18db3FHAteLl64+/TEeHZ7MxDHzxby1AMPH0vSk+6zvncEVnQ87o7G/SFZSqV66mauMu+onh/WJhi9HkzOSXK3nvgek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odhDnIy4HdJKIzfkoFWheOkVYAgGq0TkrCCIFLszYriuimt5520/kvu6bfUHOr3P7EBdA30VQz3nJjYLxaIgOuNGkm2ulIsT3lys7HIW9SspVM7eW7WmRVva/bm9mBYemN9adIemu+vMfAPOWdFmBEDf1WuNL4HAolanyHCFWpdg8fYWoS2rzEX7qgUzRcjlg7HpWhAWnqhRlRltpScE3VqyXdjVmByxiXTPfW9Yd+eQ1gK+dBZvxwUZ8cZROt/2Ey42T7Z7gGR0N7ErAZtEO9Igby2EwgYU/5adIZmDFg1gAHBQmjt/MuVM3TiskNLXQKDhA= 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 e142cc87ac4ec618f2ccf5f68aedcd6e28a59d9d. fork_event_consumer may be called by other tests that do not initialize the pthread_barrier, so this approach is not correct. The subsequent patch will revert to using atomic_bool instead. Fixes: e142cc87ac4e ("fix deadlock for fork after pthread_create on ARM") CC: Ryan Roberts Signed-off-by: Edward Liaw --- tools/testing/selftests/mm/uffd-unit-tests.c | 7 ------- 1 file changed, 7 deletions(-) diff --git a/tools/testing/selftests/mm/uffd-unit-tests.c b/tools/testing/selftests/mm/uffd-unit-tests.c index c8a3b1c7edff..3db2296ac631 100644 --- a/tools/testing/selftests/mm/uffd-unit-tests.c +++ b/tools/testing/selftests/mm/uffd-unit-tests.c @@ -241,9 +241,6 @@ static void *fork_event_consumer(void *data) fork_event_args *args = data; struct uffd_msg msg = { 0 }; - /* Ready for parent thread to fork */ - pthread_barrier_wait(&ready_for_fork); - /* Read until a full msg received */ while (uffd_read_msg(args->parent_uffd, &msg)); @@ -311,12 +308,8 @@ static int pagemap_test_fork(int uffd, bool with_event, bool test_pin) /* Prepare a thread to resolve EVENT_FORK */ if (with_event) { - pthread_barrier_init(&ready_for_fork, NULL, 2); if (pthread_create(&thread, NULL, fork_event_consumer, &args)) err("pthread_create()"); - /* Wait for child thread to start before forking */ - pthread_barrier_wait(&ready_for_fork); - pthread_barrier_destroy(&ready_for_fork); } child = fork(); 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+QScxXOLuvDpvX6iS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a0L6FwwxfmmTbYbFl6kPt6wiwqZLdo1IYDbP7JUFx6W+pP49OQ6decjtdweIGNedtyqh9x07XAlnCHG35K+3eDEqoF3r3MUQCgxH4eeIqB9dNsexD8ZanEk+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) From patchwork Fri Oct 18 17:17:24 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Edward Liaw X-Patchwork-Id: 13842075 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 A54C9D3DEA0 for ; Fri, 18 Oct 2024 17:18:16 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 346BB6B008C; Fri, 18 Oct 2024 13:18:16 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 2F6C66B0092; Fri, 18 Oct 2024 13:18:16 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 196F26B0093; Fri, 18 Oct 2024 13:18:16 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id EE20F6B008C for ; Fri, 18 Oct 2024 13:18:15 -0400 (EDT) Received: from smtpin30.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 58375C04BD for ; Fri, 18 Oct 2024 17:18:02 +0000 (UTC) X-FDA: 82687381014.30.A2848C6 Received: from mail-yb1-f202.google.com (mail-yb1-f202.google.com [209.85.219.202]) by imf29.hostedemail.com (Postfix) with ESMTP id 9341612001F for ; Fri, 18 Oct 2024 17:17:58 +0000 (UTC) Authentication-Results: imf29.hostedemail.com; dkim=pass header.d=google.com header.s=20230601 header.b=QfqdxVkU; spf=pass (imf29.hostedemail.com: domain of 3VJgSZwYKCA8ts0xpBv33v0t.r310x29C-11zAprz.36v@flex--edliaw.bounces.google.com designates 209.85.219.202 as permitted sender) smtp.mailfrom=3VJgSZwYKCA8ts0xpBv33v0t.r310x29C-11zAprz.36v@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=1729271748; 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=dqicHt23y2Txc3ltQfz9r7Ld+Ys6zd7l3ho/WLmRnAI=; b=fBeGfLnNS6NcQ8YJDx/X7N5X60CtxyYzHqXXhMuhVIVsgKz3FWhIVvf/XxqGlswaDFCZ3G CKR86OO/IsC/WWCWIBPGuXGEPWCqYgty4Um4zTV3YaZ0+Z2T93aosyqCdpaDBiZmhy6slR rUArk7YsyFtGRFADczluK12oi5nxNf4= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1729271748; a=rsa-sha256; cv=none; b=mCtqnTFhE5hAgBkPZnF4g+FyZ2Df3uivpkwJxVPWDaYp8O3TmdUSP/vZ5Rv1HK4WydRpyD OL+IPf7AwHuRnz/X7FQURgNHYozg6Eu+LF0HLb8DIxOBoaFjiF5oVk6387efTdbVydaBWJ 0T2bqZq8/SZTipLlqW2DMwg7eM6XLZk= ARC-Authentication-Results: i=1; imf29.hostedemail.com; dkim=pass header.d=google.com header.s=20230601 header.b=QfqdxVkU; spf=pass (imf29.hostedemail.com: domain of 3VJgSZwYKCA8ts0xpBv33v0t.r310x29C-11zAprz.36v@flex--edliaw.bounces.google.com designates 209.85.219.202 as permitted sender) smtp.mailfrom=3VJgSZwYKCA8ts0xpBv33v0t.r310x29C-11zAprz.36v@flex--edliaw.bounces.google.com; dmarc=pass (policy=reject) header.from=google.com Received: by mail-yb1-f202.google.com with SMTP id 3f1490d57ef6-e0b8fa94718so3539638276.0 for ; Fri, 18 Oct 2024 10:18:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1729271893; x=1729876693; 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=dqicHt23y2Txc3ltQfz9r7Ld+Ys6zd7l3ho/WLmRnAI=; b=QfqdxVkUurrTC+Akby+Sp5ih3QrPjbXCy4tjyraOQZqKkLettvO0w0U2OH2srPeASi mxyvsTY6IJypAE39QP8y4yhLxm33mgNdkjDIJwfQqs+Ui4SFku/f8vtc/nSG2DlFLJYt ZX2xI9vVvCWuXETzJoHjiEKFbSk2gcjDGKFX+jXOEeOeT8ieZW5Gp4neGKmYaVJNtQdc bzGXFIFdkaPxQsaQ02dIO/MT9+gEVZn7bWwos2KV9XqSRSzUXFi1EoNfKAPo8UXW6zdx CL60emEPOFUgBr6IFCashJqyWAahoiRRWuklfRbyhmEAk5hVCrsI7Qjs7ENTPCvAjIe0 yUzQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1729271893; x=1729876693; 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=dqicHt23y2Txc3ltQfz9r7Ld+Ys6zd7l3ho/WLmRnAI=; b=LujcNla9Rz8kDHhzqtntMbwocFANxlyE+mBVblFvxsKLD6IuIE9fa3ehNN6R1onjuN KhwAHOxOOok2WPnUxjXGctZ+cnbD5ebwnEUXROUhdDFZtgl/tPSXJ9EoxpZLckjK4D31 1GrttmmH4F4OsgmGCPQ2YD9IuWIqu+ZYxxuplw7EkSpe4GIxwHl1qTJFg7cqQUFx4KU8 MpjCFhhQJRMBnc2fStN75ju+jVb6XiJEzPsWYa1DGVgE9qTYXypYn0P3t0XbKFyOTdFv ZJGTtTH7VV+mkfuyY+cVgXfXwYzQTBaQmW2X+r9SzNxgM1Pn3543yLNjMovGHzdzOPyt CJoA== X-Forwarded-Encrypted: i=1; AJvYcCWgsl2W5sANU/TX/5az08Rxlc1CdynAOWf+BoK0W7gqTM8QtZNemZujQU0aC17nh+fT1m+Z0Qc09A==@kvack.org X-Gm-Message-State: AOJu0Ywlv3QM1WuZwpF24vb823I9/gKCUsaSqj9kvwys8Ub7LIjSST92 Elx7ZAFk1kpvMbIlDc8ERTjmG6bf/AlWXUsufEcKA5BjGgDoNxy6MH4jfbBSWvCBl0Z9wSpRzAy MXQ== X-Google-Smtp-Source: AGHT+IETe8cpTBCpQKyA4kbFf3lNf2xFOaZ0iITih7uovjfurWUIEAi/snUf1XNhONUTm2/f6zAtyiP2pUI= X-Received: from edliaw.c.googlers.com ([fda3:e722:ac3:cc00:24:72f4:c0a8:305d]) (user=edliaw job=sendgmr) by 2002:a25:360c:0:b0:e22:3aea:6eb5 with SMTP id 3f1490d57ef6-e2bb158a8cbmr4986276.7.1729271892276; Fri, 18 Oct 2024 10:18:12 -0700 (PDT) Date: Fri, 18 Oct 2024 17:17:24 +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-4-edliaw@google.com> Subject: [PATCH 3/3] selftests/mm: fix deadlock for fork after pthread_create with atomic_bool 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-Rspamd-Queue-Id: 9341612001F X-Stat-Signature: 8efnojakx1ife46mt11ace6bqphad8um X-Rspamd-Server: rspam09 X-Rspam-User: X-HE-Tag: 1729271878-512503 X-HE-Meta: U2FsdGVkX19jHjlRj9KKLU94ayFSyJXVDvJN5cuvkFYskLODmhAgDKTwrT/yc/7TisZJEqgSLcIY8McXk8dCuqrM4CGIvsKmDBL1qqmgW/nkJAufuwOiiasVi/DKt3CzGZvZ6b3PqPRc4x2btFadVouzC2MaM6xxIm1GilimOowkgB3429fMj4vS/yPT27wX+n1pju7Utlp0azJIS7oKQMdKuHd6jStSBY+OnxwftKMix2G9d4g84JCICdgUMF/KZtRj+FWoQ5J53h3VciYUHoSCYxiA2qMy62dXBL+eDqnJxZOUsBuYmVp5H2S/2o8kLjqghArr+CnyZSwokZsaLK8aattBUUYcbt0bkXMw+6T8ln0mrJRrIjn1Mq3GMN6DX4DSNZTTtBQSaOTO0KHagqsyVkHXJGeh7lPGl4ZtNaTHIoBPQZROR85Edyh4csN4uNU7OlOkB5da5GjVsZGumTYFYJNAmwDDdi8jaPHucZALVD3iURc0SHV6oKjI2If+oXHvfJs2LJ2o2+zDDQjz/B26MVUbJhpId0Br3A5/A5RE7KetSoljyRspy0V7lCeu0W+Ks7yceNVIKhs3w6kYIjS4r6kBZW5t0TJeSZL9j/PafbDFhm6ny5Upz35z1WzN6wEECgvgVmZevSs9DFjoT2d+ttDsh4HLb1ZBPAFysLBExDnec+sELVMdRmDbOWgea8Ym0RpA8y0UfVlJWgnMNsrNcDpxlvaaXVKx31ROU5kc63+Ckh6UYT8iJKIUGlZtHPwMB9mP1UniGwuqh7vllmsCy8tvUNLgWRbdviPyPoBtLjqxm6OFblc6UTYILNddN2JD4Lv0l5HL8xymRWivo0S+cxNcoFq292vtJzMw1CbfbdqhXu6wfIorO0AuZ2W4aedR+BcZ0HsIYMKhcRsQOnMaf8ERK5SEKoiPnA/j3qtJTavCXBlIHHX9kl+0+IWTkud1i9S9LWcK7OrA4a5 mGXyeyDJ 6PY/r7GvzleGkeng1lcsDzs7LasgC4/aCH0g3NT9aryDhja57ZXURVmucHySwXhxULUA362H07zqPr8uULtzrgg9JHXQNSDysyZ6LrNZsjPD9XnWgkBeWNOc8y7dn8D1YDsljVW+cuBD4FFm/4mWtN2oLmpdBrIFu2dIbukM/h7YUTI7KWTxvNcKfb8CRVIBj/TAQs0SGiaIXRBnSnJ8/FcrECCXFr2R2EDkTZH3mXA3xt4I4+MgjloNSg6qUjXh2cmS520gSiMZX4YfwcbXXhNN+L4OF0x/bowRxJgEUMSUDvoNpa0BrKBx6oSwGw4g1fqJVZcl0g88I+8AFk2OqHbw1VE4lVCqebEySRoOOs8eSoFK8aRnXs5TrAASorGStjR0HRwji6g2wQs3SqI8mNfbx1tzdYQmN7V7z6TJ/Kk2oE9o6OqPduAP7p1eoIkFGV4cQOF3T21yU4rD8+v/4h40ZZs+q5JeqSky3iTzI8NMvaqafwi4ROx5qZ66dRiCehbSrslKFiwrKFz2+BYK8vbDxwhJbSZVNdiSDwZt/j/pn64wjoPmBv9lMWJdNEaRiSZBsE8TH9DJeRInweI7/0ask4W/Z+M3YKQxzcnXuri1aYosce27/tExxeGt7B/8aJVk8kaQ56keJSZg= 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: Some additional synchronization is needed on Android ARM64; we see a deadlock with pthread_create when the parent thread races forward before the child has a chance to start doing work. Fixes: cff294582798 ("selftests/mm: extend and rename uffd pagemap test") CC: Ryan Roberts Signed-off-by: Edward Liaw --- tools/testing/selftests/mm/uffd-unit-tests.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/tools/testing/selftests/mm/uffd-unit-tests.c b/tools/testing/selftests/mm/uffd-unit-tests.c index b3d21eed203d..a2e71b1636e7 100644 --- a/tools/testing/selftests/mm/uffd-unit-tests.c +++ b/tools/testing/selftests/mm/uffd-unit-tests.c @@ -241,6 +241,8 @@ static void *fork_event_consumer(void *data) fork_event_args *args = data; struct uffd_msg msg = { 0 }; + ready_for_fork = true; + /* Read until a full msg received */ while (uffd_read_msg(args->parent_uffd, &msg)); @@ -308,8 +310,11 @@ static int pagemap_test_fork(int uffd, bool with_event, bool test_pin) /* Prepare a thread to resolve EVENT_FORK */ if (with_event) { + ready_for_fork = false; if (pthread_create(&thread, NULL, fork_event_consumer, &args)) err("pthread_create()"); + while (!ready_for_fork) + ; /* Wait for the poll_thread to start executing before forking */ } child = fork();