Skip to contentSkip to conversation

Sync unmappings in vmalloc/ioremap areas

PATCH Superseded Joerg Roedel 5 participants 18 messages Jul 17, 2019 – Jul 19, 2019

Subsystems (4)

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

v2 cover Sync unmappings in vmalloc/ioremap areas

Hi,

here is a small patch-set to sync unmappings in the vmalloc/ioremap areas between page-tables in the system.

This is only needed x86-32 with !SHARED_KERNEL_PMD, which is the case on a PAE kernel with PTI enabled.

On affected systems the missing sync causes old mappings to persist in some page-tables, causing data corruption and other undefined behavior.

Please review.

Thanks,

Joerg

Changes since v1:
- Added correct Fixes-tags to all patches

Joerg Roedel (3):
x86/mm: Check for pfn instead of page in vmalloc_sync_one() x86/mm: Sync also unmappings in vmalloc_sync_one() mm/vmalloc: Sync unmappings in vunmap_page_range()

 arch/x86/mm/fault.c | 9 +++++----
 mm/vmalloc.c        | 2 ++
 2 files changed, 7 insertions(+), 4 deletions(-)
Signature · 1 line
2.17.1
#1 lore raw

PATCH v2 1/3 x86/mm: Check for pfn instead of page in vmalloc_sync_one()

From: Joerg Roedel <[email protected]>

Do not require a struct page for the mapped memory location because it might not exist. This can happen when an ioremapped region is mapped with 2MB pages.

Fixes 5d72b4fba40ef ('x86, mm: support huge I/O mapping capability I/F')
---
 arch/x86/mm/fault.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/x86/mm/fault.c +1 -1
index 794f364cb882..4a4049f6d458 100644
@@ -200,7 +200,7 @@ static inline pmd_t *vmalloc_sync_one(pgd_t *pgd, unsigned long address)
 	if (!pmd_present(*pmd))
 		set_pmd(pmd, *pmd_k);
 	else
-		BUG_ON(pmd_page(*pmd) != pmd_page(*pmd_k));
+		BUG_ON(pmd_pfn(*pmd) != pmd_pfn(*pmd_k));
 
 	return pmd_k;
 }
Signature · 1 line
2.17.1
#2 lore raw

PATCH v2 2/3 x86/mm: Sync also unmappings in vmalloc_sync_one()

In reply to Joerg Roedel

From: Joerg Roedel <[email protected]>

With huge-page ioremap areas the unmappings also need to be synced between all page-tables. Otherwise it can cause data corruption when a region is unmapped and later re-used.

Make the vmalloc_sync_one() function ready to sync unmappings.

Fixes 5d72b4fba40ef ('x86, mm: support huge I/O mapping capability I/F')
---
 arch/x86/mm/fault.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)
arch/x86/mm/fault.c +4 -3
index 4a4049f6d458..d71e167662c3 100644
@@ -194,11 +194,12 @@ static inline pmd_t *vmalloc_sync_one(pgd_t *pgd, unsigned long address)
 
 	pmd = pmd_offset(pud, address);
 	pmd_k = pmd_offset(pud_k, address);
-	if (!pmd_present(*pmd_k))
-		return NULL;
 
-	if (!pmd_present(*pmd))
+	if (pmd_present(*pmd) ^ pmd_present(*pmd_k))
 		set_pmd(pmd, *pmd_k);
+
+	if (!pmd_present(*pmd_k))
+		return NULL;
 	else
 		BUG_ON(pmd_pfn(*pmd) != pmd_pfn(*pmd_k));
 
Signature · 1 line
2.17.1
Reviewed-by on v2 2/3
#3 lore raw

Re: [PATCH 2/3] x86/mm: Sync also unmappings in vmalloc_sync_one()

Quoted 6 lines · Joerg Roedel
arch/x86/mm/fault.c +0 -0
index 4a4049f6d458..d71e167662c3 100644

arch/x86/mm/fault.c static inline pmd_t *vmalloc_sync_one(pgd_t *pgd, unsigned long address) · line 199

Quoted 9 lines
arch/x86/mm/fault.c +1 -3
@@ -194,11 +194,12 @@ static inline pmd_t *vmalloc_sync_one(pgd_t *pgd, unsigned long address)
 
 	pmd = pmd_offset(pud, address);
 	pmd_k = pmd_offset(pud_k, address);
-	if (!pmd_present(*pmd_k))
-		return NULL;
 
