From: Huang Ying <ying.huang(a)intel.com>
ANBZ: #80
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: zhong jiang <zhongjiang-ali(a)linux.alibaba.com>
Signed-off-by: zhongjiang-ali <zhongjiang-ali(a)linux.alibaba.com>
---
include/linux/rmap.h | 7 ++++++-
mm/huge_memory.c | 6 +++---
mm/migrate.c | 15 ++++++++-------
3 files changed, 17 insertions(+), 11 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..d316308 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);
}
}
@@ -3465,7 +3465,7 @@ static bool replace_zero_page(struct page *page)
if (!unmap_success || !is_zero_page(page)) {
/* remap the page */
- remove_migration_ptes(page, page, true);
+ remove_migration_ptes(page, page, RMPTE_LOCKED);
ret = false;
} else
replace_zero_ptes_locked(page);
diff --git a/mm/migrate.c b/mm/migrate.c
index 1128642c..e549a27 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);
@@ -897,7 +898,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);
@@ -1144,7 +1145,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);
@@ -1403,7 +1404,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);
@@ -2747,7 +2748,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);
@@ -3009,7 +3010,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