Re: [RFC PATCH] mm/mbind: Introduce process_mbind() syscall for external memory binding

From: Gregory Price
Date: Fri Nov 24 2023 - 15:09:36 EST


On Fri, Nov 24, 2023 at 04:13:41PM +0800, Zhongkun He wrote:
>
> Per my understanding, the process_mbind() is implementable without
> many difficult challenges,
> since it is always protected by mm->mmap_lock. But task mempolicy does
> not acquire any lock
> in alloc_pages().

per-vma policies are protected by the mmap lock, while the task
mempolicy is protected by the task lock on replacement, and
task->mems_allowed (protected by task_lock).

There is an update in my refactor tickets that enforces the acquisition
of task_lock on mpol_set_nodemask, which prevents the need for
alloc_pages to do anything else. That's not present in this patch.

Basically mems_allowed deals with the majority of situations, and
mmap_lock deals with per-vma mempolicy changes and migrations.

~Gregory