Re: [RFC PATCH v2 1/4] rseq: Add sched_state field to struct rseq

From: Florian Weimer
Date: Mon May 29 2023 - 15:36:35 EST


* Mathieu Desnoyers:

> +/*
> + * rseq_sched_state should be aligned on the cache line size.
> + */
> +struct rseq_sched_state {
> + /*
> + * Version of this structure. Populated by the kernel, read by
> + * user-space.
> + */
> + __u32 version;
> + /*
> + * The state is updated by the kernel. Read by user-space with
> + * single-copy atomicity semantics. This field can be read by any
> + * userspace thread. Aligned on 32-bit. Contains a bitmask of enum
> + * rseq_sched_state_flags. This field is provided as a hint by the
> + * scheduler, and requires that the page holding this state is
> + * faulted-in for the state update to be performed by the scheduler.
> + */
> + __u32 state;
> + /*
> + * Thread ID associated with the thread registering this structure.
> + * Initialized by user-space before registration.
> + */
> + __u32 tid;
> +};

How does the version handshake protocol in practice? Given that this
user-allocated?

I don't see why we can't stick this directly into struct rseq because
it's all public anyway.

The TID field would be useful in its own right.

Thanks,
Florian