[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <606ae81e-3339-41eb-88a9-21ed6289a948@suse.cz>
Date: Tue, 5 Nov 2024 10:17:31 +0100
From: Vlastimil Babka <vbabka@...e.cz>
To: Lorenzo Stoakes <lorenzo.stoakes@...cle.com>,
Andrew Morton <akpm@...ux-foundation.org>
Cc: "Liam R . Howlett" <Liam.Howlett@...cle.com>, Jann Horn
<jannh@...gle.com>, Linus Torvalds <torvalds@...ux-foundation.org>,
linux-mm@...ck.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH] mm: remove unnecessary page_table_lock on stack expansion
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@...cle.com>
Acked-by: Vlastimil Babka <vbabka@...e.cz>
Powered by blists - more mailing lists