aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMathieu Desnoyers <mathieu.desnoyers@efficios.com>2014-03-21 01:19:01 -0400
committerSteven Rostedt <rostedt@goodmis.org>2014-03-21 14:01:15 -0400
commit0dea6d52638b2693b18cd2ed8938b236e0789ddb (patch)
tree3b7e20b680b63900e81dee3a0f2469c4ae4abe7a
parentbc4c426ee2431d1f717004d3bbaacbd819b544fd (diff)
tracepoint: Remove unused API functions
After the following commit: commit b75ef8b44b1cb95f5a26484b0e2fe37a63b12b44 Author: Mathieu Desnoyers <mathieu.desnoyers@efficios.com> Date: Wed Aug 10 15:18:39 2011 -0400 Tracepoint: Dissociate from module mutex The following functions became unnecessary: - tracepoint_probe_register_noupdate, - tracepoint_probe_unregister_noupdate, - tracepoint_probe_update_all. In fact, none of the in-kernel tracers, nor LTTng, nor SystemTAP use them. Remove those. Moreover, the functions: - tracepoint_iter_start, - tracepoint_iter_next, - tracepoint_iter_stop, - tracepoint_iter_reset. are unused by in-kernel tracers, LTTng and SystemTAP. Remove those too. Link: http://lkml.kernel.org/r/1395379142-2118-2-git-send-email-mathieu.desnoyers@efficios.com Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com> Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
-rw-r--r--include/linux/tracepoint.h18
-rw-r--r--kernel/tracepoint.c222
2 files changed, 5 insertions, 235 deletions
diff --git a/include/linux/tracepoint.h b/include/linux/tracepoint.h
index accc497f8d72..a3b2837d8dd1 100644
--- a/include/linux/tracepoint.h
+++ b/include/linux/tracepoint.h
@@ -48,12 +48,6 @@ extern int tracepoint_probe_register(const char *name, void *probe, void *data);
48extern int 48extern int
49tracepoint_probe_unregister(const char *name, void *probe, void *data); 49tracepoint_probe_unregister(const char *name, void *probe, void *data);
50 50
51extern int tracepoint_probe_register_noupdate(const char *name, void *probe,
52 void *data);
53extern int tracepoint_probe_unregister_noupdate(const char *name, void *probe,
54 void *data);
55extern void tracepoint_probe_update_all(void);
56
57#ifdef CONFIG_MODULES 51#ifdef CONFIG_MODULES
58struct tp_module { 52struct tp_module {
59 struct list_head list; 53 struct list_head list;
@@ -62,18 +56,6 @@ struct tp_module {
62}; 56};
63#endif /* CONFIG_MODULES */ 57#endif /* CONFIG_MODULES */
64 58
65struct tracepoint_iter {
66#ifdef CONFIG_MODULES
67 struct tp_module *module;
68#endif /* CONFIG_MODULES */
69 struct tracepoint * const *tracepoint;
70};
71
72extern void tracepoint_iter_start(struct tracepoint_iter *iter);
73extern void tracepoint_iter_next(struct tracepoint_iter *iter);
74extern void tracepoint_iter_stop(struct tracepoint_iter *iter);
75extern void tracepoint_iter_reset(struct tracepoint_iter *iter);
76
77/* 59/*
78 * tracepoint_synchronize_unregister must be called between the last tracepoint 60 * tracepoint_synchronize_unregister must be called between the last tracepoint
79 * probe unregistration and the end of module exit to make sure there is no 61 * probe unregistration and the end of module exit to make sure there is no
diff --git a/kernel/tracepoint.c b/kernel/tracepoint.c
index e2a58a22b0f4..65d9f9459a75 100644
--- a/kernel/tracepoint.c
+++ b/kernel/tracepoint.c
@@ -67,10 +67,7 @@ struct tracepoint_entry {
67}; 67};
68 68
69struct tp_probes { 69struct tp_probes {
70 union { 70 struct rcu_head rcu;
71 struct rcu_head rcu;
72 struct list_head list;
73 } u;
74 struct tracepoint_func probes[0]; 71 struct tracepoint_func probes[0];
75}; 72};
76 73
@@ -83,7 +80,7 @@ static inline void *allocate_probes(int count)
83 80
84static void rcu_free_old_probes(struct rcu_head *head) 81static void rcu_free_old_probes(struct rcu_head *head)
85{ 82{
86 kfree(container_of(head, struct tp_probes, u.rcu)); 83 kfree(container_of(head, struct tp_probes, rcu));
87} 84}
88 85
89static inline void release_probes(struct tracepoint_func *old) 86static inline void release_probes(struct tracepoint_func *old)
@@ -91,7 +88,7 @@ static inline void release_probes(struct tracepoint_func *old)
91 if (old) { 88 if (old) {
92 struct tp_probes *tp_probes = container_of(old, 89 struct tp_probes *tp_probes = container_of(old,
93 struct tp_probes, probes[0]); 90 struct tp_probes, probes[0]);
94 call_rcu_sched(&tp_probes->u.rcu, rcu_free_old_probes); 91 call_rcu_sched(&tp_probes->rcu, rcu_free_old_probes);
95 } 92 }
96} 93}
97 94
@@ -459,204 +456,11 @@ int tracepoint_probe_unregister(const char *name, void *probe, void *data)
459} 456}
460EXPORT_SYMBOL_GPL(tracepoint_probe_unregister); 457EXPORT_SYMBOL_GPL(tracepoint_probe_unregister);
461 458
462static LIST_HEAD(old_probes);
463static int need_update;
464
465static void tracepoint_add_old_probes(void *old)
466{
467 need_update = 1;
468 if (old) {
469 struct tp_probes *tp_probes = container_of(old,
470 struct tp_probes, probes[0]);
471 list_add(&tp_probes->u.list, &old_probes);
472 }
473}
474
475/**
476 * tracepoint_probe_register_noupdate - register a probe but not connect
477 * @name: tracepoint name
478 * @probe: probe handler
479 * @data: probe private data
480 *
481 * caller must call tracepoint_probe_update_all()
482 */
483int tracepoint_probe_register_noupdate(const char *name, void *probe,
484 void *data)
485{
486 struct tracepoint_func *old;
487
488 mutex_lock(&tracepoints_mutex);
489 old = tracepoint_add_probe(name, probe, data);
490 if (IS_ERR(old)) {
491 mutex_unlock(&tracepoints_mutex);
492 return PTR_ERR(old);
493 }
494 tracepoint_add_old_probes(old);
495 mutex_unlock(&tracepoints_mutex);
496 return 0;
497}
498EXPORT_SYMBOL_GPL(tracepoint_probe_register_noupdate);
499
500/**
501 * tracepoint_probe_unregister_noupdate - remove a probe but not disconnect
502 * @name: tracepoint name
503 * @probe: probe function pointer
504 * @data: probe private data
505 *
506 * caller must call tracepoint_probe_update_all()
507 */
508int tracepoint_probe_unregister_noupdate(const char *name, void *probe,
509 void *data)
510{
511 struct tracepoint_func *old;
512
513 mutex_lock(&tracepoints_mutex);
514 old = tracepoint_remove_probe(name, probe, data);
515 if (IS_ERR(old)) {
516 mutex_unlock(&tracepoints_mutex);
517 return PTR_ERR(old);
518 }
519 tracepoint_add_old_probes(old);
520 mutex_unlock(&tracepoints_mutex);
521 return 0;
522}
523EXPORT_SYMBOL_GPL(tracepoint_probe_unregister_noupdate);
524
525/**
526 * tracepoint_probe_update_all - update tracepoints
527 */
528void tracepoint_probe_update_all(void)
529{
530 LIST_HEAD(release_probes);
531 struct tp_probes *pos, *next;
532
533 mutex_lock(&tracepoints_mutex);
534 if (!need_update) {
535 mutex_unlock(&tracepoints_mutex);
536 return;
537 }
538 if (!list_empty(&old_probes))
539 list_replace_init(&old_probes, &release_probes);
540 need_update = 0;
541 tracepoint_update_probes();
542 mutex_unlock(&tracepoints_mutex);
543 list_for_each_entry_safe(pos, next, &release_probes, u.list) {
544 list_del(&pos->u.list);
545 call_rcu_sched(&pos->u.rcu, rcu_free_old_probes);
546 }
547}
548EXPORT_SYMBOL_GPL(tracepoint_probe_update_all);
549
550/**
551 * tracepoint_get_iter_range - Get a next tracepoint iterator given a range.
552 * @tracepoint: current tracepoints (in), next tracepoint (out)
553 * @begin: beginning of the range
554 * @end: end of the range
555 *
556 * Returns whether a next tracepoint has been found (1) or not (0).
557 * Will return the first tracepoint in the range if the input tracepoint is
558 * NULL.
559 */
560static int tracepoint_get_iter_range(struct tracepoint * const **tracepoint,
561 struct tracepoint * const *begin, struct tracepoint * const *end)
562{
563 if (!*tracepoint && begin != end) {
564 *tracepoint = begin;
565 return 1;
566 }
567 if (*tracepoint >= begin && *tracepoint < end)
568 return 1;
569 return 0;
570}
571
572#ifdef CONFIG_MODULES
573static void tracepoint_get_iter(struct tracepoint_iter *iter)
574{
575 int found = 0;
576 struct tp_module *iter_mod;
577
578 /* Core kernel tracepoints */
579 if (!iter->module) {
580 found = tracepoint_get_iter_range(&iter->tracepoint,
581 __start___tracepoints_ptrs,
582 __stop___tracepoints_ptrs);
583 if (found)
584 goto end;
585 }
586 /* Tracepoints in modules */
587 mutex_lock(&tracepoints_mutex);
588 list_for_each_entry(iter_mod, &tracepoint_module_list, list) {
589 /*
590 * Sorted module list
591 */
592 if (iter_mod < iter->module)
593 continue;
594 else if (iter_mod > iter->module)
595 iter->tracepoint = NULL;
596 found = tracepoint_get_iter_range(&iter->tracepoint,
597 iter_mod->tracepoints_ptrs,
598 iter_mod->tracepoints_ptrs
599 + iter_mod->num_tracepoints);
600 if (found) {
601 iter->module = iter_mod;
602 break;
603 }
604 }
605 mutex_unlock(&tracepoints_mutex);
606end:
607 if (!found)
608 tracepoint_iter_reset(iter);
609}
610#else /* CONFIG_MODULES */
611static void tracepoint_get_iter(struct tracepoint_iter *iter)
612{
613 int found = 0;
614
615 /* Core kernel tracepoints */
616 found = tracepoint_get_iter_range(&iter->tracepoint,
617 __start___tracepoints_ptrs,
618 __stop___tracepoints_ptrs);
619 if (!found)
620 tracepoint_iter_reset(iter);
621}
622#endif /* CONFIG_MODULES */
623
624void tracepoint_iter_start(struct tracepoint_iter *iter)
625{
626 tracepoint_get_iter(iter);
627}
628EXPORT_SYMBOL_GPL(tracepoint_iter_start);
629
630void tracepoint_iter_next(struct tracepoint_iter *iter)
631{
632 iter->tracepoint++;
633 /*
634 * iter->tracepoint may be invalid because we blindly incremented it.
635 * Make sure it is valid by marshalling on the tracepoints, getting the
636 * tracepoints from following modules if necessary.
637 */
638 tracepoint_get_iter(iter);
639}
640EXPORT_SYMBOL_GPL(tracepoint_iter_next);
641
642void tracepoint_iter_stop(struct tracepoint_iter *iter)
643{
644}
645EXPORT_SYMBOL_GPL(tracepoint_iter_stop);
646
647void tracepoint_iter_reset(struct tracepoint_iter *iter)
648{
649#ifdef CONFIG_MODULES
650 iter->module = NULL;
651#endif /* CONFIG_MODULES */
652 iter->tracepoint = NULL;
653}
654EXPORT_SYMBOL_GPL(tracepoint_iter_reset);
655 459
656#ifdef CONFIG_MODULES 460#ifdef CONFIG_MODULES
657static int tracepoint_module_coming(struct module *mod) 461static int tracepoint_module_coming(struct module *mod)
658{ 462{
659 struct tp_module *tp_mod, *iter; 463 struct tp_module *tp_mod;
660 int ret = 0; 464 int ret = 0;
661 465
662 if (!mod->num_tracepoints) 466 if (!mod->num_tracepoints)
@@ -677,23 +481,7 @@ static int tracepoint_module_coming(struct module *mod)
677 } 481 }
678 tp_mod->num_tracepoints = mod->num_tracepoints; 482 tp_mod->num_tracepoints = mod->num_tracepoints;
679 tp_mod->tracepoints_ptrs = mod->tracepoints_ptrs; 483 tp_mod->tracepoints_ptrs = mod->tracepoints_ptrs;
680 484 list_add_tail(&tp_mod->list, &tracepoint_module_list);
681 /*
682 * tracepoint_module_list is kept sorted by struct module pointer
683 * address for iteration on tracepoints from a seq_file that can release
684 * the mutex between calls.
685 */
686 list_for_each_entry_reverse(iter, &tracepoint_module_list, list) {
687 BUG_ON(iter == tp_mod); /* Should never be in the list twice */
688 if (iter < tp_mod) {
689 /* We belong to the location right after iter. */
690 list_add(&tp_mod->list, &iter->list);
691 goto module_added;
692 }
693 }
694 /* We belong to the beginning of the list */
695 list_add(&tp_mod->list, &tracepoint_module_list);
696module_added:
697 tracepoint_update_probe_range(mod->tracepoints_ptrs, 485 tracepoint_update_probe_range(mod->tracepoints_ptrs,
698 mod->tracepoints_ptrs + mod->num_tracepoints); 486 mod->tracepoints_ptrs + mod->num_tracepoints);
699end: 487end: