* [RFC][PATCH 0/7] trace memory objects
@ 2011-08-29 3:29 Wu Fengguang
0 siblings, 0 replies; 3+ messages in thread
From: Wu Fengguang @ 2011-08-29 3:29 UTC (permalink / raw)
To: Andrew Morton, Ingo Molnar
Cc: Mel Gorman, Linux Memory Management List, Wu Fengguang, LKML
Andrew, Ingo,
I'd like to introduce three memory object interfaces
/debug/tracing/objects/mm/pages/dump-pfn
/debug/tracing/objects/mm/pages/dump-file
/debug/tracing/objects/mm/pages/dump-fs
for dumping
- a range of PFNs
- the cached inodes (icache)
- the cached inode pages (page cache)
The "dump-pfn" interface is a superset of the existing /proc/kpageflags and
/proc/kpagecount interfaces. Example output:
# echo 10000 +10 > /debug/tracing/objects/mm/pages/dump-pfn
# cat /debug/tracing/trace
# tracer: nop
#
# TASK-PID CPU# TIMESTAMP FUNCTION
# | | | | |
zsh-3128 [000] 1393.460292: dump_page_frame: pfn=10001 page=ffffea000009c400 count=1 mapcount=0 memcg=0 private=0 mapping=0 index=0 flags=reserved
zsh-3128 [000] 1393.460296: dump_page_frame: pfn=10002 page=ffffea000009c440 count=1 mapcount=0 memcg=0 private=0 mapping=0 index=0 flags=reserved
zsh-3128 [000] 1393.460298: dump_page_frame: pfn=10003 page=ffffea000009c480 count=1 mapcount=0 memcg=0 private=0 mapping=0 index=0 flags=reserved
zsh-3128 [000] 1393.460299: dump_page_frame: pfn=10004 page=ffffea000009c4c0 count=1 mapcount=0 memcg=0 private=0 mapping=0 index=0 flags=reserved
zsh-3128 [000] 1393.460300: dump_page_frame: pfn=10005 page=ffffea000009c500 count=1 mapcount=0 memcg=0 private=0 mapping=0 index=0 flags=reserved
zsh-3128 [000] 1393.460301: dump_page_frame: pfn=10006 page=ffffea000009c540 count=1 mapcount=0 memcg=0 private=0 mapping=0 index=0 flags=reserved
zsh-3128 [000] 1393.460301: dump_page_frame: pfn=10007 page=ffffea000009c580 count=1 mapcount=0 memcg=0 private=0 mapping=0 index=0 flags=reserved
zsh-3128 [000] 1393.460302: dump_page_frame: pfn=10008 page=ffffea000009c5c0 count=1 mapcount=0 memcg=0 private=0 mapping=0 index=0 flags=reserved
zsh-3128 [000] 1393.460303: dump_page_frame: pfn=10009 page=ffffea000009c600 count=1 mapcount=0 memcg=0 private=0 mapping=0 index=0 flags=reserved
zsh-3128 [000] 1393.460304: dump_page_frame: pfn=10010 page=ffffea000009c640 count=1 mapcount=0 memcg=0 private=0 mapping=0 index=0 flags=reserved
The "dump-file", "dump-fs" interfaces could be pretty useful for examining
the page cache status. Example output:
# echo > /debug/tracing/trace
# echo / > /debug/tracing/objects/mm/pages/dump-fs
# head -50 /debug/tracing/trace
# tracer: nop
#
# TASK-PID CPU# TIMESTAMP FUNCTION
# | | | | |
zsh-3128 [000] 1482.623149: dump_inode_cache: ino=1507329 size=4096 cached=4096 dirtied_when=4294676467 age=1482 state=____ type=DIR name=/
zsh-3128 [000] 1482.623157: dump_page_cache: index=0 len=1 flags=___ARU_____ count=1 mapcount=0 memcg=1
zsh-3128 [000] 1482.623340: dump_inode_cache: ino=1786836 size=12288 cached=12288 dirtied_when=4294676472 age=1482 state=____ type=DIR name=/sbin
zsh-3128 [000] 1482.623355: dump_page_cache: index=0 len=3 flags=___ARU_____ count=1 mapcount=0 memcg=1
zsh-3128 [000] 1482.623393: dump_inode_cache: ino=1786946 size=37312 cached=40960 dirtied_when=4294676473 age=1482 state=____ type=REG name=/sbin/init
zsh-3128 [000] 1482.623404: dump_page_cache: index=0 len=6 flags=M__ARU_____ count=2 mapcount=1 memcg=1
zsh-3128 [000] 1482.623405: dump_page_cache: index=6 len=1 flags=M__A_U_____ count=2 mapcount=1 memcg=1
zsh-3128 [000] 1482.623406: dump_page_cache: index=7 len=1 flags=M__ARU_____ count=2 mapcount=1 memcg=1
zsh-3128 [000] 1482.623408: dump_page_cache: index=8 len=2 flags=_____U_____ count=1 mapcount=0 memcg=1
zsh-3128 [000] 1482.623422: dump_inode_cache: ino=1507464 size=4 cached=4096 dirtied_when=4294676477 age=1482 state=____ type=LNK name=/lib64
zsh-3128 [000] 1482.623427: dump_page_cache: index=0 len=1 flags=___ARU_____ count=1 mapcount=0 memcg=1
zsh-3128 [000] 1482.623441: dump_inode_cache: ino=1590173 size=12288 cached=0 dirtied_when=4294676477 age=1482 state=____ type=DIR name=/lib
zsh-3128 [000] 1482.623458: dump_inode_cache: ino=1590265 size=27 cached=4096 dirtied_when=4294676478 age=1482 state=____ type=LNK name=/lib/ld-linux-x86-64.so.2
zsh-3128 [000] 1482.623462: dump_page_cache: index=0 len=1 flags=___ARU_____ count=1 mapcount=0 memcg=1
zsh-3128 [000] 1482.623478: dump_inode_cache: ino=1663440 size=4096 cached=0 dirtied_when=4294676479 age=1482 state=____ type=DIR name=/lib/x86_64-linux-gnu
zsh-3128 [000] 1482.623495: dump_inode_cache: ino=3293287 size=136936 cached=139264 dirtied_when=4294676480 age=1482 state=____ type=REG name=/lib/x86_64-linux-gnu/ld-2.13.so
zsh-3128 [000] 1482.623499: dump_page_cache: index=0 len=1 flags=M__ARU_____ count=28 mapcount=27 memcg=1
zsh-3128 [000] 1482.623501: dump_page_cache: index=1 len=3 flags=M__ARU_____ count=23 mapcount=22 memcg=1
zsh-3128 [000] 1482.623503: dump_page_cache: index=4 len=4 flags=M__ARU_____ count=26 mapcount=25 memcg=1
zsh-3128 [000] 1482.623504: dump_page_cache: index=8 len=2 flags=M__ARU_____ count=34 mapcount=33 memcg=1
zsh-3128 [000] 1482.623506: dump_page_cache: index=10 len=3 flags=M__ARU_____ count=26 mapcount=25 memcg=1
zsh-3128 [000] 1482.623508: dump_page_cache: index=13 len=1 flags=M__ARU_____ count=34 mapcount=33 memcg=1
zsh-3128 [000] 1482.623509: dump_page_cache: index=14 len=1 flags=M__ARU_____ count=33 mapcount=32 memcg=1
zsh-3128 [000] 1482.623510: dump_page_cache: index=15 len=1 flags=M__ARU_____ count=26 mapcount=25 memcg=1
zsh-3128 [000] 1482.623511: dump_page_cache: index=16 len=1 flags=M__ARU_____ count=25 mapcount=24 memcg=1
zsh-3128 [000] 1482.623512: dump_page_cache: index=17 len=1 flags=M__ARU_____ count=26 mapcount=25 memcg=1
zsh-3128 [000] 1482.623513: dump_page_cache: index=18 len=1 flags=M__ARU_____ count=10 mapcount=9 memcg=1
zsh-3128 [000] 1482.623514: dump_page_cache: index=19 len=1 flags=M__ARU_____ count=34 mapcount=33 memcg=1
zsh-3128 [000] 1482.623515: dump_page_cache: index=20 len=1 flags=M__ARU_____ count=23 mapcount=22 memcg=1
zsh-3128 [000] 1482.623516: dump_page_cache: index=21 len=1 flags=M__ARU_____ count=26 mapcount=25 memcg=1
zsh-3128 [000] 1482.623517: dump_page_cache: index=22 len=1 flags=M__ARU_____ count=34 mapcount=33 memcg=1
zsh-3128 [000] 1482.623518: dump_page_cache: index=23 len=2 flags=M__ARU_____ count=26 mapcount=25 memcg=1
zsh-3128 [000] 1482.623519: dump_page_cache: index=25 len=1 flags=M__ARU_____ count=33 mapcount=32 memcg=1
zsh-3128 [000] 1482.623520: dump_page_cache: index=26 len=1 flags=M__ARU_____ count=10 mapcount=9 memcg=1
zsh-3128 [000] 1482.623522: dump_page_cache: index=27 len=1 flags=M__ARU_____ count=4 mapcount=3 memcg=1
zsh-3128 [000] 1482.623523: dump_page_cache: index=28 len=1 flags=M__ARU_____ count=26 mapcount=25 memcg=1
zsh-3128 [000] 1482.623525: dump_page_cache: index=29 len=5 flags=_____U_____ count=1 mapcount=0 memcg=1
zsh-3128 [000] 1482.623540: dump_inode_cache: ino=1525477 size=12288 cached=0 dirtied_when=4294676489 age=1482 state=____ type=DIR name=/etc
zsh-3128 [000] 1482.623556: dump_inode_cache: ino=1526474 size=69589 cached=69632 dirtied_when=4294676491 age=1482 state=____ type=REG name=/etc/ld.so.cache
zsh-3128 [000] 1482.623561: dump_page_cache: index=0 len=1 flags=___ARU_____ count=1 mapcount=0 memcg=1
zsh-3128 [000] 1482.623562: dump_page_cache: index=1 len=1 flags=_____U_____ count=1 mapcount=0 memcg=1
zsh-3128 [000] 1482.623569: dump_page_cache: index=2 len=15 flags=___ARU_____ count=1 mapcount=0 memcg=1
zsh-3128 [000] 1482.623585: dump_inode_cache: ino=1590258 size=241632 cached=241664 dirtied_when=4294676493 age=1482 state=____ type=REG name=/lib/libsepol.so.1
zsh-3128 [000] 1482.623591: dump_page_cache: index=0 len=5 flags=M__ARU_____ count=2 mapcount=1 memcg=1
zsh-3128 [000] 1482.623609: dump_page_cache: index=5 len=42 flags=_____U_____ count=1 mapcount=0 memcg=1
zsh-3128 [000] 1482.623610: dump_page_cache: index=47 len=1 flags=M__ARU_____ count=2 mapcount=1 memcg=1
patches:
dump-pfn interface
(it looks more clean and easier for review to fold patches 1-5 into one, but
let's keep the changelog for the initial post)
[RFC][PATCH 1/7] tracing/mm: add page frame snapshot trace
[RFC][PATCH 2/7] tracing/mm: rename trigger file to dump-pfn
[RFC][PATCH 3/7] tracing/mm: create trace_objects.c
[RFC][PATCH 4/7] tracing/mm: dump more page frame information
[RFC][PATCH 5/7] tracing/mm: accept echo-able input format for pfn range
dump-file and dump-fs interfaces
[RFC][PATCH 6/7] tracing/mm: add dump-file and dump-fs interfaces
add memcg support
[RFC][PATCH 7/7] tracing/mm: add memcg field
diffstat:
fs/inode.c | 8
fs/internal.h | 5
include/linux/fs.h | 1
include/linux/memcontrol.h | 6
include/linux/page-flags.h | 1
include/trace/events/mm.h | 170 ++++++++++++++
kernel/trace/Makefile | 2
kernel/trace/trace.h | 1
kernel/trace/trace_mm.c | 378 +++++++++++++++++++++++++++++++++
kernel/trace/trace_objects.c | 26 ++
mm/memcontrol.c | 18 +
mm/page_alloc.c | 4
12 files changed, 612 insertions(+), 8 deletions(-)
Thanks,
Fengguang
^ permalink raw reply [flat|nested] 3+ messages in thread* [RFC][PATCH 0/7] trace memory objects
@ 2011-08-29 3:29 Wu Fengguang
2011-08-29 3:59 ` Wu Fengguang
0 siblings, 1 reply; 3+ messages in thread
From: Wu Fengguang @ 2011-08-29 3:29 UTC (permalink / raw)
To: Andrew Morton, Ingo Molnar
Cc: Mel Gorman, Linux Memory Management List, Wu Fengguang, LKML
Andrew, Ingo,
I'd like to introduce three memory object interfaces
/debug/tracing/objects/mm/pages/dump-pfn
/debug/tracing/objects/mm/pages/dump-file
/debug/tracing/objects/mm/pages/dump-fs
for dumping
- a range of PFNs
- the cached inodes (icache)
- the cached inode pages (page cache)
The "dump-pfn" interface is a superset of the existing /proc/kpageflags and
/proc/kpagecount interfaces. Example output:
# echo 10000 +10 > /debug/tracing/objects/mm/pages/dump-pfn
# cat /debug/tracing/trace
# tracer: nop
#
# TASK-PID CPU# TIMESTAMP FUNCTION
# | | | | |
zsh-3128 [000] 1393.460292: dump_page_frame: pfn=10001 page=ffffea000009c400 count=1 mapcount=0 memcg=0 private=0 mapping=0 index=0 flags=reserved
zsh-3128 [000] 1393.460296: dump_page_frame: pfn=10002 page=ffffea000009c440 count=1 mapcount=0 memcg=0 private=0 mapping=0 index=0 flags=reserved
zsh-3128 [000] 1393.460298: dump_page_frame: pfn=10003 page=ffffea000009c480 count=1 mapcount=0 memcg=0 private=0 mapping=0 index=0 flags=reserved
zsh-3128 [000] 1393.460299: dump_page_frame: pfn=10004 page=ffffea000009c4c0 count=1 mapcount=0 memcg=0 private=0 mapping=0 index=0 flags=reserved
zsh-3128 [000] 1393.460300: dump_page_frame: pfn=10005 page=ffffea000009c500 count=1 mapcount=0 memcg=0 private=0 mapping=0 index=0 flags=reserved
zsh-3128 [000] 1393.460301: dump_page_frame: pfn=10006 page=ffffea000009c540 count=1 mapcount=0 memcg=0 private=0 mapping=0 index=0 flags=reserved
zsh-3128 [000] 1393.460301: dump_page_frame: pfn=10007 page=ffffea000009c580 count=1 mapcount=0 memcg=0 private=0 mapping=0 index=0 flags=reserved
zsh-3128 [000] 1393.460302: dump_page_frame: pfn=10008 page=ffffea000009c5c0 count=1 mapcount=0 memcg=0 private=0 mapping=0 index=0 flags=reserved
zsh-3128 [000] 1393.460303: dump_page_frame: pfn=10009 page=ffffea000009c600 count=1 mapcount=0 memcg=0 private=0 mapping=0 index=0 flags=reserved
zsh-3128 [000] 1393.460304: dump_page_frame: pfn=10010 page=ffffea000009c640 count=1 mapcount=0 memcg=0 private=0 mapping=0 index=0 flags=reserved
The "dump-file", "dump-fs" interfaces could be pretty useful for examining
the page cache status. Example output:
# echo > /debug/tracing/trace
# echo / > /debug/tracing/objects/mm/pages/dump-fs
# head -50 /debug/tracing/trace
# tracer: nop
#
# TASK-PID CPU# TIMESTAMP FUNCTION
# | | | | |
zsh-3128 [000] 1482.623149: dump_inode_cache: ino=1507329 size=4096 cached=4096 dirtied_when=4294676467 age=1482 state=____ type=DIR name=/
zsh-3128 [000] 1482.623157: dump_page_cache: index=0 len=1 flags=___ARU_____ count=1 mapcount=0 memcg=1
zsh-3128 [000] 1482.623340: dump_inode_cache: ino=1786836 size=12288 cached=12288 dirtied_when=4294676472 age=1482 state=____ type=DIR name=/sbin
zsh-3128 [000] 1482.623355: dump_page_cache: index=0 len=3 flags=___ARU_____ count=1 mapcount=0 memcg=1
zsh-3128 [000] 1482.623393: dump_inode_cache: ino=1786946 size=37312 cached=40960 dirtied_when=4294676473 age=1482 state=____ type=REG name=/sbin/init
zsh-3128 [000] 1482.623404: dump_page_cache: index=0 len=6 flags=M__ARU_____ count=2 mapcount=1 memcg=1
zsh-3128 [000] 1482.623405: dump_page_cache: index=6 len=1 flags=M__A_U_____ count=2 mapcount=1 memcg=1
zsh-3128 [000] 1482.623406: dump_page_cache: index=7 len=1 flags=M__ARU_____ count=2 mapcount=1 memcg=1
zsh-3128 [000] 1482.623408: dump_page_cache: index=8 len=2 flags=_____U_____ count=1 mapcount=0 memcg=1
zsh-3128 [000] 1482.623422: dump_inode_cache: ino=1507464 size=4 cached=4096 dirtied_when=4294676477 age=1482 state=____ type=LNK name=/lib64
zsh-3128 [000] 1482.623427: dump_page_cache: index=0 len=1 flags=___ARU_____ count=1 mapcount=0 memcg=1
zsh-3128 [000] 1482.623441: dump_inode_cache: ino=1590173 size=12288 cached=0 dirtied_when=4294676477 age=1482 state=____ type=DIR name=/lib
zsh-3128 [000] 1482.623458: dump_inode_cache: ino=1590265 size=27 cached=4096 dirtied_when=4294676478 age=1482 state=____ type=LNK name=/lib/ld-linux-x86-64.so.2
zsh-3128 [000] 1482.623462: dump_page_cache: index=0 len=1 flags=___ARU_____ count=1 mapcount=0 memcg=1
zsh-3128 [000] 1482.623478: dump_inode_cache: ino=1663440 size=4096 cached=0 dirtied_when=4294676479 age=1482 state=____ type=DIR name=/lib/x86_64-linux-gnu
zsh-3128 [000] 1482.623495: dump_inode_cache: ino=3293287 size=136936 cached=139264 dirtied_when=4294676480 age=1482 state=____ type=REG name=/lib/x86_64-linux-gnu/ld-2.13.so
zsh-3128 [000] 1482.623499: dump_page_cache: index=0 len=1 flags=M__ARU_____ count=28 mapcount=27 memcg=1
zsh-3128 [000] 1482.623501: dump_page_cache: index=1 len=3 flags=M__ARU_____ count=23 mapcount=22 memcg=1
zsh-3128 [000] 1482.623503: dump_page_cache: index=4 len=4 flags=M__ARU_____ count=26 mapcount=25 memcg=1
zsh-3128 [000] 1482.623504: dump_page_cache: index=8 len=2 flags=M__ARU_____ count=34 mapcount=33 memcg=1
zsh-3128 [000] 1482.623506: dump_page_cache: index=10 len=3 flags=M__ARU_____ count=26 mapcount=25 memcg=1
zsh-3128 [000] 1482.623508: dump_page_cache: index=13 len=1 flags=M__ARU_____ count=34 mapcount=33 memcg=1
zsh-3128 [000] 1482.623509: dump_page_cache: index=14 len=1 flags=M__ARU_____ count=33 mapcount=32 memcg=1
zsh-3128 [000] 1482.623510: dump_page_cache: index=15 len=1 flags=M__ARU_____ count=26 mapcount=25 memcg=1
zsh-3128 [000] 1482.623511: dump_page_cache: index=16 len=1 flags=M__ARU_____ count=25 mapcount=24 memcg=1
zsh-3128 [000] 1482.623512: dump_page_cache: index=17 len=1 flags=M__ARU_____ count=26 mapcount=25 memcg=1
zsh-3128 [000] 1482.623513: dump_page_cache: index=18 len=1 flags=M__ARU_____ count=10 mapcount=9 memcg=1
zsh-3128 [000] 1482.623514: dump_page_cache: index=19 len=1 flags=M__ARU_____ count=34 mapcount=33 memcg=1
zsh-3128 [000] 1482.623515: dump_page_cache: index=20 len=1 flags=M__ARU_____ count=23 mapcount=22 memcg=1
zsh-3128 [000] 1482.623516: dump_page_cache: index=21 len=1 flags=M__ARU_____ count=26 mapcount=25 memcg=1
zsh-3128 [000] 1482.623517: dump_page_cache: index=22 len=1 flags=M__ARU_____ count=34 mapcount=33 memcg=1
zsh-3128 [000] 1482.623518: dump_page_cache: index=23 len=2 flags=M__ARU_____ count=26 mapcount=25 memcg=1
zsh-3128 [000] 1482.623519: dump_page_cache: index=25 len=1 flags=M__ARU_____ count=33 mapcount=32 memcg=1
zsh-3128 [000] 1482.623520: dump_page_cache: index=26 len=1 flags=M__ARU_____ count=10 mapcount=9 memcg=1
zsh-3128 [000] 1482.623522: dump_page_cache: index=27 len=1 flags=M__ARU_____ count=4 mapcount=3 memcg=1
zsh-3128 [000] 1482.623523: dump_page_cache: index=28 len=1 flags=M__ARU_____ count=26 mapcount=25 memcg=1
zsh-3128 [000] 1482.623525: dump_page_cache: index=29 len=5 flags=_____U_____ count=1 mapcount=0 memcg=1
zsh-3128 [000] 1482.623540: dump_inode_cache: ino=1525477 size=12288 cached=0 dirtied_when=4294676489 age=1482 state=____ type=DIR name=/etc
zsh-3128 [000] 1482.623556: dump_inode_cache: ino=1526474 size=69589 cached=69632 dirtied_when=4294676491 age=1482 state=____ type=REG name=/etc/ld.so.cache
zsh-3128 [000] 1482.623561: dump_page_cache: index=0 len=1 flags=___ARU_____ count=1 mapcount=0 memcg=1
zsh-3128 [000] 1482.623562: dump_page_cache: index=1 len=1 flags=_____U_____ count=1 mapcount=0 memcg=1
zsh-3128 [000] 1482.623569: dump_page_cache: index=2 len=15 flags=___ARU_____ count=1 mapcount=0 memcg=1
zsh-3128 [000] 1482.623585: dump_inode_cache: ino=1590258 size=241632 cached=241664 dirtied_when=4294676493 age=1482 state=____ type=REG name=/lib/libsepol.so.1
zsh-3128 [000] 1482.623591: dump_page_cache: index=0 len=5 flags=M__ARU_____ count=2 mapcount=1 memcg=1
zsh-3128 [000] 1482.623609: dump_page_cache: index=5 len=42 flags=_____U_____ count=1 mapcount=0 memcg=1
zsh-3128 [000] 1482.623610: dump_page_cache: index=47 len=1 flags=M__ARU_____ count=2 mapcount=1 memcg=1
patches:
dump-pfn interface
(it looks more clean and easier for review to fold patches 1-5 into one, but
let's keep the changelog for the initial post)
[RFC][PATCH 1/7] tracing/mm: add page frame snapshot trace
[RFC][PATCH 2/7] tracing/mm: rename trigger file to dump-pfn
[RFC][PATCH 3/7] tracing/mm: create trace_objects.c
[RFC][PATCH 4/7] tracing/mm: dump more page frame information
[RFC][PATCH 5/7] tracing/mm: accept echo-able input format for pfn range
dump-file and dump-fs interfaces
[RFC][PATCH 6/7] tracing/mm: add dump-file and dump-fs interfaces
add memcg support
[RFC][PATCH 7/7] tracing/mm: add memcg field
diffstat:
fs/inode.c | 8
fs/internal.h | 5
include/linux/fs.h | 1
include/linux/memcontrol.h | 6
include/linux/page-flags.h | 1
include/trace/events/mm.h | 170 ++++++++++++++
kernel/trace/Makefile | 2
kernel/trace/trace.h | 1
kernel/trace/trace_mm.c | 378 +++++++++++++++++++++++++++++++++
kernel/trace/trace_objects.c | 26 ++
mm/memcontrol.c | 18 +
mm/page_alloc.c | 4
12 files changed, 612 insertions(+), 8 deletions(-)
Thanks,
Fengguang
--
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>
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [RFC][PATCH 0/7] trace memory objects 2011-08-29 3:29 Wu Fengguang @ 2011-08-29 3:59 ` Wu Fengguang 0 siblings, 0 replies; 3+ messages in thread From: Wu Fengguang @ 2011-08-29 3:59 UTC (permalink / raw) To: Andrew Morton, Ingo Molnar; +Cc: Mel Gorman, Linux Memory Management List, LKML > dump-pfn interface > (it looks more clean and easier for review to fold patches 1-5 into one, but > let's keep the changelog for the initial post) > > [RFC][PATCH 1/7] tracing/mm: add page frame snapshot trace > [RFC][PATCH 2/7] tracing/mm: rename trigger file to dump-pfn > [RFC][PATCH 3/7] tracing/mm: create trace_objects.c > [RFC][PATCH 4/7] tracing/mm: dump more page frame information > [RFC][PATCH 5/7] tracing/mm: accept echo-able input format for pfn range For your convenience, here is the combined diff for the above 5 incremental ones. --- /dev/null 1970-01-01 00:00:00.000000000 +0000 +++ linux-mmotm/include/trace/events/mm.h 2011-08-29 11:57:16.000000000 +0800 @@ -0,0 +1,69 @@ +#if !defined(_TRACE_MM_H) || defined(TRACE_HEADER_MULTI_READ) +#define _TRACE_MM_H + +#include <linux/tracepoint.h> +#include <linux/page-flags.h> +#include <linux/mm.h> + +#undef TRACE_SYSTEM +#define TRACE_SYSTEM mm + +extern struct trace_print_flags pageflag_names[]; + +/** + * dump_page_frame - called by the trace page dump trigger + * @pfn: page frame number + * @page: pointer to the page frame + * + * This is a helper trace point into the dumping of the page frames. + * It will record various infromation about a page frame. + */ +TRACE_EVENT(dump_page_frame, + + TP_PROTO(unsigned long pfn, struct page *page), + + TP_ARGS(pfn, page), + + TP_STRUCT__entry( + __field( unsigned long, pfn ) + __field( struct page *, page ) + __field( u64, stable_flags ) + __field( unsigned long, flags ) + __field( unsigned int, count ) + __field( unsigned int, mapcount ) + __field( unsigned long, private ) + __field( unsigned long, mapping ) + __field( unsigned long, index ) + ), + + TP_fast_assign( + __entry->pfn = pfn; + __entry->page = page; + __entry->stable_flags = stable_page_flags(page); + __entry->flags = page->flags; + __entry->count = atomic_read(&page->_count); + __entry->mapcount = page_mapcount(page); + __entry->private = page->private; + __entry->mapping = (unsigned long)page->mapping; + __entry->index = page->index; + ), + + TP_printk("pfn=%lu page=%p count=%u mapcount=%u " + "private=%lx mapping=%lx index=%lx flags=%s", + __entry->pfn, + __entry->page, + __entry->count, + __entry->mapcount, + __entry->private, + __entry->mapping, + __entry->index, + ftrace_print_flags_seq(p, "|", + __entry->flags & PAGE_FLAGS_MASK, + pageflag_names) + ) +); + +#endif /* _TRACE_MM_H */ + +/* This part must be outside protection */ +#include <trace/define_trace.h> --- linux-mmotm.orig/kernel/trace/Makefile 2011-08-28 10:09:25.000000000 +0800 +++ linux-mmotm/kernel/trace/Makefile 2011-08-28 10:09:28.000000000 +0800 @@ -26,6 +26,7 @@ obj-$(CONFIG_RING_BUFFER) += ring_buffer obj-$(CONFIG_RING_BUFFER_BENCHMARK) += ring_buffer_benchmark.o obj-$(CONFIG_TRACING) += trace.o +obj-$(CONFIG_TRACING) += trace_objects.o obj-$(CONFIG_TRACING) += trace_output.o obj-$(CONFIG_TRACING) += trace_stat.o obj-$(CONFIG_TRACING) += trace_printk.o @@ -53,6 +54,7 @@ endif obj-$(CONFIG_EVENT_TRACING) += trace_events_filter.o obj-$(CONFIG_KPROBE_EVENT) += trace_kprobe.o obj-$(CONFIG_TRACEPOINTS) += power-traces.o +obj-$(CONFIG_EVENT_TRACING) += trace_mm.o ifeq ($(CONFIG_TRACING),y) obj-$(CONFIG_KGDB_KDB) += trace_kdb.o endif --- /dev/null 1970-01-01 00:00:00.000000000 +0000 +++ linux-mmotm/kernel/trace/trace_mm.c 2011-08-29 11:57:16.000000000 +0800 @@ -0,0 +1,150 @@ +/* + * Trace mm pages + * + * Copyright (C) 2009 Red Hat Inc, Steven Rostedt <srostedt@redhat.com> + * + * Code based on Matt Mackall's /proc/[kpagecount|kpageflags] code. + */ +#include <linux/module.h> +#include <linux/bootmem.h> +#include <linux/debugfs.h> +#include <linux/uaccess.h> + +#include "trace_output.h" + +#define CREATE_TRACE_POINTS +#include <trace/events/mm.h> + +void trace_mm_page_frames(unsigned long start, unsigned long end, + void (*trace)(unsigned long pfn, struct page *page)) +{ + unsigned long pfn = start; + struct page *page; + + if (start > max_pfn - 1) + return; + + if (end > max_pfn - 1) + end = max_pfn - 1; + + while (pfn < end) { + page = NULL; + if (pfn_valid(pfn)) + page = pfn_to_page(pfn); + pfn++; + if (page) + trace(pfn, page); + } +} + +static void trace_mm_page_frame(unsigned long pfn, struct page *page) +{ + trace_dump_page_frame(pfn, page); +} + +static ssize_t +trace_mm_pfn_range_read(struct file *filp, char __user *ubuf, size_t cnt, + loff_t *ppos) +{ + return simple_read_from_buffer(ubuf, cnt, ppos, "0\n", 2); +} + + +static ssize_t +trace_mm_pfn_range_write(struct file *filp, const char __user *ubuf, size_t cnt, + loff_t *ppos) +{ + unsigned long val, start, end; + char buf[64]; + int ret; + + if (cnt >= sizeof(buf)) + return -EINVAL; + + if (copy_from_user(&buf, ubuf, cnt)) + return -EFAULT; + + if (tracing_update_buffers() < 0) + return -ENOMEM; + + if (trace_set_clr_event("mm", "dump_page_frame", 1)) + return -EINVAL; + + buf[cnt] = 0; + + ret = strict_strtol(buf, 10, &val); + if (ret < 0) + return ret; + + start = *ppos; + if (val < 0) + end = max_pfn - 1; + else + end = start + val; + + trace_mm_page_frames(start, end, trace_mm_page_frame); + + *ppos += cnt; + + return cnt; +} + +static const struct file_operations trace_mm_fops = { + .open = tracing_open_generic, + .read = trace_mm_pfn_range_read, + .write = trace_mm_pfn_range_write, +}; + +static struct dentry *trace_objects_mm_dir(void) +{ + static struct dentry *d_mm; + struct dentry *d_objects; + + if (d_mm) + return d_mm; + + d_objects = trace_objects_dir(); + if (!d_objects) + return NULL; + + d_mm = debugfs_create_dir("mm", d_objects); + if (!d_mm) + pr_warning("Could not create 'objects/mm' directory\n"); + + return d_mm; +} + +static struct dentry *trace_objects_mm_pages_dir(void) +{ + static struct dentry *d_pages; + struct dentry *d_mm; + + if (d_pages) + return d_pages; + + d_mm = trace_objects_mm_dir(); + if (!d_mm) + return NULL; + + d_pages = debugfs_create_dir("pages", d_mm); + if (!d_pages) + pr_warning("Could not create debugfs " + "'objects/mm/pages' directory\n"); + + return d_pages; +} + +static __init int trace_objects_mm_init(void) +{ + struct dentry *d_pages; + + d_pages = trace_objects_mm_pages_dir(); + if (!d_pages) + return 0; + + trace_create_file("dump-pfn", 0600, d_pages, NULL, + &trace_mm_fops); + + return 0; +} +fs_initcall(trace_objects_mm_init); --- linux-mmotm.orig/kernel/trace/trace.h 2011-08-28 10:09:25.000000000 +0800 +++ linux-mmotm/kernel/trace/trace.h 2011-08-28 10:09:28.000000000 +0800 @@ -318,6 +318,7 @@ struct dentry *trace_create_file(const c const struct file_operations *fops); struct dentry *tracing_init_dentry(void); +struct dentry *trace_objects_dir(void); struct ring_buffer_event; --- /dev/null 1970-01-01 00:00:00.000000000 +0000 +++ linux-mmotm/kernel/trace/trace_objects.c 2011-08-28 10:09:28.000000000 +0800 @@ -0,0 +1,26 @@ +#include <linux/debugfs.h> + +#include "trace.h" +#include "trace_output.h" + +struct dentry *trace_objects_dir(void) +{ + static struct dentry *d_objects; + struct dentry *d_tracer; + + if (d_objects) + return d_objects; + + d_tracer = tracing_init_dentry(); + if (!d_tracer) + return NULL; + + d_objects = debugfs_create_dir("objects", d_tracer); + if (!d_objects) + pr_warning("Could not create debugfs " + "'objects' directory\n"); + + return d_objects; +} + + --- linux-mmotm.orig/mm/page_alloc.c 2011-08-29 10:43:01.000000000 +0800 +++ linux-mmotm/mm/page_alloc.c 2011-08-29 10:43:03.000000000 +0800 @@ -5743,7 +5743,7 @@ bool is_free_buddy_page(struct page *pag } #endif -static struct trace_print_flags pageflag_names[] = { +struct trace_print_flags pageflag_names[] = { {1UL << PG_locked, "locked" }, {1UL << PG_error, "error" }, {1UL << PG_referenced, "referenced" }, @@ -5790,7 +5790,7 @@ static void dump_page_flags(unsigned lon printk(KERN_ALERT "page flags: %#lx(", flags); /* remove zone id */ - flags &= (1UL << NR_PAGEFLAGS) - 1; + flags &= PAGE_FLAGS_MASK; for (i = 0; pageflag_names[i].name && flags; i++) { --- linux-mmotm.orig/include/linux/page-flags.h 2011-08-29 10:43:01.000000000 +0800 +++ linux-mmotm/include/linux/page-flags.h 2011-08-29 10:43:03.000000000 +0800 @@ -462,6 +462,7 @@ static inline int PageTransCompound(stru * there has been a kernel bug or struct page corruption. */ #define PAGE_FLAGS_CHECK_AT_PREP ((1 << NR_PAGEFLAGS) - 1) +#define PAGE_FLAGS_MASK ((1 << NR_PAGEFLAGS) - 1) #define PAGE_FLAGS_PRIVATE \ (1 << PG_private | 1 << PG_private_2) -- 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> ^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2011-08-29 3:59 UTC | newest] Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2011-08-29 3:29 [RFC][PATCH 0/7] trace memory objects Wu Fengguang 2011-08-29 3:29 Wu Fengguang 2011-08-29 3:59 ` Wu Fengguang
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox