Re: [PATCH v3 08/14] sched: Replace rq->curr access w/ rq_curr(rq)

Peter Zijlstra
2023-04-22T10:42:25Z

On Tue, Apr 11, 2023 at 04:25:05AM +0000, John Stultz wrote:
> +static inline struct task_struct *rq_curr(struct rq *rq)
> +{
> + return rq->curr_exec;
> +}
> +
> +static inline struct task_struct *rq_curr_rcu(struct rq *rq)
> +{
> + return rcu_dereference(rq->curr_exec);
> +}
> +
> +static inline struct task_struct *rq_curr_once(struct rq *rq)
> +{
> + return READ_ONCE(rq->curr_exec);
> +}
> +
> +static inline void rq_set_curr(struct rq *rq, struct task_struct *task)
> +{
> + rcu_assign_pointer(rq->curr_exec, task);
> +}
> +
> +/*
> + * XXX jstultz: seems like rcu_assign_pointer above would also
> + * work for this, but trying to match usage.
> + */
> +static inline void rq_set_curr_rcu_init(struct rq *rq, struct task_struct *task)
> +{
> + RCU_INIT_POINTER(rq->curr_exec, task);
> +}

> +static inline struct task_struct *rq_selected(struct rq *rq)
> +{
> + return rq->curr_sched;
> +}
> +
> +static inline struct task_struct *rq_selected_rcu(struct rq *rq)
> +{
> + return rcu_dereference(rq->curr_sched);
> +}
> +
> +static inline struct task_struct *rq_selected_once(struct rq *rq)
> +{
> + return READ_ONCE(rq->curr_sched);
> +}
> +
> +static inline void rq_set_selected(struct rq *rq, struct task_struct *t)
> +{
> + rcu_assign_pointer(rq->curr_sched, t);
> +}

How is any of that helping? That's just making it harder to read.

Can we please just keep it rq->curr and rq->proxy and stop this wrapper
fettish.