@@ -67,10 +67,7 @@ struct tracepoint_entry {
6767};
6868
6969struct tp_probes {
70- union {
71- struct rcu_head rcu ;
72- struct list_head list ;
73- } u ;
70+ struct rcu_head rcu ;
7471 struct tracepoint_func probes [0 ];
7572};
7673
@@ -83,15 +80,15 @@ static inline void *allocate_probes(int count)
8380
8481static void rcu_free_old_probes (struct rcu_head * head )
8582{
86- kfree (container_of (head , struct tp_probes , u . rcu ));
83+ kfree (container_of (head , struct tp_probes , rcu ));
8784}
8885
8986static inline void release_probes (struct tracepoint_func * old )
9087{
9188 if (old ) {
9289 struct tp_probes * tp_probes = container_of (old ,
9390 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 );
9592 }
9693}
9794
@@ -459,204 +456,11 @@ int tracepoint_probe_unregister(const char *name, void *probe, void *data)
459456}
460457EXPORT_SYMBOL_GPL (tracepoint_probe_unregister );
461458
462- static LIST_HEAD (old_probes );
463- static int need_update ;
464-
465- static 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- */
483- int 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- }
498- EXPORT_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- */
508- int 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- }
523- EXPORT_SYMBOL_GPL (tracepoint_probe_unregister_noupdate );
524-
525- /**
526- * tracepoint_probe_update_all - update tracepoints
527- */
528- void 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- }
548- EXPORT_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- */
560- static 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
573- static 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 );
606- end :
607- if (!found )
608- tracepoint_iter_reset (iter );
609- }
610- #else /* CONFIG_MODULES */
611- static 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-
624- void tracepoint_iter_start (struct tracepoint_iter * iter )
625- {
626- tracepoint_get_iter (iter );
627- }
628- EXPORT_SYMBOL_GPL (tracepoint_iter_start );
629-
630- void 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- }
640- EXPORT_SYMBOL_GPL (tracepoint_iter_next );
641-
642- void tracepoint_iter_stop (struct tracepoint_iter * iter )
643- {
644- }
645- EXPORT_SYMBOL_GPL (tracepoint_iter_stop );
646-
647- void 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- }
654- EXPORT_SYMBOL_GPL (tracepoint_iter_reset );
655459
656460#ifdef CONFIG_MODULES
657461static int tracepoint_module_coming (struct module * mod )
658462{
659- struct tp_module * tp_mod , * iter ;
463+ struct tp_module * tp_mod ;
660464 int ret = 0 ;
661465
662466 if (!mod -> num_tracepoints )
@@ -677,23 +481,7 @@ static int tracepoint_module_coming(struct module *mod)
677481 }
678482 tp_mod -> num_tracepoints = mod -> num_tracepoints ;
679483 tp_mod -> tracepoints_ptrs = mod -> tracepoints_ptrs ;
680-
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 );
696- module_added :
484+ list_add_tail (& tp_mod -> list , & tracepoint_module_list );
697485 tracepoint_update_probe_range (mod -> tracepoints_ptrs ,
698486 mod -> tracepoints_ptrs + mod -> num_tracepoints );
699487end :
0 commit comments