-	if (!pmd_present(*pmd))
+	if (pmd_present(*pmd) ^ pmd_present(*pmd_k))
 		set_pmd(pmd, *pmd_k);

Wouldn't:

	if (pmd_present(*pmd) != pmd_present(*pmd_k))
		set_pmd(pmd, *pmd_k);

be a bit more intuitive?

But, either way, these look fine. For the series:

#4 lore raw

Re: [PATCH 2/3] x86/mm: Sync also unmappings in vmalloc_sync_one()

Hi Dave,

Quoted 11 lines · Dave Hansen

arch/x86/mm/fault.c static inline pmd_t *vmalloc_sync_one(pgd_t *pgd, unsigned long address) · line 199

Quoted 3 lines · Joerg Roedel
arch/x86/mm/fault.c +1 -1
-	if (!pmd_present(*pmd))
+	if (pmd_present(*pmd) ^ pmd_present(*pmd_k))
 		set_pmd(pmd, *pmd_k);

Wouldn't:

	if (pmd_present(*pmd) != pmd_present(*pmd_k))
		set_pmd(pmd, *pmd_k);

be a bit more intuitive?

Yes, right. That is much better, I changed it in the patch.

Quoted 3 lines

But, either way, these look fine. For the series:

Thanks!

Joerg

#5 lore raw

Re: [PATCH 2/3] x86/mm: Sync also unmappings in vmalloc_sync_one()

In reply to Joerg Roedel
Quoted 24 lines · Joerg Roedel

From: Joerg Roedel <[email protected]>

With huge-page ioremap areas the unmappings also need to be synced between all page-tables. Otherwise it can cause data corruption when a region is unmapped and later re-used.

Make the vmalloc_sync_one() function ready to sync unmappings.

Fixes 5d72b4fba40ef ('x86, mm: support huge I/O mapping capability I/F')
---
 arch/x86/mm/fault.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)
arch/x86/mm/fault.c +0 -1
index 4a4049f6d458..d71e167662c3 100644
@@ -194,11 +194,12 @@ static inline pmd_t *vmalloc_sync_one(pgd_t *pgd, unsigned long address)
 
 	pmd = pmd_offset(pud, address);
 	pmd_k = pmd_offset(pud_k, address);
-	if (!pmd_present(*pmd_k))

arch/x86/mm/fault.c static inline pmd_t *vmalloc_sync_one(pgd_t *pgd, unsigned long address) · line 204

Quoted 10 lines
arch/x86/mm/fault.c +4 -2
-		return NULL;
 
-	if (!pmd_present(*pmd))
+	if (pmd_present(*pmd) ^ pmd_present(*pmd_k))
 		set_pmd(pmd, *pmd_k);
+
+	if (!pmd_present(*pmd_k))
+		return NULL;
 	else
 		BUG_ON(pmd_pfn(*pmd) != pmd_pfn(*pmd_k));

So in case of unmap, this updates only the first entry in the pgd_list because vmalloc_sync_all() will break out of the iteration over pgd_list when NULL is returned from vmalloc_sync_one().

I'm surely missing something, but how is that supposed to sync _all_ page tables on unmap as the changelog claims?

Thanks,

tglx

#6 lore raw

Re: [PATCH 2/3] x86/mm: Sync also unmappings in vmalloc_sync_one()

Hi Thomas,

Quoted 11 lines · Thomas Gleixner

arch/x86/mm/fault.c static inline pmd_t *vmalloc_sync_one(pgd_t *pgd, unsigned long address) · line 204

Quoted 5 lines · Joerg Roedel
arch/x86/mm/fault.c +3 -0
+
+	if (!pmd_present(*pmd_k))
+		return NULL;
 	else
 		BUG_ON(pmd_pfn(*pmd) != pmd_pfn(*pmd_k));

So in case of unmap, this updates only the first entry in the pgd_list because vmalloc_sync_all() will break out of the iteration over pgd_list when NULL is returned from vmalloc_sync_one().

Quoted 2 lines

I'm surely missing something, but how is that supposed to sync _all_ page tables on unmap as the changelog claims?

No, you are right, I missed that. It is a bug in this patch, the code that breaks out of the loop in vmalloc_sync_all() needs to be removed as well. Will do that in the next version.

Thanks,

Joerg

#7 lore raw

Re: [PATCH 2/3] x86/mm: Sync also unmappings in vmalloc_sync_one()

