Re: [RFC PATCH for 4.17 02/21] rseq: Introduce restartable sequences system call (v12)

From: Peter Zijlstra
Date: Wed Mar 28 2018 - 07:20:25 EST


On Tue, Mar 27, 2018 at 12:05:23PM -0400, Mathieu Desnoyers wrote:
> +#ifdef CONFIG_RSEQ
> + struct rseq __user *rseq;
> + u32 rseq_len;
> + u32 rseq_sig;
> + /*
> + * RmW on rseq_event_mask must be performed atomically
> + * with respect to preemption.
> + */
> + unsigned long rseq_event_mask;
> +#endif

> +static inline void rseq_signal_deliver(struct pt_regs *regs)
> +{
> + set_bit(RSEQ_EVENT_SIGNAL_BIT, &current->rseq_event_mask);
> + rseq_handle_notify_resume(regs);
> +}
> +
> +static inline void rseq_preempt(struct task_struct *t)
> +{
> + set_bit(RSEQ_EVENT_PREEMPT_BIT, &t->rseq_event_mask);
> + rseq_set_notify_resume(t);
> +}
> +
> +static inline void rseq_migrate(struct task_struct *t)
> +{
> + set_bit(RSEQ_EVENT_MIGRATE_BIT, &t->rseq_event_mask);
> + rseq_set_notify_resume(t);
> +}

Given that comment above, do you really need the full atomic set bit?
Isn't __set_bit() sufficient?