From nobody Fri Dec 19 17:19:27 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 F3F54205AC1 for ; Sat, 17 May 2025 15:15:01 +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=1747494903; cv=none; b=ANUrc6mMZ7rw0Nq6Yozv5XqdNavEeSm6Y6QhZyw+I3mTv1WW+8j/HS6sdG4CcckFPPy4nYiU6vmbEpv+L2pLxRPAdso8QjPE2v2fOSTPAS4HIf6ofALBO3grXu10tqIujS/DFvJBRNY1yj/eJm8eNqE1bJ+IzU/LCrQHm9vE3VM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1747494903; c=relaxed/simple; bh=/ztD58wSr3hkwLimw8rX0TDM9G65KhOB8R0a8UCmA28=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=O+sWILk2p1ySccOaKWIDmydBlT28cXMkvx3dTzqk7NQAkArkv4H5ylT47LrIOu562empFD9P0po9E7ter1lb1c4a0nRg41HGp4i4U1sIr212olSMFLNr+n5C4yhj9iUrGfEDGgOP8WSemCplip1oMo8N/MwvX7a7tGe3gxiE/xE= 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=f3fgH6nx; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=FEwdrgfU; 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="f3fgH6nx"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="FEwdrgfU" From: Sebastian Andrzej Siewior DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1747494899; 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=uBAG2g4xyGz7CfWeA4doPef9u1z6R836/J0iL0cRwyg=; b=f3fgH6nxBjmGr+BbIcchOikAFPLpv7+AUN9SuQ0vNdfbfeyaz1TERKl5fCBrpEJwoTjvOh KK97UNKSWEmDGoHwrUaWA1yC4Kkw4zwxYNrwAoLS2i8yEqVPOMEYmCXUw2vALj5k9RrAiP ciJpfS3K4ASY3DmNhLp0AXbb5u0lB/WTEhma5qNZDBVM5Tkp00DAUih/IjehqtzQR/nqf6 qJ+oRAJCmA8X1wyfQ4ta/Wyv24D7KBZouOqhdgd9W80jmRxhEExJirAdhscI8D69DKlTkX YvA36UTDDYOZAPz7j6kP8YSmkwFpBQn1xkpUCfLjtcQusfAEXTrXEs1O3C+rWQ== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1747494899; 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=uBAG2g4xyGz7CfWeA4doPef9u1z6R836/J0iL0cRwyg=; b=FEwdrgfUVWPnkOHDd0POjSgHKV+sn8q9B2IAcJFhhiSB661BWX1XTDgopKfBLQLnC4GyGf Jgwwc7d3tPaDw1CQ== 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 v2 1/5] selftests/futex: Use TAP output in futex_priv_hash Date: Sat, 17 May 2025 17:14:51 +0200 Message-ID: <20250517151455.1065363-2-bigeasy@linutronix.de> In-Reply-To: <20250517151455.1065363-1-bigeasy@linutronix.de> References: <20250517151455.1065363-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 Reviewed-by: Andr=C3=A9 Almeida Signed-off-by: Sebastian Andrzej Siewior --- .../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 17:19:27 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 5C499206F27 for ; Sat, 17 May 2025 15:15:02 +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=1747494904; cv=none; b=T71hSlZvj6T7n8gcsvY7gWRK3brI0r2y4JJRHOksIyO0CW/xH7gIlfojTidvH7ZGhZVlRCTK3Qp+0RqWkHDE/KMYiNYYs6B0OFtCcjZEVVzNnaHQc6BEtGuSg4FATKe2tv9GnRscWA9mQyYZmKJ+VuH/mtBtiS+aDuVErx3reeI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1747494904; c=relaxed/simple; bh=tg/s+SOCUdqo2Mypqth+8HD9PqaX8+qijFNkvBrUFRw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=WDTvX3q2A3Uj+XsBJ4Rsej/O2pI31e4aEY2dcMEVbEO5PQMlMIx0rg/+m/NR0hulh31ZXvBb9UYSJ6inVw+IBYKFrojvdg76LXj5RFZ9IaQAjchvbhadMunlE7Az/qNDwkNd9qktuPpHw+W9ecub65zXqAlhJQPYwu1P7T59qTM= 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=HQa/URzH; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=TrlKEFQQ; 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="HQa/URzH"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="TrlKEFQQ" From: Sebastian Andrzej Siewior DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1747494900; 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=M4q69CQqAFE08j/dA6RKMPpS6uiR7bM/VAU4VHsNRcM=; b=HQa/URzHA5Qjd/L4NvvJ0h1PAogx7g+HhLPTg0GAESjXzfoikhG+IdBJd5G333Dmsi7QaZ pZEMIghshwAt6WcrNtjKY0kuXkeri3LLs55TKFNcmeYSiQQt0W6ipbQ1uaz1X8VkxZVqK6 O9Wum1qy2S2oM5KkavKXeM+nUbIt0AaoYfNfXnOdBElFDrgXHwo8ZyBTruwuHjTkJdv1Ow 7bp5fNxDOVVgWU/OwoHJWBXcmrRMGQKIaugULTD+N7kZVTovWBcdsShYb3DvEgUgoFlkjG /6gPxMB/Vpamv2OG8xpiPUD/ILJYtareAbMHTINW1/bchHGsUOI2O2l4SidVSQ== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1747494900; 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=M4q69CQqAFE08j/dA6RKMPpS6uiR7bM/VAU4VHsNRcM=; b=TrlKEFQQ88ROUTlFszr3dneoh+dfEbnHbJMD5RV9Jtm0fv3O56Xv7iRBnWmFtKU4Xc9NLr DYTYk7A+UNQRJwCQ== 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 v2 2/5] selftests/futex: Use TAP output in futex_numa_mpol Date: Sat, 17 May 2025 17:14:52 +0200 Message-ID: <20250517151455.1065363-3-bigeasy@linutronix.de> In-Reply-To: <20250517151455.1065363-1-bigeasy@linutronix.de> References: <20250517151455.1065363-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 Reviewed-by: Andr=C3=A9 Almeida Signed-off-by: Sebastian Andrzej Siewior --- .../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 17:19:27 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 5C42A2066F7 for ; Sat, 17 May 2025 15:15:02 +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=1747494903; cv=none; b=g2i8NhzSDdUBIjN5MNFiitCtPeaMFJmuEZ06SzeYZ/KIqxoTn+/Ahavr6OK5p1PbVwOhv+nKgVq5oO3pREzffjFXwcRm7MkK+UiwMfxbmGkz/5W5/3vOu5AfQFHVnnbrywwjypoP9VvYnh7+cTSr/K/s+sUw5xtS8l75AuBLZ18= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1747494903; c=relaxed/simple; bh=j/BzPvwStte+u580GD3gncn95b2rBkz0AAqHpk6bJBc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=dvtDZMCcAvtM0C09d368ikPOLYsNVMC6BbCbWbaSaXf2X1CWUYK4pgxiz0osan6uLDeYFTVJ5mbJFk4XL2qtHvFuSAeep9OxAghG+qqVZVydCpH4uOaVaPEmYRApHlWxh2LK6GbGosyH3bCUMa0KG1zq6n1Uatr7c5sX78TcsMg= 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=sWcU8T1m; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=og4+uu82; 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="sWcU8T1m"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="og4+uu82" From: Sebastian Andrzej Siewior DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1747494900; 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=sWcU8T1mYTcRg85jYjJqMtJAWIgT/JRVzucc7XbXbVZpYgBbL4MoKyddYakADNLfm6ZWcg 2jG0rLT0gYv0iXuADswPdtopQ1Sx7gOu4mzzIZdeEeLvVNsVFXOfKbWj3slN4vB2nJ0Eim 7jGm+trjgivh2C5RwPfznxXPm/xvSilQ4FjEO3nVV1k7BAdu07eQvMXVjxTZYDkhHHkuoI cWOMYMOYJQRB68gLXxsel8mjfHdTs3lASlD8J2POs1IVY4YEmWKandeot7JilaFCKMsBhA SDZbm9tMhjmVmTQCzWaHra6y3v/ywiLk7JBanUT5KMYxhVH8GKY1pStoEYFyBA== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1747494900; 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=og4+uu82dJ53pqzfbqw0nYZCoYojp3u3cAgMg2pZK/PWyW+ItuE9UNBIZSIktvcNHzIJCp H604cMpvKnK8J8Ag== 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 v2 3/5] futex: Use RCU_INIT_POINTER() in futex_mm_init(). Date: Sat, 17 May 2025 17:14:53 +0200 Message-ID: <20250517151455.1065363-4-bigeasy@linutronix.de> In-Reply-To: <20250517151455.1065363-1-bigeasy@linutronix.de> References: <20250517151455.1065363-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 17:19:27 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 0B23B207A22 for ; Sat, 17 May 2025 15:15:02 +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=1747494904; cv=none; b=PIDIN5USQEQ7w5h2DUJbG74YZ4GoiwQnEe1fMtJfsual6kDjXPRw45U5QMNe8GPHGBwbe7cNO8EUn+fFZcu/hBR2YBUoYTMGgN7sOFbMUteydXSmozAnOXA6jf3iSVYxQNrJuwNo1aj96UNIDhvY1k1CarzHZrWJqnsYQWesfPA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1747494904; c=relaxed/simple; bh=xrw/4Wa70FNBVuuwvIbx94B9KkA7A1h5zM7t86zhlvc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=m7cejRVDxaxJjArYI4C6+IWhI7obIcnLBWbNYyqWgapxl71BUZTLPb/ZzILcJD6DAFZ7DY2gTmU/BQPXSrRqORCuKBDrAA0eIa1q6O8rghumcfp+9RT+Xifnhl1HBT9Q2NApi1tsIVRjHtmhXVaNiYXnfbVDkQfuCwrRLe/qUSE= 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=J1yj5TJS; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=pLq3KsFG; 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="J1yj5TJS"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="pLq3KsFG" From: Sebastian Andrzej Siewior DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1747494901; 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=mMIptnBrOzGmCpOc2DaVkApQWy1JRd4QqrU7q7taBvE=; b=J1yj5TJSb69gxjiBlRIVdY4zIDC9RvkAPTxlH/eQZjJUqcR5pUlz/D7o1nqYMLawEQZC19 ixfAobzVvBVXYsWibG+gCTvOiiQH9IcfowLiWIchgjkDhkXdl8hHgcFxwAw2Crl4CPADIR +zkjH3N7H7KNSB+DUDJC4x9VCXxQMLmICPv/V167Bemmd0anW2DFJ9lBw0pXHKkXDJUrg2 waJC079/DqwDBXZuH6oOsut5+3w+ow9yvxyeE0pNm/CO/Bqj6rQASPRsP4Ipz/daVDBqek Hr3X8iXMQoiNUZgeYVc/9Nk1wRzvh6zxgHO7DyVKw6ad/xQi2SXZFsCXVGRLGQ== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1747494901; 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=mMIptnBrOzGmCpOc2DaVkApQWy1JRd4QqrU7q7taBvE=; b=pLq3KsFGldOa5NaL8WWywlqolJTR9AU6fQg6GEbTuW6MSJwW3FJk/wJDC2hi/NRC/93s/f NClvIptlQUKWj3Dg== 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 v2 4/5] tools headers: Synchronize prctl.h ABI header Date: Sat, 17 May 2025 17:14:54 +0200 Message-ID: <20250517151455.1065363-5-bigeasy@linutronix.de> In-Reply-To: <20250517151455.1065363-1-bigeasy@linutronix.de> References: <20250517151455.1065363-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 and "perf bench futex". Reviewed-by: Andr=C3=A9 Almeida Signed-off-by: Sebastian Andrzej Siewior --- tools/include/uapi/linux/prctl.h | 1 + tools/perf/bench/futex.c | 4 +++- .../futex/functional/futex_priv_hash.c | 21 ++++++++++--------- 3 files changed, 15 insertions(+), 11 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/perf/bench/futex.c b/tools/perf/bench/futex.c index 02ae6c52ba881..26382e4d8d4ce 100644 --- a/tools/perf/bench/futex.c +++ b/tools/perf/bench/futex.c @@ -9,12 +9,14 @@ =20 void futex_set_nbuckets_param(struct bench_futex_parameters *params) { + unsigned long flags; int ret; =20 if (params->nbuckets < 0) return; =20 - ret =3D prctl(PR_FUTEX_HASH, PR_FUTEX_HASH_SET_SLOTS, params->nbuckets, p= arams->buckets_immutable); + flags =3D params->buckets_immutable ? FH_FLAG_IMMUTABLE : 0; + ret =3D prctl(PR_FUTEX_HASH, PR_FUTEX_HASH_SET_SLOTS, params->nbuckets, f= lags); if (ret) { printf("Requesting %d hash buckets failed: %d/%m\n", params->nbuckets, ret); 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..2dca18fefedcd 100644 --- a/tools/testing/selftests/futex/functional/futex_priv_hash.c +++ b/tools/testing/selftests/futex/functional/futex_priv_hash.c @@ -26,13 +26,14 @@ static int counter; #ifndef PR_FUTEX_HASH #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 #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,13 +64,13 @@ 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); + slots, flags); } =20 static void *thread_return_fn(void *arg) @@ -254,18 +255,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 17:19:27 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 4E66F20D516 for ; Sat, 17 May 2025 15:15:04 +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=1747494907; cv=none; b=LjzlqGYPBRBd0OnzyiHTo7yrS4h1Ya+G+bHwUz6u1maWXmKr4GfEGoLlO/ndHt5KNmxHbNdaQD/v7jIRVd+JG17LIYwAJ5OqqCyO0Jik5gt15oyw35p28iRCo5OYld+ldlN6eHOdQGLAqshREhMNcBvx60qBiKvV3FpchN/p+lA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1747494907; c=relaxed/simple; bh=QwL5UTZb5VDMfNGxGWHnJ5EDf+WSNqcCfowPSq1/Ndw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=uAMeU0aJh9oCDQ546OOUsBAJHasjQdehKVRa778vYZo8OxWmnMmNKd/+Zf29DEvyeiuF9gnjahTP0FkH/a7azPS/2FCoFP9Cpe2X5DTQ/dvFfncc1jqNb9nRtPGvCPElP64L16pvErc34Z9zGcaUeZYl05bmcU3t225T2aVwXpw= 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=Sdw6GdR5; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=Z2/dRCOA; 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="Sdw6GdR5"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="Z2/dRCOA" From: Sebastian Andrzej Siewior DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1747494901; 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=ZaDBuiR2gKznTjuWYmUloD3ZUVLsi1k8LQTJYuhNwNg=; b=Sdw6GdR5DjW1HMPHdstwd5pNEwgyESSi0QRvjB4K9OftlpmxN1uxj4tj+l1/9aq4hCgXsf Gjg5R3LHWsTpIMQanpTfh0BoPafduG2R+kvAg2T2R9HsMh7gz9z0jXwb9MRXNT0AAJEh87 l7TAyQDsiG1RmYFxQgnwL4dbj/r5rRk7d8qf1Bc+C6c0+VF+uIAtV0KjRTntk+hGa/bEg2 cFPHImaL0DKF0R7rcvauxEiUmSvV25aw0amTbbtQ9pPSF+S27u1BmpZS2f6Hr87Etx71OL d4TJW+u6eG2MCR0xRDv47b1tpq3z/yU6lG4VSAKtQgSy28hHIIAHZwm0dQkrzw== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1747494901; 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=ZaDBuiR2gKznTjuWYmUloD3ZUVLsi1k8LQTJYuhNwNg=; b=Z2/dRCOAyr/t6S+hiuO3zjPqP8cT8wpw2gMGs03K9GrscMrEPPHVoqa0XXCp5BBg7gHDcT mfStfliSCreLMfDA== 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 v2 5/5] futex: Correct the kernedoc return value for futex_wait_setup(). Date: Sat, 17 May 2025 17:14:55 +0200 Message-ID: <20250517151455.1065363-6-bigeasy@linutronix.de> In-Reply-To: <20250517151455.1065363-1-bigeasy@linutronix.de> References: <20250517151455.1065363-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. Reviewed-by: Andr=C3=A9 Almeida Signed-off-by: Sebastian Andrzej Siewior --- 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