From nobody Thu Oct 2 14:26:15 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 B42132BFC70 for ; Mon, 15 Sep 2025 21:26:36 +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=1757971599; cv=none; b=Mg6B2IMXQmOQt8VI9xn84HWxWZ/l9MvgHg1bQQ78pD33iYSapgbAwTYwiQSjaEHNpnOFiWMKGni+k0nHIIWHeTU8CwLPUCjpTGbAPlYSnNUqs4o5c14DDuNW12QPHnO6LlTmk2f6rgGof1pJIXqyThIbKcez9Whw9ZqvdfyP5bU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1757971599; c=relaxed/simple; bh=YhFEwzEIvubuo0TNT6znatq/ife0AtZ62ONaCKwn3+Y=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=fcusZiBdoT7A+KX1lQt1icOwkCCJqOVWCQ1uxLHf4D7K4VgCKSmAQFdnVjOTwpweL01/QJ7fzXnA/sTVDWMlpA/95lsYl1DMnry8wzPmNh/t/qg+QTp/fqhwkhs7R8+rAGHP3GTlunG8P+qA9pqu8it/pA76pDDSTXb48W0dtMA= 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=hN6WDuWd; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=uLU9r9US; 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="hN6WDuWd"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="uLU9r9US" From: Sebastian Andrzej Siewior DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1757971595; 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=XVEKX7jrb4owN8sB6DCMvwUlGC8C6fTvdYmspEO00rM=; b=hN6WDuWdrtJBylV74OUWQzpcFboZDp6VI9PKswJ23pZbBpWZAc+ZIM8t7qWic51OhHa00f kIUv6v2JikaN7AXHipyFn90M2a7eCZkVZDuPbnOTzjCqu5DIuGBeUhykTYsTu5iZ/y51UN eegoIO4G1xxSQDdQ1CPmYgQEz4GPpxRopuLeMpDmkljFBZb0UIntpoSW2hXtaqGzm36sa3 ubtc2uGWYhfAOmmvJ9kb30IL23DNFOTBJxfuecr5rAFH2+AWfLj5aUbEen38wbUaFruFm+ nj8sJF9WPNf9/Pc1FCrf6RxX1NBnr1JTcluzmTA3Dj2ivsmhqJUfang0mMZnKw== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1757971595; 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=XVEKX7jrb4owN8sB6DCMvwUlGC8C6fTvdYmspEO00rM=; b=uLU9r9USnVX/p13/HXZZ6uN2IONFQCDBvkuGuqLTh5X2AJRuXaWGxJShujnnO/+hdWEcOc Nd5A2K8g9O+mZGAQ== 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 , Borislav Petkov , Waiman Long , Sebastian Andrzej Siewior Subject: [PATCH v2 1/3] selftest/futex: Make the error check more precise for futex_numa_mpol Date: Mon, 15 Sep 2025 23:26:28 +0200 Message-ID: <20250915212630.965328-2-bigeasy@linutronix.de> In-Reply-To: <20250915212630.965328-1-bigeasy@linutronix.de> References: <20250915212630.965328-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" From: Andr=C3=A9 Almeida Instead of just checking if the syscall failed as expected, check as well if the returned error code matches the expected error code. [ bigeasy: reword the commmit message ] Signed-off-by: Andr=C3=A9 Almeida Reviewed-by: Waiman Long Signed-off-by: Sebastian Andrzej Siewior --- .../futex/functional/futex_numa_mpol.c | 36 +++++++++++-------- 1 file changed, 21 insertions(+), 15 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 802c15c821906..dd7b05e8cda45 100644 --- a/tools/testing/selftests/futex/functional/futex_numa_mpol.c +++ b/tools/testing/selftests/futex/functional/futex_numa_mpol.c @@ -77,7 +77,7 @@ static void join_max_threads(void) } } =20 -static void __test_futex(void *futex_ptr, int must_fail, unsigned int fute= x_flags) +static void __test_futex(void *futex_ptr, int err_value, unsigned int fute= x_flags) { int to_wake, ret, i, need_exit =3D 0; =20 @@ -88,11 +88,17 @@ static void __test_futex(void *futex_ptr, int must_fail= , unsigned int futex_flag =20 do { ret =3D futex2_wake(futex_ptr, to_wake, futex_flags); - if (must_fail) { - if (ret < 0) - break; - ksft_exit_fail_msg("futex2_wake(%d, 0x%x) should fail, but didn't\n", - to_wake, futex_flags); + + if (err_value) { + if (ret >=3D 0) + ksft_exit_fail_msg("futex2_wake(%d, 0x%x) should fail, but didn't\n", + to_wake, futex_flags); + + if (errno !=3D err_value) + ksft_exit_fail_msg("futex2_wake(%d, 0x%x) expected error was %d, but r= eturned %d (%s)\n", + to_wake, futex_flags, err_value, errno, strerror(errno)); + + break; } if (ret < 0) { ksft_exit_fail_msg("Failed futex2_wake(%d, 0x%x): %m\n", @@ -106,12 +112,12 @@ static void __test_futex(void *futex_ptr, int must_fa= il, unsigned int futex_flag join_max_threads(); =20 for (i =3D 0; i < MAX_THREADS; i++) { - if (must_fail && thread_args[i].result !=3D -1) { + if (err_value && thread_args[i].result !=3D -1) { 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) { + if (!err_value && thread_args[i].result !=3D 0) { ksft_print_msg("Thread %d failed (%d)\n", i, thread_args[i].result); need_exit =3D 1; } @@ -120,14 +126,14 @@ static void __test_futex(void *futex_ptr, int must_fa= il, unsigned int futex_flag ksft_exit_fail_msg("Aborting due to earlier errors.\n"); } =20 -static void test_futex(void *futex_ptr, int must_fail) +static void test_futex(void *futex_ptr, int err_value) { - __test_futex(futex_ptr, must_fail, FUTEX2_SIZE_U32 | FUTEX_PRIVATE_FLAG |= FUTEX2_NUMA); + __test_futex(futex_ptr, err_value, FUTEX2_SIZE_U32 | FUTEX_PRIVATE_FLAG |= FUTEX2_NUMA); } =20 -static void test_futex_mpol(void *futex_ptr, int must_fail) +static void test_futex_mpol(void *futex_ptr, int err_value) { - __test_futex(futex_ptr, must_fail, FUTEX2_SIZE_U32 | FUTEX_PRIVATE_FLAG |= FUTEX2_NUMA | FUTEX2_MPOL); + __test_futex(futex_ptr, err_value, FUTEX2_SIZE_U32 | FUTEX_PRIVATE_FLAG |= FUTEX2_NUMA | FUTEX2_MPOL); } =20 static void usage(char *prog) @@ -184,16 +190,16 @@ int main(int argc, char *argv[]) =20 /* FUTEX2_NUMA futex must be 8-byte aligned */ ksft_print_msg("Mis-aligned futex\n"); - test_futex(futex_ptr + mem_size - 4, 1); + test_futex(futex_ptr + mem_size - 4, EINVAL); =20 futex_numa->numa =3D FUTEX_NO_NODE; mprotect(futex_ptr, mem_size, PROT_READ); ksft_print_msg("Memory, RO\n"); - test_futex(futex_ptr, 1); + test_futex(futex_ptr, EFAULT); =20 mprotect(futex_ptr, mem_size, PROT_NONE); ksft_print_msg("Memory, no access\n"); - test_futex(futex_ptr, 1); + test_futex(futex_ptr, EFAULT); =20 mprotect(futex_ptr, mem_size, PROT_READ | PROT_WRITE); ksft_print_msg("Memory back to RW\n"); --=20 2.51.0 From nobody Thu Oct 2 14:26:15 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 899252C027A for ; Mon, 15 Sep 2025 21:26:37 +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=1757971599; cv=none; b=l5gOpGu6G+JbT88vGN/toviEcJSjqo6tWAdaBbqkJXzjQPRa3X49zZsnC1J3ni89RaYHUCBgEPu6DVDK++snAZH20D6070+Nu1Pon/+7hiO1uQm/+bo7TGzC8NsxNuuIP5KJlriHGzUHXKFK1iP1LPb6ev8+gCsFa7e0/vgjkeU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1757971599; c=relaxed/simple; bh=RcMD9vg5oTlZQkJ4Fd/QSiglAf0gmMZoJQ6DcNhuFgw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=l48HlrLf/W9EjnpIW9XXm/RYu/TX0cPg52kCgu2et48cVT1qQikS+pZoq6vqezPosTKM6VToZ9t2/8pM+LGGTnGSUfgpbPsbDOEREbstU3QQarNmRBKo6NNjs+rEDTeau1Drh812qKhvQxJA9wNYThvSDKSlA/KUY+0+t+nahls= 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=PtRIcnc8; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=2t7BfZc0; 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="PtRIcnc8"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="2t7BfZc0" From: Sebastian Andrzej Siewior DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1757971595; 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=6nT/1NUrkIw2D/vynHl81wBogxtmdsKj0QnGXnt7lss=; b=PtRIcnc86sqaLZKNUpIRQSQG947gNhlpZNU1FGpApdf9gb/k4EDelfxS4qQYZX8VYONhGg 5SCCaxvlsadNH0cPWA2iCyjRXCW79+GKQFoJQbp0/LkaE0TLgi+snZe1grbLOzV/CpTbjf Jah+F+hWXlyFWrF3+7pjUFcBplTK4xB8dVipn7E2gFi/IZ4SjYuJSaufITlG3OtA248Xd3 OAKEy3x/rS8OdNzE7/xH6gPLxx3PNoENb0hWNtsgGKFSn0Q5B4vI9VtkY1BU76DiBcodKj 8c7apNHcKtwk7BLeRBhbu1qd8eUcJu4LUvDazqMjmR3KeOQJlgdKVNCyHk6QRQ== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1757971595; 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=6nT/1NUrkIw2D/vynHl81wBogxtmdsKj0QnGXnt7lss=; b=2t7BfZc0sAEX5mXN2w3xYnzpGoZpFD9pXrSxa3ZtTacaDUM5Ix/dJoMZ0VsDZzwlfeRxlX c+Z4qmFR5S1yrtDw== 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 , Borislav Petkov , Waiman Long , Sebastian Andrzej Siewior Subject: [PATCH v2 2/3] selftest/futex: Reintroduce "Memory out of range" numa_mpol's subtest Date: Mon, 15 Sep 2025 23:26:29 +0200 Message-ID: <20250915212630.965328-3-bigeasy@linutronix.de> In-Reply-To: <20250915212630.965328-1-bigeasy@linutronix.de> References: <20250915212630.965328-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" From: Andr=C3=A9 Almeida Commit d8e2f919997 ("selftests/futex: Fix some futex_numa_mpol subtests") removed the "Memory out of range" subtest due to it being dependent on the memory layout of the test process having an invalid memory address just after the `*futex_ptr` allocated memory. Reintroduce this test and make it deterministic, by allocation two memory pages and marking the second one with PROT_NONE. Signed-off-by: Andr=C3=A9 Almeida Reviewed-by: Waiman Long Signed-off-by: Sebastian Andrzej Siewior --- .../testing/selftests/futex/functional/futex_numa_mpol.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/tools/testing/selftests/futex/functional/futex_numa_mpol.c b/t= ools/testing/selftests/futex/functional/futex_numa_mpol.c index dd7b05e8cda45..5f4e3111269c3 100644 --- a/tools/testing/selftests/futex/functional/futex_numa_mpol.c +++ b/tools/testing/selftests/futex/functional/futex_numa_mpol.c @@ -174,10 +174,13 @@ int main(int argc, char *argv[]) ksft_set_plan(1); =20 mem_size =3D sysconf(_SC_PAGE_SIZE); - futex_ptr =3D mmap(NULL, mem_size, PROT_READ | PROT_WRITE, MAP_PRIVATE | = MAP_ANONYMOUS, 0, 0); + futex_ptr =3D mmap(NULL, mem_size * 2, PROT_READ | PROT_WRITE, MAP_PRIVAT= E | MAP_ANONYMOUS, 0, 0); if (futex_ptr =3D=3D MAP_FAILED) ksft_exit_fail_msg("mmap() for %d bytes failed\n", mem_size); =20 + /* Create an invalid memory region for the "Memory out of range" test */ + mprotect(futex_ptr + mem_size, mem_size, PROT_NONE); + futex_numa =3D futex_ptr; =20 ksft_print_msg("Regular test\n"); @@ -192,6 +195,9 @@ int main(int argc, char *argv[]) ksft_print_msg("Mis-aligned futex\n"); test_futex(futex_ptr + mem_size - 4, EINVAL); =20 + ksft_print_msg("Memory out of range\n"); + test_futex(futex_ptr + mem_size, EFAULT); + futex_numa->numa =3D FUTEX_NO_NODE; mprotect(futex_ptr, mem_size, PROT_READ); ksft_print_msg("Memory, RO\n"); --=20 2.51.0 From nobody Thu Oct 2 14:26:15 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 8C0DD2C028A for ; Mon, 15 Sep 2025 21:26:37 +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=1757971599; cv=none; b=dlMXuEpH0mbyLb8RRVUUVQG2+KS2Aah6B1PuQCWq7h3pw9NNfZrK0dgSaHlwv6ELhMCCA2N5BCgYfGck8Q8piyh7j+/PSOnGfhuwIsMFzJxaWiFk7LFrVtoyMEA6pAQuWrqPNqXHGS2qfmj6vEgZYMp8quEVUF9FKE2HwaXmWnE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1757971599; c=relaxed/simple; bh=dr922krkn3hTKNerCcihi/Uwzwm+Q3m5iVVRm+3rbJs=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=kceIKw2Xyhxo+i2rCCfDEIrts/L85F+s/lXk6ukB1hRXTjQsPAHqsisqPQb9qD4iDaDg2kKhrkOHdakPoj7CdzoaZL63IArbnky0j+SwLu6T1zbQhxe6hXoB0+FY7Wbz/xO0vprewiQXCaF67vEjpCJoHBYjfkM2P+O/8OC9bgs= 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=MgHBPEv7; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=fHXffJKs; 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="MgHBPEv7"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="fHXffJKs" From: Sebastian Andrzej Siewior DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1757971595; 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=lncqhFfIQHgTUezFqndTiqcMxgd5BZtZaRBFHNPNwhs=; b=MgHBPEv7SFoKvsb4sJDQlDGUL9FuOXEb7jeNmF6ZQioAt7C7Bkguzn3db1pLVc0aUUw91h 7QFybSeBmIeKU74wqMFpgXWEzDTd8h2ZrabDnSPcrLrXyHQQuf+BmBhEIgTOboPci8YeuH si6SEYUeqi2pbhlYpsHI5r3ZANrqOykayz7Drf1MktD4lEuqVsfOh5Q+KOXvhKaMaYLnst X2CepdvkrZv0GeM1i//bFhuPL4C2oyKqXHJ9zUrlIQkYV/HDmLoaVMfnvALgKQ+k3hwBNX DYfWecYeDtDpslY//XYT6/5SX9xj7f/JV+G2ljMHqy0yheL2ntnJAFnogPbXCQ== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1757971595; 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=lncqhFfIQHgTUezFqndTiqcMxgd5BZtZaRBFHNPNwhs=; b=fHXffJKsDBYx4L61k/7n2IDXVcU2FmSnc1M7HKHPFrNW1AGshGMvY0pNIcL1nriKLW7wGs C1AHPbL3MXZzNOCA== 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 , Borislav Petkov , Waiman Long , Sebastian Andrzej Siewior , kernel test robot Subject: [PATCH v2 3/3] selftest/futex: Compile also with libnuma < 2.0.16 Date: Mon, 15 Sep 2025 23:26:30 +0200 Message-ID: <20250915212630.965328-4-bigeasy@linutronix.de> In-Reply-To: <20250915212630.965328-1-bigeasy@linutronix.de> References: <20250915212630.965328-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" After using numa_set_mempolicy_home_node() the test fails to compile on systems with libnuma library versioned lower than 2.0.16. In order to allow lower library version add a pkg-config related check and exclude that part of the code. Without the proper MPOL setup it can't be tested. Make a total number of tests two. The first one is the first batch and the second is the MPOL related one. The goal is to let the user know if it has been skipped due to library limitation. Remove test_futex_mpol(), it was unused and it is now complained by the compiler if the part is not compiled. Fixes: 0ecb4232fc65e ("selftests/futex: Set the home_node in futex_numa_mpo= l") Reported-by: kernel test robot Closes: https://lore.kernel.org/oe-lkp/202507150858.bedaf012-lkp@intel.com Signed-off-by: Sebastian Andrzej Siewior --- .../selftests/futex/functional/Makefile | 5 ++++- .../futex/functional/futex_numa_mpol.c | 21 +++++++++---------- 2 files changed, 14 insertions(+), 12 deletions(-) diff --git a/tools/testing/selftests/futex/functional/Makefile b/tools/test= ing/selftests/futex/functional/Makefile index ddfa61d857b9b..bd50aecfca8a3 100644 --- a/tools/testing/selftests/futex/functional/Makefile +++ b/tools/testing/selftests/futex/functional/Makefile @@ -1,6 +1,9 @@ # SPDX-License-Identifier: GPL-2.0 +PKG_CONFIG ?=3D pkg-config +LIBNUMA_TEST =3D $(shell sh -c "$(PKG_CONFIG) numa --atleast-version 2.0.1= 6 > /dev/null 2>&1 && echo SUFFICIENT || echo NO") + INCLUDES :=3D -I../include -I../../ $(KHDR_INCLUDES) -CFLAGS :=3D $(CFLAGS) -g -O2 -Wall -pthread -D_FILE_OFFSET_BITS=3D64 -D_TI= ME_BITS=3D64 $(INCLUDES) $(KHDR_INCLUDES) +CFLAGS :=3D $(CFLAGS) -g -O2 -Wall -pthread -D_FILE_OFFSET_BITS=3D64 -D_TI= ME_BITS=3D64 $(INCLUDES) $(KHDR_INCLUDES) -DLIBNUMA_VER_$(LIBNUMA_TEST)=3D1 LDLIBS :=3D -lpthread -lrt -lnuma =20 LOCAL_HDRS :=3D \ diff --git a/tools/testing/selftests/futex/functional/futex_numa_mpol.c b/t= ools/testing/selftests/futex/functional/futex_numa_mpol.c index 5f4e3111269c3..722427fe90bf0 100644 --- a/tools/testing/selftests/futex/functional/futex_numa_mpol.c +++ b/tools/testing/selftests/futex/functional/futex_numa_mpol.c @@ -131,11 +131,6 @@ static void test_futex(void *futex_ptr, int err_value) __test_futex(futex_ptr, err_value, FUTEX2_SIZE_U32 | FUTEX_PRIVATE_FLAG |= FUTEX2_NUMA); } =20 -static void test_futex_mpol(void *futex_ptr, int err_value) -{ - __test_futex(futex_ptr, err_value, FUTEX2_SIZE_U32 | FUTEX_PRIVATE_FLAG |= FUTEX2_NUMA | FUTEX2_MPOL); -} - static void usage(char *prog) { printf("Usage: %s\n", prog); @@ -148,7 +143,7 @@ static void usage(char *prog) int main(int argc, char *argv[]) { struct futex32_numa *futex_numa; - int mem_size, i; + int mem_size; void *futex_ptr; int c; =20 @@ -171,7 +166,7 @@ int main(int argc, char *argv[]) } =20 ksft_print_header(); - ksft_set_plan(1); + ksft_set_plan(2); =20 mem_size =3D sysconf(_SC_PAGE_SIZE); futex_ptr =3D mmap(NULL, mem_size * 2, PROT_READ | PROT_WRITE, MAP_PRIVAT= E | MAP_ANONYMOUS, 0, 0); @@ -211,8 +206,11 @@ int main(int argc, char *argv[]) ksft_print_msg("Memory back to RW\n"); test_futex(futex_ptr, 0); =20 + ksft_test_result_pass("futex2 memory boundarie tests passed\n"); + /* MPOL test. Does not work as expected */ - for (i =3D 0; i < 4; i++) { +#ifdef LIBNUMA_VER_SUFFICIENT + for (int i =3D 0; i < 4; i++) { unsigned long nodemask; int ret; =20 @@ -231,15 +229,16 @@ int main(int argc, char *argv[]) ret =3D futex2_wake(futex_ptr, 0, FUTEX2_SIZE_U32 | FUTEX_PRIVATE_FLAG = | FUTEX2_NUMA | FUTEX2_MPOL); if (ret < 0) 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) { ksft_exit_fail_msg("Returned NUMA node is %d expected %d\n", futex_numa->numa, i); } } } - ksft_test_result_pass("NUMA MPOL tests passed\n"); + ksft_test_result_pass("futex2 MPOL hints test passed\n"); +#else + ksft_test_result_skip("futex2 MPOL hints test requires libnuma 2.0.16+\n"= ); +#endif ksft_finished(); return 0; } --=20 2.51.0