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

John Stultz
2023-04-25T14:47:34Z

On Sat, Apr 22, 2023 at 11:42 AM Peter Zijlstra <peterz@infradead.org> wrote:
>
> 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.

Heh. So the main reason I added these was so the !CONFIG_PROXY_EXEC
case would be able to collapse down cleanly.

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

So, I could go back and set the rq_curr() back to rq->curr, but it
seems like we'd still want the rq_selected() [whatever its named]
wrapper to avoid the extra pointer in the task struct when proxy-exec
isn't used. Or do you have a different suggestion for this?

thanks
-john