Re: [PATCH 1/2 v3] rseq/membarrier: add MEMBARRIER_CMD_PRIVATE_EXPEDITED_RSEQ

From: Peter Zijlstra
Date: Tue Aug 11 2020 - 03:54:34 EST


On Tue, Aug 11, 2020 at 08:27:33AM +0200, Peter Zijlstra wrote:
> SYSCALL_DEFINE2(membarrier, int, cmd, int, flags)
> {
> + int cflags = 0, int cpuid = -1;
> +
> if (unlikely(flags) && cmd != MEMBARRIER_CMD_PRIVATE_EXPEDITED_RSEQ)
> return -EINVAL;
> +
> + if (cmd & (MEMBARRIER_CMD_PRIVATE_EXPEDITED |
> + MEMBARRIER_CMD_PRIVATE_EXPEDITED_SYNC_CORE |
> + MEMBARRIER_CMD_PRIVATE_EXPEDITED_RSEQ)) {
> +
> + if (cmd & MEMBARRIER_CMD_PRIVATE_EXPEDITED_RSEQ)
> + cflags |= MEMBARRIER_FLAG_RSEQ;
> +
> + if (cmd & MEMBARRIER_CMD_PRIVATE_EXPEDITED_SYNC_CORE) {
> + cflags |= MEMBARRIER_FLAG_SYNC_CORE;
> + cpuid = flags;
> + }
> +
> + cmd = MEMBARRIER_CMD_PRIVATE_EXPEDITED;
> + }

This of course fails to check if other bits are set, and it goes really
'funny' if you use cpuid != -1.

That all needs a little more thought.