From abb277d9f11f6e6ccf688a28f71c23c94026a4ef Mon Sep 17 00:00:00 2001 From: Robin Murphy Date: Fri, 19 Aug 2022 13:54:25 +0100 Subject: [PATCH] FROMGIT: mm/vmalloc: Add override for lazy vunmap Add an interface for arch code 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) Change-Id: I694523564357b4c43d30c129af1e89fd803824d3 Signed-off-by: Robin Murphy Signed-off-by: Beata Michalska --- include/linux/vmalloc.h | 4 ++++ mm/vmalloc.c | 3 +++ 2 files changed, 7 insertions(+) diff --git a/include/linux/vmalloc.h b/include/linux/vmalloc.h index 0549ca17ba6f..12c55bbec8c0 100644 --- a/include/linux/vmalloc.h +++ b/include/linux/vmalloc.h @@ -245,4 +245,8 @@ 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); +#ifndef arch_disable_lazy_vunmap +#define arch_disable_lazy_vunmap false +#endif + #endif /* _LINUX_VMALLOC_H */ diff --git a/mm/vmalloc.c b/mm/vmalloc.c index 817a472ee30f..50d49ca35885 100644 --- a/mm/vmalloc.c +++ b/mm/vmalloc.c @@ -1297,6 +1297,9 @@ static unsigned long lazy_max_pages(void) { unsigned int log; + if (arch_disable_lazy_vunmap) + return 0; + log = fls(num_online_cpus()); return log * (32UL * 1024 * 1024 / PAGE_SIZE);