Received: by 2002:a25:e7d8:0:0:0:0:0 with SMTP id e207csp117593ybh; Tue, 10 Mar 2020 20:46:50 -0700 (PDT) X-Google-Smtp-Source: ADFU+vtuj4ojYEbT5cct2ZeIBHCZESi820oNkavSdmZ6oBZi+NlbDkGWx4P5AwVKPos/6Pxcb9sH X-Received: by 2002:a05:6808:b2d:: with SMTP id t13mr585537oij.107.1583898410142; Tue, 10 Mar 2020 20:46:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1583898410; cv=none; d=google.com; s=arc-20160816; b=FSUn9A9a+xtpCwdgwzL4SHvuoU0NMPnHuniwiUq9NP1x4qZ2ZLHdPyC4t6zeV/ndjs NBDBOsBnGAzh8qipQ8mPvJhlkO8l4IR8GaQciqg4YPOiC+fP4f8v5V2JdIkUa/vTLx1V f9hKyrAjha1946SmrpbZFxuZJztzQ6b7HL7UgxUogKcyQriM0p8JuYe0ZYXcu4jV57Fa SCqh4KE6+qRCRr+a1p40d3IxpG1QXrzZUetfCChVoQlIjFUjlhSvRrZZCqCQakqn6hYX g1H+G7FYP8ZVMQwNuv1Z2BvZEwC/iwP0x8U/QrYQHlUZtZRLNKWXtTEdRj5peBpqK9+x ElKA== 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=g9/Soy66OC22nAKgazf5iA56h4uOPCS4a1ETM2dLFpo=; b=ErJaHi+1qsYJqSVCy58QWBPBog8MBCWhAWwsJJiUPoEmszEzcCmLnzCy4iez1xskg8 lEdJYpoxGhSuobgWrKnP0JYpYcaB8Slw7kB19bg1rwz4jdBSE4swQOywo3LNKwQdMFH2 WbMxadc2GFKh6ejeLwYwFQdfAnNNgPqAldFA4JjngB+G6pkYToRoGcNYa5c6OmwUJu2r apMjXu1by5gGRLdGZEZSurWoiEtOQFaM3l9zgS1Il8YIVzRVVUw6OsHD+PL9MybM/mR6 AXYRMKNojNkWXh/XpwA1/oZwihjjPXzsXdDXjNiBww6WFHCMMThQDUsFj74M6gBeMzQ8 ++Pg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@samsung.com header.s=mail20170921 header.b=Lg8Psrxp; 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 t144si451060oie.129.2020.03.10.20.46.38; Tue, 10 Mar 2020 20:46:50 -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=Lg8Psrxp; 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 S1728172AbgCKDpD (ORCPT + 99 others); Tue, 10 Mar 2020 23:45:03 -0400 Received: from mailout3.samsung.com ([203.254.224.33]:18680 "EHLO mailout3.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728122AbgCKDpA (ORCPT ); Tue, 10 Mar 2020 23:45:00 -0400 Received: from epcas1p4.samsung.com (unknown [182.195.41.48]) by mailout3.samsung.com (KnoxPortal) with ESMTP id 20200311034456epoutp039f41b7e8ca59bfcc2ad3dc6983b3c1bf~7IxvdMHQ71400414004epoutp03U for ; Wed, 11 Mar 2020 03:44:56 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout3.samsung.com 20200311034456epoutp039f41b7e8ca59bfcc2ad3dc6983b3c1bf~7IxvdMHQ71400414004epoutp03U DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1583898296; bh=g9/Soy66OC22nAKgazf5iA56h4uOPCS4a1ETM2dLFpo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Lg8Psrxp/bm8AG21OtRAU6c2mGgcEE3gYLtCi+QHt9Rlhfrbkj/MHlnDHTMYOaD2O UrWh4V4mk0u/l+ei2RzDEL41EIw1UJj9EReaaRapVwHY8nD768yUk9BH+y83KEiF/i hRv6/GEOa+MEUSXaROwR2ByLQHIaDilhyfN5AMTE= Received: from epsnrtp3.localdomain (unknown [182.195.42.164]) by epcas1p4.samsung.com (KnoxPortal) with ESMTP id 20200311034455epcas1p49a471398213ae95d722d296eba01af54~7Ixu5CM8h1814418144epcas1p4L; Wed, 11 Mar 2020 03:44:55 +0000 (GMT) Received: from epsmges1p2.samsung.com (unknown [182.195.40.165]) by epsnrtp3.localdomain (Postfix) with ESMTP id 48cdBZ6jtSzMqYkb; Wed, 11 Mar 2020 03:44:54 +0000 (GMT) Received: from epcas1p1.samsung.com ( [182.195.41.45]) by epsmges1p2.samsung.com (Symantec Messaging Gateway) with SMTP id 8F.7A.48498.6BE586E5; Wed, 11 Mar 2020 12:44:54 +0900 (KST) Received: from epsmtrp1.samsung.com (unknown [182.195.40.13]) by epcas1p4.samsung.com (KnoxPortal) with ESMTPA id 20200311034454epcas1p46f44b4c1e75fa52b7598749566228a11~7Ixtek13a2104521045epcas1p4X; Wed, 11 Mar 2020 03:44:54 +0000 (GMT) Received: from epsmgms1p2new.samsung.com (unknown [182.195.42.42]) by epsmtrp1.samsung.com (KnoxPortal) with ESMTP id 20200311034454epsmtrp131c0cb622dc4d191f256ded94186c246~7Ixtdn5343001830018epsmtrp1c; Wed, 11 Mar 2020 03:44:54 +0000 (GMT) X-AuditID: b6c32a36-a55ff7000001bd72-f1-5e685eb69487 Received: from epsmtip1.samsung.com ( [182.195.34.30]) by epsmgms1p2new.samsung.com (Symantec Messaging Gateway) with SMTP id C1.12.06569.6BE586E5; Wed, 11 Mar 2020 12:44:54 +0900 (KST) Received: from jaewon-linux.10.32.193.11 (unknown [10.253.104.82]) by epsmtip1.samsung.com (KnoxPortal) with ESMTPA id 20200311034454epsmtip1b642b362ae1283f0e23af46aeb7c0353~7IxtV5C8A1922919229epsmtip1j; Wed, 11 Mar 2020 03:44:54 +0000 (GMT) From: Jaewon Kim To: 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 Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, jaewon31.kim@gmail.com, Jaewon Kim Subject: [RFC PATCH 3/3] android: ion: include system heap size in proc/meminfo Date: Wed, 11 Mar 2020 12:44:41 +0900 Message-Id: <20200311034441.23243-4-jaewon31.kim@samsung.com> X-Mailer: git-send-email 2.13.7 In-Reply-To: <20200311034441.23243-1-jaewon31.kim@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFprIJsWRmVeSWpSXmKPExsWy7bCmru62uIw4gxOHzC2mN3pZzFm/hs2i e/NMRove96+YLFbu+cFkcXnXHDaLe2v+s1os+/qe3WJDyyx2i0cTJjFZnLr7md2B22PnrLvs HptWdbJ5bPo0id3jzrU9bB4nZvxm8Xi/7yqbR9+WVYweOz9tZvX4vEkugDMqxyYjNTEltUgh NS85PyUzL91WyTs43jne1MzAUNfQ0sJcSSEvMTfVVsnFJ0DXLTMH6FolhbLEnFKgUEBicbGS vp1NUX5pSapCRn5xia1SakFKToGhQYFecWJucWleul5yfq6VoYGBkSlQZUJOxutTOgVHRCsu LZNvYJwq1MXIySEhYCLx8vt75i5GLg4hgR2MEht3LWOHcD4xSqy7+ZQJwvnGKHHz4V5mmJZN uxawQCT2Mkp0zL7BCuF8Z5S4u2U/K0gVm4C2xPsFk8ASIgJrGSX+Ni1hAUkwC5RKvH1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YDmBkW8B I8MqRsnUguLc9NxiwwKjvNRyveLE3OLSvHS95PzcTYzg0NXS2sF44kT8IUYBDkYlHt4Xdelx QqyJZcWVuYcYJTiYlUR44+WBQrwpiZVVqUX58UWlOanFhxilOViUxHnl849FCgmkJ5akZqem FqQWwWSZODilGhgt9LY6377H0v2g7ITB/jfLo48dkLAsvtwQHGRlYHWZ9z3TNnX1gofPWVkX LntuEvuHW7QiYp6c75kDJnJv+MQPFsWGx7QoiO119We99n7TgZq+V1412S37Lcq/P/BJ9PhS ei7zxTe5e2u8mEV2X72g6+c9Y06jn96KWVNe1KzMUgm+6FhULaXEUpyRaKjFXFScCAAuE9e/ WQIAAA== X-CMS-MailID: 20200311034454epcas1p46f44b4c1e75fa52b7598749566228a11 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: 20200311034454epcas1p46f44b4c1e75fa52b7598749566228a11 References: <20200311034441.23243-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. To include heap size, use register_extra_meminfo 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 | 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..2cc568e2bc9c 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_extra_meminfo(&heap->heap.total_allocated, PAGE_SHIFT, + "IonSystemHeap"); return &heap->heap; free_heap: -- 2.13.7