concurrencykit / ck

Concurrency primitives, safe memory reclamation mechanisms and non-blocking (including lock-free) data structures designed to aid in the research, design and implementation of high performance concurrent systems developed in C99+.
http://concurrencykit.org/
Other
2.38k stars 313 forks source link

Rework ck_ec tests when invoking FUTEX_WAIT_BITSET #172

Closed michael-grunder closed 3 years ago

michael-grunder commented 3 years ago

This PR reworks how futex is called in the ck_ec tests and benchmarks.

Presently, the wait half of the syscall is invoked like so:

    syscall(SYS_futex, address,
        FUTEX_WAIT_BITSET, expected, deadline,
        NULL, /* `val3` argument */ deadline, 0);

This results in the syscall failing with EINVAL when deadline is NULL.

   FUTEX_WAIT_BITSET (since Linux 2.6.25)
              This operation is like FUTEX_WAIT except that val3 is used
              to provide a 32-bit bit mask to the kernel.  This bit
              mask, in which at least one bit must be set, is stored in
              the kernel-internal state of the waiter.  See the
              description of FUTEX_WAKE_BITSET for further details.

I think this may cause confusion if people use the benchmark/validation code as a starting point for their wait/wake callbacks. The callbacks will work but NULL timeouts will result in a busy-wait.

Small program demonstrating the behavior

pkhuong commented 3 years ago

Good catch, thank you!