From nobody Wed Apr 15 04:24:52 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 33206C00140 for ; Tue, 26 Jul 2022 14:47:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239414AbiGZOro (ORCPT ); Tue, 26 Jul 2022 10:47:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54168 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229757AbiGZOrm (ORCPT ); Tue, 26 Jul 2022 10:47:42 -0400 Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7D21BDFD5 for ; Tue, 26 Jul 2022 07:47:40 -0700 (PDT) Received: from dggpemm500020.china.huawei.com (unknown [172.30.72.55]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4Lsfmb5KchzWfWR; Tue, 26 Jul 2022 22:43:43 +0800 (CST) Received: from dggpemm500001.china.huawei.com (7.185.36.107) by dggpemm500020.china.huawei.com (7.185.36.49) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.24; Tue, 26 Jul 2022 22:47:37 +0800 Received: from localhost.localdomain.localdomain (10.175.113.25) by dggpemm500001.china.huawei.com (7.185.36.107) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.24; Tue, 26 Jul 2022 22:47:36 +0800 From: Kefeng Wang To: Andrew Morton , , CC: David Hildenbrand , Kefeng Wang , Yongqiang Liu Subject: [PATCH v2] mm: add warning if __vm_enough_memory fails Date: Tue, 26 Jul 2022 22:54:28 +0800 Message-ID: <20220726145428.8030-1-wangkefeng.wang@huawei.com> X-Mailer: git-send-email 2.35.3 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Originating-IP: [10.175.113.25] X-ClientProxiedBy: dggems701-chm.china.huawei.com (10.3.19.178) To dggpemm500001.china.huawei.com (7.185.36.107) X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" If a process has no enough memory to allocate a new virtual mapping, we may meet 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 easy to check this scenario if __vm_enough_memory fails. Reported-by: Yongqiang Liu Signed-off-by: Kefeng Wang Acked-by: David Hildenbrand --- v2: use pr_warn_ratelimited, suggested by David Hildenbrand mm/util.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/mm/util.c b/mm/util.c index 1266a33a49ea..c786e21c6051 100644 --- a/mm/util.c +++ b/mm/util.c @@ -1020,6 +1020,8 @@ int __vm_enough_memory(struct mm_struct *mm, long pag= es, 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 allo= cation\n", + __func__, current->pid, current->comm); vm_unacct_memory(pages); =20 return -ENOMEM; --=20 2.35.3