From e23d4ea590da05a78292a497f1bcad709ebf621f Mon Sep 17 00:00:00 2001 From: Sultan Alsawaf Date: Thu, 6 May 2021 00:00:32 -0700 Subject: [PATCH] mm: Perform PID map reads on the little CPU cluster PID map reads for processes with thousands of mappings can be done extensively by certain Android apps, burning through CPU time on higher-performance CPUs even though reading PID maps is never a performance-critical task. We can relieve the load on the important CPUs by moving PID map reads to little CPUs via sched_migrate_to_cpumask_*(). Signed-off-by: Sultan Alsawaf Signed-off-by: dreamisbaka --- fs/proc/internal.h | 1 + fs/proc/task_mmu.c | 6 ++++++ 2 files changed, 7 insertions(+) diff --git a/fs/proc/internal.h b/fs/proc/internal.h index e05deaee80d9..041af21ebc0b 100644 --- a/fs/proc/internal.h +++ b/fs/proc/internal.h @@ -298,6 +298,7 @@ struct proc_maps_private { #ifdef CONFIG_NUMA struct mempolicy *task_mempolicy; #endif + unsigned long old_cpus_allowed; } __randomize_layout; struct mm_struct *proc_mem_open(struct inode *inode, unsigned int mode); diff --git a/fs/proc/task_mmu.c b/fs/proc/task_mmu.c index 9eee1676e8d9..1ce8423eb648 100644 --- a/fs/proc/task_mmu.c +++ b/fs/proc/task_mmu.c @@ -181,6 +181,9 @@ static void vma_stop(struct proc_maps_private *priv) release_task_mempolicy(priv); up_read(&mm->mmap_sem); mmput(mm); + + sched_migrate_to_cpumask_end(to_cpumask(&priv->old_cpus_allowed), + cpu_lp_mask); } static struct vm_area_struct * @@ -217,6 +220,9 @@ static void *m_start(struct seq_file *m, loff_t *ppos) if (!mm || !mmget_not_zero(mm)) return NULL; + sched_migrate_to_cpumask_start(to_cpumask(&priv->old_cpus_allowed), + cpu_lp_mask); + if (down_read_killable(&mm->mmap_sem)) { mmput(mm); return ERR_PTR(-EINTR);