Patch "selftests/futex: Order calls to futex_lock_pi" has been added to the 6.4-stable tree

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This is a note to let you know that I've just added the patch titled

    selftests/futex: Order calls to futex_lock_pi

to the 6.4-stable tree which can be found at:
    http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
     selftests-futex-order-calls-to-futex_lock_pi.patch
and it can be found in the queue-6.4 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree,
please let <stable@xxxxxxxxxxxxxxx> know about it.



commit 47a4b2be1dca331a92820b10e6c424eb65821eec
Author: Nysal Jan K.A <nysal@xxxxxxxxxxxxx>
Date:   Mon Aug 14 13:39:27 2023 +0530

    selftests/futex: Order calls to futex_lock_pi
    
    [ Upstream commit fbf4dec702774286db409815ffb077711a96b824 ]
    
    Observed occassional failures in the futex_wait_timeout test:
    
    ok 1 futex_wait relative succeeds
    ok 2 futex_wait_bitset realtime succeeds
    ok 3 futex_wait_bitset monotonic succeeds
    ok 4 futex_wait_requeue_pi realtime succeeds
    ok 5 futex_wait_requeue_pi monotonic succeeds
    not ok 6 futex_lock_pi realtime returned 0
    ......
    
    The test expects the child thread to complete some steps before
    the parent thread gets to run. There is an implicit expectation
    of the order of invocation of futex_lock_pi between the child thread
    and the parent thread. Make this order explicit. If the order is
    not met, the futex_lock_pi call in the parent thread succeeds and
    will not timeout.
    
    Fixes: f4addd54b161 ("selftests: futex: Expand timeout test")
    Signed-off-by: Nysal Jan K.A <nysal@xxxxxxxxxxxxx>
    Signed-off-by: Shuah Khan <skhan@xxxxxxxxxxxxxxxxxxx>
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

diff --git a/tools/testing/selftests/futex/functional/futex_wait_timeout.c b/tools/testing/selftests/futex/functional/futex_wait_timeout.c
index 3651ce17beeb9..d183f878360bc 100644
--- a/tools/testing/selftests/futex/functional/futex_wait_timeout.c
+++ b/tools/testing/selftests/futex/functional/futex_wait_timeout.c
@@ -24,6 +24,7 @@
 
 static long timeout_ns = 100000;	/* 100us default timeout */
 static futex_t futex_pi;
+static pthread_barrier_t barrier;
 
 void usage(char *prog)
 {
@@ -48,6 +49,8 @@ void *get_pi_lock(void *arg)
 	if (ret != 0)
 		error("futex_lock_pi failed\n", ret);
 
+	pthread_barrier_wait(&barrier);
+
 	/* Blocks forever */
 	ret = futex_wait(&lock, 0, NULL, 0);
 	error("futex_wait failed\n", ret);
@@ -130,6 +133,7 @@ int main(int argc, char *argv[])
 	       basename(argv[0]));
 	ksft_print_msg("\tArguments: timeout=%ldns\n", timeout_ns);
 
+	pthread_barrier_init(&barrier, NULL, 2);
 	pthread_create(&thread, NULL, get_pi_lock, NULL);
 
 	/* initialize relative timeout */
@@ -163,6 +167,9 @@ int main(int argc, char *argv[])
 	res = futex_wait_requeue_pi(&f1, f1, &futex_pi, &to, 0);
 	test_timeout(res, &ret, "futex_wait_requeue_pi monotonic", ETIMEDOUT);
 
+	/* Wait until the other thread calls futex_lock_pi() */
+	pthread_barrier_wait(&barrier);
+	pthread_barrier_destroy(&barrier);
 	/*
 	 * FUTEX_LOCK_PI with CLOCK_REALTIME
 	 * Due to historical reasons, FUTEX_LOCK_PI supports only realtime



[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux