Skip to contentSkip to conversation

selftests-mm-fix-deadlock-for-fork-after-pthread_create-with-atomic_bool.patch removed from -mm tree

merged mm-hotfixes-stable Andrew Morton 1 participant 1 message Oct 24, 2024

lore
Share & tools
lore

Andrew Morton

author tree notice Applied
#0 lore raw

The quilt patch titled
Subject: selftests/mm: fix deadlock for fork after pthread_create with atomic_bool
has been removed from the -mm tree. Its filename was
selftests-mm-fix-deadlock-for-fork-after-pthread_create-with-atomic_bool.patch

This patch was dropped because it was merged into the mm-hotfixes-stable branch of git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm

------------------------------------------------------
From: Edward Liaw <[email protected]>
Subject: selftests/mm: fix deadlock for fork after pthread_create with atomic_bool
Date: Fri, 18 Oct 2024 17:17:24 +0000

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 <[email protected]>
Cc Peter Xu <[email protected]>
Cc Shuah Khan <[email protected]>

---

 tools/testing/selftests/mm/uffd-unit-tests.c |    5 +++++
 1 file changed, 5 insertions(+)
tools/testing/selftests/mm/uffd-unit-tests.c renamed from tools/testing/selftests/mm/uffd-unit-tests.c~selftests-mm-fix-deadlock-for-fork-after-pthread_create-with-atomic_bool +5 -0
@@ -241,6 +241,8 @@ static void *fork_event_consumer(void *d
 	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, b
 
 	/* 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();

_

Patches currently in -mm which might be from [email protected] are