Messages in this thread | | | Date | Thu, 9 Dec 2021 12:14:33 -1000 | From | Tejun Heo <> | Subject | Re: [RFC PATCH 7/7] workqueue: Replace pool lock with preemption disabling in wq_worker_sleeping() |
| |
Hello,
On Tue, Dec 07, 2021 at 03:35:43PM +0800, Lai Jiangshan wrote: > From: Lai Jiangshan <laijs@linux.alibaba.com> > > Once upon a time, wq_worker_sleeping() was called with rq lock held, > so wq_worker_sleeping() can not use pool lock. Instead it used "X:" > protection: preemption disabled on local cpu and wq_worker_sleeping() > didn't depend on rq lock to work even with it held. > > Now, wq_worker_sleeping() isn't called with rq lock held and is using > pool lock. But the functionality of "X:" protection isn't removed and > wq_worker_running() is still using it. > > So we can also use "X:" protection in wq_worker_sleeping() and avoid > locking the pool lock. > > This patch also documents that only idle_list.next is under "X:" > protection, not the whole idle_list because destroy_worker() in idle > timer can remove non-first idle workers. Idle timer can be possible > strayed in different CPU, or even in the same CPU, it can interrupt > preemption disabled context.
It's nice to go back to not needing to grab pool lock in the worker sleeping path but I'm not sure it actually matters. This isn't in a red-hot path and we're touching a bunch of stuff in the pool anyway, so the overhead of grabbing a lock which likely isn't too contended shouldn't matter all that much. So, maybe it'd be better to just keep things simple?
Thanks.
-- tejun
| |