From mboxrd@z Thu Jan 1 00:00:00 1970 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=-12.5 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=unavailable 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 34A05C47423 for ; Fri, 2 Oct 2020 11:58:07 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id B5EC9206C9 for ; Fri, 2 Oct 2020 11:58:06 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=mg.codeaurora.org header.i=@mg.codeaurora.org header.b="aXaylnqs" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org B5EC9206C9 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=codeaurora.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 29752900004; Fri, 2 Oct 2020 07:58:06 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 24713900002; Fri, 2 Oct 2020 07:58:06 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 11C79900004; Fri, 2 Oct 2020 07:58:06 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0241.hostedemail.com [216.40.44.241]) by kanga.kvack.org (Postfix) with ESMTP id D4567900002 for ; Fri, 2 Oct 2020 07:58:05 -0400 (EDT) Received: from smtpin19.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id 65995362B for ; Fri, 2 Oct 2020 11:58:05 +0000 (UTC) X-FDA: 77326836930.19.elbow12_2209882271a3 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin19.hostedemail.com (Postfix) with ESMTP id 2CD091ACC48 for ; Fri, 2 Oct 2020 11:58:04 +0000 (UTC) X-HE-Tag: elbow12_2209882271a3 X-Filterd-Recvd-Size: 4705 Received: from z5.mailgun.us (z5.mailgun.us [104.130.96.5]) by imf49.hostedemail.com (Postfix) with ESMTP for ; Fri, 2 Oct 2020 11:58:03 +0000 (UTC) DKIM-Signature: a=rsa-sha256; v=1; c=relaxed/relaxed; d=mg.codeaurora.org; q=dns/txt; s=smtp; t=1601639883; h=Message-Id: Date: Subject: Cc: To: From: Sender; bh=qDQzbm47CYdBUkE20350VaDtfWjfmMFoiz8B19hWedA=; b=aXaylnqsu0trIs9M1OM/9fEoCnwPBrJXprdx1WzwRP9FzFIAwYJxBp1R6/snPIaIAVQ5mCJS 8ONnI7vb/VJFBb34Bu5qXpalqH1EO2SlPugDlmgueNFxabQl22YSfvzYnsnczvis1FJnZBr3 d680+lzUckfVH1osfhszfpxQeDQ= X-Mailgun-Sending-Ip: 104.130.96.5 X-Mailgun-Sid: WyIwY2Q3OCIsICJsaW51eC1tbUBrdmFjay5vcmciLCAiYmU5ZTRhIl0= Received: from smtp.codeaurora.org (ec2-35-166-182-171.us-west-2.compute.amazonaws.com [35.166.182.171]) by smtp-out-n05.prod.us-west-2.postgun.com with SMTP id 5f7715cbd1b9b502cebb8728 (version=TLS1.2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256); Fri, 02 Oct 2020 11:58:03 GMT Received: by smtp.codeaurora.org (Postfix, from userid 1001) id 05E70C433FF; Fri, 2 Oct 2020 11:58:03 +0000 (UTC) Received: from blr-ubuntu-498.qualcomm.com (blr-bdr-fw-01_GlobalNAT_AllZones-Outside.qualcomm.com [103.229.18.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: pintu) by smtp.codeaurora.org (Postfix) with ESMTPSA id CBCB8C433FE; Fri, 2 Oct 2020 11:58:00 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org CBCB8C433FE Authentication-Results: aws-us-west-2-caf-mail-1.web.codeaurora.org; dmarc=none (p=none dis=none) header.from=codeaurora.org Authentication-Results: aws-us-west-2-caf-mail-1.web.codeaurora.org; spf=fail smtp.mailfrom=pintu@codeaurora.org From: Pintu Kumar To: linux-kernel@vger.kernel.org, akpm@linux-foundation.org, linux-mm@kvack.org Cc: pintu@codeaurora.org, pintu.ping@gmail.com Subject: [PATCH] mm/util.c: Add error logs for commitment overflow Date: Fri, 2 Oct 2020 17:27:41 +0530 Message-Id: <1601639861-32171-1-git-send-email-pintu@codeaurora.org> X-Mailer: git-send-email 2.7.4 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: The headless embedded devices often come with very limited amount of RAM such as: 256MB or even lesser. These types of system often rely on command line interface which can execute system commands in the background using the fork/exec combination. There could be even many child tasks invoked internally to handle multiple requests. In this scenario, if the parent task keeps committing large amount of memory, there are chances that this commitment can easily overflow the total RAM available in the system. Now if the parent process invokes fork or system commands (using system() call) and the commitment ratio is at 50%, the request fails with the following, even though there are large amount of free memory available in the system: fork failed: Cannot allocate memory If there are too many 3rd party tasks calling fork, it becomes difficult to identify exactly which parent process is overcommitting memory. Since, free memory is also available, this "Cannot allocate memory" from fork creates confusion to application developer. Thus, I found that this simple print message (even once) is helping in quickly identifying the culprit. This is the output we can see on a 256MB system and with a simple malloc and fork program. [root@ ~]# cat /proc/meminfo MemTotal: 249520 kB ==> 243MB MemFree: 179100 kB PPID PID USER RSS VSZ STAT ARGS 150 164 root 1440 250580 S ./consume-and-fork.out 243 __vm_enough_memory: commitment overflow: ppid:150, pid:164, pages:62451 fork failed[count:0]: Cannot allocate memory Signed-off-by: Pintu Kumar --- mm/util.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/mm/util.c b/mm/util.c index 5ef378a..9431ce7a 100644 --- a/mm/util.c +++ b/mm/util.c @@ -895,6 +895,9 @@ int __vm_enough_memory(struct mm_struct *mm, long pages, int cap_sys_admin) error: vm_unacct_memory(pages); + pr_err_once("%s: commitment overflow: ppid:%d, pid:%d, pages:%ld\n", + __func__, current->parent->pid, current->pid, pages); + return -ENOMEM; } -- Qualcomm India Private Limited, on behalf of Qualcomm Innovation Center, Inc., is a member of Code Aurora Forum, a Linux Foundation Collaborative Project.