On Wed, Mar 27, 2019 at 12:07:20PM -0700, Tejun Heo (tj@xxxxxxxxxx) wrote: > Hello, > > On Wed, Mar 27, 2019 at 02:16:11PM -0300, Jason Gunthorpe wrote: > > So, is it OK for a WQ entry on a WQ_MEM_RECLAIM queue to call > > kmalloc(GFP_KERNEL) ? > > In most cases, you can answer these questions by mapping them to a > block device driver. A block device driver which performs GFP_KERNEL > allocation on IO path may cause a deadlock. If the workqueue is > sitting in a path which can be depended upon for memory reclaim IOs, > the same applies to the workqueue. Well, at least I'm not super familiar with the block layer and wouldn't know about this.. But your explanation is helpful. I will be watching for WQ_MEM_RECLAIM users that are allocating memory in their work functions. Would it be possible to have a lockdep-like debugging under kmalloc similar to check_flush_dependency() that complains if a WQ_MEM_RECLAIM work is doing inappropriate allocations? That would help discourage using it in WQ's it shouldn't be used on. Thanks, Jason