OSDN Git Service

mm: move vma locking out of vma_prepare and dup_anon_vma
authorSuren Baghdasaryan <surenb@google.com>
Fri, 4 Aug 2023 15:27:24 +0000 (08:27 -0700)
committerAndrew Morton <akpm@linux-foundation.org>
Mon, 21 Aug 2023 20:37:46 +0000 (13:37 -0700)
commitc9d6e982c3f8703c24f488d3de15e0ee97f4655e
treebbc0499be0e5660132dd59ab08b360960db24691
parentad9f006351c3368171458ae7ab14d72f031b239f
mm: move vma locking out of vma_prepare and dup_anon_vma

vma_prepare() is currently the central place where vmas are being locked
before vma_complete() applies changes to them. While this is convenient,
it also obscures vma locking and makes it harder to follow the locking
rules. Move vma locking out of vma_prepare() and take vma locks
explicitly at the locations where vmas are being modified. Move vma
locking and replace it with an assertion inside dup_anon_vma() to further
clarify the locking pattern inside vma_merge().

Link: https://lkml.kernel.org/r/20230804152724.3090321-7-surenb@google.com
Suggested-by: Linus Torvalds <torvalds@linuxfoundation.org>
Suggested-by: Liam R. Howlett <Liam.Howlett@oracle.com>
Signed-off-by: Suren Baghdasaryan <surenb@google.com>
Cc: Jann Horn <jannh@google.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
mm/mmap.c