From: Huang Ying <ying.huang(a)intel.com>
ANBZ: #80
cherry-picked from
https://git.kernel.org/pub/scm/linux/kernel/git/vishal/tiering.git/commit/?…
Now remove_migration_ptes() uses "bool" parameter for the single flag
parameter.
We will add more flag parameters in the following patch. So in this patch, we
replace the "bool" with "flags" parameter. This will improve the
code
readability and ease adding more flag parameters.
Signed-off-by: "Huang, Ying" <ying.huang(a)intel.com>
Signed-off-by: Baolin Wang <baolin.wang(a)linux.alibaba.com>
---
include/linux/rmap.h | 7 ++++++-
mm/huge_memory.c | 4 ++--
mm/migrate.c | 15 ++++++++-------
3 files changed, 16 insertions(+), 10 deletions(-)
diff --git a/include/linux/rmap.h b/include/linux/rmap.h
index 988d176..2c455f9 100644
--- a/include/linux/rmap.h
+++ b/include/linux/rmap.h
@@ -241,7 +241,12 @@ static inline void page_vma_mapped_walk_done(struct
page_vma_mapped_walk *pvmw)
*/
void try_to_munlock(struct page *);
-void remove_migration_ptes(struct page *old, struct page *new, bool locked);
+enum rmpte_flags {
+ RMPTE_LOCKED = 0x1,
+};
+
+void remove_migration_ptes(struct page *old, struct page *new,
+ enum rmpte_flags flags);
/*
* Called by memory-failure.c to kill processes.
diff --git a/mm/huge_memory.c b/mm/huge_memory.c
index 98ab428..0cd99d3 100644
--- a/mm/huge_memory.c
+++ b/mm/huge_memory.c
@@ -2707,10 +2707,10 @@ static void remap_page(struct page *page)
{
int i;
if (PageTransHuge(page)) {
- remove_migration_ptes(page, page, true);
+ remove_migration_ptes(page, page, RMPTE_LOCKED);
} else {
for (i = 0; i < HPAGE_PMD_NR; i++)
- remove_migration_ptes(page + i, page + i, true);
+ remove_migration_ptes(page + i, page + i, RMPTE_LOCKED);
}
}
diff --git a/mm/migrate.c b/mm/migrate.c
index 6d25ea0..a75d10b 100644
--- a/mm/migrate.c
+++ b/mm/migrate.c
@@ -291,14 +291,15 @@ static bool remove_migration_pte(struct page *page, struct
vm_area_struct *vma,
* Get rid of all migration entries and replace them by
* references to the indicated page.
*/
-void remove_migration_ptes(struct page *old, struct page *new, bool locked)
+void remove_migration_ptes(struct page *old, struct page *new,
+ enum rmpte_flags flags)
{
struct rmap_walk_control rwc = {
.rmap_one = remove_migration_pte,
.arg = old,
};
- if (locked)
+ if (flags & RMPTE_LOCKED)
rmap_walk_locked(new, &rwc);
else
rmap_walk(new, &rwc);
@@ -896,7 +897,7 @@ static int writeout(struct address_space *mapping, struct page *page)
* At this point we know that the migration attempt cannot
* be successful.
*/
- remove_migration_ptes(page, page, false);
+ remove_migration_ptes(page, page, 0);
rc = mapping->a_ops->writepage(page, &wbc);
@@ -1143,7 +1144,7 @@ static int __unmap_and_move(struct page *page, struct page
*newpage,
if (page_was_mapped)
remove_migration_ptes(page,
- rc == MIGRATEPAGE_SUCCESS ? newpage : page, false);
+ rc == MIGRATEPAGE_SUCCESS ? newpage : page, 0);
out_unlock_both:
unlock_page(newpage);
@@ -1402,7 +1403,7 @@ static int unmap_and_move_huge_page(new_page_t get_new_page,
if (page_was_mapped)
remove_migration_ptes(hpage,
- rc == MIGRATEPAGE_SUCCESS ? new_hpage : hpage, false);
+ rc == MIGRATEPAGE_SUCCESS ? new_hpage : hpage, 0);
unlock_page(new_hpage);
@@ -2710,7 +2711,7 @@ static void migrate_vma_unmap(struct migrate_vma *migrate)
if (!page || (migrate->src[i] & MIGRATE_PFN_MIGRATE))
continue;
- remove_migration_ptes(page, page, false);
+ remove_migration_ptes(page, page, 0);
migrate->src[i] = 0;
unlock_page(page);
@@ -2972,7 +2973,7 @@ static void migrate_vma_finalize(struct migrate_vma *migrate)
newpage = page;
}
- remove_migration_ptes(page, newpage, false);
+ remove_migration_ptes(page, newpage, 0);
unlock_page(page);
migrate->cpages--;
--
1.8.3.1