Joerg,

Quoted 12 lines · Joerg Roedel
Quoted 11 lines · Thomas Gleixner

arch/x86/mm/fault.c static inline pmd_t *vmalloc_sync_one(pgd_t *pgd, unsigned long address) · line 204

Quoted 5 lines · Joerg Roedel
arch/x86/mm/fault.c +3 -0
+
+	if (!pmd_present(*pmd_k))
+		return NULL;
 	else
 		BUG_ON(pmd_pfn(*pmd) != pmd_pfn(*pmd_k));

So in case of unmap, this updates only the first entry in the pgd_list because vmalloc_sync_all() will break out of the iteration over pgd_list when NULL is returned from vmalloc_sync_one().

Quoted 6 lines
Quoted 2 lines

I'm surely missing something, but how is that supposed to sync _all_ page tables on unmap as the changelog claims?

No, you are right, I missed that. It is a bug in this patch, the code that breaks out of the loop in vmalloc_sync_all() needs to be removed as well. Will do that in the next version.

I assume that p4d/pud do not need the pmd treatment, but a comment explaining why would be appreciated.

Thanks,

tglx

#8 lore raw

Re: [PATCH 2/3] x86/mm: Sync also unmappings in vmalloc_sync_one()

Quoted 7 lines · Thomas Gleixner
Quoted 3 lines · Joerg Roedel

No, you are right, I missed that. It is a bug in this patch, the code that breaks out of the loop in vmalloc_sync_all() needs to be removed as well. Will do that in the next version.

I assume that p4d/pud do not need the pmd treatment, but a comment explaining why would be appreciated.

Yes, p4d and pud don't need to be handled here, as the code is 32-bit only and there p4d is folded anyway. Pud is only relevant for PAE and will already be mapped when the page-table is created (for performance reasons, because pud is top-level at PAE and mapping it later requires a TLB flush).
The pud with PAE also never changes during the life-time of the page-table because we can't map a huge-page there. I will put that into a comment.

Thanks,

Joerg

#9 lore raw

Re: [PATCH 2/3] x86/mm: Sync also unmappings in vmalloc_sync_one()

In reply to Thomas Gleixner
Quoted 18 lines · Thomas Gleixner

Joerg,

Quoted 15 lines · Joerg Roedel
Quoted 13 lines · Thomas Gleixner

arch/x86/mm/fault.c static inline pmd_t *vmalloc_sync_one(pgd_t *pgd, unsigned long address) · line 204

Quoted 5 lines · Joerg Roedel
arch/x86/mm/fault.c +3 -0
+
+	if (!pmd_present(*pmd_k))
+		return NULL;
 	else
 		BUG_ON(pmd_pfn(*pmd) != pmd_pfn(*pmd_k));

So in case of unmap, this updates only the first entry in the pgd_list because vmalloc_sync_all() will break out of the iteration over pgd_list when NULL is returned from vmalloc_sync_one().

I'm surely missing something, but how is that supposed to sync _all_ page tables on unmap as the changelog claims?

Quoted 6 lines
Quoted 3 lines

No, you are right, I missed that. It is a bug in this patch, the code that breaks out of the loop in vmalloc_sync_all() needs to be removed as well. Will do that in the next version.

I assume that p4d/pud do not need the pmd treatment, but a comment explaining why would be appreciated.

Actually there is already a comment in this function explaining why p4d and pud don't need any treatment:

/*
* set_pgd(pgd, *pgd_k); here would be useless on PAE
* and redundant with the set_pmd() on non-PAE. As would
* set_p4d/set_pud.
*/

I couldn't say it with less words :)

Regards,

Joerg

#10 lore raw

Re: [PATCH 2/3] x86/mm: Sync also unmappings in vmalloc_sync_one()

Quoted 26 lines · Joerg Roedel
Quoted 18 lines · Thomas Gleixner

Joerg,

Quoted 15 lines · Joerg Roedel
Quoted 13 lines · Thomas Gleixner

arch/x86/mm/fault.c static inline pmd_t *vmalloc_sync_one(pgd_t *pgd, unsigned long address) · line 204

Quoted 5 lines · Joerg Roedel
arch/x86/mm/fault.c +3 -0
+
+	if (!pmd_present(*pmd_k))
+		return NULL;
 	else
 		BUG_ON(pmd_pfn(*pmd) != pmd_pfn(*pmd_k));

