Re: [RFC][PATCH] task_struct::state frobbing

From: Peter Zijlstra
Date: Fri Mar 26 2021 - 03:58:31 EST


On Thu, Mar 25, 2021 at 08:51:10PM +0100, Thomas Gleixner wrote:
> On Thu, Mar 25 2021 at 19:11, Peter Zijlstra wrote:
> > --- a/block/blk-mq.c
> > +++ b/block/blk-mq.c
> > @@ -3867,7 +3867,7 @@ static bool blk_mq_poll_hybrid(struct request_queue *q,
> > int blk_poll(struct request_queue *q, blk_qc_t cookie, bool spin)
> > {
> > struct blk_mq_hw_ctx *hctx;
> > - long state;
> > + unsigned int state;
> >
> > if (!blk_qc_t_valid(cookie) ||
> > !test_bit(QUEUE_FLAG_POLL, &q->queue_flags))
> > @@ -3891,7 +3891,7 @@ int blk_poll(struct request_queue *q, blk_qc_t cookie, bool spin)
> >
> > hctx->poll_considered++;
> >
> > - state = current->state;
> > + state = READ_ONCE(current->__state);
>
> Can we please have get_current_state() for that?

Sure...

> > static bool io_wq_worker_affinity(struct io_worker *worker, void *data)
> > {
> > - struct task_struct *task = worker->task;
> > - struct rq_flags rf;
> > - struct rq *rq;
> > -
> > - rq = task_rq_lock(task, &rf);
> > - do_set_cpus_allowed(task, cpumask_of_node(worker->wqe->node));
> > - task->flags |= PF_NO_SETAFFINITY;
> > - task_rq_unlock(rq, task, &rf);
> > + set_cpus_allowed_ptr(worker->task, cpumask_of_node(worker->wqe->node));
>
> Duh, I thought we got all of them by now.

It's new and horrible crap, already send an email to Jens about it. It
shouldn't be in this patch, but I didn't clean up.