From patchwork Tue Jul 26 14:54:28 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kefeng Wang X-Patchwork-Id: 12929388 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 kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id BE052C00144 for ; Tue, 26 Jul 2022 14:47:49 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 448F78E0002; Tue, 26 Jul 2022 10:47:49 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 3F9138E0001; Tue, 26 Jul 2022 10:47:49 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 2C05D8E0002; Tue, 26 Jul 2022 10:47:49 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id 1A74C8E0001 for ; Tue, 26 Jul 2022 10:47:49 -0400 (EDT) Received: from smtpin05.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id D219716092A for ; Tue, 26 Jul 2022 14:47:48 +0000 (UTC) X-FDA: 79729530216.05.B3C1D50 Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by imf13.hostedemail.com (Postfix) with ESMTP id 0248920020 for ; Tue, 26 Jul 2022 14:47:47 +0000 (UTC) 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 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 ARC-Authentication-Results: i=1; imf13.hostedemail.com; dkim=none; spf=pass (imf13.hostedemail.com: domain of wangkefeng.wang@huawei.com designates 45.249.212.188 as permitted sender) smtp.mailfrom=wangkefeng.wang@huawei.com; dmarc=pass (policy=quarantine) header.from=huawei.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1658846868; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding:in-reply-to: references; bh=CwGHek/B34KjTT7Vx7i2XTKQkr2rjL7/567VK79Kbg4=; b=Iv4wwetPE1EVT7PWZMNgHYI6TkwzGkwqWExdl0a+FElj908iW8p6mT9T+eV4fL89uCmJWR +yvGzka6J7/L4kqvlLOkMIXvHTX2kDbzs63cT7388gAd87KJSKXXj9xigMjdttATH99s3/ IhQ4auuv91gNPF099U0FywID6++T6dA= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1658846868; a=rsa-sha256; cv=none; b=E/Qi3KUSPjr6IRp+FQ+VtogAuh7n7IoAYWxhKvubLy89h2gcoQt65dWt1nt4ecSSP/JrVz RMtggSow/84f3k/PGIswa5mRQBv87SemXHPLb3OcDnWl6cOS0O/1n3kB7YTXhOnaME0Szi wLHD+Xi75TALLdluEfZXnaEhg/0az4E= Authentication-Results: imf13.hostedemail.com; dkim=none; spf=pass (imf13.hostedemail.com: domain of wangkefeng.wang@huawei.com designates 45.249.212.188 as permitted sender) smtp.mailfrom=wangkefeng.wang@huawei.com; dmarc=pass (policy=quarantine) header.from=huawei.com X-Rspam-User: X-Stat-Signature: boowtes39gqcr7qfqukertcafsk3eynq X-Rspamd-Queue-Id: 0248920020 X-Rspamd-Server: rspam02 X-HE-Tag: 1658846867-618565 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: 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 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;