@@ -1153,17 +1153,36 @@ static void remove_event_file_dir(struct trace_event_file *file)
1153
1153
*/
1154
1154
static int
1155
1155
__ftrace_set_clr_event_nolock (struct trace_array * tr , const char * match ,
1156
- const char * sub , const char * event , int set )
1156
+ const char * sub , const char * event , int set ,
1157
+ const char * mod )
1157
1158
{
1158
1159
struct trace_event_file * file ;
1159
1160
struct trace_event_call * call ;
1161
+ char * module __free (kfree ) = NULL ;
1160
1162
const char * name ;
1161
1163
int ret = - EINVAL ;
1162
1164
int eret = 0 ;
1163
1165
1166
+ if (mod ) {
1167
+ char * p ;
1168
+
1169
+ module = kstrdup (mod , GFP_KERNEL );
1170
+ if (!module )
1171
+ return - ENOMEM ;
1172
+
1173
+ /* Replace all '-' with '_' as that's what modules do */
1174
+ for (p = strchr (module , '-' ); p ; p = strchr (p + 1 , '-' ))
1175
+ * p = '_' ;
1176
+ }
1177
+
1164
1178
list_for_each_entry (file , & tr -> events , list ) {
1165
1179
1166
1180
call = file -> event_call ;
1181
+
1182
+ /* If a module is specified, skip events that are not that module */
1183
+ if (module && (!call -> module || strcmp (module_name (call -> module ), module )))
1184
+ continue ;
1185
+
1167
1186
name = trace_event_name (call );
1168
1187
1169
1188
if (!name || !call -> class || !call -> class -> reg )
@@ -1200,24 +1219,34 @@ __ftrace_set_clr_event_nolock(struct trace_array *tr, const char *match,
1200
1219
}
1201
1220
1202
1221
static int __ftrace_set_clr_event (struct trace_array * tr , const char * match ,
1203
- const char * sub , const char * event , int set )
1222
+ const char * sub , const char * event , int set ,
1223
+ const char * mod )
1204
1224
{
1205
1225
int ret ;
1206
1226
1207
1227
mutex_lock (& event_mutex );
1208
- ret = __ftrace_set_clr_event_nolock (tr , match , sub , event , set );
1228
+ ret = __ftrace_set_clr_event_nolock (tr , match , sub , event , set , mod );
1209
1229
mutex_unlock (& event_mutex );
1210
1230
1211
1231
return ret ;
1212
1232
}
1213
1233
1214
1234
int ftrace_set_clr_event (struct trace_array * tr , char * buf , int set )
1215
1235
{
1216
- char * event = NULL , * sub = NULL , * match ;
1236
+ char * event = NULL , * sub = NULL , * match , * mod ;
1217
1237
int ret ;
1218
1238
1219
1239
if (!tr )
1220
1240
return - ENOENT ;
1241
+
1242
+ /* Modules events can be appened with :mod:<module> */
1243
+ mod = strstr (buf , ":mod:" );
1244
+ if (mod ) {
1245
+ * mod = '\0' ;
1246
+ /* move to the module name */
1247
+ mod += 5 ;
1248
+ }
1249
+
1221
1250
/*
1222
1251
* The buf format can be <subsystem>:<event-name>
1223
1252
* *:<event-name> means any event by that name.
@@ -1240,9 +1269,13 @@ int ftrace_set_clr_event(struct trace_array *tr, char *buf, int set)
1240
1269
sub = NULL ;
1241
1270
if (!strlen (event ) || strcmp (event , "*" ) == 0 )
1242
1271
event = NULL ;
1272
+ } else if (mod ) {
1273
+ /* Allow wildcard for no length or star */
1274
+ if (!strlen (match ) || strcmp (match , "*" ) == 0 )
1275
+ match = NULL ;
1243
1276
}
1244
1277
1245
- ret = __ftrace_set_clr_event (tr , match , sub , event , set );
1278
+ ret = __ftrace_set_clr_event (tr , match , sub , event , set , mod );
1246
1279
1247
1280
/* Put back the colon to allow this to be called again */
1248
1281
if (buf )
@@ -1270,7 +1303,7 @@ int trace_set_clr_event(const char *system, const char *event, int set)
1270
1303
if (!tr )
1271
1304
return - ENODEV ;
1272
1305
1273
- return __ftrace_set_clr_event (tr , NULL , system , event , set );
1306
+ return __ftrace_set_clr_event (tr , NULL , system , event , set , NULL );
1274
1307
}
1275
1308
EXPORT_SYMBOL_GPL (trace_set_clr_event );
1276
1309
@@ -1296,7 +1329,7 @@ int trace_array_set_clr_event(struct trace_array *tr, const char *system,
1296
1329
return - ENOENT ;
1297
1330
1298
1331
set = (enable == true) ? 1 : 0 ;
1299
- return __ftrace_set_clr_event (tr , NULL , system , event , set );
1332
+ return __ftrace_set_clr_event (tr , NULL , system , event , set , NULL );
1300
1333
}
1301
1334
EXPORT_SYMBOL_GPL (trace_array_set_clr_event );
1302
1335
@@ -1646,7 +1679,7 @@ system_enable_write(struct file *filp, const char __user *ubuf, size_t cnt,
1646
1679
if (system )
1647
1680
name = system -> name ;
1648
1681
1649
- ret = __ftrace_set_clr_event (dir -> tr , NULL , name , NULL , val );
1682
+ ret = __ftrace_set_clr_event (dir -> tr , NULL , name , NULL , val , NULL );
1650
1683
if (ret )
1651
1684
goto out ;
1652
1685
@@ -4094,7 +4127,7 @@ int event_trace_del_tracer(struct trace_array *tr)
4094
4127
__ftrace_clear_event_pids (tr , TRACE_PIDS | TRACE_NO_PIDS );
4095
4128
4096
4129
/* Disable any running events */
4097
- __ftrace_set_clr_event_nolock (tr , NULL , NULL , NULL , 0 );
4130
+ __ftrace_set_clr_event_nolock (tr , NULL , NULL , NULL , 0 , NULL );
4098
4131
4099
4132
/* Make sure no more events are being executed */
4100
4133
tracepoint_synchronize_unregister ();
@@ -4378,7 +4411,7 @@ static __init void event_trace_self_tests(void)
4378
4411
4379
4412
pr_info ("Testing event system %s: " , system -> name );
4380
4413
4381
- ret = __ftrace_set_clr_event (tr , NULL , system -> name , NULL , 1 );
4414
+ ret = __ftrace_set_clr_event (tr , NULL , system -> name , NULL , 1 , NULL );
4382
4415
if (WARN_ON_ONCE (ret )) {
4383
4416
pr_warn ("error enabling system %s\n" ,
4384
4417
system -> name );
@@ -4387,7 +4420,7 @@ static __init void event_trace_self_tests(void)
4387
4420
4388
4421
event_test_stuff ();
4389
4422
4390
- ret = __ftrace_set_clr_event (tr , NULL , system -> name , NULL , 0 );
4423
+ ret = __ftrace_set_clr_event (tr , NULL , system -> name , NULL , 0 , NULL );
4391
4424
if (WARN_ON_ONCE (ret )) {
4392
4425
pr_warn ("error disabling system %s\n" ,
4393
4426
system -> name );
@@ -4402,7 +4435,7 @@ static __init void event_trace_self_tests(void)
4402
4435
pr_info ("Running tests on all trace events:\n" );
4403
4436
pr_info ("Testing all events: " );
4404
4437
4405
- ret = __ftrace_set_clr_event (tr , NULL , NULL , NULL , 1 );
4438
+ ret = __ftrace_set_clr_event (tr , NULL , NULL , NULL , 1 , NULL );
4406
4439
if (WARN_ON_ONCE (ret )) {
4407
4440
pr_warn ("error enabling all events\n" );
4408
4441
return ;
@@ -4411,7 +4444,7 @@ static __init void event_trace_self_tests(void)
4411
4444
event_test_stuff ();
4412
4445
4413
4446
/* reset sysname */
4414
- ret = __ftrace_set_clr_event (tr , NULL , NULL , NULL , 0 );
4447
+ ret = __ftrace_set_clr_event (tr , NULL , NULL , NULL , 0 , NULL );
4415
4448
if (WARN_ON_ONCE (ret )) {
4416
4449
pr_warn ("error disabling all events\n" );
4417
4450
return ;
0 commit comments