diff options
-rw-r--r-- | include/linux/ftrace_event.h | 7 | ||||
-rw-r--r-- | include/trace/ftrace.h | 16 | ||||
-rw-r--r-- | kernel/trace/trace.h | 1 | ||||
-rw-r--r-- | kernel/trace/trace_event_types.h | 4 | ||||
-rw-r--r-- | kernel/trace/trace_events.c | 3 | ||||
-rw-r--r-- | kernel/trace/trace_export.c | 29 |
6 files changed, 39 insertions, 21 deletions
diff --git a/include/linux/ftrace_event.h b/include/linux/ftrace_event.h index 46a27f2695a6..e61a7403f3d0 100644 --- a/include/linux/ftrace_event.h +++ b/include/linux/ftrace_event.h | |||
@@ -122,8 +122,9 @@ extern int filter_current_check_discard(struct ftrace_event_call *call, | |||
122 | struct ring_buffer_event *event); | 122 | struct ring_buffer_event *event); |
123 | 123 | ||
124 | extern int trace_define_field(struct ftrace_event_call *call, char *type, | 124 | extern int trace_define_field(struct ftrace_event_call *call, char *type, |
125 | char *name, int offset, int size); | 125 | char *name, int offset, int size, int is_signed); |
126 | 126 | ||
127 | #define is_signed_type(type) (((type)(-1)) < 0) | ||
127 | 128 | ||
128 | /* | 129 | /* |
129 | * The double __builtin_constant_p is because gcc will give us an error | 130 | * The double __builtin_constant_p is because gcc will give us an error |
@@ -144,10 +145,10 @@ do { \ | |||
144 | __trace_printk(ip, fmt, ##args); \ | 145 | __trace_printk(ip, fmt, ##args); \ |
145 | } while (0) | 146 | } while (0) |
146 | 147 | ||
147 | #define __common_field(type, item) \ | 148 | #define __common_field(type, item, is_signed) \ |
148 | ret = trace_define_field(event_call, #type, "common_" #item, \ | 149 | ret = trace_define_field(event_call, #type, "common_" #item, \ |
149 | offsetof(typeof(field.ent), item), \ | 150 | offsetof(typeof(field.ent), item), \ |
150 | sizeof(field.ent.item)); \ | 151 | sizeof(field.ent.item), is_signed); \ |
151 | if (ret) \ | 152 | if (ret) \ |
152 | return ret; | 153 | return ret; |
153 | 154 | ||
diff --git a/include/trace/ftrace.h b/include/trace/ftrace.h index 1e681142f1da..edb02bc9f8ff 100644 --- a/include/trace/ftrace.h +++ b/include/trace/ftrace.h | |||
@@ -225,7 +225,7 @@ ftrace_format_##call(struct trace_seq *s) \ | |||
225 | #define __field(type, item) \ | 225 | #define __field(type, item) \ |
226 | ret = trace_define_field(event_call, #type, #item, \ | 226 | ret = trace_define_field(event_call, #type, #item, \ |
227 | offsetof(typeof(field), item), \ | 227 | offsetof(typeof(field), item), \ |
228 | sizeof(field.item)); \ | 228 | sizeof(field.item), is_signed_type(type)); \ |
229 | if (ret) \ | 229 | if (ret) \ |
230 | return ret; | 230 | return ret; |
231 | 231 | ||
@@ -234,7 +234,7 @@ ftrace_format_##call(struct trace_seq *s) \ | |||
234 | BUILD_BUG_ON(len > MAX_FILTER_STR_VAL); \ | 234 | BUILD_BUG_ON(len > MAX_FILTER_STR_VAL); \ |
235 | ret = trace_define_field(event_call, #type "[" #len "]", #item, \ | 235 | ret = trace_define_field(event_call, #type "[" #len "]", #item, \ |
236 | offsetof(typeof(field), item), \ | 236 | offsetof(typeof(field), item), \ |
237 | sizeof(field.item)); \ | 237 | sizeof(field.item), 0); \ |
238 | if (ret) \ | 238 | if (ret) \ |
239 | return ret; | 239 | return ret; |
240 | 240 | ||
@@ -242,7 +242,7 @@ ftrace_format_##call(struct trace_seq *s) \ | |||
242 | #define __string(item, src) \ | 242 | #define __string(item, src) \ |
243 | ret = trace_define_field(event_call, "__str_loc", #item, \ | 243 | ret = trace_define_field(event_call, "__str_loc", #item, \ |
244 | offsetof(typeof(field), __str_loc_##item), \ | 244 | offsetof(typeof(field), __str_loc_##item), \ |
245 | sizeof(field.__str_loc_##item)); | 245 | sizeof(field.__str_loc_##item), 0); |
246 | 246 | ||
247 | #undef TRACE_EVENT | 247 | #undef TRACE_EVENT |
248 | #define TRACE_EVENT(call, proto, args, tstruct, func, print) \ | 248 | #define TRACE_EVENT(call, proto, args, tstruct, func, print) \ |
@@ -253,11 +253,11 @@ ftrace_define_fields_##call(void) \ | |||
253 | struct ftrace_event_call *event_call = &event_##call; \ | 253 | struct ftrace_event_call *event_call = &event_##call; \ |
254 | int ret; \ | 254 | int ret; \ |
255 | \ | 255 | \ |
256 | __common_field(int, type); \ | 256 | __common_field(int, type, 1); \ |
257 | __common_field(unsigned char, flags); \ | 257 | __common_field(unsigned char, flags, 0); \ |
258 | __common_field(unsigned char, preempt_count); \ | 258 | __common_field(unsigned char, preempt_count, 0); \ |
259 | __common_field(int, pid); \ | 259 | __common_field(int, pid, 1); \ |
260 | __common_field(int, tgid); \ | 260 | __common_field(int, tgid, 1); \ |
261 | \ | 261 | \ |
262 | tstruct; \ | 262 | tstruct; \ |
263 | \ | 263 | \ |
diff --git a/kernel/trace/trace.h b/kernel/trace/trace.h index 1fb7d6ccadf4..866d0108fd2f 100644 --- a/kernel/trace/trace.h +++ b/kernel/trace/trace.h | |||
@@ -729,6 +729,7 @@ struct ftrace_event_field { | |||
729 | char *type; | 729 | char *type; |
730 | int offset; | 730 | int offset; |
731 | int size; | 731 | int size; |
732 | int is_signed; | ||
732 | }; | 733 | }; |
733 | 734 | ||
734 | struct event_filter { | 735 | struct event_filter { |
diff --git a/kernel/trace/trace_event_types.h b/kernel/trace/trace_event_types.h index cfcecc4fd86d..5e32e375134d 100644 --- a/kernel/trace/trace_event_types.h +++ b/kernel/trace/trace_event_types.h | |||
@@ -141,8 +141,8 @@ TRACE_EVENT_FORMAT(hw_branch, TRACE_HW_BRANCHES, hw_branch_entry, ignore, | |||
141 | 141 | ||
142 | TRACE_EVENT_FORMAT(power, TRACE_POWER, trace_power, ignore, | 142 | TRACE_EVENT_FORMAT(power, TRACE_POWER, trace_power, ignore, |
143 | TRACE_STRUCT( | 143 | TRACE_STRUCT( |
144 | TRACE_FIELD(ktime_t, state_data.stamp, stamp) | 144 | TRACE_FIELD_SIGN(ktime_t, state_data.stamp, stamp, 1) |
145 | TRACE_FIELD(ktime_t, state_data.end, end) | 145 | TRACE_FIELD_SIGN(ktime_t, state_data.end, end, 1) |
146 | TRACE_FIELD(int, state_data.type, type) | 146 | TRACE_FIELD(int, state_data.type, type) |
147 | TRACE_FIELD(int, state_data.state, state) | 147 | TRACE_FIELD(int, state_data.state, state) |
148 | ), | 148 | ), |
diff --git a/kernel/trace/trace_events.c b/kernel/trace/trace_events.c index 1cd1f37373dd..bbbea7479371 100644 --- a/kernel/trace/trace_events.c +++ b/kernel/trace/trace_events.c | |||
@@ -26,7 +26,7 @@ static DEFINE_MUTEX(event_mutex); | |||
26 | LIST_HEAD(ftrace_events); | 26 | LIST_HEAD(ftrace_events); |
27 | 27 | ||
28 | int trace_define_field(struct ftrace_event_call *call, char *type, | 28 | int trace_define_field(struct ftrace_event_call *call, char *type, |
29 | char *name, int offset, int size) | 29 | char *name, int offset, int size, int is_signed) |
30 | { | 30 | { |
31 | struct ftrace_event_field *field; | 31 | struct ftrace_event_field *field; |
32 | 32 | ||
@@ -44,6 +44,7 @@ int trace_define_field(struct ftrace_event_call *call, char *type, | |||
44 | 44 | ||
45 | field->offset = offset; | 45 | field->offset = offset; |
46 | field->size = size; | 46 | field->size = size; |
47 | field->is_signed = is_signed; | ||
47 | list_add(&field->link, &call->fields); | 48 | list_add(&field->link, &call->fields); |
48 | 49 | ||
49 | return 0; | 50 | return 0; |
diff --git a/kernel/trace/trace_export.c b/kernel/trace/trace_export.c index 0cb1a142c74f..d06cf898dc86 100644 --- a/kernel/trace/trace_export.c +++ b/kernel/trace/trace_export.c | |||
@@ -50,6 +50,9 @@ extern void __bad_type_size(void); | |||
50 | if (!ret) \ | 50 | if (!ret) \ |
51 | return 0; | 51 | return 0; |
52 | 52 | ||
53 | #undef TRACE_FIELD_SIGN | ||
54 | #define TRACE_FIELD_SIGN(type, item, assign, is_signed) \ | ||
55 | TRACE_FIELD(type, item, assign) | ||
53 | 56 | ||
54 | #undef TP_RAW_FMT | 57 | #undef TP_RAW_FMT |
55 | #define TP_RAW_FMT(args...) args | 58 | #define TP_RAW_FMT(args...) args |
@@ -98,6 +101,10 @@ ftrace_format_##call(struct trace_seq *s) \ | |||
98 | #define TRACE_FIELD(type, item, assign)\ | 101 | #define TRACE_FIELD(type, item, assign)\ |
99 | entry->item = assign; | 102 | entry->item = assign; |
100 | 103 | ||
104 | #undef TRACE_FIELD_SIGN | ||
105 | #define TRACE_FIELD_SIGN(type, item, assign, is_signed) \ | ||
106 | TRACE_FIELD(type, item, assign) | ||
107 | |||
101 | #undef TP_CMD | 108 | #undef TP_CMD |
102 | #define TP_CMD(cmd...) cmd | 109 | #define TP_CMD(cmd...) cmd |
103 | 110 | ||
@@ -149,7 +156,7 @@ __attribute__((section("_ftrace_events"))) event_##call = { \ | |||
149 | #define TRACE_FIELD(type, item, assign) \ | 156 | #define TRACE_FIELD(type, item, assign) \ |
150 | ret = trace_define_field(event_call, #type, #item, \ | 157 | ret = trace_define_field(event_call, #type, #item, \ |
151 | offsetof(typeof(field), item), \ | 158 | offsetof(typeof(field), item), \ |
152 | sizeof(field.item)); \ | 159 | sizeof(field.item), is_signed_type(type)); \ |
153 | if (ret) \ | 160 | if (ret) \ |
154 | return ret; | 161 | return ret; |
155 | 162 | ||
@@ -157,7 +164,15 @@ __attribute__((section("_ftrace_events"))) event_##call = { \ | |||
157 | #define TRACE_FIELD_SPECIAL(type, item, len, cmd) \ | 164 | #define TRACE_FIELD_SPECIAL(type, item, len, cmd) \ |
158 | ret = trace_define_field(event_call, #type "[" #len "]", #item, \ | 165 | ret = trace_define_field(event_call, #type "[" #len "]", #item, \ |
159 | offsetof(typeof(field), item), \ | 166 | offsetof(typeof(field), item), \ |
160 | sizeof(field.item)); \ | 167 | sizeof(field.item), 0); \ |
168 | if (ret) \ | ||
169 | return ret; | ||
170 | |||
171 | #undef TRACE_FIELD_SIGN | ||
172 | #define TRACE_FIELD_SIGN(type, item, assign, is_signed) \ | ||
173 | ret = trace_define_field(event_call, #type, #item, \ | ||
174 | offsetof(typeof(field), item), \ | ||
175 | sizeof(field.item), is_signed); \ | ||
161 | if (ret) \ | 176 | if (ret) \ |
162 | return ret; | 177 | return ret; |
163 | 178 | ||
@@ -173,11 +188,11 @@ ftrace_define_fields_##call(void) \ | |||
173 | struct args field; \ | 188 | struct args field; \ |
174 | int ret; \ | 189 | int ret; \ |
175 | \ | 190 | \ |
176 | __common_field(unsigned char, type); \ | 191 | __common_field(unsigned char, type, 0); \ |
177 | __common_field(unsigned char, flags); \ | 192 | __common_field(unsigned char, flags, 0); \ |
178 | __common_field(unsigned char, preempt_count); \ | 193 | __common_field(unsigned char, preempt_count, 0); \ |
179 | __common_field(int, pid); \ | 194 | __common_field(int, pid, 1); \ |
180 | __common_field(int, tgid); \ | 195 | __common_field(int, tgid, 1); \ |
181 | \ | 196 | \ |
182 | tstruct; \ | 197 | tstruct; \ |
183 | \ | 198 | \ |