[lkml]   [2011]   [Apr]   [13]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
Messages in this thread
    Subject[futex] Regression in 2.6.38 regarding FLAGS_HAS_TIMEOUT

    I noticed that the behaviour of FUTEX_WAIT changed between 2.6.37 and
    2.6.38. The error was initially found in a java program where a
    Thread.sleep never returned after resuming from a suspend to ram.
    Thread.sleep is implemented using pthread_cond_timedwait which itself
    uses futex with the op FUTEX_WAIT.

    The error can also be triggered with a simple test program (attached as
    test-futex.c) which calls FUTEX_WAIT with a timeout of 200ms in a loop.
    While running the test program the machine is suspended using "echo mem
    > /sys/power/state".

    After resume the futex syscall never returns. The return can be provoked
    by sending the process a combination of SIGSTOP and SIGCONT.

    The bug didn't occur in 2.6.37.

    I found this bug report

    which describes a related problem and presented a patch. This patch
    (adding the FLAGS_HAS_TIMEOUT in futex_wait to the restart_block) fixes
    the problem for my initial java problem and the test program.

    I found the following pull request which probably introduced the



    #include <errno.h>
    #include <linux/futex.h>
    #include <stdio.h>
    #include <string.h>
    #include <sys/syscall.h>
    #include <sys/time.h>
    #include <unistd.h>

    static inline int futex(int *uaddr, int op, int val,
    const struct timespec *timeout,
    int *uaddr2, int val3)
    return syscall(SYS_futex, uaddr, op, val,
    timeout, uaddr2, val3);

    static void futex_sleep(int ms)
    static int round;
    struct timespec ts;
    int condition = 0;
    int rc;
    fprintf(stderr, "Before sleep %d\n", ++round);
    ts.tv_sec = 0;
    ts.tv_nsec = ms * 1000L * 1000L;
    rc = futex(&condition, FUTEX_WAIT, condition, &ts, NULL, 0);
    fprintf(stderr, "After sleep (error: %s)\n",
    (rc < 0 ? strerror(errno) : "none"));

    int main()
    while(1) {
    return 0;
     \ /
      Last update: 2011-04-13 09:07    [W:0.025 / U:62.764 seconds]
    ©2003-2017 Jasper Spaans. hosted at Digital OceanAdvertise on this site