So in case of unmap, this updates only the first entry in the pgd_list because vmalloc_sync_all() will break out of the iteration over pgd_list when NULL is returned from vmalloc_sync_one().

I'm surely missing something, but how is that supposed to sync _all_ page tables on unmap as the changelog claims?

Quoted 6 lines
Quoted 3 lines

No, you are right, I missed that. It is a bug in this patch, the code that breaks out of the loop in vmalloc_sync_all() needs to be removed as well. Will do that in the next version.

I assume that p4d/pud do not need the pmd treatment, but a comment explaining why would be appreciated.

Quoted 8 lines

Actually there is already a comment in this function explaining why p4d and pud don't need any treatment:

/*
* set_pgd(pgd, *pgd_k); here would be useless on PAE
* and redundant with the set_pmd() on non-PAE. As would
* set_p4d/set_pud.
*/

Indeed. Why did I think there was none?

Quoted 1 line

I couldn't say it with less words :)

It's perfectly fine.

Thanks,

tglx

#11 lore raw

PATCH v2 3/3 mm/vmalloc: Sync unmappings in vunmap_page_range()

In reply to Joerg Roedel

From: Joerg Roedel <[email protected]>

On x86-32 with PTI enabled, parts of the kernel page-tables are not shared between processes. This can cause mappings in the vmalloc/ioremap area to persist in some page-tables after the regions is unmapped and released.

When the region is re-used the processes with the old mappings do not fault in the new mappings but still access the old ones.

This causes undefined behavior, in reality often data corruption, kernel oopses and panics and even spontaneous reboots.

Fix this problem by activly syncing unmaps in the vmalloc/ioremap area to all page-tables in the system.

References: https://bugzilla.suse.com/show_bug.cgi?id=1118689

Fixes 5d72b4fba40ef ('x86, mm: support huge I/O mapping capability I/F')
---
 mm/vmalloc.c | 2 ++
 1 file changed, 2 insertions(+)
mm/vmalloc.c +2 -0
index 4fa8d84599b0..322b11a374fd 100644
@@ -132,6 +132,8 @@ static void vunmap_page_range(unsigned long addr, unsigned long end)
 			continue;
 		vunmap_p4d_range(pgd, addr, next);
 	} while (pgd++, addr = next, addr != end);
+
+	vmalloc_sync_all();
 }
 
 static int vmap_pte_range(pmd_t *pmd, unsigned long addr,
Signature · 1 line
2.17.1
maintainer
#12 lore raw

Re: [PATCH 3/3] mm/vmalloc: Sync unmappings in vunmap_page_range()

Quoted 31 lines · Joerg Roedel

From: Joerg Roedel <[email protected]>

On x86-32 with PTI enabled, parts of the kernel page-tables are not shared between processes. This can cause mappings in the vmalloc/ioremap area to persist in some page-tables after the regions is unmapped and released.

When the region is re-used the processes with the old mappings do not fault in the new mappings but still access the old ones.

This causes undefined behavior, in reality often data corruption, kernel oopses and panics and even spontaneous reboots.

Fix this problem by activly syncing unmaps in the vmalloc/ioremap area to all page-tables in the system.

References: https://bugzilla.suse.com/show_bug.cgi?id=1118689

Fixes 5d72b4fba40ef ('x86, mm: support huge I/O mapping capability I/F')
---
 mm/vmalloc.c | 2 ++
 1 file changed, 2 insertions(+)
mm/vmalloc.c +0 -0
index 4fa8d84599b0..322b11a374fd 100644

mm/vmalloc.c static void vunmap_page_range(unsigned long addr, unsigned long end) · line 137

Quoted 6 lines
mm/vmalloc.c +2 -0
@@ -132,6 +132,8 @@ static void vunmap_page_range(unsigned long addr, unsigned long end)
                        continue;
                vunmap_p4d_range(pgd, addr, next);
        } while (pgd++, addr = next, addr != end);
+
+       vmalloc_sync_all();
 }

I'm confused. Shouldn't the code in _vm_unmap_aliases handle this? As it stands, won't your patch hurt performance on x86_64? If x86_32 is a special snowflake here, maybe flush_tlb_kernel_range() should handle this?

Even if your patch is correct, a comment would be nice

#13 lore raw

Re: [PATCH 3/3] mm/vmalloc: Sync unmappings in vunmap_page_range()

Hi Andy,

Quoted 17 lines · Andy Lutomirski

