From: bill4carson <bill4carson@gmail.com>
To: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>
Cc: "linux-mm@kvack.org" <linux-mm@kvack.org>
Subject: Re: Why memory.usage_in_bytes is always increasing after every mmap/dirty/unmap sequence
Date: Fri, 23 Mar 2012 16:43:24 +0800 [thread overview]
Message-ID: <4F6C37AC.4080101@gmail.com> (raw)
In-Reply-To: <4F6C31F7.2010804@jp.fujitsu.com>
On 2012a1'03ae??23ae?JPY 16:19, KAMEZAWA Hiroyuki wrote:
> (2012/03/23 17:04), bill4carson wrote:
>
>> Hi, all
>>
>> I'm playing with memory cgroup, I'm a bit confused why
>> memory.usage in bytes is steadily increasing at 4K page pace
>> after every mmap/dirty/unmap sequence.
>>
>> On linux-3.6.34.10/linux-3.3.0-rc5
>> A simple test case does following:
>>
>> a) mmap 128k memory in private anonymous way
>> b) dirty all 128k to demand physical page
>> c) print memory.usage_in_bytes<-- increased at 4K after every loop
>> d) unmap previous 128 memory
>> e) goto a) to repeat
>
> In Documentation/cgroup/memory.txt
> ==
> 5.5 usage_in_bytes
>
> For efficiency, as other kernel components, memory cgroup uses some optimization
> to avoid unnecessary cacheline false sharing. usage_in_bytes is affected by the
> method and doesn't show 'exact' value of memory(and swap) usage, it's an fuzz
> value for efficient access. (Of course, when necessary, it's synchronized.)
> If you want to know more exact memory usage, you should use RSS+CACHE(+SWAP)
> value in memory.stat(see 5.2).
> ==
>
> In current implementation, memcg tries to charge resource in size of 32 pages.
> So, if you get 32 pages and free 32pages, usage_in_bytes may not change.
> This is affected by caches in other cpus and other flushing operations caused
> by some workload in other cgroups. memcg's usage_in_bytes is not precise in
> 128k degree.
Thanks for the internal design details.
I noticed on 2.6.34, it's checked on every 512 Kbytes
See http://lxr.linux.no/#linux+v2.6.34/mm/memcontrol.c#L571
And I haven't see the 3.3.0 changes.
>
> - How memory.stat changes ?
root@localhost:/sys/fs/cgroup/memory/a> cat memory.stat;cat
memory.usage_in_bytes
cache 0
rss 131072 <------ when mmap/dirty/
mapped_file 0
pgpgin 1278
pgpgout 1246
inactive_anon 0
active_anon 131072
inactive_file 0
active_file 0
unevictable 0
hierarchical_memory_limit 9223372036854775807
total_cache 0
total_rss 131072
total_mapped_file 0
total_pgpgin 1278
total_pgpgout 1246
total_inactive_anon 0
total_active_anon 131072
total_inactive_file 0
total_active_file 0
total_unevictable 0
root@localhost:/sys/fs/cgroup/memory/a> cat memory.stat;cat
memory.usage_in_bytes
cache 0
rss 4096 <------ when mmap/dirty/unmap
mapped_file 0
pgpgin 1278
pgpgout 1277
inactive_anon 0
active_anon 4096
inactive_file 0
active_file 0
unevictable 0
hierarchical_memory_limit 9223372036854775807
total_cache 0
total_rss 4096
total_mapped_file 0
total_pgpgin 1278
total_pgpgout 1277
total_inactive_anon 0
total_active_anon 4096
total_inactive_file 0
total_active_file 0
total_unevictable 0
> - What happens when you do test with 4M alloc/free ?
>
I tried on 2.6.34, it's the same behavior.
> Thanks,
> -Kame
>
>
>
>
>
>
>
>
>
--
Love each day!
--bill
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
next prev parent reply other threads:[~2012-03-23 8:44 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-03-23 8:04 Why memory.usage_in_bytes is always increasing after every mmap/dirty/unmap sequence bill4carson
2012-03-23 8:19 ` KAMEZAWA Hiroyuki
2012-03-23 8:43 ` bill4carson [this message]
2012-03-23 8:59 ` bill4carson
2012-03-23 9:04 ` KAMEZAWA Hiroyuki
2012-03-23 9:15 ` bill4carson
2012-03-23 9:57 ` KAMEZAWA Hiroyuki
2012-03-27 8:26 ` Glauber Costa
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=4F6C37AC.4080101@gmail.com \
--to=bill4carson@gmail.com \
--cc=kamezawa.hiroyu@jp.fujitsu.com \
--cc=linux-mm@kvack.org \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.