On 2022/03/22 21:42, Tetsuo Handa wrote: > On 2022/03/22 20:10, Christoph Hellwig wrote: >> On Wed, Mar 16, 2022 at 10:24:20PM +0900, Tetsuo Handa wrote: >>> Since this WQ is invoked when flushing data to disk, this WQ had better use >>> WQ_MEM_RECLAIM flag when creating. A WQ created with WQ_MEM_RECLAIM flag has >>> at least one "struct task_struct" in order to guarantee forward progress, but >>> results in consuming more kernel resources. Therefore, it is preferable to >>> destroy the WQ when clearing unbinding a loop device from a backing file. >> >> Whіch then gets us into lock dependency problems. A previously used >> but lingering around device will use some resources, so what? If you >> care about the least used resources the only way to get there is to >> destroy the device. > > There is no dependency problems and there is no resource wasting if we choose > task_work approach, for that approach runs in lockless context and allows > destroying "struct task_struct" as soon as device is unbound. This lockdep problem is reaching to whether the loop module should continue using WQ. There must be a reason to convert kernel threads into WQ again, but use of WQ_MEM_RECLAIM flag is causing troubles. https://lkml.kernel.org/r/20220322235032.GS1544202@xxxxxxxxxxxxxxxxxxx