Skip to contentSkip to conversation

mm: Improve readability of clear_huge_page

PATCH New Huang, Ying 1 participant 1 message Aug 30, 2017

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 mm: Improve readability of clear_huge_page

From: Huang Ying <[email protected]>

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

---
 mm/memory.c | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)
mm/memory.c +7 -4
index 20ac58c128e9..694ddbd3a020 100644
@@ -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);
 	}
 }
 
Signature · 7 lines
2.13.2

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to [email protected].  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>