[PATCH -mm] mm: Improve readability of clear_huge_page

From: Huang, Ying
Date: Wed Aug 30 2017 - 01:19:31 EST


From: Huang Ying <ying.huang@xxxxxxxxx>

The optimized clear_huge_page() isn't easy to read and understand.
This is suggested by Michael Hocko to improve it.

Suggested-by: Michal Hocko <mhocko@xxxxxxxx>
Signed-off-by: "Huang, Ying" <ying.huang@xxxxxxxxx>
---
mm/memory.c | 11 +++++++----
1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/mm/memory.c b/mm/memory.c
index 20ac58c128e9..694ddbd3a020 100644
--- a/mm/memory.c
+++ b/mm/memory.c
@@ -4507,12 +4507,15 @@ void clear_huge_page(struct page *page,
* towards the sub-page to access
*/
for (i = 0; i < l; i++) {
+ int left_idx = base + i;
+ int right_idx = base + 2 * l - 1 - i;
+
cond_resched();
- clear_user_highpage(page + base + i,
- addr + (base + i) * PAGE_SIZE);
+ clear_user_highpage(page + left_idx,
+ addr + left_idx * PAGE_SIZE);
cond_resched();
- clear_user_highpage(page + base + 2 * l - 1 - i,
- addr + (base + 2 * l - 1 - i) * PAGE_SIZE);
+ clear_user_highpage(page + right_idx,
+ addr + right_idx * PAGE_SIZE);
}
}

--
2.13.2