Received: by 2002:a25:e7d8:0:0:0:0:0 with SMTP id e207csp1146383ybh; Thu, 12 Mar 2020 18:15:09 -0700 (PDT) X-Google-Smtp-Source: ADFU+vv0KSUTNbInVEeqv72pif4iWckhLrPXGquG6VThdx8JDmuv6K5SNQoY9iU9VMWyuKM+frrA X-Received: by 2002:a54:4816:: with SMTP id j22mr5056128oij.179.1584062109025; Thu, 12 Mar 2020 18:15:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1584062109; cv=none; d=google.com; s=arc-20160816; b=tUziL6q2p5DZOUZ1RB0h6GDhXg53fuCcsGVN/xQRczKLfsuDaVOtj22cG1pB38/1CD JHhycDEhS54EuGotjteEnJkO/n6rONW/Hf7Qbd9rtIZVQKdp194vbaFd9xsV72YJsV/6 VW2BW2pAS3nkQltsEP4ZD8Po6uv3DOTKdvtsX3vYUw0+5XlbKwwOa3ivWgnkDR46NYbk Hqj3jBSdn5F1WwLMLVII9tiWaWLmRkWonMs50eOjdmKHRKEccgnmdg7S/JW2fwioNskn x1jMy+bL/X1NwQ6KmMOSn7QqiRYtEcNm3j4c9bENyYDG+d5NVUhFjBfdd/gfAC8uLj/5 4MBw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:dlp-filter:cms-type :in-reply-to:message-id:date:subject:cc:to:from:dkim-signature :dkim-filter; bh=NvJFVm2bsV+GemohYVQY+wUum4EmPRZJ8wPRx8bxLLE=; b=fjQ12Nfp5f5YIexWLtMNnl4OPSPWY+CgpwDd+/D60kUmZBVMvr4Dppxk1WwquJyW5H Q/hOvNMUMMojzjf/ItoS0Zwcr/CbcZscMySstXKLcV8Kf5BsBUjy63TWPFluF9M/ak4p C8TkNK+iySSiqTrERBxvc7ZDT0AhOqtRst5Y7NjoKmZGaUZ8hJBsqvfSTmINPTkw8moU WOaorkBx1vJBewKrD6PMfIUuVTgQpMwlbpJ9ebK1+gkSUIGecNYW10Im8rzVYkP3ONyi 472Q4KRUKxzn7xW2QDFkbulJB9MZr99wVp3RduHlCH2M1HsB6SWEw5moV43qRJdLHden Qc0A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@samsung.com header.s=mail20170921 header.b=jYBkpxRM; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=samsung.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id f9si3974689oti.44.2020.03.12.18.14.56; Thu, 12 Mar 2020 18:15:09 -0700 (PDT) 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=@samsung.com header.s=mail20170921 header.b=jYBkpxRM; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=samsung.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727073AbgCMBOh (ORCPT + 99 others); Thu, 12 Mar 2020 21:14:37 -0400 Received: from mailout2.samsung.com ([203.254.224.25]:46853 "EHLO mailout2.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726932AbgCMBOg (ORCPT ); Thu, 12 Mar 2020 21:14:36 -0400 Received: from epcas1p1.samsung.com (unknown [182.195.41.45]) by mailout2.samsung.com (KnoxPortal) with ESMTP id 20200313011433epoutp02311b6d980016537ee6c54fbb693f6d20~7uBAVuIfG1299912999epoutp029 for ; Fri, 13 Mar 2020 01:14:33 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.samsung.com 20200313011433epoutp02311b6d980016537ee6c54fbb693f6d20~7uBAVuIfG1299912999epoutp029 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1584062073; bh=NvJFVm2bsV+GemohYVQY+wUum4EmPRZJ8wPRx8bxLLE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=jYBkpxRMsOyUPgxDQ0PwoQ8MU/wEfqB75QP980oK7dArmZ1I213NtqJCloYGxujRh cBkhxpvVmSa5nXA+BOUQvhRMxRmSHBqgLrv7w8nv52/BpO2MvMF2Rlh1DiEXdF+Bqk 29sixdGEjxi/zwbfVO2HWgGjLDsBqWWYkRBI9uxY= Received: from epsnrtp2.localdomain (unknown [182.195.42.163]) by epcas1p1.samsung.com (KnoxPortal) with ESMTP id 20200313011432epcas1p1b5673dd781286a312b8dca88253b3115~7uA-9xDdm1118711187epcas1p16; Fri, 13 Mar 2020 01:14:32 +0000 (GMT) Received: from epsmges1p3.samsung.com (unknown [182.195.40.160]) by epsnrtp2.localdomain (Postfix) with ESMTP id 48dnm70VtrzMqYkq; Fri, 13 Mar 2020 01:14:31 +0000 (GMT) Received: from epcas1p1.samsung.com ( [182.195.41.45]) by epsmges1p3.samsung.com (Symantec Messaging Gateway) with SMTP id 61.40.52419.67EDA6E5; Fri, 13 Mar 2020 10:14:31 +0900 (KST) Received: from epsmtrp1.samsung.com (unknown [182.195.40.13]) by epcas1p4.samsung.com (KnoxPortal) with ESMTPA id 20200313011430epcas1p436a6c02a262debcd755f3e1378331764~7uA96yy9I0946109461epcas1p4m; Fri, 13 Mar 2020 01:14:30 +0000 (GMT) Received: from epsmgms1p1new.samsung.com (unknown [182.195.42.41]) by epsmtrp1.samsung.com (KnoxPortal) with ESMTP id 20200313011430epsmtrp1ef4f3ccca6893c6725e579532befeed3~7uA96GG1j1195111951epsmtrp19; Fri, 13 Mar 2020 01:14:30 +0000 (GMT) X-AuditID: b6c32a37-59fff7000001ccc3-8d-5e6ade76d50b Received: from epsmtip2.samsung.com ( [182.195.34.31]) by epsmgms1p1new.samsung.com (Symantec Messaging Gateway) with SMTP id 9C.67.06963.67EDA6E5; Fri, 13 Mar 2020 10:14:30 +0900 (KST) Received: from jaewon-linux.10.32.193.11 (unknown [10.253.104.82]) by epsmtip2.samsung.com (KnoxPortal) with ESMTPA id 20200313011430epsmtip22fbaed503f8f0c4bd57967a0e932ded6~7uA9wdaxy1860718607epsmtip22; Fri, 13 Mar 2020 01:14:30 +0000 (GMT) From: Jaewon Kim To: willy@infradead.org, walken@google.com, bp@suse.de, akpm@linux-foundation.org Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, jaewon31.kim@gmail.com, Jaewon Kim Subject: [PATCH v2 2/2] mm: mmap: add trace point of vm_unmapped_area Date: Fri, 13 Mar 2020 10:14:20 +0900 Message-Id: <20200313011420.15995-3-jaewon31.kim@samsung.com> X-Mailer: git-send-email 2.13.7 In-Reply-To: <20200313011420.15995-1-jaewon31.kim@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA02SbUhTYRTHedx2d9VWl2V2GJF6S2HqamtNb6Fib3orAykK8oPropep7Y3d zVIrrMzCNJv5IU1JETNKUjYJV4iwypdWoUQIgVZKgvZiabPA1LZdo779zjn/85w/5zm4QDov kuH5RitrMTJ6EgsRPnwiVyhOjRVkK5cMVENHO0bZq+XUVWcdoqpmpoOo148aMGqsfVlELdWc pRZ+NWCpOO2qHxXTTQ4b7bwbSztma8T0wM0FIX2t6x6inZ4Ses6xMRPP0iflsUwua4lkjTmm 3HyjLpk8eES7R6tJUKoUqh1UIhlpZAxsMrk3I1ORlq/3mSIjCxm9zZfKZDiO3JqSZDHZrGxk nomzJpOsOVdvVinNWzjGwNmMui05JsNOlVK5TeNTntDn1bVVIvP5iNP2ifRSZJdVoGAciO3w zjWPVaAQXEp0I2huvyTig1kE4y8Gg/hgHoGnpl74t+VCRWuApUQPgtHFOF70E8GCa1LgL2BE HMw01fiewvEw4ghM1GH+tICwwZfPAwHJWmIfTHkbAiwkouFBUzXml0uIZOj9dtSPQERA83JA EUykgMP5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KdXAGKppJab5e9Hq3WZZPjl3 8qcz8GuZXg9xvfX8jUhdQpHL68V7Sr54S5mcis9M95WUznzrySWS8MzsUrHvz/PPvh/3Su3s atY/+7Uja11n9m2rkiktc3kmG0pX5HnkH0xdf1nGtmSv0p8dQV77o9mPHkqy6j0974PKvqly epdXr6tl2b59s+trJZbijERDLeai4kQAdsQJAUECAAA= X-CMS-MailID: 20200313011430epcas1p436a6c02a262debcd755f3e1378331764 X-Msg-Generator: CA Content-Type: text/plain; charset="utf-8" X-Sendblock-Type: SVC_REQ_APPROVE CMS-TYPE: 101P DLP-Filter: Pass X-CFilter-Loop: Reflected X-CMS-RootMailID: 20200313011430epcas1p436a6c02a262debcd755f3e1378331764 References: <20200313011420.15995-1-jaewon31.kim@samsung.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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. In my platform, GPU driver calls to vm_unmapped_area and the driver returns -ENOMEM even in GPU side shortage. It can be hard to distinguish which code layer returns the -ENOMEM. Create mmap trace file and add trace point of vm_unmapped_area. i.e.) 265.214275: vm_unmapped_area: addr=fffffffffffffff4 err=-12 tvm=0xffb08 flags=0x1 len=0x100000 lo=0x8000 hi=0xf7182000 mask=0x0 ofs=0x22 265.214276: vm_unmapped_area: addr=fffffffffffffff4 err=-12 tvm=0xffb08 flags=0x0 len=0x100000 lo=0x40000000 hi=0xfffff000 mask=0x0 ofs=0x22 510.827472: vm_unmapped_area: addr=7377060000 err=0 tvm=0x262f flags=0x1 len=0x7f000 lo=0x8000 hi=0x73795f7000 mask=0x0 ofs=0x22 510.827668: vm_unmapped_area: addr=73794d1000 err=0 tvm=0x25cc flags=0x1 len=0x1000 lo=0x8000 hi=0x73795f7000 mask=0x0 ofs=0x22 Signed-off-by: Jaewon Kim --- include/trace/events/mmap.h | 52 +++++++++++++++++++++++++++++++++++++++++++++ mm/mmap.c | 12 +++++++++-- 2 files changed, 62 insertions(+), 2 deletions(-) create mode 100644 include/trace/events/mmap.h diff --git a/include/trace/events/mmap.h b/include/trace/events/mmap.h new file mode 100644 index 000000000000..a51dd8af6f8c --- /dev/null +++ b/include/trace/events/mmap.h @@ -0,0 +1,52 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +#undef TRACE_SYSTEM +#define TRACE_SYSTEM mmap + +#if !defined(_TRACE_MMAP_H) || defined(TRACE_HEADER_MULTI_READ) +#define _TRACE_MMAP_H + +#include + +TRACE_EVENT(vm_unmapped_area, + + TP_PROTO(unsigned long addr, struct vm_unmapped_area_info *info), + + TP_ARGS(addr, info), + + TP_STRUCT__entry( + __field(unsigned long, addr) + __field(unsigned long, error) + __field(unsigned long, total_vm) + __field(unsigned long, flags) + __field(unsigned long, length) + __field(unsigned long, low_limit) + __field(unsigned long, high_limit) + __field(unsigned long, align_mask) + __field(unsigned long, align_offset) + ), + + TP_fast_assign( + __entry->addr = addr; + if (IS_ERR_VALUE(addr)) + __entry->error = addr; + else + __entry->error = 0; + __entry->total_vm = current->mm->total_vm; + __entry->flags = info->flags; + __entry->length = info->length; + __entry->low_limit = info->low_limit; + __entry->high_limit = info->high_limit; + __entry->align_mask = info->align_mask; + __entry->align_offset = info->align_offset; + ), + + TP_printk("addr=%lx err=%ld tvm=0x%lx flags=0x%lx len=0x%lx lo=0x%lx hi=0x%lx mask=0x%lx ofs=0x%lx\n", + __entry->addr, __entry->error, __entry->total_vm, + __entry->flags, __entry->length, __entry->low_limit, + __entry->high_limit, __entry->align_mask, + __entry->align_offset) +); +#endif + +/* This part must be outside protection */ +#include diff --git a/mm/mmap.c b/mm/mmap.c index eeaddb76286c..68ccbd7d5256 100644 --- a/mm/mmap.c +++ b/mm/mmap.c @@ -53,6 +53,9 @@ #include #include +#define CREATE_TRACE_POINTS +#include + #include "internal.h" #ifndef arch_mmap_check @@ -2061,10 +2064,15 @@ unsigned long unmapped_area_topdown(struct vm_unmapped_area_info *info) */ 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); + + trace_vm_unmapped_area(addr, info); + return addr; } #ifndef arch_get_mmap_end -- 2.13.7