mirror of
https://gitee.com/bianbu-linux/linux-6.6
synced 2025-04-24 14:07:52 -04:00
mm: use maple tree operations for find_vma_intersection()
Move find_vma_intersection() to mmap.c and change implementation to maple tree. When searching for a vma within a range, it is easier to use the maple tree interface. Exported find_vma_intersection() for kvm module. Link: https://lkml.kernel.org/r/20220906194824.2110408-24-Liam.Howlett@oracle.com Signed-off-by: Liam R. Howlett <Liam.Howlett@Oracle.com> Tested-by: Yu Zhao <yuzhao@google.com> Cc: Catalin Marinas <catalin.marinas@arm.com> Cc: David Hildenbrand <david@redhat.com> Cc: David Howells <dhowells@redhat.com> Cc: Davidlohr Bueso <dave@stgolabs.net> Cc: "Matthew Wilcox (Oracle)" <willy@infradead.org> Cc: SeongJae Park <sj@kernel.org> Cc: Sven Schnelle <svens@linux.ibm.com> Cc: Vlastimil Babka <vbabka@suse.cz> Cc: Will Deacon <will@kernel.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
This commit is contained in:
parent
2e7ce7d354
commit
abdba2dda0
3 changed files with 44 additions and 18 deletions
|
@ -2778,26 +2778,12 @@ extern struct vm_area_struct * find_vma(struct mm_struct * mm, unsigned long add
|
|||
extern struct vm_area_struct * find_vma_prev(struct mm_struct * mm, unsigned long addr,
|
||||
struct vm_area_struct **pprev);
|
||||
|
||||
/**
|
||||
* find_vma_intersection() - Look up the first VMA which intersects the interval
|
||||
* @mm: The process address space.
|
||||
* @start_addr: The inclusive start user address.
|
||||
* @end_addr: The exclusive end user address.
|
||||
*
|
||||
* Returns: The first VMA within the provided range, %NULL otherwise. Assumes
|
||||
* start_addr < end_addr.
|
||||
/*
|
||||
* Look up the first VMA which intersects the interval [start_addr, end_addr)
|
||||
* NULL if none. Assume start_addr < end_addr.
|
||||
*/
|
||||
static inline
|
||||
struct vm_area_struct *find_vma_intersection(struct mm_struct *mm,
|
||||
unsigned long start_addr,
|
||||
unsigned long end_addr)
|
||||
{
|
||||
struct vm_area_struct *vma = find_vma(mm, start_addr);
|
||||
|
||||
if (vma && end_addr <= vma->vm_start)
|
||||
vma = NULL;
|
||||
return vma;
|
||||
}
|
||||
unsigned long start_addr, unsigned long end_addr);
|
||||
|
||||
/**
|
||||
* vma_lookup() - Find a VMA at a specific address
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue