The patch titled Subject: memcg: schedule high reclaim for remote memcgs on high_work has been removed from the -mm tree. Its filename was memcg-schedule-high-reclaim-for-remote-memcgs-on-high_work.patch This patch was dropped because it was withdrawn ------------------------------------------------------ From: Shakeel Butt <shakeelb@xxxxxxxxxx> Subject: memcg: schedule high reclaim for remote memcgs on high_work If a memcg is over high limit, memory reclaim is scheduled to run on return-to-userland. However it is assumed that the memcg is the current process's memcg. With remote memcg charging for kmem or swapping in a page charged to remote memcg, current process can trigger reclaim on remote memcg. So, scheduling reclaim on return-to-userland for remote memcgs will ignore the high reclaim altogether. So, record the memcg needing high reclaim and trigger high reclaim for that memcg on return-to-userland. However if the memcg is already recorded for high reclaim and the recorded memcg is not the descendant of the the memcg needing high reclaim, punt the high reclaim to the work queue. [shakeelb@xxxxxxxxxx: v3] Link: http://lkml.kernel.org/r/20190110174432.82064-1-shakeelb@xxxxxxxxxx Link: http://lkml.kernel.org/r/20190108200538.80371-1-shakeelb@xxxxxxxxxx Signed-off-by: Shakeel Butt <shakeelb@xxxxxxxxxx> Cc: Johannes Weiner <hannes@xxxxxxxxxxx> Cc: Vladimir Davydov <vdavydov.dev@xxxxxxxxx> Cc: Michal Hocko <mhocko@xxxxxxxx> Signed-off-by: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx> --- include/linux/sched.h | 3 +++ kernel/fork.c | 1 + mm/memcontrol.c | 22 ++++++++++++++++------ 3 files changed, 20 insertions(+), 6 deletions(-) --- a/include/linux/sched.h~memcg-schedule-high-reclaim-for-remote-memcgs-on-high_work +++ a/include/linux/sched.h @@ -1160,6 +1160,9 @@ struct task_struct { /* Used by memcontrol for targeted memcg charge: */ struct mem_cgroup *active_memcg; + + /* Used by memcontrol for high relcaim: */ + struct mem_cgroup *memcg_high_reclaim; #endif #ifdef CONFIG_BLK_CGROUP --- a/kernel/fork.c~memcg-schedule-high-reclaim-for-remote-memcgs-on-high_work +++ a/kernel/fork.c @@ -922,6 +922,7 @@ static struct task_struct *dup_task_stru #ifdef CONFIG_MEMCG tsk->active_memcg = NULL; + tsk->memcg_high_reclaim = NULL; #endif return tsk; --- a/mm/memcontrol.c~memcg-schedule-high-reclaim-for-remote-memcgs-on-high_work +++ a/mm/memcontrol.c @@ -2265,14 +2265,17 @@ static void high_work_func(struct work_s void mem_cgroup_handle_over_high(void) { unsigned int nr_pages = current->memcg_nr_pages_over_high; - struct mem_cgroup *memcg; + struct mem_cgroup *memcg = current->memcg_high_reclaim; if (likely(!nr_pages)) return; - memcg = get_mem_cgroup_from_mm(current->mm); + if (!memcg) + memcg = get_mem_cgroup_from_mm(current->mm); + reclaim_high(memcg, nr_pages, GFP_KERNEL); css_put(&memcg->css); + current->memcg_high_reclaim = NULL; current->memcg_nr_pages_over_high = 0; } @@ -2422,10 +2425,10 @@ done_restock: * If the hierarchy is above the normal consumption range, schedule * reclaim on returning to userland. We can perform reclaim here * if __GFP_RECLAIM but let's always punt for simplicity and so that - * GFP_KERNEL can consistently be used during reclaim. @memcg is - * not recorded as it most likely matches current's and won't - * change in the meantime. As high limit is checked again before - * reclaim, the cost of mismatch is negligible. + * GFP_KERNEL can consistently be used during reclaim. Record the memcg + * for the return-to-userland high reclaim. If the memcg is already + * recorded and the recorded memcg is not the descendant of the memcg + * needing high reclaim, punt the high reclaim to the work queue. */ do { if (page_counter_read(&memcg->memory) > memcg->high) { @@ -2433,6 +2436,13 @@ done_restock: if (in_interrupt()) { schedule_work(&memcg->high_work); break; + } else if (!current->memcg_high_reclaim) { + css_get(&memcg->css); + current->memcg_high_reclaim = memcg; + } else if (!mem_cgroup_is_descendant( + current->memcg_high_reclaim, memcg)) { + schedule_work(&memcg->high_work); + break; } current->memcg_nr_pages_over_high += batch; set_notify_resume(current); _ Patches currently in -mm which might be from shakeelb@xxxxxxxxxx are memcg-oom-no-oom-kill-for-__gfp_retry_mayfail.patch memcg-fsnotify-no-oom-kill-for-remote-memcg-charging.patch