Re: [PATCH v8 23/70] mm/mmap: change do_brk_flags() to expand existing VMA and add do_brk_munmap()

From: Guenter Roeck
Date: Thu Apr 28 2022 - 12:09:57 EST


On Tue, Apr 26, 2022 at 03:06:35PM +0000, Liam Howlett wrote:
> From: "Liam R. Howlett" <Liam.Howlett@xxxxxxxxxx>
>
> Avoid allocating a new VMA when it a vma modification can occur. When a
> brk() can expand or contract a VMA, then the single store operation will
> only modify one index of the maple tree instead of causing a node to split
> or coalesce. This avoids unnecessary allocations/frees of maple tree
> nodes and VMAs.
>
> Move some limit & flag verifications out of the do_brk_flags() function to
> use only relevant checks in the code path of bkr() and vm_brk_flags().
>
> Set the vma to check if it can expand in vm_brk_flags() if extra criteria
> are met.
>
> Drop userfaultfd from do_brk_flags() path and only use it in
> vm_brk_flags() path since that is the only place a munmap will happen.
>
> Signed-off-by: Liam R. Howlett <Liam.Howlett@xxxxxxxxxx>

This patch results in boot failures on alpha. Trying to revert it results
in conflicts, so I was unable to cross-check. Bisect log attached. The failure
is silent - boot simply stalls after "random: crng init done", so attaching
a boot log doesn't add value.

Guenter

---
# bad: [bdc61aad77faf67187525028f1f355eff3849f22] Add linux-next specific files for 20220428
# good: [af2d861d4cd2a4da5137f795ee3509e6f944a25b] Linux 5.18-rc4
git bisect start 'HEAD' 'v5.18-rc4'
# good: [a6ffa4aa7e81a54632f3370f4c93fce603160192] Merge branch 'master' of git://git.kernel.org/pub/scm/linux/kernel/git/herbert/cryptodev-2.6.git
git bisect good a6ffa4aa7e81a54632f3370f4c93fce603160192
# good: [cd63f17e3bb63006f9f88bf7f5947b8e1601bcd9] Merge branch 'edac-for-next' of git://git.kernel.org/pub/scm/linux/kernel/git/ras/ras.git
git bisect good cd63f17e3bb63006f9f88bf7f5947b8e1601bcd9
# good: [cee7bbed3e5cc089b5c364ac8ad4a186c2a28bb6] Merge branch 'next' of git://git.kernel.org/pub/scm/linux/kernel/git/vkoul/dmaengine.git
git bisect good cee7bbed3e5cc089b5c364ac8ad4a186c2a28bb6
# good: [d5a23156ea99f10b584221893a6a7d6f6554cde8] Merge branch 'for-next' of git://git.kernel.org/pub/scm/linux/kernel/git/vbabka/slab.git
git bisect good d5a23156ea99f10b584221893a6a7d6f6554cde8
# good: [2f1fde90d983bc404503100c9c4bbbf1e191bcf4] selftests: cgroup: fix alloc_anon_noexit() instantly freeing memory
git bisect good 2f1fde90d983bc404503100c9c4bbbf1e191bcf4
# good: [fca1db6ff251278c532231552e840c7dc36dfa76] Merge branch 'bitmap-for-next' of https://github.com/norov/linux.git
git bisect good fca1db6ff251278c532231552e840c7dc36dfa76
# bad: [40b39116fe8e6fb66e3166ea40138eec506dfd91] perf: use VMA iterator
git bisect bad 40b39116fe8e6fb66e3166ea40138eec506dfd91
# good: [3f2187cf9b93a58343dd01273afdab9df04b0ca3] proc: remove VMA rbtree use from nommu
git bisect good 3f2187cf9b93a58343dd01273afdab9df04b0ca3
# bad: [7dbf1873ad5953d8cf732d5fd5a94c1b95c022b0] parisc: remove mmap linked list from cache handling
git bisect bad 7dbf1873ad5953d8cf732d5fd5a94c1b95c022b0
# bad: [c6e0b59766907a73be6cb77683f3ba60d0115495] mm/mmap: use advanced maple tree API for mmap_region()
git bisect bad c6e0b59766907a73be6cb77683f3ba60d0115495
# good: [f461d9862fdab8e6aea51094e7286f3ec1b25402] mm: optimize find_exact_vma() to use vma_lookup()
git bisect good f461d9862fdab8e6aea51094e7286f3ec1b25402
# bad: [c19a5ccbcbc6fe2c422fd85b22b40abed96c6f6b] mm/mmap: change do_brk_flags() to expand existing VMA and add do_brk_munmap()
git bisect bad c19a5ccbcbc6fe2c422fd85b22b40abed96c6f6b
# good: [993adc76c4d7afb40133be90333b5303b02115b6] mm/khugepaged: optimize collapse_pte_mapped_thp() by using vma_lookup()
git bisect good 993adc76c4d7afb40133be90333b5303b02115b6
# first bad commit: [c19a5ccbcbc6fe2c422fd85b22b40abed96c6f6b] mm/mmap: change do_brk_flags() to expand existing VMA and add do_brk_munmap()