Skip to content

Commit

Permalink
mm/util.c: add warning if __vm_enough_memory fails
Browse files Browse the repository at this point in the history
If a process has not enough memory to allocate a new virtual mapping, we
may meet verious kinds of error, eg, fork cannot allocate memory, SIGBUS
error in shmem, but it is difficult to confirm them, let's add some debug
information to easily to check this scenario if __vm_enough_memory fails.

Link: https://lkml.kernel.org/r/20220726145428.8030-1-wangkefeng.wang@huawei.com
Reported-by: Yongqiang Liu <liuyongqiang13@huawei.com>
Signed-off-by: Kefeng Wang <wangkefeng.wang@huawei.com>
Acked-by: David Hildenbrand <david@redhat.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
  • Loading branch information
Kefeng Wang authored and Andrew Morton committed Sep 12, 2022
1 parent 4d86d4f commit 44b414c
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions mm/util.c
Original file line number Diff line number Diff line change
Expand Up @@ -1052,6 +1052,8 @@ int __vm_enough_memory(struct mm_struct *mm, long pages, int cap_sys_admin)
if (percpu_counter_read_positive(&vm_committed_as) < allowed)
return 0;
error:
pr_warn_ratelimited("%s: pid: %d, comm: %s, no enough memory for the allocation\n",
__func__, current->pid, current->comm);
vm_unacct_memory(pages);

return -ENOMEM;
Expand Down

0 comments on commit 44b414c

Please sign in to comment.