From nobody Fri Dec 19 19:03:08 2025 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1AA91185E7F for ; Fri, 16 May 2025 16:03:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=193.142.43.55 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1747411433; cv=none; b=CUwu7yr7u/H9hn3WW1tuN/i+1sxysIOkkNlQi1K/uIxCr9hql9+dZRr1lLz2lsQ7MjD1U6WTIQH1OkPtUAzL5dyAk2X1WQb3y+Apa+9WwbDs+2B6lpm2jlO/H/LH+cH+3TtFOtaoTdYQDFfJ4jt2ojSs9YBh9AA8ETEyM7UmK3g= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1747411433; c=relaxed/simple; bh=+Nuby/da43rkNd8wJ4TjPMDY0zqZJK0GZ9Q8sdM3dCs=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=KtboWsXSjB3y604UsP7pzLISkEFC8GcJpNglVsV6qWj2vmcElVC24AfJNesCIqVealvACWcw/E9qDB1eNSSpwtL0g7x/++c+TI6FrrapZeU9MOsKCYek8dgQ+6s5q5Xa8jOIpY6t0IMZZn78ldJJcTtA9gWdR+EpS4St6luDY/o= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de; spf=pass smtp.mailfrom=linutronix.de; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=qySa7i2p; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=f9ETIf8T; arc=none smtp.client-ip=193.142.43.55 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linutronix.de Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="qySa7i2p"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="f9ETIf8T" From: Sebastian Andrzej Siewior DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1747411429; h=from:from: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:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Md1Iu/Vc6/tFjsAFQawntDSjXyMhe0xSdZLpvaoPbo8=; b=qySa7i2pMvKkhBZUPtTKMLzIlYFquIr7/5eGwRfl6+anehe5DNaS+ze9zp7wDPWvutDXoD VK50rV6KbAHdkNlfW8vtFlAmMKTzWYwSLvP8pfTd3MVKgjISkDYpiKhUoB933LdMu4nphD gm+d15+LY0bd8rkQMJh5PNNjNVdtiHUPQf8eN6yp2tBJdEVIUhqpeSuOghQkID/jDwP7Zh ilWzCC1Br5eOVNhQV6TFkGX3mXpO6gwQyBWFaqoGPj7zFxjib5xoh6lYffmyV3WlYsH+gw Tvi2sF7aRinZHuwlScGRzZCsfUi5lVV4e9b4yc4vJ27ICsFdiPfoKEx2+yypag== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1747411429; h=from:from: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:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Md1Iu/Vc6/tFjsAFQawntDSjXyMhe0xSdZLpvaoPbo8=; b=f9ETIf8ToGN9omRzzX3yKp1ZoJqVIIrveTPpSLqCwa7tgYa3WNLFnNbxNP1uMqDOOwM/SR 2V5bbauwEwgUbtBA== To: linux-kernel@vger.kernel.org Cc: =?UTF-8?q?Andr=C3=A9=20Almeida?= , Darren Hart , Davidlohr Bueso , Ingo Molnar , Juri Lelli , Peter Zijlstra , Thomas Gleixner , Valentin Schneider , Waiman Long , Sebastian Andrzej Siewior Subject: [PATCH 1/5] selftests/futex: Use TAP output in futex_priv_hash Date: Fri, 16 May 2025 18:03:35 +0200 Message-ID: <20250516160339.1022507-2-bigeasy@linutronix.de> In-Reply-To: <20250516160339.1022507-1-bigeasy@linutronix.de> References: <20250516160339.1022507-1-bigeasy@linutronix.de> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Use TAP output for easier automated testing. Suggested-by: Andr=C3=A9 Almeida Signed-off-by: Sebastian Andrzej Siewior Reviewed-by: Andr=C3=A9 Almeida --- .../futex/functional/futex_priv_hash.c | 150 ++++++++---------- 1 file changed, 63 insertions(+), 87 deletions(-) diff --git a/tools/testing/selftests/futex/functional/futex_priv_hash.c b/t= ools/testing/selftests/futex/functional/futex_priv_hash.c index 4d37650baa192..72a621d9313f3 100644 --- a/tools/testing/selftests/futex/functional/futex_priv_hash.c +++ b/tools/testing/selftests/futex/functional/futex_priv_hash.c @@ -51,15 +51,16 @@ static void futex_hash_slots_set_verify(int slots) =20 ret =3D futex_hash_slots_set(slots, 0); if (ret !=3D 0) { - error("Failed to set slots to %d\n", errno, slots); - exit(1); + ksft_test_result_fail("Failed to set slots to %d: %m\n", slots); + ksft_finished(); } ret =3D futex_hash_slots_get(); if (ret !=3D slots) { - error("Set %d slots but PR_FUTEX_HASH_GET_SLOTS returns: %d\n", - errno, slots, ret); - exit(1); + ksft_test_result_fail("Set %d slots but PR_FUTEX_HASH_GET_SLOTS returns:= %d, %m\n", + slots, ret); + ksft_finished(); } + ksft_test_result_pass("SET and GET slots %d passed\n", slots); } =20 static void futex_hash_slots_set_must_fail(int slots, int immutable) @@ -67,12 +68,8 @@ static void futex_hash_slots_set_must_fail(int slots, in= t immutable) int ret; =20 ret =3D futex_hash_slots_set(slots, immutable); - if (ret < 0) - return; - - fail("futex_hash_slots_set(%d, %d) expected to fail but succeeded.\n", - slots, immutable); - exit(1); + ksft_test_result(ret < 0, "futex_hash_slots_set(%d, %d)\n", + slots, immutable); } =20 static void *thread_return_fn(void *arg) @@ -97,10 +94,8 @@ static void create_max_threads(void *(*thread_fn)(void *= )) =20 for (i =3D 0; i < MAX_THREADS; i++) { ret =3D pthread_create(&threads[i], NULL, thread_fn, NULL); - if (ret) { - error("pthread_create failed\n", errno); - exit(1); - } + if (ret) + ksft_exit_fail_msg("pthread_create failed: %m\n"); } } =20 @@ -110,10 +105,8 @@ static void join_max_threads(void) =20 for (i =3D 0; i < MAX_THREADS; i++) { ret =3D pthread_join(threads[i], NULL); - if (ret) { - error("pthread_join failed for thread %d\n", errno, i); - exit(1); - } + if (ret) + ksft_exit_fail_msg("pthread_join failed for thread %d\n", i); } } =20 @@ -127,6 +120,9 @@ static void usage(char *prog) VQUIET, VCRITICAL, VINFO); } =20 +static const char *test_msg_auto_create =3D "Automatic hash bucket init on= thread creation.\n"; +static const char *test_msg_auto_inc =3D "Automatic increase with more tha= n 16 CPUs\n"; + int main(int argc, char *argv[]) { int futex_slots1, futex_slotsn, online_cpus; @@ -156,56 +152,50 @@ int main(int argc, char *argv[]) } } =20 + ksft_print_header(); + ksft_set_plan(22); =20 ret =3D pthread_mutexattr_init(&mutex_attr_pi); ret |=3D pthread_mutexattr_setprotocol(&mutex_attr_pi, PTHREAD_PRIO_INHER= IT); ret |=3D pthread_mutex_init(&global_lock, &mutex_attr_pi); if (ret !=3D 0) { - fail("Failed to initialize pthread mutex.\n"); - return 1; + ksft_exit_fail_msg("Failed to initialize pthread mutex.\n"); } - /* First thread, expect to be 0, not yet initialized */ ret =3D futex_hash_slots_get(); - if (ret !=3D 0) { - error("futex_hash_slots_get() failed: %d\n", errno, ret); - return 1; - } - ret =3D futex_hash_immutable_get(); - if (ret !=3D 0) { - error("futex_hash_immutable_get() failed: %d\n", errno, ret); - return 1; - } + if (ret !=3D 0) + ksft_exit_fail_msg("futex_hash_slots_get() failed: %d, %m\n", ret); =20 + ret =3D futex_hash_immutable_get(); + if (ret !=3D 0) + ksft_exit_fail_msg("futex_hash_immutable_get() failed: %d, %m\n", ret); + + ksft_test_result_pass("Basic get slots and immutable status.\n"); ret =3D pthread_create(&threads[0], NULL, thread_return_fn, NULL); - if (ret !=3D 0) { - error("pthread_create() failed: %d\n", errno, ret); - return 1; - } + if (ret !=3D 0) + ksft_exit_fail_msg("pthread_create() failed: %d, %m\n", ret); + ret =3D pthread_join(threads[0], NULL); - if (ret !=3D 0) { - error("pthread_join() failed: %d\n", errno, ret); - return 1; - } + if (ret !=3D 0) + ksft_exit_fail_msg("pthread_join() failed: %d, %m\n", ret); + /* First thread, has to initialiaze private hash */ futex_slots1 =3D futex_hash_slots_get(); if (futex_slots1 <=3D 0) { - fail("Expected > 0 hash buckets, got: %d\n", futex_slots1); - return 1; + ksft_print_msg("Current hash buckets: %d\n", futex_slots1); + ksft_exit_fail_msg(test_msg_auto_create); } =20 + ksft_test_result_pass(test_msg_auto_create); + online_cpus =3D sysconf(_SC_NPROCESSORS_ONLN); ret =3D pthread_barrier_init(&barrier_main, NULL, MAX_THREADS + 1); - if (ret !=3D 0) { - error("pthread_barrier_init failed.\n", errno); - return 1; - } + if (ret !=3D 0) + ksft_exit_fail_msg("pthread_barrier_init failed: %m.\n"); =20 ret =3D pthread_mutex_lock(&global_lock); - if (ret !=3D 0) { - error("pthread_mutex_lock failed.\n", errno); - return 1; - } + if (ret !=3D 0) + ksft_exit_fail_msg("pthread_mutex_lock failed: %m.\n"); =20 counter =3D 0; create_max_threads(thread_lock_fn); @@ -215,14 +205,17 @@ int main(int argc, char *argv[]) * The current default size of hash buckets is 16. The auto increase * works only if more than 16 CPUs are available. */ + ksft_print_msg("Online CPUs: %d\n", online_cpus); if (online_cpus > 16) { futex_slotsn =3D futex_hash_slots_get(); if (futex_slotsn < 0 || futex_slots1 =3D=3D futex_slotsn) { - fail("Expected increase of hash buckets but got: %d -> %d\n", - futex_slots1, futex_slotsn); - info("Online CPUs: %d\n", online_cpus); - return 1; + ksft_print_msg("Expected increase of hash buckets but got: %d -> %d\n", + futex_slots1, futex_slotsn); + ksft_exit_fail_msg(test_msg_auto_inc); } + ksft_test_result_pass(test_msg_auto_inc); + } else { + ksft_test_result_skip(test_msg_auto_inc); } ret =3D pthread_mutex_unlock(&global_lock); =20 @@ -234,17 +227,12 @@ int main(int argc, char *argv[]) futex_hash_slots_set_verify(16); =20 ret =3D futex_hash_slots_set(15, 0); - if (ret >=3D 0) { - fail("Expected to fail with 15 slots but succeeded: %d.\n", ret); - return 1; - } + ksft_test_result(ret < 0, "Use 15 slots\n"); + futex_hash_slots_set_verify(2); join_max_threads(); - if (counter !=3D MAX_THREADS) { - fail("Expected thread counter at %d but is %d\n", - MAX_THREADS, counter); - return 1; - } + ksft_test_result(counter =3D=3D MAX_THREADS, "Created of waited for %d of= %d threads\n", + counter, MAX_THREADS); counter =3D 0; /* Once the user set something, auto reisze must be disabled */ ret =3D pthread_barrier_init(&barrier_main, NULL, MAX_THREADS); @@ -253,10 +241,8 @@ int main(int argc, char *argv[]) join_max_threads(); =20 ret =3D futex_hash_slots_get(); - if (ret !=3D 2) { - printf("Expected 2 slots, no auto-resize, got %d\n", ret); - return 1; - } + ksft_test_result(ret =3D=3D 2, "No more auto-resize after manaul setting,= got %d\n", + ret); =20 futex_hash_slots_set_must_fail(1 << 29, 0); =20 @@ -266,17 +252,13 @@ int main(int argc, char *argv[]) */ if (use_global_hash) { ret =3D futex_hash_slots_set(0, 0); - if (ret !=3D 0) { - printf("Can't request global hash: %m\n"); - return 1; - } + ksft_test_result(ret =3D=3D 0, "Global hash request\n"); } else { ret =3D futex_hash_slots_set(4, 1); - if (ret !=3D 0) { - printf("Immutable resize to 4 failed: %m\n"); - return 1; - } + ksft_test_result(ret =3D=3D 0, "Immutable resize to 4\n"); } + if (ret !=3D 0) + goto out; =20 futex_hash_slots_set_must_fail(4, 0); futex_hash_slots_set_must_fail(4, 1); @@ -287,7 +269,7 @@ int main(int argc, char *argv[]) =20 ret =3D pthread_barrier_init(&barrier_main, NULL, MAX_THREADS); if (ret !=3D 0) { - error("pthread_barrier_init failed.\n", errno); + ksft_exit_fail_msg("pthread_barrier_init failed: %m\n"); return 1; } create_max_threads(thread_lock_fn); @@ -295,21 +277,15 @@ int main(int argc, char *argv[]) =20 ret =3D futex_hash_slots_get(); if (use_global_hash) { - if (ret !=3D 0) { - error("Expected global hash, got %d\n", errno, ret); - return 1; - } + ksft_test_result(ret =3D=3D 0, "Continue to use global hash\n"); } else { - if (ret !=3D 4) { - error("Expected 4 slots, no auto-resize, got %d\n", errno, ret); - return 1; - } + ksft_test_result(ret =3D=3D 4, "Continue to use the 4 hash buckets\n"); } =20 ret =3D futex_hash_immutable_get(); - if (ret !=3D 1) { - fail("Expected immutable private hash, got %d\n", ret); - return 1; - } + ksft_test_result(ret =3D=3D 1, "Hash reports to be immutable\n"); + +out: + ksft_finished(); return 0; } --=20 2.49.0 From nobody Fri Dec 19 19:03:08 2025 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4C0B819007D for ; Fri, 16 May 2025 16:03:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=193.142.43.55 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1747411433; cv=none; b=TlaiIDV6NJLfA64zdMsEsoVGbefbu6BI30cBRcumtS/FQK7L22wcM9uY9M4YcgLoLJ1Y7dBmUOSeeWEwC3KwnQJuWmaNvfwgbt1IwVX/w54l7nhPqILhGXdPQc0BEznA6M5nVolLmq52GavVPRdizK5d/izUPLxMAefhmqokjXA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1747411433; c=relaxed/simple; bh=7quEVCGbCH2J/NQogOv1jyN8vMCSyQTngwDy7ifxKfo=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=qKV6XGVZS/ex+hh0bZ1Ii5xwytrbD0I3HstgIYYlRKSeJlBs75zYsYgwZSL+4eAzOWS1SRrXu924tLXW3zxjaqbmndh04GsMzdJ8PDYV9khObrANn+OPNnr3QMLCvhuN2mwZXzGGZ8SQHZ9Qn9yxETB77XpYnjAP53BOvmZa7pw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de; spf=pass smtp.mailfrom=linutronix.de; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=No/NinQ6; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=5KEMvBkG; arc=none smtp.client-ip=193.142.43.55 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linutronix.de Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="No/NinQ6"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="5KEMvBkG" From: Sebastian Andrzej Siewior DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1747411429; h=from:from: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:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=OgPtag8YLEfLZf6k4CCxGs8DpMmSVn6yKu/hnu3LgNs=; b=No/NinQ64fCwmsVpXXpPwIbCWz0G6bsJx8FkPbotC21FOXsmSFRfZH2NyIKc+mVTKVunpW 3lAZlUpjJo5g5yo0sYp4hZkZMLfJKZeWQ57YPEsXDAnOyErDdnYetSiMnSgeC11GYnK6vu S4qDbj04l1cVDjJ0v7K28FWERfIIzTvk8ooWoImZ0KMYDlP+22wBv3uXs5CIlFSZ8zhVp+ 8m/OUsq6nsjizQ6BunYs3KyHfHssi5mXo7sT/T05/2wFKzw3L+qpf+3NNCQF2WeTDCIG0X 4FoehmvOhm4GK5GdhgVAdfJfPBEMrL+HDLbJ+RyWi5raVo7eU3hKaa0Pe0+IoA== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1747411429; h=from:from: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:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=OgPtag8YLEfLZf6k4CCxGs8DpMmSVn6yKu/hnu3LgNs=; b=5KEMvBkG54Kusk+LD7LLRUPLvPjlSD1UQYhLrMYlQ+mTkQgwSfG5AjdRuBgsXbC+/OSirP ObaRlBWSn7jzZXAw== To: linux-kernel@vger.kernel.org Cc: =?UTF-8?q?Andr=C3=A9=20Almeida?= , Darren Hart , Davidlohr Bueso , Ingo Molnar , Juri Lelli , Peter Zijlstra , Thomas Gleixner , Valentin Schneider , Waiman Long , Sebastian Andrzej Siewior Subject: [PATCH 2/5] selftests/futex: Use TAP output in futex_numa_mpol Date: Fri, 16 May 2025 18:03:36 +0200 Message-ID: <20250516160339.1022507-3-bigeasy@linutronix.de> In-Reply-To: <20250516160339.1022507-1-bigeasy@linutronix.de> References: <20250516160339.1022507-1-bigeasy@linutronix.de> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Use TAP output for easier automated testing. Suggested-by: Andr=C3=A9 Almeida Signed-off-by: Sebastian Andrzej Siewior Reviewed-by: Andr=C3=A9 Almeida --- .../futex/functional/futex_numa_mpol.c | 65 +++++++++---------- 1 file changed, 32 insertions(+), 33 deletions(-) diff --git a/tools/testing/selftests/futex/functional/futex_numa_mpol.c b/t= ools/testing/selftests/futex/functional/futex_numa_mpol.c index dd70532f293ec..d18949ea915aa 100644 --- a/tools/testing/selftests/futex/functional/futex_numa_mpol.c +++ b/tools/testing/selftests/futex/functional/futex_numa_mpol.c @@ -61,10 +61,8 @@ static void create_max_threads(void *futex_ptr) thread_args[i].flags =3D FUTEX2_SIZE_U32 | FUTEX_PRIVATE_FLAG | FUTEX2_N= UMA; thread_args[i].result =3D 0; ret =3D pthread_create(&threads[i], NULL, thread_lock_fn, &thread_args[i= ]); - if (ret) { - error("pthread_create failed\n", errno); - exit(1); - } + if (ret) + ksft_exit_fail_msg("pthread_create failed\n"); } } =20 @@ -74,10 +72,8 @@ static void join_max_threads(void) =20 for (i =3D 0; i < MAX_THREADS; i++) { ret =3D pthread_join(threads[i], NULL); - if (ret) { - error("pthread_join failed for thread %d\n", errno, i); - exit(1); - } + if (ret) + ksft_exit_fail_msg("pthread_join failed for thread %d\n", i); } } =20 @@ -95,12 +91,12 @@ static void __test_futex(void *futex_ptr, int must_fail= , unsigned int futex_flag if (must_fail) { if (ret < 0) break; - fail("Should fail, but didn't\n"); - exit(1); + ksft_exit_fail_msg("futex2_wake(%d, 0x%x) should fail, but didn't\n", + to_wake, futex_flags); } if (ret < 0) { - error("Failed futex2_wake(%d)\n", errno, to_wake); - exit(1); + ksft_exit_fail_msg("Failed futex2_wake(%d, 0x%x): %m\n", + to_wake, futex_flags); } if (!ret) usleep(50); @@ -111,16 +107,17 @@ static void __test_futex(void *futex_ptr, int must_fa= il, unsigned int futex_flag =20 for (i =3D 0; i < MAX_THREADS; i++) { if (must_fail && thread_args[i].result !=3D -1) { - fail("Thread %d should fail but succeeded (%d)\n", i, thread_args[i].re= sult); + ksft_print_msg("Thread %d should fail but succeeded (%d)\n", + i, thread_args[i].result); need_exit =3D 1; } if (!must_fail && thread_args[i].result !=3D 0) { - fail("Thread %d failed (%d)\n", i, thread_args[i].result); + ksft_print_msg("Thread %d failed (%d)\n", i, thread_args[i].result); need_exit =3D 1; } } if (need_exit) - exit(1); + ksft_exit_fail_msg("Aborting due to earlier errors.\n"); } =20 static void test_futex(void *futex_ptr, int must_fail) @@ -167,41 +164,41 @@ int main(int argc, char *argv[]) } } =20 + ksft_print_header(); + ksft_set_plan(1); + mem_size =3D sysconf(_SC_PAGE_SIZE); futex_ptr =3D mmap(NULL, mem_size, PROT_READ | PROT_WRITE, MAP_PRIVATE | = MAP_ANONYMOUS, 0, 0); - if (futex_ptr =3D=3D MAP_FAILED) { - error("mmap() for %d bytes failed\n", errno, mem_size); - return 1; - } + if (futex_ptr =3D=3D MAP_FAILED) + ksft_exit_fail_msg("mmap() for %d bytes failed\n", mem_size); + futex_numa =3D futex_ptr; =20 - info("Regular test\n"); + ksft_print_msg("Regular test\n"); futex_numa->futex =3D 0; futex_numa->numa =3D FUTEX_NO_NODE; test_futex(futex_ptr, 0); =20 - if (futex_numa->numa =3D=3D FUTEX_NO_NODE) { - fail("NUMA node is left unitiliazed\n"); - return 1; - } + if (futex_numa->numa =3D=3D FUTEX_NO_NODE) + ksft_exit_fail_msg("NUMA node is left unitiliazed\n"); =20 - info("Memory too small\n"); + ksft_print_msg("Memory too small\n"); test_futex(futex_ptr + mem_size - 4, 1); =20 - info("Memory out of range\n"); + ksft_print_msg("Memory out of range\n"); test_futex(futex_ptr + mem_size, 1); =20 futex_numa->numa =3D FUTEX_NO_NODE; mprotect(futex_ptr, mem_size, PROT_READ); - info("Memory, RO\n"); + ksft_print_msg("Memory, RO\n"); test_futex(futex_ptr, 1); =20 mprotect(futex_ptr, mem_size, PROT_NONE); - info("Memory, no access\n"); + ksft_print_msg("Memory, no access\n"); test_futex(futex_ptr, 1); =20 mprotect(futex_ptr, mem_size, PROT_READ | PROT_WRITE); - info("Memory back to RW\n"); + ksft_print_msg("Memory back to RW\n"); test_futex(futex_ptr, 0); =20 /* MPOL test. Does not work as expected */ @@ -213,20 +210,22 @@ int main(int argc, char *argv[]) ret =3D mbind(futex_ptr, mem_size, MPOL_BIND, &nodemask, sizeof(nodemask) * 8, 0); if (ret =3D=3D 0) { - info("Node %d test\n", i); + ksft_print_msg("Node %d test\n", i); futex_numa->futex =3D 0; futex_numa->numa =3D FUTEX_NO_NODE; =20 ret =3D futex2_wake(futex_ptr, 0, FUTEX2_SIZE_U32 | FUTEX_PRIVATE_FLAG = | FUTEX2_NUMA | FUTEX2_MPOL); if (ret < 0) - error("Failed to wake 0 with MPOL.\n", errno); + ksft_test_result_fail("Failed to wake 0 with MPOL: %m\n"); if (0) test_futex_mpol(futex_numa, 0); if (futex_numa->numa !=3D i) { - fail("Returned NUMA node is %d expected %d\n", - futex_numa->numa, i); + ksft_test_result_fail("Returned NUMA node is %d expected %d\n", + futex_numa->numa, i); } } } + ksft_test_result_pass("NUMA MPOL tests passed\n"); + ksft_finished(); return 0; } --=20 2.49.0 From nobody Fri Dec 19 19:03:08 2025 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 93F8F1922FB for ; Fri, 16 May 2025 16:03:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=193.142.43.55 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1747411433; cv=none; b=s1GZJfXcTLfKW49cjMoaREB/P1GwIcj7kW4CeWUiSSkEkKMaNylqhABWzeUE9GCNVaXm6ZSTs+VzHGU8M3+FB2sLkU4y65YD+XCIjTtXh6Pi4nXLEbihapORtBq6AJOVVO58lv8gDAv3s/FLF12ekKpcosU/3Gl8TldEzFTJcPQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1747411433; c=relaxed/simple; bh=j/BzPvwStte+u580GD3gncn95b2rBkz0AAqHpk6bJBc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=YjpAoJRKNwVfWC62G6ugRS6fTW3bTFwWDTRcDzRGOPvpncPMjL3ijEuXafJHTseDFiISkMxczQA64xGqXnZAgUHiCulHTiuqmWD9ovj5Tdg9XF+Ulx84jNYrgQI960+YjAxPLsc+A3Pr3f341emOvyNlRBEFOIam4li8K06b3mE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de; spf=pass smtp.mailfrom=linutronix.de; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=Gt0x0UDR; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=p1as1lxM; arc=none smtp.client-ip=193.142.43.55 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linutronix.de Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="Gt0x0UDR"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="p1as1lxM" From: Sebastian Andrzej Siewior DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1747411429; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=tuFsKmSU09nElHvJf8RpcCbmx97tu90mrN0WgRIDs1o=; b=Gt0x0UDRlqbzCMf3WZWXcjyIKDMEXF2DP1na5G5uRRliI6jM2oeJXvnpHZiWngwhuFHc4S VVh2BzxyCBi8sxUCqp9ZJxXBmZb+9H5lZJINSPdPtsW0LUfepedNTuuWtCAtzvGAsfzWIe W+Xu+RmTUnihdj47dr1AJo3k/0lEepXkA6B6h/p8WOrxidF3XlXGu3dalWY7GtuJDlcOZe h5UTH80Yow8jlzkZzYFfF/F4vUITnlK2yN9Ih8PenpLRCc8BWNyl5PB1kUD7GORLDcZksz W7vPncoNTEZMUkxeYFfGUy90QNpDvG9KZKK2aujLauhcnhsvo53cPLmLRD3Bzg== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1747411429; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=tuFsKmSU09nElHvJf8RpcCbmx97tu90mrN0WgRIDs1o=; b=p1as1lxMTu99FODwmIB+5sc+w3lSmVkSmv2G6f5dW0ZoDRhEhJEE2k9ve7XF0fOEb08fLv J5cv4EOeXCEizFBg== To: linux-kernel@vger.kernel.org Cc: =?UTF-8?q?Andr=C3=A9=20Almeida?= , Darren Hart , Davidlohr Bueso , Ingo Molnar , Juri Lelli , Peter Zijlstra , Thomas Gleixner , Valentin Schneider , Waiman Long , Sebastian Andrzej Siewior Subject: [PATCH 3/5] futex: Use RCU_INIT_POINTER() in futex_mm_init(). Date: Fri, 16 May 2025 18:03:37 +0200 Message-ID: <20250516160339.1022507-4-bigeasy@linutronix.de> In-Reply-To: <20250516160339.1022507-1-bigeasy@linutronix.de> References: <20250516160339.1022507-1-bigeasy@linutronix.de> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" There is no need for an explicit NULL pointer initialisation plus a comment why it is okay. RCU_INIT_POINTER() can be used for NULL initialisations and it is documented. This has been build tested with gcc version 9.3.0 (Debian 9.3.0-22) on a x86-64 defconfig. Fixes: 094ac8cff7858 ("futex: Relax the rcu_assign_pointer() assignment of = mm->futex_phash in futex_mm_init()") Signed-off-by: Sebastian Andrzej Siewior --- include/linux/futex.h | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/include/linux/futex.h b/include/linux/futex.h index 168ffd5996b48..005b040c4791b 100644 --- a/include/linux/futex.h +++ b/include/linux/futex.h @@ -88,14 +88,7 @@ void futex_hash_free(struct mm_struct *mm); =20 static inline void futex_mm_init(struct mm_struct *mm) { - /* - * No need for rcu_assign_pointer() here, as we can rely on - * tasklist_lock write-ordering in copy_process(), before - * the task's MM becomes visible and the ->futex_phash - * becomes externally observable: - */ - mm->futex_phash =3D NULL; - + RCU_INIT_POINTER(mm->futex_phash, NULL); mutex_init(&mm->futex_hash_lock); } =20 --=20 2.49.0 From nobody Fri Dec 19 19:03:08 2025 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E4AD513A3ED for ; Fri, 16 May 2025 16:03:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=193.142.43.55 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1747411433; cv=none; b=T7JFuGNFJN4+nX5C1iA+cdm9/JEEieqwmZeeujdckD9WEuYcATGwgDLEjqqYOLGN1OhX/2u6RtUVKL5M+d8EMYTjHRYw8Q+eATy5qRS6A9s+DtGcCD5U4EYG+uG5nrW3ehYFYVdAASYnwk4xlA8QAKnkUNRwWp8r6by8io0ll7Y= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1747411433; c=relaxed/simple; bh=Q3h53einSp2rQD+2e6peNlK0GqD6WCe3aehcIGdB/OY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=kB7IT3u0uOLgRXlulxeiHGvjwV0WRTTAg9oaK8dINIqCap83hRrrmZZg2/CIcRLVg69qSOZIlfzPod4Jh2skzNNebo+5gWMbtRuR7YQxXvIIOiz8tZSiWvKIuyyQWdJWwF5LGN3hW7uECb3olkRYQcuPtvwNYjfQZdCcccVKIzs= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de; spf=pass smtp.mailfrom=linutronix.de; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=4VFj0kdP; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=9agI9YLt; arc=none smtp.client-ip=193.142.43.55 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linutronix.de Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="4VFj0kdP"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="9agI9YLt" From: Sebastian Andrzej Siewior DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1747411430; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=HGohYDFWFlr+myl6Dzhrw+soITHCqOqPB4Qu9PLO+4E=; b=4VFj0kdPmmldFasr6fsNhg++FuUNzmnEh5gCBORHOnT2zzgNpUcJB622DlF7IOeIdJm9HT GPIBCvxDgxU9QNS74+q9S3pcFyurXt3/kNptbhJQzpllVJ3YeMhAXJ4xsuBa1DL/L80RSQ 8EzDfJqt1j2hNvvm+V8wFcKDwCLHCitQ1tStmhRFwo7A8avqZS99HSZzFOcTUP7DaFz2U+ 4znN+AwKIyfC+SHffdV4NjcWC63+jspxbCyvWEmPdwswMsEiImtnz/lwYrraIdScrf8VMw FXktsx0z2YJSf2qselJvV+Swj8dpPJ6HVarOOqsOLdI04+MilSNrYJTJCoUF5g== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1747411430; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=HGohYDFWFlr+myl6Dzhrw+soITHCqOqPB4Qu9PLO+4E=; b=9agI9YLt5aCMdchmuD9n6NFRwdWCRngnfoNe0YLE6uUNi+sOdshTTcCa2rNgC6R4oXvSNU asN3Kf90ttBO9AAw== To: linux-kernel@vger.kernel.org Cc: =?UTF-8?q?Andr=C3=A9=20Almeida?= , Darren Hart , Davidlohr Bueso , Ingo Molnar , Juri Lelli , Peter Zijlstra , Thomas Gleixner , Valentin Schneider , Waiman Long , Sebastian Andrzej Siewior Subject: [PATCH 4/5] tools headers: Synchronize prctl.h ABI header Date: Fri, 16 May 2025 18:03:38 +0200 Message-ID: <20250516160339.1022507-5-bigeasy@linutronix.de> In-Reply-To: <20250516160339.1022507-1-bigeasy@linutronix.de> References: <20250516160339.1022507-1-bigeasy@linutronix.de> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" The prctl.h ABI header was slightly updated during the development of the interface. In particular the "immutable" parameter became a bit in the option argument. Synchronize prctl.h ABI header again and make use of the definition in the testsuite. Signed-off-by: Sebastian Andrzej Siewior Reviewed-by: Andr=C3=A9 Almeida --- tools/include/uapi/linux/prctl.h | 1 + .../futex/functional/futex_priv_hash.c | 18 +++++++++--------- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/tools/include/uapi/linux/prctl.h b/tools/include/uapi/linux/pr= ctl.h index 21f30b3ded74b..43dec6eed559a 100644 --- a/tools/include/uapi/linux/prctl.h +++ b/tools/include/uapi/linux/prctl.h @@ -367,6 +367,7 @@ struct prctl_mm_map { /* FUTEX hash management */ #define PR_FUTEX_HASH 78 # define PR_FUTEX_HASH_SET_SLOTS 1 +# define FH_FLAG_IMMUTABLE (1ULL << 0) # define PR_FUTEX_HASH_GET_SLOTS 2 # define PR_FUTEX_HASH_GET_IMMUTABLE 3 =20 diff --git a/tools/testing/selftests/futex/functional/futex_priv_hash.c b/t= ools/testing/selftests/futex/functional/futex_priv_hash.c index 72a621d9313f3..32abd9acdf186 100644 --- a/tools/testing/selftests/futex/functional/futex_priv_hash.c +++ b/tools/testing/selftests/futex/functional/futex_priv_hash.c @@ -30,9 +30,9 @@ static int counter; # define PR_FUTEX_HASH_GET_IMMUTABLE 3 #endif =20 -static int futex_hash_slots_set(unsigned int slots, int immutable) +static int futex_hash_slots_set(unsigned int slots, int flags) { - return prctl(PR_FUTEX_HASH, PR_FUTEX_HASH_SET_SLOTS, slots, immutable); + return prctl(PR_FUTEX_HASH, PR_FUTEX_HASH_SET_SLOTS, slots, flags); } =20 static int futex_hash_slots_get(void) @@ -63,11 +63,11 @@ static void futex_hash_slots_set_verify(int slots) ksft_test_result_pass("SET and GET slots %d passed\n", slots); } =20 -static void futex_hash_slots_set_must_fail(int slots, int immutable) +static void futex_hash_slots_set_must_fail(int slots, int flags) { int ret; =20 - ret =3D futex_hash_slots_set(slots, immutable); + ret =3D futex_hash_slots_set(slots, flags); ksft_test_result(ret < 0, "futex_hash_slots_set(%d, %d)\n", slots, immutable); } @@ -254,18 +254,18 @@ int main(int argc, char *argv[]) ret =3D futex_hash_slots_set(0, 0); ksft_test_result(ret =3D=3D 0, "Global hash request\n"); } else { - ret =3D futex_hash_slots_set(4, 1); + ret =3D futex_hash_slots_set(4, FH_FLAG_IMMUTABLE); ksft_test_result(ret =3D=3D 0, "Immutable resize to 4\n"); } if (ret !=3D 0) goto out; =20 futex_hash_slots_set_must_fail(4, 0); - futex_hash_slots_set_must_fail(4, 1); + futex_hash_slots_set_must_fail(4, FH_FLAG_IMMUTABLE); futex_hash_slots_set_must_fail(8, 0); - futex_hash_slots_set_must_fail(8, 1); - futex_hash_slots_set_must_fail(0, 1); - futex_hash_slots_set_must_fail(6, 1); + futex_hash_slots_set_must_fail(8, FH_FLAG_IMMUTABLE); + futex_hash_slots_set_must_fail(0, FH_FLAG_IMMUTABLE); + futex_hash_slots_set_must_fail(6, FH_FLAG_IMMUTABLE); =20 ret =3D pthread_barrier_init(&barrier_main, NULL, MAX_THREADS); if (ret !=3D 0) { --=20 2.49.0 From nobody Fri Dec 19 19:03:08 2025 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B46C41D5ACE for ; Fri, 16 May 2025 16:03:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=193.142.43.55 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1747411435; cv=none; b=C5RTjzAGuxr+X+SpOPZGAKQmOpo0Zur32BgzzoBsfUqz7u9EKEoxInYnnrg9izpwKnd1BPhRwMu8PkmYpyZGgw3MUl2nDeRllZKoGtoZYgnZjbksaZn9d6pnqWAZ6nBE8oWchXHqTOdSBVOS18zSOxSkRmfDAIjDiFcgw8KciJ4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1747411435; c=relaxed/simple; bh=UEOKv11enIFpCK2oVRSy1ul3aPEAXc6EBGaVRdNt/hM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=i/y6+DJWRVUZ8mI3MyTRR8j+6Ydm0twi4bqJYv3ND4lOW3wGW69mpY9dOoePc6hSN60veKIHMfEZpVAj4COiyQpwGWsltL4YksqM69LCiMAUfdWPi4hLPzs1qtnqSDFgiu3zAHpJa3/UI24nir6/sz8hoFhlkz76adhLuaQmUiU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de; spf=pass smtp.mailfrom=linutronix.de; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=NHlOhMpr; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=qOpNI+uL; arc=none smtp.client-ip=193.142.43.55 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linutronix.de Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="NHlOhMpr"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="qOpNI+uL" From: Sebastian Andrzej Siewior DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1747411430; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=QtVBdKPTm7T943W3PPJoranNLaZ2FktfS3xeuVJaJVs=; b=NHlOhMpr27FKduk6nv3Ug1XL/kmTDeR8zj4XV6oVCP69DqQ9DHV7o9wr+7mWNzNgzR+m6y r5YBBi/3swe9aPUXKfKN6HPx6oXY6o6Jln407X1sMSr3fN2DprURf5IH3ZrPBd8CE+bTTY R5DYhHThjO+m4Z1Xakg80z+GegZoVj4sKzfbJNSGkAjZJ4I1uIA8okNlpk/I/1IKWWwd31 4Mbdx/s7J62xRX3WwcQwx2ad3tI0fTylL9fRdvvxX8KRRsGTFssc6GjMZb/oVizyOT6f3w e51iM/rxQsMjhyH2kelTjxb5M1y5/UhbWUcgHg+NUs9LQeWjx3r2XCarQh5Z9A== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1747411430; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=QtVBdKPTm7T943W3PPJoranNLaZ2FktfS3xeuVJaJVs=; b=qOpNI+uL88mQrbp4GJ3ET/NDGKqnV071Fozcd9kpHv3L4j4ifPEGH404DqeityfBBJzGXx ToeHvWItNJFAXHCQ== To: linux-kernel@vger.kernel.org Cc: =?UTF-8?q?Andr=C3=A9=20Almeida?= , Darren Hart , Davidlohr Bueso , Ingo Molnar , Juri Lelli , Peter Zijlstra , Thomas Gleixner , Valentin Schneider , Waiman Long , Sebastian Andrzej Siewior Subject: [PATCH 5/5] futex: Correct the kernedoc return value for futex_wait_setup() Date: Fri, 16 May 2025 18:03:39 +0200 Message-ID: <20250516160339.1022507-6-bigeasy@linutronix.de> In-Reply-To: <20250516160339.1022507-1-bigeasy@linutronix.de> References: <20250516160339.1022507-1-bigeasy@linutronix.de> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" The kerneldoc for futex_wait_setup() states it can return "0" or "<1". This isn't true because the error case is "<0" not less than 1. Document that <0 is returned on error. Drop the possible return values and state possible reasons. Signed-off-by: Sebastian Andrzej Siewior Reviewed-by: Andr=C3=A9 Almeida --- kernel/futex/waitwake.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/kernel/futex/waitwake.c b/kernel/futex/waitwake.c index b3738fbe83c62..e2bbe5509ec27 100644 --- a/kernel/futex/waitwake.c +++ b/kernel/futex/waitwake.c @@ -585,7 +585,8 @@ int futex_wait_multiple(struct futex_vector *vs, unsign= ed int count, * * Return: * - 0 - uaddr contains val and hb has been locked; - * - <1 - -EFAULT or -EWOULDBLOCK (uaddr does not contain val) and hb is = unlocked + * - <0 - On error and the hb is unlocked. A possible reason: the uaddr c= an not + * be read, does not contain the expected value or is not properly alig= ned. */ int futex_wait_setup(u32 __user *uaddr, u32 val, unsigned int flags, struct futex_q *q, union futex_key *key2, --=20 2.49.0