LTTng modularization, import of lttng 0.226
[lttng-modules.git] / probes / mm-trace.c
CommitLineData
1c8284eb
MD
1/*
2 * ltt/probes/mm-trace.c
3 *
4 * MM tracepoint probes.
5 *
6 * (C) Copyright 2009 - Mathieu Desnoyers <mathieu.desnoyers@polymtl.ca>
7 * Dual LGPL v2.1/GPL v2 license.
8 */
9
10#include <linux/module.h>
11#include <linux/mm.h>
12#include <linux/swap.h>
13
14#include <asm/pgtable.h>
15#include <asm/tlbflush.h>
16#include <linux/swapops.h>
17#include <trace/page_alloc.h>
18#include <trace/filemap.h>
19#include <trace/swap.h>
20#include <trace/hugetlb.h>
21
22#include "../ltt-type-serializer.h"
23
24void probe_wait_on_page_start(void *_data, struct page *page, int bit_nr)
25{
26 trace_mark_tp(mm, wait_on_page_start, wait_on_page_start,
27 probe_wait_on_page_start, "pfn %lu bit_nr %d",
28 page_to_pfn(page), bit_nr);
29}
30
31void probe_wait_on_page_end(void *_data, struct page *page, int bit_nr)
32{
33 trace_mark_tp(mm, wait_on_page_end, wait_on_page_end,
34 probe_wait_on_page_end, "pfn %lu bit_nr %d",
35 page_to_pfn(page), bit_nr);
36}
37
38void probe_hugetlb_page_free(void *_data, struct page *page)
39{
40 trace_mark_tp(mm, huge_page_free, hugetlb_page_free,
41 probe_hugetlb_page_free, "pfn %lu", page_to_pfn(page));
42}
43
44void probe_hugetlb_page_alloc(void *_data, struct page *page)
45{
46 if (page)
47 trace_mark_tp(mm, huge_page_alloc, hugetlb_page_alloc,
48 probe_hugetlb_page_alloc, "pfn %lu", page_to_pfn(page));
49}
50
51/* mm_page_free specialized tracepoint probe */
52
53void probe_page_free(void *_data, struct page *page, unsigned int order);
54
55DEFINE_MARKER_TP(mm, page_free, page_free, probe_page_free,
56 "pfn %lu order %u");
57
58notrace void probe_page_free(void *_data, struct page *page, unsigned int order)
59{
60 struct marker *marker;
61 struct serialize_long_int data;
62
63 data.f1 = page_to_pfn(page);
64 data.f2 = order;
65
66 marker = &GET_MARKER(mm, page_free);
67 ltt_specialized_trace(marker, marker->single.probe_private,
68 &data, serialize_sizeof(data), sizeof(long));
69}
70
71/* mm_page_alloc specialized tracepoint probe */
72
73void probe_page_alloc(void *_data, struct page *page, unsigned int order);
74
75DEFINE_MARKER_TP(mm, page_alloc, page_alloc, probe_page_alloc,
76 "pfn %lu order %u");
77
78notrace void probe_page_alloc(void *_data, struct page *page, unsigned int order)
79{
80 struct marker *marker;
81 struct serialize_long_int data;
82
83 if (unlikely(!page))
84 return;
85
86 data.f1 = page_to_pfn(page);
87 data.f2 = order;
88
89 marker = &GET_MARKER(mm, page_alloc);
90 ltt_specialized_trace(marker, marker->single.probe_private,
91 &data, serialize_sizeof(data), sizeof(long));
92}
93
94#ifdef CONFIG_SWAP
95void probe_swap_in(void *_data, struct page *page, swp_entry_t entry)
96{
97 trace_mark_tp(mm, swap_in, swap_in, probe_swap_in,
98 "pfn %lu filp %p offset %lu",
99 page_to_pfn(page),
100 get_swap_info_struct(swp_type(entry))->swap_file,
101 swp_offset(entry));
102}
103
104void probe_swap_out(void *_data, struct page *page)
105{
106 trace_mark_tp(mm, swap_out, swap_out, probe_swap_out,
107 "pfn %lu filp %p offset %lu",
108 page_to_pfn(page),
109 get_swap_info_struct(swp_type(
110 page_swp_entry(page)))->swap_file,
111 swp_offset(page_swp_entry(page)));
112}
113
114void probe_swap_file_close(void *_data, struct file *file)
115{
116 trace_mark_tp(mm, swap_file_close, swap_file_close,
117 probe_swap_file_close, "filp %p", file);
118}
119
120void probe_swap_file_open(void *_data, struct file *file, char *filename)
121{
122 trace_mark_tp(mm, swap_file_open, swap_file_open,
123 probe_swap_file_open, "filp %p filename %s",
124 file, filename);
125}
126#endif
127
128void probe_add_to_page_cache(void *_data, struct address_space *mapping, pgoff_t offset)
129{
130 trace_mark_tp(mm, add_to_page_cache, add_to_page_cache,
131 probe_add_to_page_cache,
132 "inode %lu sdev %u",
133 mapping->host->i_ino, mapping->host->i_sb->s_dev);
134}
135
136void probe_remove_from_page_cache(void *_data, struct address_space *mapping)
137{
138 trace_mark_tp(mm, remove_from_page_cache, remove_from_page_cache,
139 probe_remove_from_page_cache,
140 "inode %lu sdev %u",
141 mapping->host->i_ino, mapping->host->i_sb->s_dev);
142}
143
144MODULE_LICENSE("GPL and additional rights");
145MODULE_AUTHOR("Mathieu Desnoyers");
146MODULE_DESCRIPTION("MM Tracepoint Probes");
This page took 0.027933 seconds and 4 git commands to generate.