The patch titled memrlimit-improve-error-handling update has been added to the -mm tree. Its filename is memrlimit-improve-error-handling-update.patch Before you just go and hit "reply", please: a) Consider who else should be cc'ed b) Prefer to cc a suitable mailing list as well c) Ideally: find the original patch on the mailing list and do a reply-to-all to that, adding suitable additional cc's *** Remember to use Documentation/SubmitChecklist when testing your code *** See http://www.zip.com.au/~akpm/linux/patches/stuff/added-to-mm.txt to find out what to do about this The current -mm tree may be found at http://userweb.kernel.org/~akpm/mmotm/ ------------------------------------------------------ Subject: memrlimit-improve-error-handling update From: Balbir Singh <balbir@xxxxxxxxxxxxxxxxxx> This is a newer version of the patch, could you please drop the older one and pick this. Aplogies for the inconvenience. Changelog v2->v1 1. Address some of Hugh's comments. Reuse error (don't add new ret variable) TODO: Merge ret & ~PAGE_MASK and vm_expanded. memrlimit cgroup does not handle error cases after may_expand_vm(). This BUG was reported by Kamezawa, with the test case below to reproduce it [root@iridium kamezawa]# cat /opt/cgroup/test/memrlimit.usage_in_bytes 71921664 [root@iridium kamezawa]# ulimit -s 3 [root@iridium kamezawa]# ls Killed [root@iridium kamezawa]# ls Killed [root@iridium kamezawa]# ls Killed [root@iridium kamezawa]# ls Killed [root@iridium kamezawa]# ls Killed [root@iridium kamezawa]# ulimit -s unlimited [root@iridium kamezawa]# cat /opt/cgroup/test/memrlimit.usage_in_bytes 72368128 [root@iridium kamezawa]# This patch adds better handling support to fix the reported problem. Reported-by: [kamezawa.hiroyu@xxxxxxxxxxxxxx] Signed-off-by: Balbir Singh <balbir@xxxxxxxxxxxxxxxxxx> Cc: Pavel Emelyanov <xemul@xxxxxxxxxx> Cc: Sudhir Kumar <skumar@xxxxxxxxxxxxxxxxxx> Cc: YAMAMOTO Takashi <yamamoto@xxxxxxxxxxxxx> Cc: Paul Menage <menage@xxxxxxxxxx> Cc: Li Zefan <lizf@xxxxxxxxxxxxxx> Cc: Balbir Singh <balbir@xxxxxxxxxxxxxxxxxx> Cc: David Rientjes <rientjes@xxxxxxxxxx> Cc: Vivek Goyal <vgoyal@xxxxxxxxxx> Cc: Hugh Dickins <hugh@xxxxxxxxxxx> Signed-off-by: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx> --- mm/mmap.c | 6 +++--- mm/mremap.c | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff -puN mm/mmap.c~memrlimit-improve-error-handling-update mm/mmap.c --- a/mm/mmap.c~memrlimit-improve-error-handling-update +++ a/mm/mmap.c @@ -1969,7 +1969,6 @@ unsigned long do_brk(unsigned long addr, struct rb_node ** rb_link, * rb_parent; pgoff_t pgoff = addr >> PAGE_SHIFT; int error; - int ret = -ENOMEM; len = PAGE_ALIGN(len); if (!len) @@ -2021,9 +2020,10 @@ unsigned long do_brk(unsigned long addr, goto munmap_back; } + error = -ENOMEM; /* Check against address space limits *after* clearing old maps... */ if (!may_expand_vm(mm, len >> PAGE_SHIFT)) - return ret; + return error; if (mm->map_count > sysctl_max_map_count) goto undo_charge; @@ -2061,7 +2061,7 @@ out: return addr; undo_charge: memrlimit_cgroup_uncharge_as(mm, len >> PAGE_SHIFT); - return ret; + return error; } EXPORT_SYMBOL(do_brk); diff -puN mm/mremap.c~memrlimit-improve-error-handling-update mm/mremap.c --- a/mm/mremap.c~memrlimit-improve-error-handling-update +++ a/mm/mremap.c @@ -412,7 +412,7 @@ out: if (ret & ~PAGE_MASK) vm_unacct_memory(charged); out_nc: - if (vm_expanded) + if ((ret & ~PAGE_MASK) && vm_expanded) memrlimit_cgroup_uncharge_as(mm, (new_len - old_len) >> PAGE_SHIFT); return ret; _ Patches currently in -mm which might be from balbir@xxxxxxxxxxxxxxxxxx are delay-accounting-maintainer-update.patch 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-remove-refcnt-from-page_cgroup-fix-memcg-fix-mem_cgroup_end_migration-race.patch memcg-clean-up-checking-of-the-disabled-flag.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-fix.patch memrlimit-improve-error-handling.patch memrlimit-improve-error-handling-update.patch memrlimit-handle-attach_task-failure-add-can_attach-callback.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 gcov-architecture-specific-compile-flag-adjustments-x86_64-fix.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