On Thu 18-06-20 09:20:40, Jens Axboe wrote: > Hi, > > Got a question that I couldn't immediately find an answer to. io_uring > currently jumps through a few hoops to avoid holding a process mm over > schedule, and it doesn't look like that's necessary. > > Is it fine for a kthread to do mmget/kthread_use_mm at the start, and > only put/unuse when it exits? Or is it more prudent to drop/re-acquire > over schedule for potential longer periods of idleness? Pinning the address space for a long time is not really ideal. This would prevent quite a lot of memory to be released when the primary owner of the address space goes away (willingly or by the OOM killer). Our documentation says * Never use this function to pin this address space for an * unbounded/indefinite amount of time. If you know the kthread is not going to use the mm for some time just pin the mm struct itsef by mmgrab() and then mmget_not_zero() to get the address space for your use again. -- Michal Hocko SUSE Labs