From patchwork Mon Mar 23 08:05:03 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jaewon Kim X-Patchwork-Id: 11452443 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 9CE471667 for ; Mon, 23 Mar 2020 08:05:16 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 530EE20784 for ; Mon, 23 Mar 2020 08:05:16 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=samsung.com header.i=@samsung.com header.b="UcEXFM2W" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 530EE20784 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=samsung.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 835486B0005; Mon, 23 Mar 2020 04:05:15 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 7E68B6B0006; Mon, 23 Mar 2020 04:05:15 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 6ADF06B0007; Mon, 23 Mar 2020 04:05:15 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0008.hostedemail.com [216.40.44.8]) by kanga.kvack.org (Postfix) with ESMTP id 53C176B0005 for ; Mon, 23 Mar 2020 04:05:15 -0400 (EDT) Received: from smtpin02.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id 0E5A6181AC9B6 for ; Mon, 23 Mar 2020 08:05:15 +0000 (UTC) X-FDA: 76625891790.02.food36_67d9ea0161307 X-Spam-Summary: 1,0,0,,d41d8cd98f00b204,jaewon31.kim@samsung.com,,RULES_HIT:30051:30054,0,RBL:203.254.224.25:@samsung.com:.lbl8.mailshell.net-62.18.1.2 64.10.201.10,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:fp,MSBL:0,DNSBL:neutral,Custom_rules:0:0:0,LFtime:233,LUA_SUMMARY:none X-HE-Tag: food36_67d9ea0161307 X-Filterd-Recvd-Size: 8792 Received: from mailout2.samsung.com (mailout2.samsung.com [203.254.224.25]) by imf35.hostedemail.com (Postfix) with ESMTP for ; Mon, 23 Mar 2020 08:05:13 +0000 (UTC) Received: from epcas1p4.samsung.com (unknown [182.195.41.48]) by mailout2.samsung.com (KnoxPortal) with ESMTP id 20200323080510epoutp0270c8ca9fde3b94b1e162c0b75645b1ff~_4EYMa7gx3028230282epoutp02t for ; Mon, 23 Mar 2020 08:05:10 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.samsung.com 20200323080510epoutp0270c8ca9fde3b94b1e162c0b75645b1ff~_4EYMa7gx3028230282epoutp02t DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1584950710; bh=P4CavwZXkNCT7Ikw0Fe20I2u/uDn4BTxVIDGmLZRxuw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=UcEXFM2WTcTtblyK758mlzUNgO3piXC6/70tFii6H5/ufSCHx6oWpXlZLJlgbZoNG eVTjUqrc/dY3OsBESsu2TKTg/xk0l5sECj+0r4xbwQpPd5+9ZvNYi+7VUZmOMCMsd/ f/+51c541VgWwscBiShDwttLL95ifxl8Q39Ii10Q= Received: from epsnrtp3.localdomain (unknown [182.195.42.164]) by epcas1p1.samsung.com (KnoxPortal) with ESMTP id 20200323080509epcas1p188e0bb9b7848da53225cb7f3c86ec8ae~_4EXouD5b0465004650epcas1p1q; Mon, 23 Mar 2020 08:05:09 +0000 (GMT) Received: from epsmges1p4.samsung.com (unknown [182.195.40.162]) by epsnrtp3.localdomain (Postfix) with ESMTP id 48m6PJ5KSCzMqYl0; Mon, 23 Mar 2020 08:05:08 +0000 (GMT) Received: from epcas1p1.samsung.com ( [182.195.41.45]) by epsmges1p4.samsung.com (Symantec Messaging Gateway) with SMTP id DE.0E.04160.4BD687E5; Mon, 23 Mar 2020 17:05:08 +0900 (KST) Received: from epsmtrp1.samsung.com (unknown [182.195.40.13]) by epcas1p3.samsung.com (KnoxPortal) with ESMTPA id 20200323080508epcas1p3c68190cd46635b9ff026a4ae70fc7a3b~_4EWPvhKj3019030190epcas1p3D; Mon, 23 Mar 2020 08:05:08 +0000 (GMT) Received: from epsmgms1p1new.samsung.com (unknown [182.195.42.41]) by epsmtrp1.samsung.com (KnoxPortal) with ESMTP id 20200323080508epsmtrp1b7b626fbe636fd09f4fa64c04c8276d1~_4EWO2m150107001070epsmtrp1-; Mon, 23 Mar 2020 08:05:08 +0000 (GMT) X-AuditID: b6c32a38-297ff70000001040-11-5e786db41e39 Received: from epsmtip1.samsung.com ( [182.195.34.30]) by epsmgms1p1new.samsung.com (Symantec Messaging Gateway) with SMTP id 08.73.04024.4BD687E5; Mon, 23 Mar 2020 17:05:08 +0900 (KST) Received: from jaewon-linux.10.32.193.11 (unknown [10.253.104.82]) by epsmtip1.samsung.com (KnoxPortal) with ESMTPA id 20200323080508epsmtip1996987f173182e8893721e72705829c8~_4EWBdNZ70114401144epsmtip1O; Mon, 23 Mar 2020 08:05:08 +0000 (GMT) From: Jaewon Kim To: gregkh@linuxfoundation.org, leon@kernel.org, vbabka@suse.cz, adobriyan@gmail.com, akpm@linux-foundation.org, labbott@redhat.com, sumit.semwal@linaro.org, minchan@kernel.org, ngupta@vflare.org, sergey.senozhatsky.work@gmail.com, kasong@redhat.com, bhe@redhat.com Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, jaewon31.kim@gmail.com, linux-api@vger.kernel.org, kexec@lists.infradead.org, Jaewon Kim Subject: [RFC PATCH v2 3/3] android: ion: include system heap size in meminfo extra Date: Mon, 23 Mar 2020 17:05:03 +0900 Message-Id: <20200323080503.6224-4-jaewon31.kim@samsung.com> X-Mailer: git-send-email 2.13.7 In-Reply-To: <20200323080503.6224-1-jaewon31.kim@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFjrCJsWRmVeSWpSXmKPExsWy7bCmru6W3Io4g/sz1C2mN3pZzFm/hs3i /INfbBbNi9ezWXRvnslo0fv+FZPF8nenGS12n/7KZLFyzw8miym/ljJbbP7ewWZxedccNot7 a/6zWiz7+p7dYkPLLHaLRxMmMVmcuvuZ3WJ2Yx+jg5DHzll32T02repk89j0aRK7x51re9g8 Tsz4zeKxf+4ado/NS+o93u+7yubRt2UVo8eZBUfYPXZ+2szq8XmTXABPVI5NRmpiSmqRQmpe cn5KZl66rZJ3cLxzvKmZgaGuoaWFuZJCXmJuqq2Si0+ArltmDtB7SgpliTmlQKGAxOJiJX07 m6L80pJUhYz84hJbpdSClJwCQ4MCveLE3OLSvHS95PxcK0MDAyNToMqEnIwrT6czFlwQrZh8 /S5rA+NCoS5GTg4JAROJT1emMYPYQgI7GCVuLiroYuQCsj8xSmzf+oUJwvnGKPF4ykVWmI6P 1zZAJfYySrzaeJ4dov07o8T+9lIQm01AW+L9gkmsIEUiAv1MEovuLmIBcZgF1jJKrOq6ywRS JSwQKnFp5iUWEJtFQFVi8oaZYDavgI3EisuTgWwOoHXyEgv/g93HKWArse/SLTaQORICi9gl LmyYxQZxkovE8afzGSFsYYlXx7ewQ9hSEi/729ghGpoZJd7O3MwI4bQwStzd1AvVYSzR23OB GWQbs4CmxPpd+hBhRYmdv+eClTAL8Em8+9rDCnEQr0RHGzTw1CRann2FBouMxN9/z6BsD4kF 89+xQoJoAqPEoZsvWScwys1C2LCAkXEVo1hqQXFuemqxYYEJcpxtYgSnYC2LHYx7zvkcYhTg YFTi4b3RWx4n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76QvGH0NJ/L/oks54niubs/J/y6PnsJGbhw7Gtui6XxJQfL+r/2Zl+LzwlxD/h7Nen M3gWibzpKPFeM0eWqYp3B+fDW1msS58kiLStmaDRLzNhsthi0b+sv5VYijMSDbWYi4oTAT2/ SM2OAgAA X-CMS-MailID: 20200323080508epcas1p3c68190cd46635b9ff026a4ae70fc7a3b X-Msg-Generator: CA X-Sendblock-Type: SVC_REQ_APPROVE CMS-TYPE: 101P DLP-Filter: Pass X-CFilter-Loop: Reflected X-CMS-RootMailID: 20200323080508epcas1p3c68190cd46635b9ff026a4ae70fc7a3b References: <20200323080503.6224-1-jaewon31.kim@samsung.com> 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: In Android system ion system heap size is huge like hundreds of MB. To know overal system memory usage, include ion system heap size in proc/meminfo_extra. To include heap size, use register_meminfo_extra introduced in previous patch. Prior to register we need to add stats to show the ion heap usage. Add total_allocated into ion heap and count it on allocation and freeing. In a ion heap using ION_HEAP_FLAG_DEFER_FREE, a buffer can be freed from user but still live on deferred free list. Keep stats until the buffer is finally freed so that we can cover situation of deferred free thread stuck problem. i.e) cat /proc/meminfo_extra | grep IonSystemHeap IonSystemHeap: 242620 kB i.e.) show_mem on oom <6>[ 420.856428] Mem-Info: <6>[ 420.856433] IonSystemHeap:32813kB Signed-off-by: Jaewon Kim --- drivers/staging/android/ion/ion.c | 2 ++ drivers/staging/android/ion/ion.h | 1 + drivers/staging/android/ion/ion_system_heap.c | 2 ++ 3 files changed, 5 insertions(+) diff --git a/drivers/staging/android/ion/ion.c b/drivers/staging/android/ion/ion.c index 38b51eace4f9..76db91a9f26a 100644 --- a/drivers/staging/android/ion/ion.c +++ b/drivers/staging/android/ion/ion.c @@ -74,6 +74,7 @@ static struct ion_buffer *ion_buffer_create(struct ion_heap *heap, INIT_LIST_HEAD(&buffer->attachments); mutex_init(&buffer->lock); + atomic_long_add(len, &heap->total_allocated); return buffer; err1: @@ -95,6 +96,7 @@ void ion_buffer_destroy(struct ion_buffer *buffer) buffer->heap->num_of_buffers--; buffer->heap->num_of_alloc_bytes -= buffer->size; spin_unlock(&buffer->heap->stat_lock); + atomic_long_sub(buffer->size, &buffer->heap->total_allocated); kfree(buffer); } diff --git a/drivers/staging/android/ion/ion.h b/drivers/staging/android/ion/ion.h index 74914a266e25..10867a2e5728 100644 --- a/drivers/staging/android/ion/ion.h +++ b/drivers/staging/android/ion/ion.h @@ -157,6 +157,7 @@ struct ion_heap { u64 num_of_buffers; u64 num_of_alloc_bytes; u64 alloc_bytes_wm; + atomic_long_t total_allocated; /* protect heap statistics */ spinlock_t stat_lock; diff --git a/drivers/staging/android/ion/ion_system_heap.c b/drivers/staging/android/ion/ion_system_heap.c index b83a1d16bd89..f7882fb7505d 100644 --- a/drivers/staging/android/ion/ion_system_heap.c +++ b/drivers/staging/android/ion/ion_system_heap.c @@ -259,6 +259,8 @@ static struct ion_heap *__ion_system_heap_create(void) if (ion_system_heap_create_pools(heap->pools)) goto free_heap; + register_meminfo_extra(&heap->heap.total_allocated, PAGE_SHIFT, + "IonSystemHeap"); return &heap->heap; free_heap: