ANDROID: mm/vmalloc: Add override for lazy vunmap

Add an interface to disable lazy vunmap by forcing the threshold
to zero. This might be interesting for debugging/testing in general,
but primarily helps a horrible situation which needs to guarantee
that vmalloc aliases are up-to-date from atomic context, wherein
the only practical solution is to never let them get stale in
the first place.

Bug: 223346425
(cherry picked from commit 2a34c1503b85f49dd472dfd932dfcd16cab8ee8a
 https://git.gitlab.arm.com/linux-arm/linux-rm.git arm64/2454944-dev)
Change-Id: I12fbbe3903f76a028ceea91ed078f0de2abe3815
Signed-off-by: Robin Murphy <robin.murphy@arm.com>
[BM: Convert to a flag that can be explicitly modified at runtime
     instead of relying on arch specific bits]
Signed-off-by: Beata Michalska <beata.michalska@arm.com>
This commit is contained in:
Robin Murphy
2022-08-19 13:54:25 +01:00
committed by Todd Kjos
parent 1eb5992d60
commit 865f370bf9
2 changed files with 7 additions and 0 deletions

View File

@@ -245,4 +245,7 @@ pcpu_free_vm_areas(struct vm_struct **vms, int nr_vms)
int register_vmap_purge_notifier(struct notifier_block *nb);
int unregister_vmap_purge_notifier(struct notifier_block *nb);
/* Allow disabling lazy TLB flushing */
extern bool lazy_vunmap_enable;
#endif /* _LINUX_VMALLOC_H */

View File

@@ -1277,6 +1277,7 @@ int unregister_vmap_purge_notifier(struct notifier_block *nb)
}
EXPORT_SYMBOL_GPL(unregister_vmap_purge_notifier);
bool lazy_vunmap_enable __read_mostly = true;
/*
* lazy_max_pages is the maximum amount of virtual address space we gather up
* before attempting to purge with a TLB flush.
@@ -1297,6 +1298,9 @@ static unsigned long lazy_max_pages(void)
{
unsigned int log;
if (!lazy_vunmap_enable)
return 0;
log = fls(num_online_cpus());
return log * (32UL * 1024 * 1024 / PAGE_SIZE);