From patchwork Wed Jun 30 07:44:33 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xu Huijie X-Patchwork-Id: 12351467 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-11.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 649E0C11F65 for ; Wed, 30 Jun 2021 07:44:42 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 1B855613B5 for ; Wed, 30 Jun 2021 07:44:42 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 1B855613B5 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=huawei.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 79F828D0190; Wed, 30 Jun 2021 03:44:41 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 74F0B8D017A; Wed, 30 Jun 2021 03:44:41 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 5EFAA8D0190; Wed, 30 Jun 2021 03:44:41 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0221.hostedemail.com [216.40.44.221]) by kanga.kvack.org (Postfix) with ESMTP id 37FEB8D017A for ; Wed, 30 Jun 2021 03:44:41 -0400 (EDT) Received: from smtpin01.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id 0F0D7235CB for ; Wed, 30 Jun 2021 07:44:41 +0000 (UTC) X-FDA: 78309603162.01.BF17961 Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by imf05.hostedemail.com (Postfix) with ESMTP id CFDAE5000343 for ; Wed, 30 Jun 2021 07:44:39 +0000 (UTC) Received: from dggemv704-chm.china.huawei.com (unknown [172.30.72.54]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4GFCvs09vnzYrXq for ; Wed, 30 Jun 2021 15:41:29 +0800 (CST) Received: from dggemi758-chm.china.huawei.com (10.1.198.144) by dggemv704-chm.china.huawei.com (10.3.19.47) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256) id 15.1.2176.2; Wed, 30 Jun 2021 15:44:35 +0800 Received: from huawei.com (10.174.176.37) by dggemi758-chm.china.huawei.com (10.1.198.144) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2176.2; Wed, 30 Jun 2021 15:44:34 +0800 From: Xu Huijie To: CC: Subject: [PATCH] add kernel log when allocate a new virtual mapping failed because of overcommit Date: Wed, 30 Jun 2021 15:44:33 +0800 Message-ID: <20210630074433.41992-1-xuhuijie2@huawei.com> X-Mailer: git-send-email 2.21.0.windows.1 MIME-Version: 1.0 Signed-off-by: Xu Huijie X-Originating-IP: [10.174.176.37] X-ClientProxiedBy: dggeme706-chm.china.huawei.com (10.1.199.102) To dggemi758-chm.china.huawei.com (10.1.198.144) X-CFilter-Loop: Reflected Authentication-Results: imf05.hostedemail.com; dkim=none; dmarc=pass (policy=none) header.from=huawei.com; spf=pass (imf05.hostedemail.com: domain of xuhuijie2@huawei.com designates 45.249.212.187 as permitted sender) smtp.mailfrom=xuhuijie2@huawei.com X-Stat-Signature: w9r6qmwhtj39mf5nktu7gh6er8fujwde X-Rspamd-Queue-Id: CFDAE5000343 X-Rspamd-Server: rspam06 X-HE-Tag: 1625039079-234048 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: From: xuhuijie diff --git a/mm/mmap.c b/mm/mmap.c index aa9de981b..f019fc6b2 100644 --- a/mm/mmap.c +++ b/mm/mmap.c @@ -1758,8 +1758,10 @@ unsigned long mmap_region(struct file *file, unsigned long addr, */ if (accountable_mapping(file, vm_flags)) { charged = len >> PAGE_SHIFT; - if (security_vm_enough_memory_mm(mm, charged)) + if (security_vm_enough_memory_mm(mm, charged)) { + pr_err("Unable to allocate a new virtual mapping because of the overcommit\n"); return -ENOMEM; + } vm_flags |= VM_ACCOUNT; }