The patch titled memrlimit: improve fork and error handling has been removed from the -mm tree. Its filename was memrlimit-add-memrlimit-controller-accounting-and-control-memrlimit-improve-fork-and-error-handling.patch This patch was dropped because it was folded into memrlimit-add-memrlimit-controller-accounting-and-control.patch The current -mm tree may be found at http://userweb.kernel.org/~akpm/mmotm/ ------------------------------------------------------ Subject: memrlimit: improve fork and error handling From: Balbir Singh <balbir@xxxxxxxxxxxxxxxxxx> The fork path of the memrlimit patches adds an additional down_write() of mmap_sem. Ideally memrlimit should be zero overhead for non users and the error handling path also needed improvement. This patch fixes both problems. The accounting has now been moved from copy_mm() to dup_mmap() Reviewed-by: Hugh Dickins <hugh@xxxxxxxxxxx> Signed-off-by: Balbir Singh <balbir@xxxxxxxxxxxxxxxxxx> Cc: Sudhir Kumar <skumar@xxxxxxxxxxxxxxxxxx> Cc: YAMAMOTO Takashi <yamamoto@xxxxxxxxxxxxx> Cc: Paul Menage <menage@xxxxxxxxxx> Cc: Li Zefan <lizf@xxxxxxxxxxxxxx> Cc: Pavel Emelianov <xemul@xxxxxxxxxx> Cc: Balbir Singh <balbir@xxxxxxxxxxxxxxxxxx> Cc: KAMEZAWA Hiroyuki <kamezawa.hiroyu@xxxxxxxxxxxxxx> Cc: David Rientjes <rientjes@xxxxxxxxxx> Cc: Vivek Goyal <vgoyal@xxxxxxxxxx> Signed-off-by: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx> --- kernel/fork.c | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff -puN kernel/fork.c~memrlimit-add-memrlimit-controller-accounting-and-control-memrlimit-improve-fork-and-error-handling kernel/fork.c --- a/kernel/fork.c~memrlimit-add-memrlimit-controller-accounting-and-control-memrlimit-improve-fork-and-error-handling +++ a/kernel/fork.c @@ -263,7 +263,7 @@ static int dup_mmap(struct mm_struct *mm struct vm_area_struct *mpnt, *tmp, **pprev; struct rb_node **rb_link, *rb_parent; int retval; - unsigned long charge; + unsigned long charge, uncharged = 0; struct mempolicy *pol; down_write(&oldmm->mmap_sem); @@ -273,6 +273,15 @@ static int dup_mmap(struct mm_struct *mm */ down_write_nested(&mm->mmap_sem, SINGLE_DEPTH_NESTING); + /* + * Uncharging as a result of failure is done by mmput() + * in dup_mm() + */ + if (memrlimit_cgroup_charge_as(oldmm, oldmm->total_vm)) { + retval = -ENOMEM; + goto out; + } + mm->locked_vm = 0; mm->mmap = NULL; mm->mmap_cache = NULL; @@ -294,6 +303,7 @@ static int dup_mmap(struct mm_struct *mm vm_stat_account(mm, mpnt->vm_flags, mpnt->vm_file, -pages); memrlimit_cgroup_uncharge_as(mm, pages); + uncharged += pages; continue; } charge = 0; @@ -633,12 +643,6 @@ static int copy_mm(unsigned long clone_f atomic_inc(&oldmm->mm_users); mm = oldmm; goto good_mm; - } else { - down_write(&oldmm->mmap_sem); - retval = memrlimit_cgroup_charge_as(oldmm, oldmm->total_vm); - up_write(&oldmm->mmap_sem); - if (retval) - goto fail_nomem; } retval = -ENOMEM; _ Patches currently in -mm which might be from balbir@xxxxxxxxxxxxxxxxxx are cgroup-use-read-lock-to-guard-find_existing_css_set.patch mark-res_counter_charge_locked-with-__must_check.patch memcg-make-global-var-read_mostly.patch memcg-avoid-unnecessary-initialization.patch memcg-clean-up-checking-of-the-disabled-flag.patch res_counter-limit-change-support-ebusy.patch memcg-limit-change-shrink-usage.patch memrlimit-add-memrlimit-controller-documentation.patch memrlimit-setup-the-memrlimit-controller.patch memrlimit-cgroup-mm-owner-callback-changes-to-add-task-info.patch memrlimit-add-memrlimit-controller-accounting-and-control.patch memrlimit-add-memrlimit-controller-accounting-and-control-memrlimit-improve-fork-and-error-handling.patch memrlimit-improve-error-handling.patch memrlimit-improve-error-handling-update.patch memrlimit-handle-attach_task-failure-add-can_attach-callback.patch memrlimit-handle-attach_task-failure-add-can_attach-callback-update.patch distinct-tgid-tid-i-o-statistics.patch per-task-delay-accounting-add-memory-reclaim-delay.patch per-task-delay-accounting-update-document-and-getdelaysc-for-memory-reclaim.patch -- To unsubscribe from this list: send the line "unsubscribe mm-commits" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html