On Mon, 2017-09-11 at 09:37 -0700, tj@xxxxxxxxxx wrote: > Hello, > > On Mon, Sep 11, 2017 at 04:09:12PM +0000, Bart Van Assche wrote: > > On Mon, 2017-09-11 at 06:13 -0700, Tejun Heo wrote: > > > On Fri, Sep 08, 2017 at 04:52:22PM -0700, Bart Van Assche wrote: > > > > The blk-mq core keeps track of the number of request queue users > > > > through q->q_usage_count. Make it possible to switch this counter > > > > to atomic mode from the context of the block layer power management > > > > code by introducing percpu_ref_switch_to_atomic_nowait(). > > > > > > Do you ever have to switch back? If so, how do you know whether the > > > previous transition finished? > > > > The way I would like to use this function is to check for completion of the > > transition by calling percpu_ref_is_zero(). That function namely not only > > checks the value of the refcount but also whether it is in atomic mode. See > > also "[PATCH 5/5] blk-mq: Implement power management support" > > (https://www.spinics.net/lists/linux-block/msg17143.html). Do you think this > > will work? > > Probably but that sounds really hairy. I'd much prefer if it could be > done through the usual kill / confirm / release and re-init. That's > not a possibility? Hello Tejun, Modifying this patch series such that it uses the confirmation mechanism when switching from per-cpu to atomic mode should be possible. However, the wait_event_lock_irq() call in __percpu_ref_switch_mode() is annoying when calling percpu_ref_kill_and_confirm() from atomic context. How about adding a nowait version of percpu_ref_kill_and_confirm() that returns a boolean indicating whether or not this function succeeded? Thanks, Bart.