linux/include/trace/events
Joonsoo Kim 95813b8faa mm/page_ref: add tracepoint to track down page reference manipulation
CMA allocation should be guaranteed to succeed by definition, but,
unfortunately, it would be failed sometimes.  It is hard to track down
the problem, because it is related to page reference manipulation and we
don't have any facility to analyze it.

This patch adds tracepoints to track down page reference manipulation.
With it, we can find exact reason of failure and can fix the problem.
Following is an example of tracepoint output.  (note: this example is
stale version that printing flags as the number.  Recent version will
print it as human readable string.)

<...>-9018  [004]    92.678375: page_ref_set:         pfn=0x17ac9 flags=0x0 count=1 mapcount=0 mapping=(nil) mt=4 val=1
<...>-9018  [004]    92.678378: kernel_stack:
 => get_page_from_freelist (ffffffff81176659)
 => __alloc_pages_nodemask (ffffffff81176d22)
 => alloc_pages_vma (ffffffff811bf675)
 => handle_mm_fault (ffffffff8119e693)
 => __do_page_fault (ffffffff810631ea)
 => trace_do_page_fault (ffffffff81063543)
 => do_async_page_fault (ffffffff8105c40a)
 => async_page_fault (ffffffff817581d8)
[snip]
<...>-9018  [004]    92.678379: page_ref_mod:         pfn=0x17ac9 flags=0x40048 count=2 mapcount=1 mapping=0xffff880015a78dc1 mt=4 val=1
[snip]
...
...
<...>-9131  [001]    93.174468: test_pages_isolated:  start_pfn=0x17800 end_pfn=0x17c00 fin_pfn=0x17ac9 ret=fail
[snip]
<...>-9018  [004]    93.174843: page_ref_mod_and_test: pfn=0x17ac9 flags=0x40068 count=0 mapcount=0 mapping=0xffff880015a78dc1 mt=4 val=-1 ret=1
 => release_pages (ffffffff8117c9e4)
 => free_pages_and_swap_cache (ffffffff811b0697)
 => tlb_flush_mmu_free (ffffffff81199616)
 => tlb_finish_mmu (ffffffff8119a62c)
 => exit_mmap (ffffffff811a53f7)
 => mmput (ffffffff81073f47)
 => do_exit (ffffffff810794e9)
 => do_group_exit (ffffffff81079def)
 => SyS_exit_group (ffffffff81079e74)
 => entry_SYSCALL_64_fastpath (ffffffff817560b6)

This output shows that problem comes from exit path.  In exit path, to
improve performance, pages are not freed immediately.  They are gathered
and processed by batch.  During this process, migration cannot be
possible and CMA allocation is failed.  This problem is hard to find
without this page reference tracepoint facility.

Enabling this feature bloat kernel text 30 KB in my configuration.

   text    data     bss     dec     hex filename
12127327        2243616 1507328 15878271         f2487f vmlinux_disabled
12157208        2258880 1507328 15923416         f2f8d8 vmlinux_enabled

Note that, due to header file dependency problem between mm.h and
tracepoint.h, this feature has to open code the static key functions for
tracepoints.  Proposed by Steven Rostedt in following link.

https://lkml.org/lkml/2015/12/9/699

