Skip to content

Commit

Permalink
mm: Perform PID map reads on the little CPU cluster
Browse files Browse the repository at this point in the history
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 <sultan@kerneltoast.com>
Signed-off-by: Tashfin Shakeer Rhythm <tashfinshakeerrhythm@gmail.com>
  • Loading branch information
kerneltoast authored and Tashar02 committed Feb 27, 2022
1 parent 011276a commit d46ff2c
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
1 change: 1 addition & 0 deletions fs/proc/internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
6 changes: 6 additions & 0 deletions fs/proc/task_mmu.c
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,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 *
Expand Down Expand Up @@ -218,6 +221,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);
Expand Down

0 comments on commit d46ff2c

Please sign in to comment.