trace_events.c 33 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567
  1. /*
  2. * event tracer
  3. *
  4. * Copyright (C) 2008 Red Hat Inc, Steven Rostedt <srostedt@redhat.com>
  5. *
  6. * - Added format output of fields of the trace point.
  7. * This was based off of work by Tom Zanussi <tzanussi@gmail.com>.
  8. *
  9. */
  10. #include <linux/workqueue.h>
  11. #include <linux/spinlock.h>
  12. #include <linux/kthread.h>
  13. #include <linux/debugfs.h>
  14. #include <linux/uaccess.h>
  15. #include <linux/module.h>
  16. #include <linux/ctype.h>
  17. #include <linux/slab.h>
  18. #include <linux/delay.h>
  19. #include <asm/setup.h>
  20. #include "trace_output.h"
  21. #undef TRACE_SYSTEM
  22. #define TRACE_SYSTEM "TRACE_SYSTEM"
  23. DEFINE_MUTEX(event_mutex);
  24. LIST_HEAD(ftrace_events);
  25. LIST_HEAD(ftrace_common_fields);
  26. struct list_head *
  27. trace_get_fields(struct ftrace_event_call *event_call)
  28. {
  29. if (!event_call->class->get_fields)
  30. return &event_call->class->fields;
  31. return event_call->class->get_fields(event_call);
  32. }
  33. static int __trace_define_field(struct list_head *head, const char *type,
  34. const char *name, int offset, int size,
  35. int is_signed, int filter_type)
  36. {
  37. struct ftrace_event_field *field;
  38. field = kzalloc(sizeof(*field), GFP_KERNEL);
  39. if (!field)
  40. goto err;
  41. field->name = kstrdup(name, GFP_KERNEL);
  42. if (!field->name)
  43. goto err;
  44. field->type = kstrdup(type, GFP_KERNEL);
  45. if (!field->type)
  46. goto err;
  47. if (filter_type == FILTER_OTHER)
  48. field->filter_type = filter_assign_type(type);
  49. else
  50. field->filter_type = filter_type;
  51. field->offset = offset;
  52. field->size = size;
  53. field->is_signed = is_signed;
  54. list_add(&field->link, head);
  55. return 0;
  56. err:
  57. if (field)
  58. kfree(field->name);
  59. kfree(field);
  60. return -ENOMEM;
  61. }
  62. int trace_define_field(struct ftrace_event_call *call, const char *type,
  63. const char *name, int offset, int size, int is_signed,
  64. int filter_type)
  65. {
  66. struct list_head *head;
  67. if (WARN_ON(!call->class))
  68. return 0;
  69. head = trace_get_fields(call);
  70. return __trace_define_field(head, type, name, offset, size,
  71. is_signed, filter_type);
  72. }
  73. EXPORT_SYMBOL_GPL(trace_define_field);
  74. #define __common_field(type, item) \
  75. ret = __trace_define_field(&ftrace_common_fields, #type, \
  76. "common_" #item, \
  77. offsetof(typeof(ent), item), \
  78. sizeof(ent.item), \
  79. is_signed_type(type), FILTER_OTHER); \
  80. if (ret) \
  81. return ret;
  82. static int trace_define_common_fields(void)
  83. {
  84. int ret;
  85. struct trace_entry ent;
  86. __common_field(unsigned short, type);
  87. __common_field(unsigned char, flags);
  88. __common_field(unsigned char, preempt_count);
  89. __common_field(int, pid);
  90. __common_field(int, lock_depth);
  91. return ret;
  92. }
  93. void trace_destroy_fields(struct ftrace_event_call *call)
  94. {
  95. struct ftrace_event_field *field, *next;
  96. struct list_head *head;
  97. head = trace_get_fields(call);
  98. list_for_each_entry_safe(field, next, head, link) {
  99. list_del(&field->link);
  100. kfree(field->type);
  101. kfree(field->name);
  102. kfree(field);
  103. }
  104. }
  105. int trace_event_raw_init(struct ftrace_event_call *call)
  106. {
  107. int id;
  108. id = register_ftrace_event(&call->event);
  109. if (!id)
  110. return -ENODEV;
  111. return 0;
  112. }
  113. EXPORT_SYMBOL_GPL(trace_event_raw_init);
  114. static int ftrace_event_enable_disable(struct ftrace_event_call *call,
  115. int enable)
  116. {
  117. int ret = 0;
  118. switch (enable) {
  119. case 0:
  120. if (call->flags & TRACE_EVENT_FL_ENABLED) {
  121. call->flags &= ~TRACE_EVENT_FL_ENABLED;
  122. tracing_stop_cmdline_record();
  123. if (call->class->reg)
  124. call->class->reg(call, TRACE_REG_UNREGISTER);
  125. else
  126. tracepoint_probe_unregister(call->name,
  127. call->class->probe,
  128. call);
  129. }
  130. break;
  131. case 1:
  132. if (!(call->flags & TRACE_EVENT_FL_ENABLED)) {
  133. tracing_start_cmdline_record();
  134. if (call->class->reg)
  135. ret = call->class->reg(call, TRACE_REG_REGISTER);
  136. else
  137. ret = tracepoint_probe_register(call->name,
  138. call->class->probe,
  139. call);
  140. if (ret) {
  141. tracing_stop_cmdline_record();
  142. pr_info("event trace: Could not enable event "
  143. "%s\n", call->name);
  144. break;
  145. }
  146. call->flags |= TRACE_EVENT_FL_ENABLED;
  147. }
  148. break;
  149. }
  150. return ret;
  151. }
  152. static void ftrace_clear_events(void)
  153. {
  154. struct ftrace_event_call *call;
  155. mutex_lock(&event_mutex);
  156. list_for_each_entry(call, &ftrace_events, list) {
  157. ftrace_event_enable_disable(call, 0);
  158. }
  159. mutex_unlock(&event_mutex);
  160. }
  161. /*
  162. * __ftrace_set_clr_event(NULL, NULL, NULL, set) will set/unset all events.
  163. */
  164. static int __ftrace_set_clr_event(const char *match, const char *sub,
  165. const char *event, int set)
  166. {
  167. struct ftrace_event_call *call;
  168. int ret = -EINVAL;
  169. mutex_lock(&event_mutex);
  170. list_for_each_entry(call, &ftrace_events, list) {
  171. if (!call->name || !call->class ||
  172. (!call->class->probe && !call->class->reg))
  173. continue;
  174. if (match &&
  175. strcmp(match, call->name) != 0 &&
  176. strcmp(match, call->class->system) != 0)
  177. continue;
  178. if (sub && strcmp(sub, call->class->system) != 0)
  179. continue;
  180. if (event && strcmp(event, call->name) != 0)
  181. continue;
  182. ftrace_event_enable_disable(call, set);
  183. ret = 0;
  184. }
  185. mutex_unlock(&event_mutex);
  186. return ret;
  187. }
  188. static int ftrace_set_clr_event(char *buf, int set)
  189. {
  190. char *event = NULL, *sub = NULL, *match;
  191. /*
  192. * The buf format can be <subsystem>:<event-name>
  193. * *:<event-name> means any event by that name.
  194. * :<event-name> is the same.
  195. *
  196. * <subsystem>:* means all events in that subsystem
  197. * <subsystem>: means the same.
  198. *
  199. * <name> (no ':') means all events in a subsystem with
  200. * the name <name> or any event that matches <name>
  201. */
  202. match = strsep(&buf, ":");
  203. if (buf) {
  204. sub = match;
  205. event = buf;
  206. match = NULL;
  207. if (!strlen(sub) || strcmp(sub, "*") == 0)
  208. sub = NULL;
  209. if (!strlen(event) || strcmp(event, "*") == 0)
  210. event = NULL;
  211. }
  212. return __ftrace_set_clr_event(match, sub, event, set);
  213. }
  214. /**
  215. * trace_set_clr_event - enable or disable an event
  216. * @system: system name to match (NULL for any system)
  217. * @event: event name to match (NULL for all events, within system)
  218. * @set: 1 to enable, 0 to disable
  219. *
  220. * This is a way for other parts of the kernel to enable or disable
  221. * event recording.
  222. *
  223. * Returns 0 on success, -EINVAL if the parameters do not match any
  224. * registered events.
  225. */
  226. int trace_set_clr_event(const char *system, const char *event, int set)
  227. {
  228. return __ftrace_set_clr_event(NULL, system, event, set);
  229. }
  230. /* 128 should be much more than enough */
  231. #define EVENT_BUF_SIZE 127
  232. static ssize_t
  233. ftrace_event_write(struct file *file, const char __user *ubuf,
  234. size_t cnt, loff_t *ppos)
  235. {
  236. struct trace_parser parser;
  237. ssize_t read, ret;
  238. if (!cnt)
  239. return 0;
  240. ret = tracing_update_buffers();
  241. if (ret < 0)
  242. return ret;
  243. if (trace_parser_get_init(&parser, EVENT_BUF_SIZE + 1))
  244. return -ENOMEM;
  245. read = trace_get_user(&parser, ubuf, cnt, ppos);
  246. if (read >= 0 && trace_parser_loaded((&parser))) {
  247. int set = 1;
  248. if (*parser.buffer == '!')
  249. set = 0;
  250. parser.buffer[parser.idx] = 0;
  251. ret = ftrace_set_clr_event(parser.buffer + !set, set);
  252. if (ret)
  253. goto out_put;
  254. }
  255. ret = read;
  256. out_put:
  257. trace_parser_put(&parser);
  258. return ret;
  259. }
  260. static void *
  261. t_next(struct seq_file *m, void *v, loff_t *pos)
  262. {
  263. struct ftrace_event_call *call = v;
  264. (*pos)++;
  265. list_for_each_entry_continue(call, &ftrace_events, list) {
  266. /*
  267. * The ftrace subsystem is for showing formats only.
  268. * They can not be enabled or disabled via the event files.
  269. */
  270. if (call->class && (call->class->probe || call->class->reg))
  271. return call;
  272. }
  273. return NULL;
  274. }
  275. static void *t_start(struct seq_file *m, loff_t *pos)
  276. {
  277. struct ftrace_event_call *call;
  278. loff_t l;
  279. mutex_lock(&event_mutex);
  280. call = list_entry(&ftrace_events, struct ftrace_event_call, list);
  281. for (l = 0; l <= *pos; ) {
  282. call = t_next(m, call, &l);
  283. if (!call)
  284. break;
  285. }
  286. return call;
  287. }
  288. static void *
  289. s_next(struct seq_file *m, void *v, loff_t *pos)
  290. {
  291. struct ftrace_event_call *call = v;
  292. (*pos)++;
  293. list_for_each_entry_continue(call, &ftrace_events, list) {
  294. if (call->flags & TRACE_EVENT_FL_ENABLED)
  295. return call;
  296. }
  297. return NULL;
  298. }
  299. static void *s_start(struct seq_file *m, loff_t *pos)
  300. {
  301. struct ftrace_event_call *call;
  302. loff_t l;
  303. mutex_lock(&event_mutex);
  304. call = list_entry(&ftrace_events, struct ftrace_event_call, list);
  305. for (l = 0; l <= *pos; ) {
  306. call = s_next(m, call, &l);
  307. if (!call)
  308. break;
  309. }
  310. return call;
  311. }
  312. static int t_show(struct seq_file *m, void *v)
  313. {
  314. struct ftrace_event_call *call = v;
  315. if (strcmp(call->class->system, TRACE_SYSTEM) != 0)
  316. seq_printf(m, "%s:", call->class->system);
  317. seq_printf(m, "%s\n", call->name);
  318. return 0;
  319. }
  320. static void t_stop(struct seq_file *m, void *p)
  321. {
  322. mutex_unlock(&event_mutex);
  323. }
  324. static int
  325. ftrace_event_seq_open(struct inode *inode, struct file *file)
  326. {
  327. const struct seq_operations *seq_ops;
  328. if ((file->f_mode & FMODE_WRITE) &&
  329. (file->f_flags & O_TRUNC))
  330. ftrace_clear_events();
  331. seq_ops = inode->i_private;
  332. return seq_open(file, seq_ops);
  333. }
  334. static ssize_t
  335. event_enable_read(struct file *filp, char __user *ubuf, size_t cnt,
  336. loff_t *ppos)
  337. {
  338. struct ftrace_event_call *call = filp->private_data;
  339. char *buf;
  340. if (call->flags & TRACE_EVENT_FL_ENABLED)
  341. buf = "1\n";
  342. else
  343. buf = "0\n";
  344. return simple_read_from_buffer(ubuf, cnt, ppos, buf, 2);
  345. }
  346. static ssize_t
  347. event_enable_write(struct file *filp, const char __user *ubuf, size_t cnt,
  348. loff_t *ppos)
  349. {
  350. struct ftrace_event_call *call = filp->private_data;
  351. char buf[64];
  352. unsigned long val;
  353. int ret;
  354. if (cnt >= sizeof(buf))
  355. return -EINVAL;
  356. if (copy_from_user(&buf, ubuf, cnt))
  357. return -EFAULT;
  358. buf[cnt] = 0;
  359. ret = strict_strtoul(buf, 10, &val);
  360. if (ret < 0)
  361. return ret;
  362. ret = tracing_update_buffers();
  363. if (ret < 0)
  364. return ret;
  365. switch (val) {
  366. case 0:
  367. case 1:
  368. mutex_lock(&event_mutex);
  369. ret = ftrace_event_enable_disable(call, val);
  370. mutex_unlock(&event_mutex);
  371. break;
  372. default:
  373. return -EINVAL;
  374. }
  375. *ppos += cnt;
  376. return ret ? ret : cnt;
  377. }
  378. static ssize_t
  379. system_enable_read(struct file *filp, char __user *ubuf, size_t cnt,
  380. loff_t *ppos)
  381. {
  382. const char set_to_char[4] = { '?', '0', '1', 'X' };
  383. const char *system = filp->private_data;
  384. struct ftrace_event_call *call;
  385. char buf[2];
  386. int set = 0;
  387. int ret;
  388. mutex_lock(&event_mutex);
  389. list_for_each_entry(call, &ftrace_events, list) {
  390. if (!call->name || !call->class ||
  391. (!call->class->probe && !call->class->reg))
  392. continue;
  393. if (system && strcmp(call->class->system, system) != 0)
  394. continue;
  395. /*
  396. * We need to find out if all the events are set
  397. * or if all events or cleared, or if we have
  398. * a mixture.
  399. */
  400. set |= (1 << !!(call->flags & TRACE_EVENT_FL_ENABLED));
  401. /*
  402. * If we have a mixture, no need to look further.
  403. */
  404. if (set == 3)
  405. break;
  406. }
  407. mutex_unlock(&event_mutex);
  408. buf[0] = set_to_char[set];
  409. buf[1] = '\n';
  410. ret = simple_read_from_buffer(ubuf, cnt, ppos, buf, 2);
  411. return ret;
  412. }
  413. static ssize_t
  414. system_enable_write(struct file *filp, const char __user *ubuf, size_t cnt,
  415. loff_t *ppos)
  416. {
  417. const char *system = filp->private_data;
  418. unsigned long val;
  419. char buf[64];
  420. ssize_t ret;
  421. if (cnt >= sizeof(buf))
  422. return -EINVAL;
  423. if (copy_from_user(&buf, ubuf, cnt))
  424. return -EFAULT;
  425. buf[cnt] = 0;
  426. ret = strict_strtoul(buf, 10, &val);
  427. if (ret < 0)
  428. return ret;
  429. ret = tracing_update_buffers();
  430. if (ret < 0)
  431. return ret;
  432. if (val != 0 && val != 1)
  433. return -EINVAL;
  434. ret = __ftrace_set_clr_event(NULL, system, NULL, val);
  435. if (ret)
  436. goto out;
  437. ret = cnt;
  438. out:
  439. *ppos += cnt;
  440. return ret;
  441. }
  442. static void print_event_fields(struct trace_seq *s, struct list_head *head)
  443. {
  444. struct ftrace_event_field *field;
  445. list_for_each_entry_reverse(field, head, link) {
  446. /*
  447. * Smartly shows the array type(except dynamic array).
  448. * Normal:
  449. * field:TYPE VAR
  450. * If TYPE := TYPE[LEN], it is shown:
  451. * field:TYPE VAR[LEN]
  452. */
  453. const char *array_descriptor = strchr(field->type, '[');
  454. if (!strncmp(field->type, "__data_loc", 10))
  455. array_descriptor = NULL;
  456. if (!array_descriptor) {
  457. trace_seq_printf(s, "\tfield:%s %s;\toffset:%u;"
  458. "\tsize:%u;\tsigned:%d;\n",
  459. field->type, field->name, field->offset,
  460. field->size, !!field->is_signed);
  461. } else {
  462. trace_seq_printf(s, "\tfield:%.*s %s%s;\toffset:%u;"
  463. "\tsize:%u;\tsigned:%d;\n",
  464. (int)(array_descriptor - field->type),
  465. field->type, field->name,
  466. array_descriptor, field->offset,
  467. field->size, !!field->is_signed);
  468. }
  469. }
  470. }
  471. static ssize_t
  472. event_format_read(struct file *filp, char __user *ubuf, size_t cnt,
  473. loff_t *ppos)
  474. {
  475. struct ftrace_event_call *call = filp->private_data;
  476. struct list_head *head;
  477. struct trace_seq *s;
  478. char *buf;
  479. int r;
  480. if (*ppos)
  481. return 0;
  482. s = kmalloc(sizeof(*s), GFP_KERNEL);
  483. if (!s)
  484. return -ENOMEM;
  485. trace_seq_init(s);
  486. trace_seq_printf(s, "name: %s\n", call->name);
  487. trace_seq_printf(s, "ID: %d\n", call->event.type);
  488. trace_seq_printf(s, "format:\n");
  489. /* print common fields */
  490. print_event_fields(s, &ftrace_common_fields);
  491. trace_seq_putc(s, '\n');
  492. /* print event specific fields */
  493. head = trace_get_fields(call);
  494. print_event_fields(s, head);
  495. r = trace_seq_printf(s, "\nprint fmt: %s\n", call->print_fmt);
  496. if (!r) {
  497. /*
  498. * ug! The format output is bigger than a PAGE!!
  499. */
  500. buf = "FORMAT TOO BIG\n";
  501. r = simple_read_from_buffer(ubuf, cnt, ppos,
  502. buf, strlen(buf));
  503. goto out;
  504. }
  505. r = simple_read_from_buffer(ubuf, cnt, ppos,
  506. s->buffer, s->len);
  507. out:
  508. kfree(s);
  509. return r;
  510. }
  511. static ssize_t
  512. event_id_read(struct file *filp, char __user *ubuf, size_t cnt, loff_t *ppos)
  513. {
  514. struct ftrace_event_call *call = filp->private_data;
  515. struct trace_seq *s;
  516. int r;
  517. if (*ppos)
  518. return 0;
  519. s = kmalloc(sizeof(*s), GFP_KERNEL);
  520. if (!s)
  521. return -ENOMEM;
  522. trace_seq_init(s);
  523. trace_seq_printf(s, "%d\n", call->event.type);
  524. r = simple_read_from_buffer(ubuf, cnt, ppos,
  525. s->buffer, s->len);
  526. kfree(s);
  527. return r;
  528. }
  529. static ssize_t
  530. event_filter_read(struct file *filp, char __user *ubuf, size_t cnt,
  531. loff_t *ppos)
  532. {
  533. struct ftrace_event_call *call = filp->private_data;
  534. struct trace_seq *s;
  535. int r;
  536. if (*ppos)
  537. return 0;
  538. s = kmalloc(sizeof(*s), GFP_KERNEL);
  539. if (!s)
  540. return -ENOMEM;
  541. trace_seq_init(s);
  542. print_event_filter(call, s);
  543. r = simple_read_from_buffer(ubuf, cnt, ppos, s->buffer, s->len);
  544. kfree(s);
  545. return r;
  546. }
  547. static ssize_t
  548. event_filter_write(struct file *filp, const char __user *ubuf, size_t cnt,
  549. loff_t *ppos)
  550. {
  551. struct ftrace_event_call *call = filp->private_data;
  552. char *buf;
  553. int err;
  554. if (cnt >= PAGE_SIZE)
  555. return -EINVAL;
  556. buf = (char *)__get_free_page(GFP_TEMPORARY);
  557. if (!buf)
  558. return -ENOMEM;
  559. if (copy_from_user(buf, ubuf, cnt)) {
  560. free_page((unsigned long) buf);
  561. return -EFAULT;
  562. }
  563. buf[cnt] = '\0';
  564. err = apply_event_filter(call, buf);
  565. free_page((unsigned long) buf);
  566. if (err < 0)
  567. return err;
  568. *ppos += cnt;
  569. return cnt;
  570. }
  571. static ssize_t
  572. subsystem_filter_read(struct file *filp, char __user *ubuf, size_t cnt,
  573. loff_t *ppos)
  574. {
  575. struct event_subsystem *system = filp->private_data;
  576. struct trace_seq *s;
  577. int r;
  578. if (*ppos)
  579. return 0;
  580. s = kmalloc(sizeof(*s), GFP_KERNEL);
  581. if (!s)
  582. return -ENOMEM;
  583. trace_seq_init(s);
  584. print_subsystem_event_filter(system, s);
  585. r = simple_read_from_buffer(ubuf, cnt, ppos, s->buffer, s->len);
  586. kfree(s);
  587. return r;
  588. }
  589. static ssize_t
  590. subsystem_filter_write(struct file *filp, const char __user *ubuf, size_t cnt,
  591. loff_t *ppos)
  592. {
  593. struct event_subsystem *system = filp->private_data;
  594. char *buf;
  595. int err;
  596. if (cnt >= PAGE_SIZE)
  597. return -EINVAL;
  598. buf = (char *)__get_free_page(GFP_TEMPORARY);
  599. if (!buf)
  600. return -ENOMEM;
  601. if (copy_from_user(buf, ubuf, cnt)) {
  602. free_page((unsigned long) buf);
  603. return -EFAULT;
  604. }
  605. buf[cnt] = '\0';
  606. err = apply_subsystem_event_filter(system, buf);
  607. free_page((unsigned long) buf);
  608. if (err < 0)
  609. return err;
  610. *ppos += cnt;
  611. return cnt;
  612. }
  613. static ssize_t
  614. show_header(struct file *filp, char __user *ubuf, size_t cnt, loff_t *ppos)
  615. {
  616. int (*func)(struct trace_seq *s) = filp->private_data;
  617. struct trace_seq *s;
  618. int r;
  619. if (*ppos)
  620. return 0;
  621. s = kmalloc(sizeof(*s), GFP_KERNEL);
  622. if (!s)
  623. return -ENOMEM;
  624. trace_seq_init(s);
  625. func(s);
  626. r = simple_read_from_buffer(ubuf, cnt, ppos, s->buffer, s->len);
  627. kfree(s);
  628. return r;
  629. }
  630. static const struct seq_operations show_event_seq_ops = {
  631. .start = t_start,
  632. .next = t_next,
  633. .show = t_show,
  634. .stop = t_stop,
  635. };
  636. static const struct seq_operations show_set_event_seq_ops = {
  637. .start = s_start,
  638. .next = s_next,
  639. .show = t_show,
  640. .stop = t_stop,
  641. };
  642. static const struct file_operations ftrace_avail_fops = {
  643. .open = ftrace_event_seq_open,
  644. .read = seq_read,
  645. .llseek = seq_lseek,
  646. .release = seq_release,
  647. };
  648. static const struct file_operations ftrace_set_event_fops = {
  649. .open = ftrace_event_seq_open,
  650. .read = seq_read,
  651. .write = ftrace_event_write,
  652. .llseek = seq_lseek,
  653. .release = seq_release,
  654. };
  655. static const struct file_operations ftrace_enable_fops = {
  656. .open = tracing_open_generic,
  657. .read = event_enable_read,
  658. .write = event_enable_write,
  659. };
  660. static const struct file_operations ftrace_event_format_fops = {
  661. .open = tracing_open_generic,
  662. .read = event_format_read,
  663. };
  664. static const struct file_operations ftrace_event_id_fops = {
  665. .open = tracing_open_generic,
  666. .read = event_id_read,
  667. };
  668. static const struct file_operations ftrace_event_filter_fops = {
  669. .open = tracing_open_generic,
  670. .read = event_filter_read,
  671. .write = event_filter_write,
  672. };
  673. static const struct file_operations ftrace_subsystem_filter_fops = {
  674. .open = tracing_open_generic,
  675. .read = subsystem_filter_read,
  676. .write = subsystem_filter_write,
  677. };
  678. static const struct file_operations ftrace_system_enable_fops = {
  679. .open = tracing_open_generic,
  680. .read = system_enable_read,
  681. .write = system_enable_write,
  682. };
  683. static const struct file_operations ftrace_show_header_fops = {
  684. .open = tracing_open_generic,
  685. .read = show_header,
  686. };
  687. static struct dentry *event_trace_events_dir(void)
  688. {
  689. static struct dentry *d_tracer;
  690. static struct dentry *d_events;
  691. if (d_events)
  692. return d_events;
  693. d_tracer = tracing_init_dentry();
  694. if (!d_tracer)
  695. return NULL;
  696. d_events = debugfs_create_dir("events", d_tracer);
  697. if (!d_events)
  698. pr_warning("Could not create debugfs "
  699. "'events' directory\n");
  700. return d_events;
  701. }
  702. static LIST_HEAD(event_subsystems);
  703. static struct dentry *
  704. event_subsystem_dir(const char *name, struct dentry *d_events)
  705. {
  706. struct event_subsystem *system;
  707. struct dentry *entry;
  708. /* First see if we did not already create this dir */
  709. list_for_each_entry(system, &event_subsystems, list) {
  710. if (strcmp(system->name, name) == 0) {
  711. system->nr_events++;
  712. return system->entry;
  713. }
  714. }
  715. /* need to create new entry */
  716. system = kmalloc(sizeof(*system), GFP_KERNEL);
  717. if (!system) {
  718. pr_warning("No memory to create event subsystem %s\n",
  719. name);
  720. return d_events;
  721. }
  722. system->entry = debugfs_create_dir(name, d_events);
  723. if (!system->entry) {
  724. pr_warning("Could not create event subsystem %s\n",
  725. name);
  726. kfree(system);
  727. return d_events;
  728. }
  729. system->nr_events = 1;
  730. system->name = kstrdup(name, GFP_KERNEL);
  731. if (!system->name) {
  732. debugfs_remove(system->entry);
  733. kfree(system);
  734. return d_events;
  735. }
  736. list_add(&system->list, &event_subsystems);
  737. system->filter = NULL;
  738. system->filter = kzalloc(sizeof(struct event_filter), GFP_KERNEL);
  739. if (!system->filter) {
  740. pr_warning("Could not allocate filter for subsystem "
  741. "'%s'\n", name);
  742. return system->entry;
  743. }
  744. entry = debugfs_create_file("filter", 0644, system->entry, system,
  745. &ftrace_subsystem_filter_fops);
  746. if (!entry) {
  747. kfree(system->filter);
  748. system->filter = NULL;
  749. pr_warning("Could not create debugfs "
  750. "'%s/filter' entry\n", name);
  751. }
  752. trace_create_file("enable", 0644, system->entry,
  753. (void *)system->name,
  754. &ftrace_system_enable_fops);
  755. return system->entry;
  756. }
  757. static int
  758. event_create_dir(struct ftrace_event_call *call, struct dentry *d_events,
  759. const struct file_operations *id,
  760. const struct file_operations *enable,
  761. const struct file_operations *filter,
  762. const struct file_operations *format)
  763. {
  764. struct list_head *head;
  765. int ret;
  766. /*
  767. * If the trace point header did not define TRACE_SYSTEM
  768. * then the system would be called "TRACE_SYSTEM".
  769. */
  770. if (strcmp(call->class->system, TRACE_SYSTEM) != 0)
  771. d_events = event_subsystem_dir(call->class->system, d_events);
  772. call->dir = debugfs_create_dir(call->name, d_events);
  773. if (!call->dir) {
  774. pr_warning("Could not create debugfs "
  775. "'%s' directory\n", call->name);
  776. return -1;
  777. }
  778. if (call->class->probe || call->class->reg)
  779. trace_create_file("enable", 0644, call->dir, call,
  780. enable);
  781. #ifdef CONFIG_PERF_EVENTS
  782. if (call->event.type && (call->class->perf_probe || call->class->reg))
  783. trace_create_file("id", 0444, call->dir, call,
  784. id);
  785. #endif
  786. /*
  787. * Other events may have the same class. Only update
  788. * the fields if they are not already defined.
  789. */
  790. head = trace_get_fields(call);
  791. if (list_empty(head)) {
  792. ret = call->class->define_fields(call);
  793. if (ret < 0) {
  794. pr_warning("Could not initialize trace point"
  795. " events/%s\n", call->name);
  796. return ret;
  797. }
  798. }
  799. trace_create_file("filter", 0644, call->dir, call,
  800. filter);
  801. trace_create_file("format", 0444, call->dir, call,
  802. format);
  803. return 0;
  804. }
  805. static int
  806. __trace_add_event_call(struct ftrace_event_call *call, struct module *mod,
  807. const struct file_operations *id,
  808. const struct file_operations *enable,
  809. const struct file_operations *filter,
  810. const struct file_operations *format)
  811. {
  812. struct dentry *d_events;
  813. int ret;
  814. /* The linker may leave blanks */
  815. if (!call->name)
  816. return -EINVAL;
  817. if (call->class->raw_init) {
  818. ret = call->class->raw_init(call);
  819. if (ret < 0) {
  820. if (ret != -ENOSYS)
  821. pr_warning("Could not initialize trace events/%s\n",
  822. call->name);
  823. return ret;
  824. }
  825. }
  826. d_events = event_trace_events_dir();
  827. if (!d_events)
  828. return -ENOENT;
  829. ret = event_create_dir(call, d_events, id, enable, filter, format);
  830. if (!ret)
  831. list_add(&call->list, &ftrace_events);
  832. call->mod = mod;
  833. return ret;
  834. }
  835. /* Add an additional event_call dynamically */
  836. int trace_add_event_call(struct ftrace_event_call *call)
  837. {
  838. int ret;
  839. mutex_lock(&event_mutex);
  840. ret = __trace_add_event_call(call, NULL, &ftrace_event_id_fops,
  841. &ftrace_enable_fops,
  842. &ftrace_event_filter_fops,
  843. &ftrace_event_format_fops);
  844. mutex_unlock(&event_mutex);
  845. return ret;
  846. }
  847. static void remove_subsystem_dir(const char *name)
  848. {
  849. struct event_subsystem *system;
  850. if (strcmp(name, TRACE_SYSTEM) == 0)
  851. return;
  852. list_for_each_entry(system, &event_subsystems, list) {
  853. if (strcmp(system->name, name) == 0) {
  854. if (!--system->nr_events) {
  855. struct event_filter *filter = system->filter;
  856. debugfs_remove_recursive(system->entry);
  857. list_del(&system->list);
  858. if (filter) {
  859. kfree(filter->filter_string);
  860. kfree(filter);
  861. }
  862. kfree(system->name);
  863. kfree(system);
  864. }
  865. break;
  866. }
  867. }
  868. }
  869. /*
  870. * Must be called under locking both of event_mutex and trace_event_mutex.
  871. */
  872. static void __trace_remove_event_call(struct ftrace_event_call *call)
  873. {
  874. ftrace_event_enable_disable(call, 0);
  875. if (call->event.funcs)
  876. __unregister_ftrace_event(&call->event);
  877. debugfs_remove_recursive(call->dir);
  878. list_del(&call->list);
  879. trace_destroy_fields(call);
  880. destroy_preds(call);
  881. remove_subsystem_dir(call->class->system);
  882. }
  883. /* Remove an event_call */
  884. void trace_remove_event_call(struct ftrace_event_call *call)
  885. {
  886. mutex_lock(&event_mutex);
  887. down_write(&trace_event_mutex);
  888. __trace_remove_event_call(call);
  889. up_write(&trace_event_mutex);
  890. mutex_unlock(&event_mutex);
  891. }
  892. #define for_each_event(event, start, end) \
  893. for (event = start; \
  894. (unsigned long)event < (unsigned long)end; \
  895. event++)
  896. #ifdef CONFIG_MODULES
  897. static LIST_HEAD(ftrace_module_file_list);
  898. /*
  899. * Modules must own their file_operations to keep up with
  900. * reference counting.
  901. */
  902. struct ftrace_module_file_ops {
  903. struct list_head list;
  904. struct module *mod;
  905. struct file_operations id;
  906. struct file_operations enable;
  907. struct file_operations format;
  908. struct file_operations filter;
  909. };
  910. static struct ftrace_module_file_ops *
  911. trace_create_file_ops(struct module *mod)
  912. {
  913. struct ftrace_module_file_ops *file_ops;
  914. /*
  915. * This is a bit of a PITA. To allow for correct reference
  916. * counting, modules must "own" their file_operations.
  917. * To do this, we allocate the file operations that will be
  918. * used in the event directory.
  919. */
  920. file_ops = kmalloc(sizeof(*file_ops), GFP_KERNEL);
  921. if (!file_ops)
  922. return NULL;
  923. file_ops->mod = mod;
  924. file_ops->id = ftrace_event_id_fops;
  925. file_ops->id.owner = mod;
  926. file_ops->enable = ftrace_enable_fops;
  927. file_ops->enable.owner = mod;
  928. file_ops->filter = ftrace_event_filter_fops;
  929. file_ops->filter.owner = mod;
  930. file_ops->format = ftrace_event_format_fops;
  931. file_ops->format.owner = mod;
  932. list_add(&file_ops->list, &ftrace_module_file_list);
  933. return file_ops;
  934. }
  935. static void trace_module_add_events(struct module *mod)
  936. {
  937. struct ftrace_module_file_ops *file_ops = NULL;
  938. struct ftrace_event_call *call, *start, *end;
  939. start = mod->trace_events;
  940. end = mod->trace_events + mod->num_trace_events;
  941. if (start == end)
  942. return;
  943. file_ops = trace_create_file_ops(mod);
  944. if (!file_ops)
  945. return;
  946. for_each_event(call, start, end) {
  947. __trace_add_event_call(call, mod,
  948. &file_ops->id, &file_ops->enable,
  949. &file_ops->filter, &file_ops->format);
  950. }
  951. }
  952. static void trace_module_remove_events(struct module *mod)
  953. {
  954. struct ftrace_module_file_ops *file_ops;
  955. struct ftrace_event_call *call, *p;
  956. bool found = false;
  957. down_write(&trace_event_mutex);
  958. list_for_each_entry_safe(call, p, &ftrace_events, list) {
  959. if (call->mod == mod) {
  960. found = true;
  961. __trace_remove_event_call(call);
  962. }
  963. }
  964. /* Now free the file_operations */
  965. list_for_each_entry(file_ops, &ftrace_module_file_list, list) {
  966. if (file_ops->mod == mod)
  967. break;
  968. }
  969. if (&file_ops->list != &ftrace_module_file_list) {
  970. list_del(&file_ops->list);
  971. kfree(file_ops);
  972. }
  973. /*
  974. * It is safest to reset the ring buffer if the module being unloaded
  975. * registered any events.
  976. */
  977. if (found)
  978. tracing_reset_current_online_cpus();
  979. up_write(&trace_event_mutex);
  980. }
  981. static int trace_module_notify(struct notifier_block *self,
  982. unsigned long val, void *data)
  983. {
  984. struct module *mod = data;
  985. mutex_lock(&event_mutex);
  986. switch (val) {
  987. case MODULE_STATE_COMING:
  988. trace_module_add_events(mod);
  989. break;
  990. case MODULE_STATE_GOING:
  991. trace_module_remove_events(mod);
  992. break;
  993. }
  994. mutex_unlock(&event_mutex);
  995. return 0;
  996. }
  997. #else
  998. static int trace_module_notify(struct notifier_block *self,
  999. unsigned long val, void *data)
  1000. {
  1001. return 0;
  1002. }
  1003. #endif /* CONFIG_MODULES */
  1004. static struct notifier_block trace_module_nb = {
  1005. .notifier_call = trace_module_notify,
  1006. .priority = 0,
  1007. };
  1008. extern struct ftrace_event_call __start_ftrace_events[];
  1009. extern struct ftrace_event_call __stop_ftrace_events[];
  1010. static char bootup_event_buf[COMMAND_LINE_SIZE] __initdata;
  1011. static __init int setup_trace_event(char *str)
  1012. {
  1013. strlcpy(bootup_event_buf, str, COMMAND_LINE_SIZE);
  1014. ring_buffer_expanded = 1;
  1015. tracing_selftest_disabled = 1;
  1016. return 1;
  1017. }
  1018. __setup("trace_event=", setup_trace_event);
  1019. static __init int event_trace_init(void)
  1020. {
  1021. struct ftrace_event_call *call;
  1022. struct dentry *d_tracer;
  1023. struct dentry *entry;
  1024. struct dentry *d_events;
  1025. int ret;
  1026. char *buf = bootup_event_buf;
  1027. char *token;
  1028. d_tracer = tracing_init_dentry();
  1029. if (!d_tracer)
  1030. return 0;
  1031. entry = debugfs_create_file("available_events", 0444, d_tracer,
  1032. (void *)&show_event_seq_ops,
  1033. &ftrace_avail_fops);
  1034. if (!entry)
  1035. pr_warning("Could not create debugfs "
  1036. "'available_events' entry\n");
  1037. entry = debugfs_create_file("set_event", 0644, d_tracer,
  1038. (void *)&show_set_event_seq_ops,
  1039. &ftrace_set_event_fops);
  1040. if (!entry)
  1041. pr_warning("Could not create debugfs "
  1042. "'set_event' entry\n");
  1043. d_events = event_trace_events_dir();
  1044. if (!d_events)
  1045. return 0;
  1046. /* ring buffer internal formats */
  1047. trace_create_file("header_page", 0444, d_events,
  1048. ring_buffer_print_page_header,
  1049. &ftrace_show_header_fops);
  1050. trace_create_file("header_event", 0444, d_events,
  1051. ring_buffer_print_entry_header,
  1052. &ftrace_show_header_fops);
  1053. trace_create_file("enable", 0644, d_events,
  1054. NULL, &ftrace_system_enable_fops);
  1055. if (trace_define_common_fields())
  1056. pr_warning("tracing: Failed to allocate common fields");
  1057. for_each_event(call, __start_ftrace_events, __stop_ftrace_events) {
  1058. __trace_add_event_call(call, NULL, &ftrace_event_id_fops,
  1059. &ftrace_enable_fops,
  1060. &ftrace_event_filter_fops,
  1061. &ftrace_event_format_fops);
  1062. }
  1063. while (true) {
  1064. token = strsep(&buf, ",");
  1065. if (!token)
  1066. break;
  1067. if (!*token)
  1068. continue;
  1069. ret = ftrace_set_clr_event(token, 1);
  1070. if (ret)
  1071. pr_warning("Failed to enable trace event: %s\n", token);
  1072. }
  1073. ret = register_module_notifier(&trace_module_nb);
  1074. if (ret)
  1075. pr_warning("Failed to register trace events module notifier\n");
  1076. return 0;
  1077. }
  1078. fs_initcall(event_trace_init);
  1079. #ifdef CONFIG_FTRACE_STARTUP_TEST
  1080. static DEFINE_SPINLOCK(test_spinlock);
  1081. static DEFINE_SPINLOCK(test_spinlock_irq);
  1082. static DEFINE_MUTEX(test_mutex);
  1083. static __init void test_work(struct work_struct *dummy)
  1084. {
  1085. spin_lock(&test_spinlock);
  1086. spin_lock_irq(&test_spinlock_irq);
  1087. udelay(1);
  1088. spin_unlock_irq(&test_spinlock_irq);
  1089. spin_unlock(&test_spinlock);
  1090. mutex_lock(&test_mutex);
  1091. msleep(1);
  1092. mutex_unlock(&test_mutex);
  1093. }
  1094. static __init int event_test_thread(void *unused)
  1095. {
  1096. void *test_malloc;
  1097. test_malloc = kmalloc(1234, GFP_KERNEL);
  1098. if (!test_malloc)
  1099. pr_info("failed to kmalloc\n");
  1100. schedule_on_each_cpu(test_work);
  1101. kfree(test_malloc);
  1102. set_current_state(TASK_INTERRUPTIBLE);
  1103. while (!kthread_should_stop())
  1104. schedule();
  1105. return 0;
  1106. }
  1107. /*
  1108. * Do various things that may trigger events.
  1109. */
  1110. static __init void event_test_stuff(void)
  1111. {
  1112. struct task_struct *test_thread;
  1113. test_thread = kthread_run(event_test_thread, NULL, "test-events");
  1114. msleep(1);
  1115. kthread_stop(test_thread);
  1116. }
  1117. /*
  1118. * For every trace event defined, we will test each trace point separately,
  1119. * and then by groups, and finally all trace points.
  1120. */
  1121. static __init void event_trace_self_tests(void)
  1122. {
  1123. struct ftrace_event_call *call;
  1124. struct event_subsystem *system;
  1125. int ret;
  1126. pr_info("Running tests on trace events:\n");
  1127. list_for_each_entry(call, &ftrace_events, list) {
  1128. /* Only test those that have a probe */
  1129. if (!call->class || !call->class->probe)
  1130. continue;
  1131. /*
  1132. * Testing syscall events here is pretty useless, but
  1133. * we still do it if configured. But this is time consuming.
  1134. * What we really need is a user thread to perform the
  1135. * syscalls as we test.
  1136. */
  1137. #ifndef CONFIG_EVENT_TRACE_TEST_SYSCALLS
  1138. if (call->class->system &&
  1139. strcmp(call->class->system, "syscalls") == 0)
  1140. continue;
  1141. #endif
  1142. pr_info("Testing event %s: ", call->name);
  1143. /*
  1144. * If an event is already enabled, someone is using
  1145. * it and the self test should not be on.
  1146. */
  1147. if (call->flags & TRACE_EVENT_FL_ENABLED) {
  1148. pr_warning("Enabled event during self test!\n");
  1149. WARN_ON_ONCE(1);
  1150. continue;
  1151. }
  1152. ftrace_event_enable_disable(call, 1);
  1153. event_test_stuff();
  1154. ftrace_event_enable_disable(call, 0);
  1155. pr_cont("OK\n");
  1156. }
  1157. /* Now test at the sub system level */
  1158. pr_info("Running tests on trace event systems:\n");
  1159. list_for_each_entry(system, &event_subsystems, list) {
  1160. /* the ftrace system is special, skip it */
  1161. if (strcmp(system->name, "ftrace") == 0)
  1162. continue;
  1163. pr_info("Testing event system %s: ", system->name);
  1164. ret = __ftrace_set_clr_event(NULL, system->name, NULL, 1);
  1165. if (WARN_ON_ONCE(ret)) {
  1166. pr_warning("error enabling system %s\n",
  1167. system->name);
  1168. continue;
  1169. }
  1170. event_test_stuff();
  1171. ret = __ftrace_set_clr_event(NULL, system->name, NULL, 0);
  1172. if (WARN_ON_ONCE(ret))
  1173. pr_warning("error disabling system %s\n",
  1174. system->name);
  1175. pr_cont("OK\n");
  1176. }
  1177. /* Test with all events enabled */
  1178. pr_info("Running tests on all trace events:\n");
  1179. pr_info("Testing all events: ");
  1180. ret = __ftrace_set_clr_event(NULL, NULL, NULL, 1);
  1181. if (WARN_ON_ONCE(ret)) {
  1182. pr_warning("error enabling all events\n");
  1183. return;
  1184. }
  1185. event_test_stuff();
  1186. /* reset sysname */
  1187. ret = __ftrace_set_clr_event(NULL, NULL, NULL, 0);
  1188. if (WARN_ON_ONCE(ret)) {
  1189. pr_warning("error disabling all events\n");
  1190. return;
  1191. }
  1192. pr_cont("OK\n");
  1193. }
  1194. #ifdef CONFIG_FUNCTION_TRACER
  1195. static DEFINE_PER_CPU(atomic_t, ftrace_test_event_disable);
  1196. static void
  1197. function_test_events_call(unsigned long ip, unsigned long parent_ip)
  1198. {
  1199. struct ring_buffer_event *event;
  1200. struct ring_buffer *buffer;
  1201. struct ftrace_entry *entry;
  1202. unsigned long flags;
  1203. long disabled;
  1204. int cpu;
  1205. int pc;
  1206. pc = preempt_count();
  1207. preempt_disable_notrace();
  1208. cpu = raw_smp_processor_id();
  1209. disabled = atomic_inc_return(&per_cpu(ftrace_test_event_disable, cpu));
  1210. if (disabled != 1)
  1211. goto out;
  1212. local_save_flags(flags);
  1213. event = trace_current_buffer_lock_reserve(&buffer,
  1214. TRACE_FN, sizeof(*entry),
  1215. flags, pc);
  1216. if (!event)
  1217. goto out;
  1218. entry = ring_buffer_event_data(event);
  1219. entry->ip = ip;
  1220. entry->parent_ip = parent_ip;
  1221. trace_nowake_buffer_unlock_commit(buffer, event, flags, pc);
  1222. out:
  1223. atomic_dec(&per_cpu(ftrace_test_event_disable, cpu));
  1224. preempt_enable_notrace();
  1225. }
  1226. static struct ftrace_ops trace_ops __initdata =
  1227. {
  1228. .func = function_test_events_call,
  1229. };
  1230. static __init void event_trace_self_test_with_function(void)
  1231. {
  1232. register_ftrace_function(&trace_ops);
  1233. pr_info("Running tests again, along with the function tracer\n");
  1234. event_trace_self_tests();
  1235. unregister_ftrace_function(&trace_ops);
  1236. }
  1237. #else
  1238. static __init void event_trace_self_test_with_function(void)
  1239. {
  1240. }
  1241. #endif
  1242. static __init int event_trace_self_tests_init(void)
  1243. {
  1244. if (!tracing_selftest_disabled) {
  1245. event_trace_self_tests();
  1246. event_trace_self_test_with_function();
  1247. }
  1248. return 0;
  1249. }
  1250. late_initcall(event_trace_self_tests_init);
  1251. #endif