linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: taskboxtester@gmail.com
To: Kyeongdon Kim <kyeongdon.kim@lge.com>
Cc: kemi.wang@intel.com, mhocko@suse.com, xieyisheng1@huawei.com,
	bigeasy@linutronix.de, luto@kernel.org, linux-mm@kvack.org,
	hannes@cmpxchg.org, khlebnikov@yandex-team.ru,
	akpm@linux-foundation.org, shli@fb.com,
	linux-kernel@vger.kernel.org, iamjoonsoo.kim@lge.com,
	sfr@canb.auug.org.au, bongkyu.kim@lge.com,
	mgorman@techsingularity.net, rientjes@google.com, vbabka@suse.cz,
	hillf.zj@alibaba-inc.com, ying.huang@intel.com
Subject: Re: [PATCH] mm/vmstats: add counters for the page frag cache
Date: Thu, 31 Aug 2017 19:41:26 -0400	[thread overview]
Message-ID: <60884168-4201-4915-b81f-86a02d727cc3@gmail.com> (raw)
In-Reply-To: <1504222631-2635-1-git-send-email-kyeongdon.kim@lge.com>

[-- Attachment #1: Type: text/plain, Size: 2913 bytes --]

taskboxtester@gmail.com liked your message with Boxer for Android.


On Aug 31, 2017 7:38 PM, Kyeongdon Kim <kyeongdon.kim@lge.com> wrote:

There was a memory leak problem when we did stressful test
on Android device.
The root cause of this was from page_frag_cache alloc
and it was very hard to find out.

We add to count the page frag allocation and free with function call.
The gap between pgfrag_alloc and pgfrag_free is good to to calculate
for the amount of page.
The gap between pgfrag_alloc_calls and pgfrag_free_calls is for
sub-indicator.
They can see trends of memory usage during the test.
Without it, it's difficult to check page frag usage so I believe we
should add it.

Signed-off-by: Kyeongdon Kim <kyeongdon.kim@lge.com>
---
include/linux/vm_event_item.h | 4 ++++
mm/page_alloc.c               | 9 +++++++--
mm/vmstat.c                   | 4 ++++
3 files changed, 15 insertions(+), 2 deletions(-)

diff --git a/include/linux/vm_event_item.h b/include/linux/vm_event_item.h
index d77bc35..75425d4 100644
--- a/include/linux/vm_event_item.h
+++ b/include/linux/vm_event_item.h
@@ -110,6 +110,10 @@ enum vm_event_item { PGPGIN, PGPGOUT, PSWPIN, PSWPOUT,
SWAP_RA,
SWAP_RA_HIT,
#endif
+PGFRAG_ALLOC,
+PGFRAG_FREE,
+PGFRAG_ALLOC_CALLS,
+PGFRAG_FREE_CALLS,
NR_VM_EVENT_ITEMS
};

diff --git a/mm/page_alloc.c b/mm/page_alloc.c
index db2d25f..b3ddd76 100644
--- a/mm/page_alloc.c
+++ b/mm/page_alloc.c
@@ -4322,6 +4322,7 @@ void __page_frag_cache_drain(struct page *page, unsigned int count)
free_hot_cold_page(page, false);
else
__free_pages_ok(page, order);
+__count_vm_events(PGFRAG_FREE, 1 << order);
}
}
EXPORT_SYMBOL(__page_frag_cache_drain);
@@ -4338,7 +4339,7 @@ void *page_frag_alloc(struct page_frag_cache *nc,
page = __page_frag_cache_refill(nc, gfp_mask);
if (!page)
return NULL;
-
+__count_vm_events(PGFRAG_ALLOC, 1 << compound_order(page));
#if (PAGE_SIZE < PAGE_FRAG_CACHE_MAX_SIZE)
/* if size can vary use size else just use PAGE_SIZE */
size = nc->size;
@@ -4375,6 +4376,7 @@ void *page_frag_alloc(struct page_frag_cache *nc,

nc->pagecnt_bias--;
nc->offset = offset;
+__count_vm_event(PGFRAG_ALLOC_CALLS);

return nc->va + offset;
}
@@ -4387,8 +4389,11 @@ void page_frag_free(void *addr)
{
struct page *page = virt_to_head_page(addr);

-if (unlikely(put_page_testzero(page)))
+if (unlikely(put_page_testzero(page))) {
+__count_vm_events(PGFRAG_FREE, 1 << compound_order(page));
__free_pages_ok(page, compound_order(page));
+}
+__count_vm_event(PGFRAG_FREE_CALLS);
}
EXPORT_SYMBOL(page_frag_free);

diff --git a/mm/vmstat.c b/mm/vmstat.c
index 4bb13e7..c00fe05 100644
--- a/mm/vmstat.c
+++ b/mm/vmstat.c
@@ -1217,6 +1217,10 @@ const char * const vmstat_text[] = {
"swap_ra",
"swap_ra_hit",
#endif
+"pgfrag_alloc",
+"pgfrag_free",
+"pgfrag_alloc_calls",
+"pgfrag_free_calls",
#endif /* CONFIG_VM_EVENTS_COUNTERS */
};
#endif /* CONFIG_PROC_FS || CONFIG_SYSFS || CONFIG_NUMA */
-- 
2.6.2


[-- Attachment #2: Type: text/html, Size: 4491 bytes --]

  reply	other threads:[~2017-08-31 23:41 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-08-31 23:37 Kyeongdon Kim
2017-08-31 23:41 ` taskboxtester [this message]
2017-08-31 23:41 ` taskboxtester
2017-09-01  9:12 ` Konstantin Khlebnikov
2017-09-01  9:21   ` Michal Hocko
2017-09-04  1:36     ` Kyeongdon Kim
2017-09-04  1:35   ` Kyeongdon Kim
2017-09-04  8:30     ` Konstantin Khlebnikov
2017-09-08  7:11       ` Kyeongdon Kim

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=60884168-4201-4915-b81f-86a02d727cc3@gmail.com \
    --to=taskboxtester@gmail.com \
    --cc=akpm@linux-foundation.org \
    --cc=bigeasy@linutronix.de \
    --cc=bongkyu.kim@lge.com \
    --cc=hannes@cmpxchg.org \
    --cc=hillf.zj@alibaba-inc.com \
    --cc=iamjoonsoo.kim@lge.com \
    --cc=kemi.wang@intel.com \
    --cc=khlebnikov@yandex-team.ru \
    --cc=kyeongdon.kim@lge.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=luto@kernel.org \
    --cc=mgorman@techsingularity.net \
    --cc=mhocko@suse.com \
    --cc=rientjes@google.com \
    --cc=sfr@canb.auug.org.au \
    --cc=shli@fb.com \
    --cc=vbabka@suse.cz \
    --cc=xieyisheng1@huawei.com \
    --cc=ying.huang@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox