lkml.org 
[lkml]   [2017]   [Aug]   [30]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH -mm] mm: Improve readability of clear_huge_page
Date
From: Huang Ying <ying.huang@intel.com>

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@suse.com>
Signed-off-by: "Huang, Ying" <ying.huang@intel.com>
---
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
\
 
 \ /
  Last update: 2017-08-30 07:19    [W:0.021 / U:0.296 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site