Received: by 2002:a25:6193:0:0:0:0:0 with SMTP id v141csp3453386ybb; Mon, 23 Mar 2020 01:05:45 -0700 (PDT) X-Google-Smtp-Source: ADFU+vsrDw9fUrIP3wugAjDZ/2I9YP2ltaNHYkcup7tZwwFuc18axmitCLbRPCujE6Y6Jr1Csr// X-Received: by 2002:a9d:4c8f:: with SMTP id m15mr17387674otf.273.1584950745764; Mon, 23 Mar 2020 01:05:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1584950745; cv=none; d=google.com; s=arc-20160816; b=loMwPGXoxR6MkfKs0QhRjQNa8lHnE43VrVXaXppRkz31WdGK98YB+1NcEXSaStdMR6 2rOo1kCGPIaeMUpRX+F5BPn4VzYMHwdwtXR+JOCa6xn8VlPMGy3qtscJjSxpdECEJ/Dj HgOf8meusG7eYqlK/7Wc7qoTKFJ5+1nc7mckn3Ha3h5qP5lwKkO9C0s3GIgrQ9z7hlmN bFhYMGUr+Q8/3Wz0nePHMAtN/a/Kpjxpgev3HHM7wfkjVP3jXH9yuwDST1DiiT5AHkHw C44MXJ1/jNp6JEVQejC7OL5KID1SUDPcg/IGSML4hwK/tkUq9Ga3LWHGQSBBllPXBST1 vdkw== 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=P4CavwZXkNCT7Ikw0Fe20I2u/uDn4BTxVIDGmLZRxuw=; b=IapmmxtbH0uWzdhnCmoNkhwVaWr1ssFBVoz2ChlISnGUT/yOsh9HsAZBzU6IFm/e9I +vo7YmSmku8gPwCxOFi2rEuA3wLnoTKy1p+5I45QMgJxiZHxheqvURn+EhRR7vVl1MYT T7Ww8uoMjcxhzJ4nX6k+Wi9GMzoSDKdqsn2ZaKdHz1lDIu2srgI+rLtD76OGeYY7MF0o yHbXkkASV8QuiWH97TEmU49L4DIGNmlA/YZRJBvBR1jWvKONGXNMNw84I40nh+TkWzJx ynDss1nudoEfZ5aVz8JNbQSwR88RzH1SB6W+YffhsnHaherhyH6wN2V83O0L1813NXTQ VPrA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@samsung.com header.s=mail20170921 header.b=UcEXFM2W; 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 a10si1926378otp.3.2020.03.23.01.05.32; Mon, 23 Mar 2020 01:05:45 -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=UcEXFM2W; 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 S1727510AbgCWIFO (ORCPT + 99 others); Mon, 23 Mar 2020 04:05:14 -0400 Received: from mailout4.samsung.com ([203.254.224.34]:34855 "EHLO mailout4.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727477AbgCWIFN (ORCPT ); Mon, 23 Mar 2020 04:05:13 -0400 Received: from epcas1p4.samsung.com (unknown [182.195.41.48]) by mailout4.samsung.com (KnoxPortal) with ESMTP id 20200323080510epoutp041bbad08f31085032337e3f9fb3cbb289~_4EYV65nK1412914129epoutp044 for ; Mon, 23 Mar 2020 08:05:10 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout4.samsung.com 20200323080510epoutp041bbad08f31085032337e3f9fb3cbb289~_4EYV65nK1412914129epoutp044 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 m6L80pJUhYz84hJbpdSClJwCQ4MCveLE3OLSvHS95PxcK0MDAyNToMqEnIwrT6czFlwQr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lfGlafTGQsuiFZMvn6XtYFxoVAXIyeHhICJxMdrG5i6GLk4hAR2M0r0LexghkjISLw5/5Sl i5EDyBaWOHy4GKLmK6PEul0/WUFq2AS0Jd4vmARmiwjMZ5Lob+cHKWIW2MwoMXFpMwtIQlgg WGLu8X2MIDaLgKrE5A0zweK8AjYSKy5PhlogL7HwP9heTgFbiX2XbrGB2EJAJVu7nzFPYORb wMiwilEytaA4Nz232LDAMC+1XK84Mbe4NC9dLzk/dxMjOEq0NHcwXl4Sf4hRgINRiYf3Rm95 nBBrYllxZe4hRgkOZiUR3s2pFXFCvCmJlVWpRfnxRaU5qcWHGKU5WJTEeZ/mHYsUEkhPLEnN Tk0tSC2CyTJxcEo1MBovOqR8+WWsncxxd1+XvQYMhcK/OQ4+vlhzaWPopNxSkaqt56vep2aX POpNsr76QvGH0NJ/L/oks54niubs/J/y6PnsJGbhw7Gtui6XxJQfL+r/2Zl+LzwlxD/h7Nen M3gWibzpKPFeM0eWqYp3B+fDW1msS58kiLStmaDRLzNhsthi0b+sv5VYijMSDbWYi4oTAT2/ SM2OAgAA X-CMS-MailID: 20200323080508epcas1p3c68190cd46635b9ff026a4ae70fc7a3b 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: 20200323080508epcas1p3c68190cd46635b9ff026a4ae70fc7a3b References: <20200323080503.6224-1-jaewon31.kim@samsung.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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: -- 2.13.7