mm/vmalloc.c static void vunmap_page_range(unsigned long addr, unsigned long end) · line 137

Quoted 11 lines · Joerg Roedel
mm/vmalloc.c +2 -0
index 4fa8d84599b0..322b11a374fd 100644
@@ -132,6 +132,8 @@ static void vunmap_page_range(unsigned long addr, unsigned long end)
                        continue;
                vunmap_p4d_range(pgd, addr, next);
        } while (pgd++, addr = next, addr != end);
+
+       vmalloc_sync_all();
 }

I'm confused. Shouldn't the code in _vm_unmap_aliases handle this? As it stands, won't your patch hurt performance on x86_64? If x86_32 is a special snowflake here, maybe flush_tlb_kernel_range() should handle this?

Imo this is the logical place to handle this. The code first unmaps the area from the init_mm page-table and then syncs that page-table to all other page-tables in the system, so one place to update the page-tables.

Performance-wise it makes no difference if we put that into _vm_unmap_aliases(), as that is called in the vmunmap path too. But it is right that vmunmap/iounmap performance on x86-64 will decrease to some degree. If that is a problem for some workloads I can also implement a complete separate code-path which just syncs unmappings and is only implemented for x86-32 with !SHARED_KERNEL_PMD.

Regards,

Joerg

maintainer
#14 lore raw

Re: [PATCH 3/3] mm/vmalloc: Sync unmappings in vunmap_page_range()

Quoted 22 lines · Joerg Roedel

Hi Andy,

Quoted 17 lines · Andy Lutomirski

mm/vmalloc.c static void vunmap_page_range(unsigned long addr, unsigned long end) · line 137

Quoted 11 lines · Joerg Roedel
mm/vmalloc.c +2 -0
index 4fa8d84599b0..322b11a374fd 100644
@@ -132,6 +132,8 @@ static void vunmap_page_range(unsigned long addr, unsigned long end)
                        continue;
                vunmap_p4d_range(pgd, addr, next);
        } while (pgd++, addr = next, addr != end);
+
+       vmalloc_sync_all();
 }

I'm confused. Shouldn't the code in _vm_unmap_aliases handle this? As it stands, won't your patch hurt performance on x86_64? If x86_32 is a special snowflake here, maybe flush_tlb_kernel_range() should handle this?

Quoted 3 lines

Imo this is the logical place to handle this. The code first unmaps the area from the init_mm page-table and then syncs that page-table to all other page-tables in the system, so one place to update the page-tables.

I find it problematic that there is no meaningful documentation as to what vmalloc_sync_all() is supposed to do. The closest I can find is this comment by following the x86_64 code, which calls sync_global_pgds(), which says:

/*
* When memory was added make sure all the processes MM have
* suitable PGD entries in the local PGD level page. */
void sync_global_pgds(unsigned long start, unsigned long end) {

Which is obviously entirely inapplicable. If I'm understanding correctly, the underlying issue here is that the vmalloc fault mechanism can propagate PGD entry *addition*, but nothing (not even flush_tlb_kernel_range()) propagates PGD entry *removal*.

I find it suspicious that only x86 has this. How do other architectures handle this?

At the very least, I think this series needs a comment in vmalloc_sync_all() explaining exactly what the function promises to do. But maybe a better fix is to add code to flush_tlb_kernel_range() to sync the vmalloc area if the flushed range overlaps the vmalloc area. Or, even better, improve x86_32 the way we did x86_64: adjust the memory mapping code such that top-level paging entries are never deleted in the first place.

#15 lore raw

Re: [PATCH 3/3] mm/vmalloc: Sync unmappings in vunmap_page_range()

Quoted 2 lines · Andy Lutomirski

I find it problematic that there is no meaningful documentation as to what vmalloc_sync_all() is supposed to do.

Yeah, I found that too, there is no real design around vmalloc_sync_all(). It looks like it was just added to fit the purpose on x86-32. That also makes it hard to find all necessary call-sites.

Quoted 4 lines

Which is obviously entirely inapplicable. If I'm understanding correctly, the underlying issue here is that the vmalloc fault mechanism can propagate PGD entry *addition*, but nothing (not even flush_tlb_kernel_range()) propagates PGD entry *removal*.

Close, the underlying issue is not about PGD, but PMD entry addition/removal on x86-32 pae systems.

Quoted 2 lines

I find it suspicious that only x86 has this. How do other architectures handle this?

The problem on x86-PAE arises from the !SHARED_KERNEL_PMD case, which was introduced by the Xen-PV patches and then re-used for the PTI-x32 enablement to be able to map the LDT into user-space at a fixed address.

Other architectures probably don't have the !SHARED_KERNEL_PMD case (or do unsharing of kernel page-tables on any level where a huge-page could be mapped).

Quoted 3 lines

At the very least, I think this series needs a comment in vmalloc_sync_all() explaining exactly what the function promises to do.

Okay, as it stands, it promises to sync mappings for the vmalloc area between all PGDs in the system. I will add that as a comment.

Quoted 3 lines

But maybe a better fix is to add code to flush_tlb_kernel_range() to sync the vmalloc area if the flushed range overlaps the vmalloc area.

That would also cause needless overhead on x86-64 because the vmalloc area doesn't need syncing there. I can make it x86-32 only, but that is not a clean solution imo.

Quoted 3 lines

Or, even better, improve x86_32 the way we did x86_64: adjust the memory mapping code such that top-level paging entries are never deleted in the first place.

There is not enough address space on x86-32 to partition it like on x86-64. In the default PAE configuration there are _four_ PGD entries, usually one for the kernel, and then 512 PMD entries. Partitioning happens on the PMD level, for example there is one entry (2MB of address space) reserved for the user-space LDT mapping.

Regards,

Joerg

maintainer
#16 lore raw

Re: [PATCH 3/3] mm/vmalloc: Sync unmappings in vunmap_page_range()

Quoted 35 lines · Joerg Roedel
Quoted 2 lines · Andy Lutomirski

I find it problematic that there is no meaningful documentation as to what vmalloc_sync_all() is supposed to do.

Yeah, I found that too, there is no real design around vmalloc_sync_all(). It looks like it was just added to fit the purpose on x86-32. That also makes it hard to find all necessary call-sites.

Quoted 4 lines

Which is obviously entirely inapplicable. If I'm understanding correctly, the underlying issue here is that the vmalloc fault mechanism can propagate PGD entry *addition*, but nothing (not even flush_tlb_kernel_range()) propagates PGD entry *removal*.

Close, the underlying issue is not about PGD, but PMD entry addition/removal on x86-32 pae systems.

Quoted 2 lines

I find it suspicious that only x86 has this. How do other architectures handle this?

The problem on x86-PAE arises from the !SHARED_KERNEL_PMD case, which was introduced by the Xen-PV patches and then re-used for the PTI-x32 enablement to be able to map the LDT into user-space at a fixed address.

Other architectures probably don't have the !SHARED_KERNEL_PMD case (or do unsharing of kernel page-tables on any level where a huge-page could be mapped).

Quoted 3 lines

At the very least, I think this series needs a comment in vmalloc_sync_all() explaining exactly what the function promises to do.

Okay, as it stands, it promises to sync mappings for the vmalloc area between all PGDs in the system. I will add that as a comment.

Quoted 7 lines
Quoted 3 lines

But maybe a better fix is to add code to flush_tlb_kernel_range() to sync the vmalloc area if the flushed range overlaps the vmalloc area.

That would also cause needless overhead on x86-64 because the vmalloc area doesn't need syncing there. I can make it x86-32 only, but that is not a clean solution imo.

Could you move the vmalloc_sync_all() call to the lazy purge path, though? If nothing else, it will cause it to be called fewer times under any given workload, and it looks like it could be rather slow on x86_32.

Quoted 10 lines
Quoted 4 lines

Or, even better, improve x86_32 the way we did x86_64: adjust the memory mapping code such that top-level paging entries are never deleted in the first place.

There is not enough address space on x86-32 to partition it like on x86-64. In the default PAE configuration there are _four_ PGD entries, usually one for the kernel, and then 512 PMD entries. Partitioning happens on the PMD level, for example there is one entry (2MB of address space) reserved for the user-space LDT mapping.

Ugh, fair enough.

#17 lore raw

Re: [PATCH 3/3] mm/vmalloc: Sync unmappings in vunmap_page_range()

Quoted 4 lines · Andy Lutomirski

Could you move the vmalloc_sync_all() call to the lazy purge path, though? If nothing else, it will cause it to be called fewer times under any given workload, and it looks like it could be rather slow on x86_32.

Okay, I move it to __purge_vmap_area_lazy(). That looks like the right place.

Thanks,

Joerg