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+n1p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gEUMSUDvoNpa0BrKBx6oSwGw4g1fqJVZcl0g88I+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();