History

Merge branch 'tip/tracing/urgent' of git://git.kernel.org/pub/scm/linux/kernel/git/rostedt/linux-2.6-trace into tracing/urgent

Ingo Molnar committed 16 years ago

Commit e02c4fd2 parents ae1f303 ac91d854418 files · +285747 −111234Browse files

Showing the changes to kernel/trace (8 of 4418 files). Show all

Unified · Split

8 files
  1. kernel/trace/Makefile +3 −1
  2. kernel/trace/blktrace.c +3 −2
  3. kernel/trace/ftrace.c +15 −39
  4. kernel/trace/trace.c +1 −0
  5. kernel/trace/trace_event_profile.c +47 −5
  6. kernel/trace/trace_events_filter.c +2 −2
  7. kernel/trace/trace_kprobe.c +73 −123
  8. kernel/trace/trace_syscalls.c +12 −64
kernel/trace/Makefile+3−1
@@ -51,7 +51,9 @@ endif · 50 unmodified lines
5151 obj-$(CONFIG_EVENT_TRACING) += trace_events.o
5252 obj-$(CONFIG_EVENT_TRACING) += trace_export.o
5353 obj-$(CONFIG_FTRACE_SYSCALLS) += trace_syscalls.o
54−obj-$(CONFIG_EVENT_PROFILE) += trace_event_profile.o
54+ifeq ($(CONFIG_PERF_EVENTS),y)
55+obj-$(CONFIG_EVENT_TRACING) += trace_event_profile.o
56+endif
5557 obj-$(CONFIG_EVENT_TRACING) += trace_events_filter.o
5658 obj-$(CONFIG_KPROBE_EVENT) += trace_kprobe.o
5759 obj-$(CONFIG_KSYM_TRACER) += trace_ksym.o
kernel/trace/blktrace.c+3−2
@@ -540,9 +540,10 @@ int blk_trace_setup(struct request_queue *q, char *name, dev_t dev, · 539 unmodified lines
540540 if (ret)
541541 return ret;
542542
543− if (copy_to_user(arg, &buts, sizeof(buts)))
543+ if (copy_to_user(arg, &buts, sizeof(buts))) {
544+ blk_trace_remove(q);
544545 return -EFAULT;
545−
546+ }
546547 return 0;
547548 }
548549 EXPORT_SYMBOL_GPL(blk_trace_setup);
kernel/trace/ftrace.c+15−39
@@ -22,7 +22,6 @@ · 21 unmodified lines
2222 #include <linux/hardirq.h>
2323 #include <linux/kthread.h>
2424 #include <linux/uaccess.h>
25−#include <linux/kprobes.h>
2625 #include <linux/ftrace.h>
2726 #include <linux/sysctl.h>
2827 #include <linux/ctype.h>
@@ -898,36 +897,6 @@ static struct dyn_ftrace *ftrace_free_records; · 869 unmodified lines
898897 } \
899898 }
900899
901−#ifdef CONFIG_KPROBES
902−
903−static int frozen_record_count;
904−
905−static inline void freeze_record(struct dyn_ftrace *rec)
906−{
907− if (!(rec->flags & FTRACE_FL_FROZEN)) {
908− rec->flags |= FTRACE_FL_FROZEN;
909− frozen_record_count++;
910− }
911−}
912−
913−static inline void unfreeze_record(struct dyn_ftrace *rec)
914−{
915− if (rec->flags & FTRACE_FL_FROZEN) {
916− rec->flags &= ~FTRACE_FL_FROZEN;
917− frozen_record_count--;
918− }
919−}
920−
921−static inline int record_frozen(struct dyn_ftrace *rec)
922−{
923− return rec->flags & FTRACE_FL_FROZEN;
924−}
925−#else
926−# define freeze_record(rec) ({ 0; })
927−# define unfreeze_record(rec) ({ 0; })
928−# define record_frozen(rec) ({ 0; })
929−#endif /* CONFIG_KPROBES */
930−
931900 static void ftrace_free_rec(struct dyn_ftrace *rec)
932901 {
933902 rec->freelist = ftrace_free_records;
@@ -1025,6 +994,21 @@ static void ftrace_bug(int failed, unsigned long ip) · 91 unmodified lines
1025994 }
1026995
1027996
997+/* Return 1 if the address range is reserved for ftrace */
998+int ftrace_text_reserved(void *start, void *end)
999+{
1000+ struct dyn_ftrace *rec;
1001+ struct ftrace_page *pg;
1002+
1003+ do_for_each_ftrace_rec(pg, rec) {
1004+ if (rec->ip <= (unsigned long)end &&
1005+ rec->ip + MCOUNT_INSN_SIZE > (unsigned long)start)
1006+ return 1;
1007+ } while_for_each_ftrace_rec();
1008+ return 0;
1009+}
1010+
1011+
10281012 static int
10291013 __ftrace_replace_code(struct dyn_ftrace *rec, int enable)
10301014 {
@@ -1076,14 +1060,6 @@ static void ftrace_replace_code(int enable) · 45 unmodified lines
10761060 !(rec->flags & FTRACE_FL_CONVERTED))
10771061 continue;
10781062
1079− /* ignore updates to this record's mcount site */
1080− if (get_kprobe((void *)rec->ip)) {
1081− freeze_record(rec);
1082− continue;
1083− } else {
1084− unfreeze_record(rec);
1085− }
1086−
10871063 failed = __ftrace_replace_code(rec, enable);
10881064 if (failed) {
10891065 rec->flags |= FTRACE_FL_FAILED;
kernel/trace/trace.c+1−0
@@ -1703,6 +1703,7 @@ static void *s_start(struct seq_file *m, loff_t *pos) · 1702 unmodified lines
17031703
17041704 ftrace_enable_cpu();
17051705
1706+ iter->leftover = 0;
17061707 for (p = iter; p && l < *pos; p = s_next(m, p, &l))
17071708 ;
17081709
kernel/trace/trace_event_profile.c+47−5
@@ -6,14 +6,12 @@ · 5 unmodified lines
66 */
77
88 #include <linux/module.h>
9+#include <linux/kprobes.h>
910 #include "trace.h"
1011
1112
12−char *perf_trace_buf;
13−EXPORT_SYMBOL_GPL(perf_trace_buf);
14−
15−char *perf_trace_buf_nmi;
16−EXPORT_SYMBOL_GPL(perf_trace_buf_nmi);
13+static char *perf_trace_buf;
14+static char *perf_trace_buf_nmi;
1715
1816 typedef typeof(char [FTRACE_MAX_PROFILE_SIZE]) perf_trace_t ;
1917
@@ -120,3 +118,47 @@ void ftrace_profile_disable(int event_id) · 100 unmodified lines
120118 }
121119 mutex_unlock(&event_mutex);
122120 }
121+
122+__kprobes void *ftrace_perf_buf_prepare(int size, unsigned short type,
123+ int *rctxp, unsigned long *irq_flags)
124+{
125+ struct trace_entry *entry;
126+ char *trace_buf, *raw_data;
127+ int pc, cpu;
128+
129+ pc = preempt_count();
130+
131+ /* Protect the per cpu buffer, begin the rcu read side */
132+ local_irq_save(*irq_flags);
133+
134+ *rctxp = perf_swevent_get_recursion_context();
135+ if (*rctxp < 0)
136+ goto err_recursion;
137+
138+ cpu = smp_processor_id();
139+
140+ if (in_nmi())
141+ trace_buf = rcu_dereference(perf_trace_buf_nmi);
142+ else
143+ trace_buf = rcu_dereference(perf_trace_buf);
144+
145+ if (!trace_buf)
146+ goto err;
147+
148+ raw_data = per_cpu_ptr(trace_buf, cpu);
149+
150+ /* zero the dead bytes from align to not leak stack to user */
151+ *(u64 *)(&raw_data[size - sizeof(u64)]) = 0ULL;
152+
153+ entry = (struct trace_entry *)raw_data;
154+ tracing_generic_entry_update(entry, *irq_flags, pc);
155+ entry->type = type;
156+
157+ return raw_data;
158+err:
159+ perf_swevent_put_recursion_context(*rctxp);
160+err_recursion:
161+ local_irq_restore(*irq_flags);
162+ return NULL;
163+}
164+EXPORT_SYMBOL_GPL(ftrace_perf_buf_prepare);
kernel/trace/trace_events_filter.c+2−2
@@ -1371,7 +1371,7 @@ out_unlock: · 1370 unmodified lines
13711371 return err;
13721372 }
13731373
1374−#ifdef CONFIG_EVENT_PROFILE
1374+#ifdef CONFIG_PERF_EVENTS
13751375
13761376 void ftrace_profile_free_filter(struct perf_event *event)
13771377 {
@@ -1439,5 +1439,5 @@ out_unlock: · 61 unmodified lines
14391439 return err;
14401440 }
14411441
1442−#endif /* CONFIG_EVENT_PROFILE */
1442+#endif /* CONFIG_PERF_EVENTS */
14431443
kernel/trace/trace_kprobe.c+73−123
@@ -91,11 +91,6 @@ static __kprobes unsigned long fetch_memory(struct pt_regs *regs, void *addr) · 90 unmodified lines
9191 return retval;
9292 }
9393
94−static __kprobes unsigned long fetch_argument(struct pt_regs *regs, void *num)
95−{
96− return regs_get_argument_nth(regs, (unsigned int)((unsigned long)num));
97−}
98−
9994 static __kprobes unsigned long fetch_retvalue(struct pt_regs *regs,
10095 void *dummy)
10196 {
@@ -231,9 +226,7 @@ static int probe_arg_string(char *buf, size_t n, struct fetch_func *ff) · 129 unmodified lines
231226 {
232227 int ret = -EINVAL;
233228
234− if (ff->func == fetch_argument)
235− ret = snprintf(buf, n, "$arg%lu", (unsigned long)ff->data);
236− else if (ff->func == fetch_register) {
229+ if (ff->func == fetch_register) {
237230 const char *name;
238231 name = regs_query_register_name((unsigned int)((long)ff->data));
239232 ret = snprintf(buf, n, "%%%s", name);
@@ -489,14 +482,6 @@ static int parse_probe_vars(char *arg, struct fetch_func *ff, int is_return) · 249 unmodified lines
489482 }
490483 } else
491484 ret = -EINVAL;
492− } else if (strncmp(arg, "arg", 3) == 0 && isdigit(arg[3])) {
493− ret = strict_strtoul(arg + 3, 10, &param);
494− if (ret || param > PARAM_MAX_ARGS)
495− ret = -EINVAL;
496− else {
497− ff->func = fetch_argument;
498− ff->data = (void *)param;
499− }
500485 } else
501486 ret = -EINVAL;
502487 return ret;
@@ -611,7 +596,6 @@ static int create_trace_probe(int argc, char **argv) · 108 unmodified lines
611596 * - Add kprobe: p[:[GRP/]EVENT] KSYM[+OFFS]|KADDR [FETCHARGS]
612597 * - Add kretprobe: r[:[GRP/]EVENT] KSYM[+0] [FETCHARGS]
613598 * Fetch args:
614− * $argN : fetch Nth of function argument. (N:0-)
615599 * $retval : fetch return value
616600 * $stack : fetch stack address
617601 * $stackN : fetch Nth of stack (N:0-)
@@ -958,7 +942,7 @@ static const struct file_operations kprobe_profile_ops = { · 340 unmodified lines
958942 };
959943
960944 /* Kprobe handler */
961−static __kprobes int kprobe_trace_func(struct kprobe *kp, struct pt_regs *regs)
945+static __kprobes void kprobe_trace_func(struct kprobe *kp, struct pt_regs *regs)
962946 {
963947 struct trace_probe *tp = container_of(kp, struct trace_probe, rp.kp);
964948 struct kprobe_trace_entry *entry;
@@ -978,7 +962,7 @@ static __kprobes int kprobe_trace_func(struct kprobe *kp, struct pt_regs *regs) · 13 unmodified lines
978962 event = trace_current_buffer_lock_reserve(&buffer, call->id, size,
979963 irq_flags, pc);
980964 if (!event)
981− return 0;
965+ return;
982966
983967 entry = ring_buffer_event_data(event);
984968 entry->nargs = tp->nr_args;
@@ -988,11 +972,10 @@ static __kprobes int kprobe_trace_func(struct kprobe *kp, struct pt_regs *regs) · 3 unmodified lines
988972
989973 if (!filter_current_check_discard(buffer, call, entry, event))
990974 trace_nowake_buffer_unlock_commit(buffer, event, irq_flags, pc);
991− return 0;
992975 }
993976
994977 /* Kretprobe handler */
995−static __kprobes int kretprobe_trace_func(struct kretprobe_instance *ri,
978+static __kprobes void kretprobe_trace_func(struct kretprobe_instance *ri,
996979 struct pt_regs *regs)
997980 {
998981 struct trace_probe *tp = container_of(ri->rp, struct trace_probe, rp);
@@ -1011,7 +994,7 @@ static __kprobes int kretprobe_trace_func(struct kretprobe_instance *ri, · 12 unmodified lines
1011994 event = trace_current_buffer_lock_reserve(&buffer, call->id, size,
1012995 irq_flags, pc);
1013996 if (!event)
1014− return 0;
997+ return;
1015998
1016999 entry = ring_buffer_event_data(event);
10171000 entry->nargs = tp->nr_args;
@@ -1022,8 +1005,6 @@ static __kprobes int kretprobe_trace_func(struct kretprobe_instance *ri, · 4 unmodified lines
10221005
10231006 if (!filter_current_check_discard(buffer, call, entry, event))
10241007 trace_nowake_buffer_unlock_commit(buffer, event, irq_flags, pc);
1025−
1026− return 0;
10271008 }
10281009
10291010 /* Event entry printers */
@@ -1230,137 +1211,67 @@ static int set_print_fmt(struct trace_probe *tp) · 200 unmodified lines
12301211 return 0;
12311212 }
12321213
1233−#ifdef CONFIG_EVENT_PROFILE
1214+#ifdef CONFIG_PERF_EVENTS
12341215
12351216 /* Kprobe profile handler */
1236−static __kprobes int kprobe_profile_func(struct kprobe *kp,
1217+static __kprobes void kprobe_profile_func(struct kprobe *kp,
12371218 struct pt_regs *regs)
12381219 {
12391220 struct trace_probe *tp = container_of(kp, struct trace_probe, rp.kp);
12401221 struct ftrace_event_call *call = &tp->call;
12411222 struct kprobe_trace_entry *entry;
1242− struct trace_entry *ent;
1243− int size, __size, i, pc, __cpu;
1223+ int size, __size, i;
12441224 unsigned long irq_flags;
1245− char *trace_buf;
1246− char *raw_data;
12471225 int rctx;
12481226
1249− pc = preempt_count();
12501227 __size = SIZEOF_KPROBE_TRACE_ENTRY(tp->nr_args);
12511228 size = ALIGN(__size + sizeof(u32), sizeof(u64));
12521229 size -= sizeof(u32);
12531230 if (WARN_ONCE(size > FTRACE_MAX_PROFILE_SIZE,
12541231 "profile buffer not large enough"))
1255− return 0;
1256−
1257− /*
1258− * Protect the non nmi buffer
1259− * This also protects the rcu read side
1260− */
1261− local_irq_save(irq_flags);
1232+ return;
12621233
1263− rctx = perf_swevent_get_recursion_context();
1264− if (rctx < 0)
1265− goto end_recursion;
1266−
1267− __cpu = smp_processor_id();
1268−
1269− if (in_nmi())
1270− trace_buf = rcu_dereference(perf_trace_buf_nmi);
1271− else
1272− trace_buf = rcu_dereference(perf_trace_buf);
1273−
1274− if (!trace_buf)
1275− goto end;
1276−
1277− raw_data = per_cpu_ptr(trace_buf, __cpu);
1278−
1279− /* Zero dead bytes from alignment to avoid buffer leak to userspace */
1280− *(u64 *)(&raw_data[size - sizeof(u64)]) = 0ULL;
1281− entry = (struct kprobe_trace_entry *)raw_data;
1282− ent = &entry->ent;
1234+ entry = ftrace_perf_buf_prepare(size, call->id, &rctx, &irq_flags);
1235+ if (!entry)
1236+ return;
12831237
1284− tracing_generic_entry_update(ent, irq_flags, pc);
1285− ent->type = call->id;
12861238 entry->nargs = tp->nr_args;
12871239 entry->ip = (unsigned long)kp->addr;
12881240 for (i = 0; i < tp->nr_args; i++)
12891241 entry->args[i] = call_fetch(&tp->args[i].fetch, regs);
1290− perf_tp_event(call->id, entry->ip, 1, entry, size);
12911242
1292−end:
1293− perf_swevent_put_recursion_context(rctx);
1294−end_recursion:
1295− local_irq_restore(irq_flags);
1296−
1297− return 0;
1243+ ftrace_perf_buf_submit(entry, size, rctx, entry->ip, 1, irq_flags);
12981244 }
12991245
13001246 /* Kretprobe profile handler */
1301−static __kprobes int kretprobe_profile_func(struct kretprobe_instance *ri,
1247+static __kprobes void kretprobe_profile_func(struct kretprobe_instance *ri,
13021248 struct pt_regs *regs)
13031249 {
13041250 struct trace_probe *tp = container_of(ri->rp, struct trace_probe, rp);
13051251 struct ftrace_event_call *call = &tp->call;
13061252 struct kretprobe_trace_entry *entry;
1307− struct trace_entry *ent;
1308− int size, __size, i, pc, __cpu;
1253+ int size, __size, i;
13091254 unsigned long irq_flags;
1310− char *trace_buf;
1311− char *raw_data;
13121255 int rctx;
13131256
1314− pc = preempt_count();
13151257 __size = SIZEOF_KRETPROBE_TRACE_ENTRY(tp->nr_args);
13161258 size = ALIGN(__size + sizeof(u32), sizeof(u64));
13171259 size -= sizeof(u32);
13181260 if (WARN_ONCE(size > FTRACE_MAX_PROFILE_SIZE,
13191261 "profile buffer not large enough"))
1320− return 0;
1321−
1322− /*
1323− * Protect the non nmi buffer
1324− * This also protects the rcu read side
1325− */
1326− local_irq_save(irq_flags);
1327−
1328− rctx = perf_swevent_get_recursion_context();
1329− if (rctx < 0)
1330− goto end_recursion;
1331−
1332− __cpu = smp_processor_id();
1333−
1334− if (in_nmi())
1335− trace_buf = rcu_dereference(perf_trace_buf_nmi);
1336− else
1337− trace_buf = rcu_dereference(perf_trace_buf);
1338−
1339− if (!trace_buf)
1340− goto end;
1341−
1342− raw_data = per_cpu_ptr(trace_buf, __cpu);
1262+ return;
13431263
1344− /* Zero dead bytes from alignment to avoid buffer leak to userspace */
1345− *(u64 *)(&raw_data[size - sizeof(u64)]) = 0ULL;
1346− entry = (struct kretprobe_trace_entry *)raw_data;
1347− ent = &entry->ent;
1264+ entry = ftrace_perf_buf_prepare(size, call->id, &rctx, &irq_flags);
1265+ if (!entry)
1266+ return;
13481267
1349− tracing_generic_entry_update(ent, irq_flags, pc);
1350− ent->type = call->id;
13511268 entry->nargs = tp->nr_args;
13521269 entry->func = (unsigned long)tp->rp.kp.addr;
13531270 entry->ret_ip = (unsigned long)ri->ret_addr;
13541271 for (i = 0; i < tp->nr_args; i++)
13551272 entry->args[i] = call_fetch(&tp->args[i].fetch, regs);
1356− perf_tp_event(call->id, entry->ret_ip, 1, entry, size);
1357−
1358−end:
1359− perf_swevent_put_recursion_context(rctx);
1360−end_recursion:
1361− local_irq_restore(irq_flags);
13621273
1363− return 0;
1274+ ftrace_perf_buf_submit(entry, size, rctx, entry->ret_ip, 1, irq_flags);
13641275 }
13651276
13661277 static int probe_profile_enable(struct ftrace_event_call *call)
@@ -1388,7 +1299,7 @@ static void probe_profile_disable(struct ftrace_event_call *call) · 21 unmodified lines
13881299 disable_kprobe(&tp->rp.kp);
13891300 }
13901301 }
1391−#endif /* CONFIG_EVENT_PROFILE */
1302+#endif /* CONFIG_PERF_EVENTS */
13921303
13931304
13941305 static __kprobes
@@ -1398,10 +1309,10 @@ int kprobe_dispatcher(struct kprobe *kp, struct pt_regs *regs) · 3 unmodified lines
13981309
13991310 if (tp->flags & TP_FLAG_TRACE)
14001311 kprobe_trace_func(kp, regs);
1401−#ifdef CONFIG_EVENT_PROFILE
1312+#ifdef CONFIG_PERF_EVENTS
14021313 if (tp->flags & TP_FLAG_PROFILE)
14031314 kprobe_profile_func(kp, regs);
1404−#endif /* CONFIG_EVENT_PROFILE */
1315+#endif
14051316 return 0; /* We don't tweek kernel, so just return 0 */
14061317 }
14071318
@@ -1412,10 +1323,10 @@ int kretprobe_dispatcher(struct kretprobe_instance *ri, struct pt_regs *regs) · 4 unmodified lines
14121323
14131324 if (tp->flags & TP_FLAG_TRACE)
14141325 kretprobe_trace_func(ri, regs);
1415−#ifdef CONFIG_EVENT_PROFILE
1326+#ifdef CONFIG_PERF_EVENTS
14161327 if (tp->flags & TP_FLAG_PROFILE)
14171328 kretprobe_profile_func(ri, regs);
1418−#endif /* CONFIG_EVENT_PROFILE */
1329+#endif
14191330 return 0; /* We don't tweek kernel, so just return 0 */
14201331 }
14211332
@@ -1446,7 +1357,7 @@ static int register_probe_event(struct trace_probe *tp) · 24 unmodified lines
14461357 call->regfunc = probe_event_enable;
14471358 call->unregfunc = probe_event_disable;
14481359
1449−#ifdef CONFIG_EVENT_PROFILE
1360+#ifdef CONFIG_PERF_EVENTS
14501361 call->profile_enable = probe_profile_enable;
14511362 call->profile_disable = probe_profile_disable;
14521363 #endif
@@ -1507,28 +1418,67 @@ static int kprobe_trace_selftest_target(int a1, int a2, int a3, · 54 unmodified lines
15071418
15081419 static __init int kprobe_trace_self_tests_init(void)
15091420 {
1510− int ret;
1421+ int ret, warn = 0;
15111422 int (*target)(int, int, int, int, int, int);
1423+ struct trace_probe *tp;
15121424
15131425 target = kprobe_trace_selftest_target;
15141426
15151427 pr_info("Testing kprobe tracing: ");
15161428
15171429 ret = command_trace_probe("p:testprobe kprobe_trace_selftest_target "
1518− "$arg1 $arg2 $arg3 $arg4 $stack $stack0");
1519− if (WARN_ON_ONCE(ret))
1520− pr_warning("error enabling function entry\n");
1430+ "$stack $stack0 +0($stack)");
1431+ if (WARN_ON_ONCE(ret)) {
1432+ pr_warning("error on probing function entry.\n");
1433+ warn++;
1434+ } else {
1435+ /* Enable trace point */
1436+ tp = find_probe_event("testprobe", KPROBE_EVENT_SYSTEM);
1437+ if (WARN_ON_ONCE(tp == NULL)) {
1438+ pr_warning("error on getting new probe.\n");
1439+ warn++;
1440+ } else
1441+ probe_event_enable(&tp->call);
1442+ }
15211443
15221444 ret = command_trace_probe("r:testprobe2 kprobe_trace_selftest_target "
15231445 "$retval");
1524− if (WARN_ON_ONCE(ret))
1525− pr_warning("error enabling function return\n");
1446+ if (WARN_ON_ONCE(ret)) {
1447+ pr_warning("error on probing function return.\n");
1448+ warn++;
1449+ } else {
1450+ /* Enable trace point */
1451+ tp = find_probe_event("testprobe2", KPROBE_EVENT_SYSTEM);
1452+ if (WARN_ON_ONCE(tp == NULL)) {
1453+ pr_warning("error on getting new probe.\n");
1454+ warn++;
1455+ } else
1456+ probe_event_enable(&tp->call);
1457+ }
1458+
1459+ if (warn)
1460+ goto end;
15261461
15271462 ret = target(1, 2, 3, 4, 5, 6);
15281463
1529− cleanup_all_probes();
1464+ ret = command_trace_probe("-:testprobe");
1465+ if (WARN_ON_ONCE(ret)) {
1466+ pr_warning("error on deleting a probe.\n");
1467+ warn++;
1468+ }
1469+
1470+ ret = command_trace_probe("-:testprobe2");
1471+ if (WARN_ON_ONCE(ret)) {
1472+ pr_warning("error on deleting a probe.\n");
1473+ warn++;
1474+ }
15301475
1531− pr_cont("OK\n");
1476+end:
1477+ cleanup_all_probes();
1478+ if (warn)
1479+ pr_cont("NG: Some tests are failed. Please check them.\n");
1480+ else
1481+ pr_cont("OK\n");
15321482 return 0;
15331483 }
15341484
kernel/trace/trace_syscalls.c+12−64
@@ -426,7 +426,7 @@ int __init init_ftrace_syscalls(void) · 425 unmodified lines
426426 }
427427 core_initcall(init_ftrace_syscalls);
428428
429−#ifdef CONFIG_EVENT_PROFILE
429+#ifdef CONFIG_PERF_EVENTS
430430
431431 static DECLARE_BITMAP(enabled_prof_enter_syscalls, NR_syscalls);
432432 static DECLARE_BITMAP(enabled_prof_exit_syscalls, NR_syscalls);
@@ -438,12 +438,9 @@ static void prof_syscall_enter(struct pt_regs *regs, long id) · 5 unmodified lines
438438 struct syscall_metadata *sys_data;
439439 struct syscall_trace_enter *rec;
440440 unsigned long flags;
441− char *trace_buf;
442− char *raw_data;
443441 int syscall_nr;
444442 int rctx;
445443 int size;
446− int cpu;
447444
448445 syscall_nr = syscall_get_nr(current, regs);
449446 if (!test_bit(syscall_nr, enabled_prof_enter_syscalls))
@@ -462,37 +459,15 @@ static void prof_syscall_enter(struct pt_regs *regs, long id) · 12 unmodified lines
462459 "profile buffer not large enough"))
463460 return;
464461
465− /* Protect the per cpu buffer, begin the rcu read side */
466− local_irq_save(flags);
467−
468− rctx = perf_swevent_get_recursion_context();
469− if (rctx < 0)
470− goto end_recursion;
471−
472− cpu = smp_processor_id();
473−
474− trace_buf = rcu_dereference(perf_trace_buf);
475−
476− if (!trace_buf)
477− goto end;
478−
479− raw_data = per_cpu_ptr(trace_buf, cpu);
480−
481− /* zero the dead bytes from align to not leak stack to user */
482− *(u64 *)(&raw_data[size - sizeof(u64)]) = 0ULL;
462+ rec = (struct syscall_trace_enter *)ftrace_perf_buf_prepare(size,
463+ sys_data->enter_event->id, &rctx, &flags);
464+ if (!rec)
465+ return;
483466
484− rec = (struct syscall_trace_enter *) raw_data;
485− tracing_generic_entry_update(&rec->ent, 0, 0);
486− rec->ent.type = sys_data->enter_event->id;
487467 rec->nr = syscall_nr;
488468 syscall_get_arguments(current, regs, 0, sys_data->nb_args,
489469 (unsigned long *)&rec->args);
490− perf_tp_event(sys_data->enter_event->id, 0, 1, rec, size);
491−
492−end:
493− perf_swevent_put_recursion_context(rctx);
494−end_recursion:
495− local_irq_restore(flags);
470+ ftrace_perf_buf_submit(rec, size, rctx, 0, 1, flags);
496471 }
497472
498473 int prof_sysenter_enable(struct ftrace_event_call *call)
@@ -536,11 +511,8 @@ static void prof_syscall_exit(struct pt_regs *regs, long ret) · 37 unmodified lines
536511 struct syscall_trace_exit *rec;
537512 unsigned long flags;
538513 int syscall_nr;
539− char *trace_buf;
540− char *raw_data;
541514 int rctx;
542515 int size;
543− int cpu;
544516
545517 syscall_nr = syscall_get_nr(current, regs);
546518 if (!test_bit(syscall_nr, enabled_prof_exit_syscalls))
@@ -562,38 +534,15 @@ static void prof_syscall_exit(struct pt_regs *regs, long ret) · 15 unmodified lines
562534 "exit event has grown above profile buffer size"))
563535 return;
564536
565− /* Protect the per cpu buffer, begin the rcu read side */
566− local_irq_save(flags);
567−
568− rctx = perf_swevent_get_recursion_context();
569− if (rctx < 0)
570− goto end_recursion;
571−
572− cpu = smp_processor_id();
573−
574− trace_buf = rcu_dereference(perf_trace_buf);
575−
576− if (!trace_buf)
577− goto end;
578−
579− raw_data = per_cpu_ptr(trace_buf, cpu);
580−
581− /* zero the dead bytes from align to not leak stack to user */
582− *(u64 *)(&raw_data[size - sizeof(u64)]) = 0ULL;
583−
584− rec = (struct syscall_trace_exit *)raw_data;
537+ rec = (struct syscall_trace_exit *)ftrace_perf_buf_prepare(size,
538+ sys_data->exit_event->id, &rctx, &flags);
539+ if (!rec)
540+ return;
585541
586− tracing_generic_entry_update(&rec->ent, 0, 0);
587− rec->ent.type = sys_data->exit_event->id;
588542 rec->nr = syscall_nr;
589543 rec->ret = syscall_get_return_value(current, regs);
590544
591− perf_tp_event(sys_data->exit_event->id, 0, 1, rec, size);
592−
593−end:
594− perf_swevent_put_recursion_context(rctx);
595−end_recursion:
596− local_irq_restore(flags);
545+ ftrace_perf_buf_submit(rec, size, rctx, 0, 1, flags);
597546 }
598547
599548 int prof_sysexit_enable(struct ftrace_event_call *call)
@@ -631,6 +580,5 @@ void prof_sysexit_disable(struct ftrace_event_call *call) · 31 unmodified lines
631580 mutex_unlock(&syscall_trace_lock);
632581 }
633582
634−#endif
635−
583+#endif /* CONFIG_PERF_EVENTS */
636584