Re: [GIT PULL] x86/mm for 6.2

From: kirill . shutemov
Date: Thu Dec 15 2022 - 21:16:58 EST


On Thu, Dec 15, 2022 at 09:17:11AM -0800, Linus Torvalds wrote:
> - make thread creation lock it (and unlock it on creating a new mm at
> execve, but not fork).
>
> And yes, I would actually suggest that _any_ thread creation locks it,
> so that you never *EVER* have any issues with "oh, now I need to
> synchronize with other threads". A process can set its LAM state at
> startup, not in the middle of running!

By thread creation, you mean CLONE_VM, right?

Do we care to avoid locking for CLONE_VFORK case? Seems excessive.

> Note that io_uring will automatically do that locking, because it does
> that thread creation (create_io_thread()). So io_uring threads won't
> even be a special case.

I've missed that io_uring does not use kthread_use_mm() anymore. But what
about other kthread_use_mm() users?

I did not find concrete cases where missing LAM setup would breaks things,
but I cannot prove opposite too.

kthread_use_mm() usage is suspicious in amdkfd, but I donno.

io_uring was a clear before it moved away from kthread_use_mm().

--
Kiryl Shutsemau / Kirill A. Shutemov