mm: get rid of odd jump label in find_mergeable_anon_vma
Quoted 56 lines · David Hildenbrand
Quoted 4 lines · linmiaohe
Quoted 1 line
From: Miaohe Lin <[email protected]>
I'm pro removing unnecessary jump labels.
Thank you, simpler code is good--all other things being equal.
The tradeoff is, as Qian points out: code churn and risk in critical code paths.In this case, I'd claim it's OK to improve this one, because we can likely get it right by visual inspection, and the pre-existing code is quite poor. And being in the kernel does not necessarily give weak code a free pass to remain there and incur maintenance and annoyance costs until the end of time. :)
However, please spend equal time when you write your commit descriptions, because that's also very important. Commit logs should also be clear!
Quoted 5 lines
Subject: "mm: get rid of jump labels in
find_mergeable_anon_vma()"Quoted 2 lines
The odd jump label
try_prevand none is not really needs/need/needed/
Quoted 20 lines
s/odd jump label/jump labels/
s/is/are/
mm/mmap.c
Quoted 10 lines
in func
find_mergeable_anon_vma, eliminate them to improve readability.Signed-off-by Miaohe Lin <[email protected]>--- mm/mmap.c | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-)mm/mmap.c +0
-0Let me suggest the following instead:
/* Try next first */
near =vma->vm_next;Quoted 13 lines
if (near) { anon_vma = reusable_anon_vma(near, vma, near); if (anon_vma) return anon_vma; } /* Try prev next */ near = vma->vm_prev; if (near) { anon_vma = reusable_anon_vma(near, vma, near); if (anon_vma) return anon_vma; }
Quoted 5 lines
Actually, it can be further simplified, because you don't need that last "if" statement, because you're returning NULL after this.
So just return
anon_vmathere. (And adjust the comment block at the end, so that it's clear thatanon_vmamight be null.)
Many Thanks for all of your precious advice. I will fix my patch and send a v2 patch. Thanks again.