On Wed, 2018-08-08 at 08:23 -0700, Tejun Heo wrote: +AD4- On Tue, Aug 07, 2018 at 03:51:28PM -0700, Bart Van Assche wrote: +AD4- +AD4- Introduce a function that allows to determine whether a per-cpu refcount +AD4- +AD4- is in use. This function will be used in a later patch to determine +AD4- +AD4- whether or not any block layer requests are being executed. +AD4- +AD4- I thought about it a bit and am having a bit of difficulty convincing +AD4- myself this is necessary. Switching a percpu+AF8-ref to atomic mode isn't +AD4- expensive - it's one spinlock cycle, a rcu wait and one sweep of the +AD4- percpu counters. The most expensive part - the percpu sweep - needs +AD4- to be there even with optimization, the wait doesn't really matter as +AD4- all it'll do is slightly delaying timer based PM operation and can be +AD4- overlayed with the propagation of set+AF8-pm+AF8-only() anyway. +AD4- +AD4- So, how about just doing the simple thing? Switch it to atomic mode +AD4- and check the counter and switch back to percpu mode afterwards. If +AD4- we see any issues with that, we can try to optimize it later but that +AD4- seems unlikely to me. Hello Tejun, Switching to atomic mode would require me to add a serialization mechanism against blk+AF8-freeze+AF8-queue+AF8-start() and blk+AF8-mq+AF8-unfreeze+AF8-queue() since these functions call percpu+AF8-ref+AF8-kill() and percpu+AF8-ref+AF8-reinit(). That is easy but requires additional code. I will see whether I can implement an alternative approach using blk+AF8-mq+AF8-queue+AF8-tag+AF8-busy+AF8-iter(). Thanks, Bart.