Received: by 2002:a25:c205:0:0:0:0:0 with SMTP id s5csp6416360ybf; Thu, 5 Mar 2020 20:26:51 -0800 (PST) X-Google-Smtp-Source: ADFU+vuNwL4hfIyKcNeT7H7/KzwZ4xSfvO+kz8k9Sb+ziwLSjJAPk3wq5NoGfv/hl1wxuA/AJ7qg X-Received: by 2002:aca:af97:: with SMTP id y145mr1293983oie.24.1583468811423; Thu, 05 Mar 2020 20:26:51 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1583468811; cv=none; d=google.com; s=arc-20160816; b=QaCkb0CAQGO5iblj4Psa5NNlEmjVTuuL9HITbK5X6CLmKOfxOF+3RUxL4PozHmuqZj bZDAlPGK7j5BZht4d13diTnOghvUmAMglHBnuS4UgJ3VKo9tE5+h2yJCXhdWGxWG+h89 Czbf2OxTFWDzfJT/bv5xeV+nyfDa/lrf6kvSV9nGil+2FaLjxjxOX8wuWGdBXQsb1PrS R3hwYd2MDU97HMU2WpmtlSt/yaORiolfIR3z0zPGEZsL3kbSjvWrRQLgxSufhbxXzHZ3 C72DQYlIvjVzDadJYKdiQt752oKkxduX+C60XSTazrdC8TVBWgOJtOaHckw66Y9NGw61 eb/w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:subject:cc:to:from:date :dkim-signature; bh=Blv0e9oVwKDJXyIrhD/wP+5rhCDsgBAZzAGbnywq8nc=; b=OyldycPfLKMGfKdYjrg8XKNY9+dSMCNZR1N6f7bCjPBLo8aiahubpbKmDNwZaRZqdZ SDUWGOAEkuy8BIT0XX8+0+Q32ioOv6zeQlL/VQUxGqtfCc/rFFZmRlNgiQFjCMc+OXV0 c8OEC8K7j/Pd0J1hMfJUTKh1nXXiXFowNf5JLN2NtvqB8uVsK2hFkx8rTyQ2llS/Jrtl p4MTMkJzEJZK32hSZP64SycOpXKcH47QFZHqP0RQcEza2vwFeIK/WBPhkfv6HQ/HAeg+ GZ/rPzS3Rv9W2/nsSrOLGRf1QEHeXGBmYdm5XtJJRYKAJU/qFlxmhdEivnvnbSmm/2tQ G+wA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=MbJqfxO3; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id j17si591457otl.278.2020.03.05.20.26.34; Thu, 05 Mar 2020 20:26:51 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=MbJqfxO3; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726674AbgCFEYo (ORCPT + 99 others); Thu, 5 Mar 2020 23:24:44 -0500 Received: from mail.kernel.org ([198.145.29.99]:40342 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726251AbgCFEYo (ORCPT ); Thu, 5 Mar 2020 23:24:44 -0500 Received: from localhost.localdomain (c-73-231-172-41.hsd1.ca.comcast.net [73.231.172.41]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id C86A52073D; Fri, 6 Mar 2020 04:24:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1583468684; bh=XTbr7KlqNbwV2YhVNfxiPjrjjl5yMzT1EDmmNZjlgAk=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=MbJqfxO3HaXuCRow/zTICEzxaKpC1iTuAyYHnaLVioPjsRLoOFOt7QpWqb4F2J1PJ c8D07qpGHb7aaACU2w8hT9k8hOEaULu2Ho3gFc9VqJFWcHy0pRD30TDttjARJ/TZkj /MOQDiJHpVDd8pt9JqWWJPTAcFMSYKZwZtN2Ntoc= Date: Thu, 5 Mar 2020 20:24:43 -0800 From: Andrew Morton To: Jaewon Kim Cc: walken@google.com, bp@suse.de, linux-mm@kvack.org, linux-kernel@vger.kernel.org, jaewon31.kim@gmail.com Subject: Re: [PATCH] mm: mmap: show vm_unmapped_area error log Message-Id: <20200305202443.8de3598558336b1d75afbba7@linux-foundation.org> In-Reply-To: <5E605749.9050509@samsung.com> References: <20200304030206.1706-1-jaewon31.kim@samsung.com> <5E605749.9050509@samsung.com> X-Mailer: Sylpheed 3.5.1 (GTK+ 2.24.31; x86_64-pc-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, 5 Mar 2020 10:35:05 +0900 Jaewon Kim wrote: > Hello > > sorry for build warning. > I've changed %d to %ld reported by kbuild. > Let me attach full patch again below. > -------------------------------------------------- > > > Even on 64 bit kernel, the mmap failure can happen for a 32 bit task. > Virtual memory space shortage of a task on mmap is reported to userspace > as -ENOMEM. It can be confused as physical memory shortage of overall > system. > > The vm_unmapped_area can be called to by some drivers or other kernel > core system like filesystem. It can be hard to know which code layer > returns the -ENOMEM. > > Print error log of vm_unmapped_area with rate limited. Without rate > limited, soft lockup ocurrs on infinite mmap sytem call. > > i.e.) > <3>[ 576.024088] [6: mmap_infinite:14251] mmap: vm_unmapped_area err:-12 total_vm:0xfee08 flags:0x1 len:0xa00000 low:0x8000 high:0xf3f63000 > hm, I suppose that could be useful. Although the choice of which info to display could be a source of dispute. Why did you choose this info and omit other things? Perhaps a stack trace could also be useful? > --- a/include/linux/mm.h > +++ b/include/linux/mm.h > @@ -2379,10 +2379,19 @@ extern unsigned long unmapped_area_topdown(struct vm_unmapped_area_info *info); > static inline unsigned long > vm_unmapped_area(struct vm_unmapped_area_info *info) > { > + unsigned long addr; > + > if (info->flags & VM_UNMAPPED_AREA_TOPDOWN) > - return unmapped_area_topdown(info); > + addr = unmapped_area_topdown(info); > else > - return unmapped_area(info); > + addr = unmapped_area(info); > + > + if (IS_ERR_VALUE(addr) && printk_ratelimit()) { Please avoid using printk_ratelimit(). See the comment at the printk_ratelimit() definition site: /* * Please don't use printk_ratelimit(), because it shares ratelimiting state * with all other unrelated printk_ratelimit() callsites. Instead use * printk_ratelimited() or plain old __ratelimit(). */ > + pr_err("%s err:%ld total_vm:0x%lx flags:0x%lx len:0x%lx low:0x%lx high:0x%lx\n", > + __func__, addr, current->mm->total_vm, info->flags, > + info->length, info->low_limit, info->high_limit); > + } > + return addr; > }