Thread (137 messages) 137 messages, 6 authors, 2021-05-31

Re: [PATCH 01/94] mm: Add vma_lookup()

From: Liam Howlett <hidden>
Date: 2021-05-03 16:09:18
Also in: lkml

* Michel Lespinasse [off-list ref] [210501 01:04]:
On Wed, Apr 28, 2021 at 03:35:43PM +0000, Liam Howlett wrote:
quoted
Many places in the kernel use find_vma() to get a vma and then check the
start address of the vma to ensure the next vma was not returned.

Other places use the find_vma_intersection() call with add, addr + 1 as
the range; looking for just the vma at a specific address.

The third use of find_vma() is by developers who do not know that the
function starts searching at the provided address upwards for the next
vma.  This results in a bug that is often overlooked for a long time.

Adding the new vma_lookup() function will allow for cleaner code by
removing the find_vma() calls which check limits, making
find_vma_intersection() calls of a single address to be shorter, and
potentially reduce the incorrect uses of find_vma().

Signed-off-by: Liam R. Howlett <redacted>
This seems like a good API to have, and I agree it's less error prone than
having every caller check the vma->vm_start address.

Minor nitpick, I would prefer if the implementation used find_vma()
and then checked the vma->vm_start address - I don't like using [i, i+1)
intervals to implement stabbing queries.
Okay, I will make that change.
But other than that, I think this (and the other patches adding
corresponding call sites) is safe for merging.
Thanks,
Liam
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help