Skip to content

Commit

Permalink
mm/rmap: use page_not_mapped in try_to_unmap()
Browse files Browse the repository at this point in the history
[ Upstream commit b7e188e ]

page_mapcount_is_zero() calculates accurately how many mappings a hugepage
has in order to check against 0 only.  This is a waste of cpu time.  We
can do this via page_not_mapped() to save some possible atomic_read
cycles.  Remove the function page_mapcount_is_zero() as it's not used
anymore and move page_not_mapped() above try_to_unmap() to avoid
identifier undeclared compilation error.

Link: https://lkml.kernel.org/r/20210130084904.35307-1-linmiaohe@huawei.com
Signed-off-by: Miaohe Lin <linmiaohe@huawei.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
  • Loading branch information
MiaoheLin authored and Sasha Levin committed Jun 30, 2021
1 parent ff81af8 commit bfd90b5
Showing 1 changed file with 3 additions and 8 deletions.
11 changes: 3 additions & 8 deletions mm/rmap.c
Expand Up @@ -1716,9 +1716,9 @@ static bool invalid_migration_vma(struct vm_area_struct *vma, void *arg)
return vma_is_temporary_stack(vma);
}

static int page_mapcount_is_zero(struct page *page)
static int page_not_mapped(struct page *page)
{
return !total_mapcount(page);
return !page_mapped(page);
}

/**
Expand All @@ -1736,7 +1736,7 @@ bool try_to_unmap(struct page *page, enum ttu_flags flags)
struct rmap_walk_control rwc = {
.rmap_one = try_to_unmap_one,
.arg = (void *)flags,
.done = page_mapcount_is_zero,
.done = page_not_mapped,
.anon_lock = page_lock_anon_vma_read,
};

Expand All @@ -1760,11 +1760,6 @@ bool try_to_unmap(struct page *page, enum ttu_flags flags)
return !page_mapcount(page) ? true : false;
}

static int page_not_mapped(struct page *page)
{
return !page_mapped(page);
}

/**
* try_to_munlock - try to munlock a page
* @page: the page to be munlocked
Expand Down

0 comments on commit bfd90b5

Please sign in to comment.