Commit | Line | Data |
---|---|---|
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 | ||
24 | void 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 | ||
31 | void 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 | ||
38 | void 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 | ||
44 | void 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 | ||
53 | void probe_page_free(void *_data, struct page *page, unsigned int order); | |
54 | ||
55 | DEFINE_MARKER_TP(mm, page_free, page_free, probe_page_free, | |
56 | "pfn %lu order %u"); | |
57 | ||
58 | notrace 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 | ||
73 | void probe_page_alloc(void *_data, struct page *page, unsigned int order); | |
74 | ||
75 | DEFINE_MARKER_TP(mm, page_alloc, page_alloc, probe_page_alloc, | |
76 | "pfn %lu order %u"); | |
77 | ||
78 | notrace 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 | |
95 | void 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 | ||
104 | void 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 | ||
114 | void 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 | ||
120 | void 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 | ||
128 | void 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 | ||
136 | void 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 | ||
144 | MODULE_LICENSE("GPL and additional rights"); | |
145 | MODULE_AUTHOR("Mathieu Desnoyers"); | |
146 | MODULE_DESCRIPTION("MM Tracepoint Probes"); |