FROMLIST: mm: separate mmap locked assertion from find_vma

This adds a new __find_vma() function, which implements find_vma minus
the mmap_assert_locked() assertion.

find_vma() is then implemented as an inline wrapper around __find_vma().

Signed-off-by: Michel Lespinasse <michel@lespinasse.org>
Link: https://lore.kernel.org/all/20220128131006.67712-13-michel@lespinasse.org/
Bug: 161210518
Signed-off-by: Suren Baghdasaryan <surenb@google.com>
Change-Id: Ia999b8cb8f5eed93040ab4b3caaf90d739da908d
This commit is contained in:
Michel Lespinasse
2022-01-28 04:53:01 -08:00
committed by Todd Kjos
parent 67cc8ce9a6
commit 0823d516af
4 changed files with 14 additions and 8 deletions

View File

@@ -494,7 +494,7 @@ static void error_print_context(struct drm_i915_error_state_buf *m,
} }
static struct i915_vma_coredump * static struct i915_vma_coredump *
__find_vma(struct i915_vma_coredump *vma, const char *name) __i915_find_vma(struct i915_vma_coredump *vma, const char *name)
{ {
while (vma) { while (vma) {
if (strcmp(vma->name, name) == 0) if (strcmp(vma->name, name) == 0)
@@ -508,7 +508,7 @@ __find_vma(struct i915_vma_coredump *vma, const char *name)
static struct i915_vma_coredump * static struct i915_vma_coredump *
find_batch(const struct intel_engine_coredump *ee) find_batch(const struct intel_engine_coredump *ee)
{ {
return __find_vma(ee->vma, "batch"); return __i915_find_vma(ee->vma, "batch");
} }
static void error_print_engine(struct drm_i915_error_state_buf *m, static void error_print_engine(struct drm_i915_error_state_buf *m,

View File

@@ -2693,10 +2693,17 @@ extern int expand_upwards(struct vm_area_struct *vma, unsigned long address);
#endif #endif
/* Look up the first VMA which satisfies addr < vm_end, NULL if none. */ /* Look up the first VMA which satisfies addr < vm_end, NULL if none. */
extern struct vm_area_struct * find_vma(struct mm_struct * mm, unsigned long addr); extern struct vm_area_struct * __find_vma(struct mm_struct * mm, unsigned long addr);
extern struct vm_area_struct * find_vma_prev(struct mm_struct * mm, unsigned long addr, extern struct vm_area_struct * find_vma_prev(struct mm_struct * mm, unsigned long addr,
struct vm_area_struct **pprev); struct vm_area_struct **pprev);
static inline
struct vm_area_struct *find_vma(struct mm_struct *mm, unsigned long addr)
{
mmap_assert_locked(mm);
return __find_vma(mm, addr);
}
/** /**
* find_vma_intersection() - Look up the first VMA which intersects the interval * find_vma_intersection() - Look up the first VMA which intersects the interval
* @mm: The process address space. * @mm: The process address space.

View File

@@ -2277,12 +2277,11 @@ get_unmapped_area(struct file *file, unsigned long addr, unsigned long len,
EXPORT_SYMBOL(get_unmapped_area); EXPORT_SYMBOL(get_unmapped_area);
/* Look up the first VMA which satisfies addr < vm_end, NULL if none. */ /* Look up the first VMA which satisfies addr < vm_end, NULL if none. */
struct vm_area_struct *find_vma(struct mm_struct *mm, unsigned long addr) struct vm_area_struct *__find_vma(struct mm_struct *mm, unsigned long addr)
{ {
struct rb_node *rb_node; struct rb_node *rb_node;
struct vm_area_struct *vma; struct vm_area_struct *vma;
mmap_assert_locked(mm);
/* Check the cache first. */ /* Check the cache first. */
vma = vmacache_find(mm, addr); vma = vmacache_find(mm, addr);
if (likely(vma)) if (likely(vma))
@@ -2309,7 +2308,7 @@ struct vm_area_struct *find_vma(struct mm_struct *mm, unsigned long addr)
return vma; return vma;
} }
EXPORT_SYMBOL(find_vma); EXPORT_SYMBOL(__find_vma);
/* /*
* Same as find_vma, but also return a pointer to the previous VMA in *pprev. * Same as find_vma, but also return a pointer to the previous VMA in *pprev.

View File

@@ -664,7 +664,7 @@ static void delete_vma(struct mm_struct *mm, struct vm_area_struct *vma)
* look up the first VMA in which addr resides, NULL if none * look up the first VMA in which addr resides, NULL if none
* - should be called with mm->mmap_lock at least held readlocked * - should be called with mm->mmap_lock at least held readlocked
*/ */
struct vm_area_struct *find_vma(struct mm_struct *mm, unsigned long addr) struct vm_area_struct *__find_vma(struct mm_struct *mm, unsigned long addr)
{ {
struct vm_area_struct *vma; struct vm_area_struct *vma;
@@ -686,7 +686,7 @@ struct vm_area_struct *find_vma(struct mm_struct *mm, unsigned long addr)
return NULL; return NULL;
} }
EXPORT_SYMBOL(find_vma); EXPORT_SYMBOL(__find_vma);
/* /*
* find a VMA * find a VMA