Re: [PATCH] mm: remove unnecessary page_table_lock on stack expansion
From: Vlastimil Babka
Date: Tue Nov 05 2024 - 04:17:44 EST
On 11/1/24 19:46, Lorenzo Stoakes wrote:
> Ever since commit 8d7071af8907 ("mm: always expand the stack with the mmap
> write lock held") we have been expanding the stack with the mmap write lock
> held.
>
> This is true in all code paths:
>
> get_arg_page()
> -> expand_downwards()
> setup_arg_pages()
> -> expand_stack_locked()
> -> expand_downwards() / expand_upwards()
> lock_mm_and_find_vma()
> -> expand_stack_locked()
> -> expand_downwards() / expand_upwards()
> create_elf_tables()
> -> find_extend_vma_locked()
> -> expand_stack_locked()
> expand_stack()
> -> vma_expand_down()
> -> expand_downwards()
> expand_stack()
> -> vma_expand_up()
> -> expand_upwards()
>
> Each of which acquire the mmap write lock before doing so. Despite this, we
> maintain code that acquires a page table lock in the expand_upwards() and
> expand_downwards() code, stating that we hold a shared mmap lock and thus
> this is necessary.
>
> It is not, we do not have to worry about concurrent VMA expansions so we
> can simply drop this, and update comments accordingly.
>
> We do not even need be concerned with racing page faults, as
> vma_start_write() is invoked in both cases.
>
> Signed-off-by: Lorenzo Stoakes <lorenzo.stoakes@xxxxxxxxxx>
Acked-by: Vlastimil Babka <vbabka@xxxxxxx>