[arnd@arndb.de: crypto/async_pq: use __free_page() instead of put_page()]
[iamjoonsoo.kim@lge.com: fix build failure for xtensa]
[akpm@linux-foundation.org: tweak Kconfig text, per Vlastimil]
Signed-off-by: Joonsoo Kim <iamjoonsoo.kim@lge.com>
Acked-by: Michal Nazarewicz <mina86@mina86.com>
Acked-by: Vlastimil Babka <vbabka@suse.cz>
Cc: Minchan Kim <minchan@kernel.org>
Cc: Mel Gorman <mgorman@techsingularity.net>
Cc: "Kirill A. Shutemov" <kirill.shutemov@linux.intel.com>
Cc: Sergey Senozhatsky <sergey.senozhatsky.work@gmail.com>
Acked-by: Steven Rostedt <rostedt@goodmis.org>
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2016-03-17 15:09:34 -07:00
..
9p.h net/9p/tracing: Export enums in tracepoints to userspace 2015-04-08 09:39:59 -04:00
asoc.h ASoC: trace: fix printing jack name 2016-02-26 10:52:48 +09:00
bcache.h bcache: fix crash in bcache_btree_node_alloc_fail tracepoint 2014-08-04 15:23:03 -07:00
block.h blktrace: fix accounting of partially completed requests 2014-03-05 16:11:21 -07:00
btrfs.h mm, tracing: unify mm flags handling in tracepoints and printk 2016-03-15 16:55:16 -07:00
clk.h clk: Add tracepoints for hardware operations 2015-03-12 12:18:51 -07:00
cma.h mm: cma: add trace events for CMA allocations and freeings 2015-04-15 16:35:19 -07:00
compaction.h mm, compaction: introduce kcompactd 2016-03-17 15:09:34 -07:00
context_tracking.h context_tracking: User/kernel broundary cross trace events 2013-08-14 17:14:48 +02:00
cpuhp.h cpu/hotplug: Add tracepoints 2016-03-01 20:36:54 +01:00
ext4.h ext4: implement allocation of pre-zeroed blocks 2015-12-07 15:10:26 -05:00
f2fs.h f2fs: add a tracepoint for sync_dirty_inodes 2015-12-17 09:55:27 -08:00
fence.h tracing/dma-buf/fence: Fix timeline str value on fence_annotate_wait_on 2016-01-25 11:03:17 -05:00
fib6.h net: IPv6 fib lookup tracepoint 2015-11-22 11:54:10 -05:00
fib.h net: Make table id type u32 2015-09-01 14:32:44 -07:00
filelock.h locks: sprinkle some tracepoints around the file locking code 2016-01-08 11:38:13 -05:00
filemap.h tracing, mm: Record pfn instead of pointer to struct page 2015-04-13 11:44:52 -03:00
gpio.h tracing: gpio: Add Kconfig option for enabling/disabling trace events 2015-10-20 21:56:10 -04:00
host1x.h gpu: host1x: Use struct host1x_bo pointers in traces 2014-11-13 16:11:32 +01:00
hswadsp.h Merge remote-tracking branches 'asoc/topic/ml26124', 'asoc/topic/of', 'asoc/topic/omap', 'asoc/topic/pxa' and 'asoc/topic/rcar' into asoc-next 2014-03-12 23:04:35 +00:00
huge_memory.h mm, tracing: unify mm flags handling in tracepoints and printk 2016-03-15 16:55:16 -07:00
i2c.h i2c: Add message transfer tracepoints for SMBUS [ver #2] 2014-03-13 22:15:07 +01:00
intel-sst.h tracing: Add TRACE_SYSTEM_VAR to intel-sst 2015-04-07 12:31:12 -04:00
iommu.h iommu: Change trace unmap api to report unmapped size 2015-01-19 15:19:31 +01:00
ipi.h tracepoint: add generic tracepoint definitions for IPI tracing 2014-08-07 20:40:40 -04:00
irq.h irq_poll: make blk-iopoll available outside the block layer 2015-12-11 11:52:24 -08:00
jbd2.h
kmem.h mm, tracing: unify mm flags handling in tracepoints and printk 2016-03-15 16:55:16 -07:00
kvm.h KVM: halt_polling: improve grow/shrink settings 2016-02-16 18:48:29 +01:00
libata.h libata: Add tracepoints 2015-03-27 11:59:22 -04:00
lock.h
mce.h
migrate.h mm: tracing: Export enums in tracepoints to user space 2015-04-08 09:40:01 -04:00
mmflags.h mm, tracing: refresh __def_vmaflag_names 2016-03-17 15:09:34 -07:00
module.h tracing: %pF is only for function pointers 2015-03-25 08:57:22 -04:00
napi.h
net.h net: rename vlan_tx_* helpers since "tx" is misleading there 2015-01-13 17:51:08 -05:00
nilfs2.h nilfs2: add tracepoints for analyzing reading and writing metadata files 2015-11-06 17:50:42 -08:00
nmi.h x86: Add NMI duration tracepoints 2013-06-23 11:52:58 +02:00
oom.h
page_isolation.h mm/page_isolation.c: add new tracepoint, test_pages_isolated 2016-01-14 16:00:49 -08:00
page_ref.h mm/page_ref: add tracepoint to track down page reference manipulation 2016-03-17 15:09:34 -07:00
pagemap.h mm: pagemap: avoid unnecessary overhead when tracepoints are deactivated 2014-08-06 18:01:20 -07:00
power_cpu_migrate.h ARM: bL_switcher/trace: Add trace trigger for trace bootstrapping 2013-09-23 18:47:30 -04:00
power.h cpufreq: powernv/tracing: Add powernv_throttle tracepoint 2016-02-05 02:38:02 +01:00
printk.h
random.h tracing: %pF is only for function pointers 2015-03-25 08:57:22 -04:00
rcu.h rcu: Apply rcu_seq operations to _rcu_barrier() 2015-07-17 14:58:57 -07:00
regulator.h
rpm.h
sched.h sched/core: Fix trace_sched_switch() 2015-10-06 17:08:15 +02:00
scsi.h scsi: rename SERVICE_ACTION_IN to SERVICE_ACTION_IN_16 2014-11-24 20:01:40 +01:00
signal.h
skb.h
sock.h
spi.h spi: Provide common spi_message processing loop 2013-10-11 20:09:50 +01:00
spmi.h spmi: add command tracepoints for SPMI 2015-08-05 12:27:09 -07:00
sunrpc.h net: sunrpc: fix tracepoint Warning: unknown op '->' 2015-08-31 16:32:15 -04:00
swiotlb.h tracing/events: Add bounce tracing to swiotbl 2013-10-02 12:53:26 -04:00
syscalls.h tracepoint: Fix sparse warnings in tracepoint.c 2014-04-09 10:12:11 -04:00
target.h target: Minimize SCSI header #include directives 2015-06-02 08:03:25 -07:00
task.h tracing: Don't make assumptions about length of string on task rename 2015-08-31 10:47:14 -04:00
thermal_power_allocator.h thermal: consistently use int for temperatures 2015-08-03 23:15:50 +08:00
thermal.h devfreq_cooling: add trace information 2015-10-30 10:41:38 -07:00
thp.h powerpc/thp: Add tracepoints to track hugepage invalidate 2014-08-13 18:20:42 +10:00
timer.h nohz: Use enum code for tick stop failure tracing message 2016-03-02 16:42:15 +01:00
tlb.h x86, mm: trace when an IPI is about to be sent 2015-09-04 16:54:41 -07:00
udp.h
v4l2.h [media] media: videobuf2: Move timestamp to vb2_buffer 2015-12-18 13:53:31 -02:00
vb2.h [media] media: videobuf2: Move timestamp to vb2_buffer 2015-12-18 13:53:31 -02:00
vmscan.h mm, tracing: unify mm flags handling in tracepoints and printk 2016-03-15 16:55:16 -07:00
workqueue.h
writeback.h writeback: update writeback tracepoints to report cgroup 2015-08-18 15:49:15 -07:00
xen.h x86: expose number of page table levels on Kconfig level 2015-04-14 16:49:02 -07:00