Skip to contentSkip to conversation

mm/kasan: use kasan_zero_pud for p4d table

PATCH Applied [email protected] 2 participants 2 messages May 15, 2017

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

PATCH 1/1 mm/kasan: use kasan_zero_pud for p4d table

From: Joonsoo Kim <[email protected]>

There is missing optimization in zero_p4d_populate() that can save some memory when mapping zero shadow. Implement it like as others.

---
 mm/kasan/kasan_init.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)
mm/kasan/kasan_init.c +12 -0
index b96a5f7..554e4c0 100644
@@ -118,6 +118,18 @@ static void __init zero_p4d_populate(pgd_t *pgd, unsigned long addr,
 
 	do {
 		next = p4d_addr_end(addr, end);
+		if (IS_ALIGNED(addr, P4D_SIZE) && end - addr >= P4D_SIZE) {
+			pud_t *pud;
+			pmd_t *pmd;
+
+			p4d_populate(&init_mm, p4d, lm_alias(kasan_zero_pud));
+			pud = pud_offset(p4d, addr);
+			pud_populate(&init_mm, pud, lm_alias(kasan_zero_pmd));
+			pmd = pmd_offset(pud, addr);
+			pmd_populate_kernel(&init_mm, pmd,
+						lm_alias(kasan_zero_pte));
+			continue;
+		}
 
 		if (p4d_none(*p4d)) {
 			p4d_populate(&init_mm, p4d,
Signature · 7 lines
2.7.4

--
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>
Acked-by on v1 1/1
#1 lore raw
Quoted 6 lines · On 05/15/2017 09:20 AM, [email protected] wrote:

From: Joonsoo Kim <[email protected]>

There is missing optimization in zero_p4d_populate() that can save some memory when mapping zero shadow. Implement it like as others.

Quoted 18 lines
---
 mm/kasan/kasan_init.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)
mm/kasan/kasan_init.c +5 -0
index b96a5f7..554e4c0 100644
@@ -118,6 +118,18 @@ static void __init zero_p4d_populate(pgd_t *pgd, unsigned long addr,
 
 	do {
 		next = p4d_addr_end(addr, end);
+		if (IS_ALIGNED(addr, P4D_SIZE) && end - addr >= P4D_SIZE) {
+			pud_t *pud;
+			pmd_t *pmd;
+
+			p4d_populate(&init_mm, p4d, lm_alias(kasan_zero_pud));

mm/kasan/kasan_init.c static void __init zero_p4d_populate(pgd_t *pgd, unsigned long addr, · line 135

Quoted 10 lines
mm/kasan/kasan_init.c +7 -0
+			pud = pud_offset(p4d, addr);
+			pud_populate(&init_mm, pud, lm_alias(kasan_zero_pmd));
+			pmd = pmd_offset(pud, addr);
+			pmd_populate_kernel(&init_mm, pmd,
+						lm_alias(kasan_zero_pte));
+			continue;
+		}
 
 		if (p4d_none(*p4d)) {
 			p4d_populate(&init_mm, p4d,

--
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>