2 * ltt/probes/mm-trace.c
4 * MM tracepoint probes.
6 * (C) Copyright 2009 - Mathieu Desnoyers <mathieu.desnoyers@polymtl.ca>
7 * Dual LGPL v2.1/GPL v2 license.
10 #include <linux/module.h>
12 #include <linux/swap.h>
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>
22 #include "../ltt-type-serializer.h"
24 void probe_wait_on_page_start(void *_data
, struct page
*page
, int bit_nr
)
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
);
31 void probe_wait_on_page_end(void *_data
, struct page
*page
, int bit_nr
)
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
);
38 void probe_hugetlb_page_free(void *_data
, struct page
*page
)
40 trace_mark_tp(mm
, huge_page_free
, hugetlb_page_free
,
41 probe_hugetlb_page_free
, "pfn %lu", page_to_pfn(page
));
44 void probe_hugetlb_page_alloc(void *_data
, struct page
*page
)
47 trace_mark_tp(mm
, huge_page_alloc
, hugetlb_page_alloc
,
48 probe_hugetlb_page_alloc
, "pfn %lu", page_to_pfn(page
));
51 /* mm_page_free specialized tracepoint probe */
53 void probe_page_free(void *_data
, struct page
*page
, unsigned int order
);
55 DEFINE_MARKER_TP(mm
, page_free
, page_free
, probe_page_free
,
58 notrace
void probe_page_free(void *_data
, struct page
*page
, unsigned int order
)
60 struct marker
*marker
;
61 struct serialize_long_int data
;
63 data
.f1
= page_to_pfn(page
);
66 marker
= &GET_MARKER(mm
, page_free
);
67 ltt_specialized_trace(marker
, marker
->single
.probe_private
,
68 &data
, serialize_sizeof(data
), sizeof(long));
71 /* mm_page_alloc specialized tracepoint probe */
73 void probe_page_alloc(void *_data
, struct page
*page
, unsigned int order
);
75 DEFINE_MARKER_TP(mm
, page_alloc
, page_alloc
, probe_page_alloc
,
78 notrace
void probe_page_alloc(void *_data
, struct page
*page
, unsigned int order
)
80 struct marker
*marker
;
81 struct serialize_long_int data
;
86 data
.f1
= page_to_pfn(page
);
89 marker
= &GET_MARKER(mm
, page_alloc
);
90 ltt_specialized_trace(marker
, marker
->single
.probe_private
,
91 &data
, serialize_sizeof(data
), sizeof(long));
95 void probe_swap_in(void *_data
, struct page
*page
, swp_entry_t entry
)
97 trace_mark_tp(mm
, swap_in
, swap_in
, probe_swap_in
,
98 "pfn %lu filp %p offset %lu",
100 get_swap_info_struct(swp_type(entry
))->swap_file
,
104 void probe_swap_out(void *_data
, struct page
*page
)
106 trace_mark_tp(mm
, swap_out
, swap_out
, probe_swap_out
,
107 "pfn %lu filp %p offset %lu",
109 get_swap_info_struct(swp_type(
110 page_swp_entry(page
)))->swap_file
,
111 swp_offset(page_swp_entry(page
)));
114 void probe_swap_file_close(void *_data
, struct file
*file
)
116 trace_mark_tp(mm
, swap_file_close
, swap_file_close
,
117 probe_swap_file_close
, "filp %p", file
);
120 void probe_swap_file_open(void *_data
, struct file
*file
, char *filename
)
122 trace_mark_tp(mm
, swap_file_open
, swap_file_open
,
123 probe_swap_file_open
, "filp %p filename %s",
128 void probe_add_to_page_cache(void *_data
, struct address_space
*mapping
, pgoff_t offset
)
130 trace_mark_tp(mm
, add_to_page_cache
, add_to_page_cache
,
131 probe_add_to_page_cache
,
133 mapping
->host
->i_ino
, mapping
->host
->i_sb
->s_dev
);
136 void probe_remove_from_page_cache(void *_data
, struct address_space
*mapping
)
138 trace_mark_tp(mm
, remove_from_page_cache
, remove_from_page_cache
,
139 probe_remove_from_page_cache
,
141 mapping
->host
->i_ino
, mapping
->host
->i_sb
->s_dev
);
144 MODULE_LICENSE("GPL and additional rights");
145 MODULE_AUTHOR("Mathieu Desnoyers");
146 MODULE_DESCRIPTION("MM Tracepoint Probes");