Re: [PATCH 2/6] blk-mq: replace timeout synchronization with a RCU and generation based scheme

From: Tejun Heo
Date: Tue Dec 12 2017 - 13:05:00 EST


Hello,

On Tue, Dec 12, 2017 at 12:56:57PM +0100, Peter Zijlstra wrote:
> On Sat, Dec 09, 2017 at 11:25:21AM -0800, Tejun Heo wrote:
> > +static inline void blk_mq_rq_update_state(struct request *rq,
> > + enum mq_rq_state state)
> > +{
> > + u64 new_val = (rq->gstate & ~MQ_RQ_STATE_MASK) | state;
> > +
> > + if (state == MQ_RQ_IN_FLIGHT) {
> > + WARN_ON_ONCE(blk_mq_rq_state(rq) != MQ_RQ_IDLE);
> > + new_val += MQ_RQ_GEN_INC;
> > + }
> > +
> > + /* avoid exposing interim values */
>
> My paranoia would like to see READ_ONCE() on the rq->gstate load above
> as well, that makes it a fully explicit load-store operation.

Right now, only the request owner can update the field so there's no
data coherency issue but then again there's nothing to lose by adding
READ_ONCE there. Will add it.

Thanks.

--
tejun