@@ -27,8 +27,8 @@ DEFINE_MUTEX(event_mutex);
2727
2828LIST_HEAD (ftrace_events );
2929
30- int trace_define_field (struct ftrace_event_call * call , const char * type ,
31- const char * name , int offset , int size , int is_signed ,
30+ int trace_define_field (struct ftrace_event_call * call , char * type ,
31+ char * name , int offset , int size , int is_signed ,
3232 int filter_type )
3333{
3434 struct ftrace_event_field * field ;
@@ -92,9 +92,7 @@ int trace_define_common_fields(struct ftrace_event_call *call)
9292}
9393EXPORT_SYMBOL_GPL (trace_define_common_fields );
9494
95- #ifdef CONFIG_MODULES
96-
97- static void trace_destroy_fields (struct ftrace_event_call * call )
95+ void trace_destroy_fields (struct ftrace_event_call * call )
9896{
9997 struct ftrace_event_field * field , * next ;
10098
@@ -106,8 +104,6 @@ static void trace_destroy_fields(struct ftrace_event_call *call)
106104 }
107105}
108106
109- #endif /* CONFIG_MODULES */
110-
111107static void ftrace_event_enable_disable (struct ftrace_event_call * call ,
112108 int enable )
113109{
@@ -116,14 +112,14 @@ static void ftrace_event_enable_disable(struct ftrace_event_call *call,
116112 if (call -> enabled ) {
117113 call -> enabled = 0 ;
118114 tracing_stop_cmdline_record ();
119- call -> unregfunc (call -> data );
115+ call -> unregfunc (call );
120116 }
121117 break ;
122118 case 1 :
123119 if (!call -> enabled ) {
124120 call -> enabled = 1 ;
125121 tracing_start_cmdline_record ();
126- call -> regfunc (call -> data );
122+ call -> regfunc (call );
127123 }
128124 break ;
129125 }
@@ -991,27 +987,43 @@ event_create_dir(struct ftrace_event_call *call, struct dentry *d_events,
991987 return 0 ;
992988}
993989
994- #define for_each_event ( event , start , end ) \
995- for (event = start; \
996- (unsigned long)event < (unsigned long)end; \
997- event++)
990+ static int __trace_add_event_call ( struct ftrace_event_call * call )
991+ {
992+ struct dentry * d_events ;
993+ int ret ;
998994
999- #ifdef CONFIG_MODULES
995+ if (!call -> name )
996+ return - EINVAL ;
1000997
1001- static LIST_HEAD (ftrace_module_file_list );
998+ if (call -> raw_init ) {
999+ ret = call -> raw_init (call );
1000+ if (ret < 0 ) {
1001+ if (ret != - ENOSYS )
1002+ pr_warning ("Could not initialize trace "
1003+ "events/%s\n" , call -> name );
1004+ return ret ;
1005+ }
1006+ }
10021007
1003- /*
1004- * Modules must own their file_operations to keep up with
1005- * reference counting.
1006- */
1007- struct ftrace_module_file_ops {
1008- struct list_head list ;
1009- struct module * mod ;
1010- struct file_operations id ;
1011- struct file_operations enable ;
1012- struct file_operations format ;
1013- struct file_operations filter ;
1014- };
1008+ d_events = event_trace_events_dir ();
1009+ if (!d_events )
1010+ return - ENOENT ;
1011+
1012+ list_add (& call -> list , & ftrace_events );
1013+ return event_create_dir (call , d_events , & ftrace_event_id_fops ,
1014+ & ftrace_enable_fops , & ftrace_event_filter_fops ,
1015+ & ftrace_event_format_fops );
1016+ }
1017+
1018+ /* Add an additional event_call dynamically */
1019+ int trace_add_event_call (struct ftrace_event_call * call )
1020+ {
1021+ int ret ;
1022+ mutex_lock (& event_mutex );
1023+ ret = __trace_add_event_call (call );
1024+ mutex_unlock (& event_mutex );
1025+ return ret ;
1026+ }
10151027
10161028static void remove_subsystem_dir (const char * name )
10171029{
@@ -1039,6 +1051,48 @@ static void remove_subsystem_dir(const char *name)
10391051 }
10401052}
10411053
1054+ static void __trace_remove_event_call (struct ftrace_event_call * call )
1055+ {
1056+ ftrace_event_enable_disable (call , 0 );
1057+ if (call -> event )
1058+ __unregister_ftrace_event (call -> event );
1059+ debugfs_remove_recursive (call -> dir );
1060+ list_del (& call -> list );
1061+ trace_destroy_fields (call );
1062+ destroy_preds (call );
1063+ remove_subsystem_dir (call -> system );
1064+ }
1065+
1066+ /* Remove an event_call */
1067+ void trace_remove_event_call (struct ftrace_event_call * call )
1068+ {
1069+ mutex_lock (& event_mutex );
1070+ __trace_remove_event_call (call );
1071+ mutex_unlock (& event_mutex );
1072+ }
1073+
1074+ #define for_each_event (event , start , end ) \
1075+ for (event = start; \
1076+ (unsigned long)event < (unsigned long)end; \
1077+ event++)
1078+
1079+ #ifdef CONFIG_MODULES
1080+
1081+ static LIST_HEAD (ftrace_module_file_list );
1082+
1083+ /*
1084+ * Modules must own their file_operations to keep up with
1085+ * reference counting.
1086+ */
1087+ struct ftrace_module_file_ops {
1088+ struct list_head list ;
1089+ struct module * mod ;
1090+ struct file_operations id ;
1091+ struct file_operations enable ;
1092+ struct file_operations format ;
1093+ struct file_operations filter ;
1094+ };
1095+
10421096static struct ftrace_module_file_ops *
10431097trace_create_file_ops (struct module * mod )
10441098{
@@ -1096,7 +1150,7 @@ static void trace_module_add_events(struct module *mod)
10961150 if (!call -> name )
10971151 continue ;
10981152 if (call -> raw_init ) {
1099- ret = call -> raw_init ();
1153+ ret = call -> raw_init (call );
11001154 if (ret < 0 ) {
11011155 if (ret != - ENOSYS )
11021156 pr_warning ("Could not initialize trace "
@@ -1131,14 +1185,7 @@ static void trace_module_remove_events(struct module *mod)
11311185 list_for_each_entry_safe (call , p , & ftrace_events , list ) {
11321186 if (call -> mod == mod ) {
11331187 found = true;
1134- ftrace_event_enable_disable (call , 0 );
1135- if (call -> event )
1136- __unregister_ftrace_event (call -> event );
1137- debugfs_remove_recursive (call -> dir );
1138- list_del (& call -> list );
1139- trace_destroy_fields (call );
1140- destroy_preds (call );
1141- remove_subsystem_dir (call -> system );
1188+ __trace_remove_event_call (call );
11421189 }
11431190 }
11441191
@@ -1256,7 +1303,7 @@ static __init int event_trace_init(void)
12561303 if (!call -> name )
12571304 continue ;
12581305 if (call -> raw_init ) {
1259- ret = call -> raw_init ();
1306+ ret = call -> raw_init (call );
12601307 if (ret < 0 ) {
12611308 if (ret != - ENOSYS )
12621309 pr_warning ("Could not initialize trace "
0 commit comments