@@ -1694,6 +1694,7 @@ struct perf_script {
1694
1694
bool show_lost_events ;
1695
1695
bool show_round_events ;
1696
1696
bool show_bpf_events ;
1697
+ bool show_cgroup_events ;
1697
1698
bool allocated ;
1698
1699
bool per_event_dump ;
1699
1700
struct evswitch evswitch ;
@@ -2212,6 +2213,41 @@ static int process_namespaces_event(struct perf_tool *tool,
2212
2213
return ret ;
2213
2214
}
2214
2215
2216
+ static int process_cgroup_event (struct perf_tool * tool ,
2217
+ union perf_event * event ,
2218
+ struct perf_sample * sample ,
2219
+ struct machine * machine )
2220
+ {
2221
+ struct thread * thread ;
2222
+ struct perf_script * script = container_of (tool , struct perf_script , tool );
2223
+ struct perf_session * session = script -> session ;
2224
+ struct evsel * evsel = perf_evlist__id2evsel (session -> evlist , sample -> id );
2225
+ int ret = -1 ;
2226
+
2227
+ thread = machine__findnew_thread (machine , sample -> pid , sample -> tid );
2228
+ if (thread == NULL ) {
2229
+ pr_debug ("problem processing CGROUP event, skipping it.\n" );
2230
+ return -1 ;
2231
+ }
2232
+
2233
+ if (perf_event__process_cgroup (tool , event , sample , machine ) < 0 )
2234
+ goto out ;
2235
+
2236
+ if (!evsel -> core .attr .sample_id_all ) {
2237
+ sample -> cpu = 0 ;
2238
+ sample -> time = 0 ;
2239
+ }
2240
+ if (!filter_cpu (sample )) {
2241
+ perf_sample__fprintf_start (sample , thread , evsel ,
2242
+ PERF_RECORD_CGROUP , stdout );
2243
+ perf_event__fprintf (event , stdout );
2244
+ }
2245
+ ret = 0 ;
2246
+ out :
2247
+ thread__put (thread );
2248
+ return ret ;
2249
+ }
2250
+
2215
2251
static int process_fork_event (struct perf_tool * tool ,
2216
2252
union perf_event * event ,
2217
2253
struct perf_sample * sample ,
@@ -2551,6 +2587,8 @@ static int __cmd_script(struct perf_script *script)
2551
2587
script -> tool .context_switch = process_switch_event ;
2552
2588
if (script -> show_namespace_events )
2553
2589
script -> tool .namespaces = process_namespaces_event ;
2590
+ if (script -> show_cgroup_events )
2591
+ script -> tool .cgroup = process_cgroup_event ;
2554
2592
if (script -> show_lost_events )
2555
2593
script -> tool .lost = process_lost_event ;
2556
2594
if (script -> show_round_events ) {
@@ -3476,6 +3514,7 @@ int cmd_script(int argc, const char **argv)
3476
3514
.mmap2 = perf_event__process_mmap2 ,
3477
3515
.comm = perf_event__process_comm ,
3478
3516
.namespaces = perf_event__process_namespaces ,
3517
+ .cgroup = perf_event__process_cgroup ,
3479
3518
.exit = perf_event__process_exit ,
3480
3519
.fork = perf_event__process_fork ,
3481
3520
.attr = process_attr ,
@@ -3577,6 +3616,8 @@ int cmd_script(int argc, const char **argv)
3577
3616
"Show context switch events (if recorded)" ),
3578
3617
OPT_BOOLEAN ('\0' , "show-namespace-events" , & script .show_namespace_events ,
3579
3618
"Show namespace events (if recorded)" ),
3619
+ OPT_BOOLEAN ('\0' , "show-cgroup-events" , & script .show_cgroup_events ,
3620
+ "Show cgroup events (if recorded)" ),
3580
3621
OPT_BOOLEAN ('\0' , "show-lost-events" , & script .show_lost_events ,
3581
3622
"Show lost events (if recorded)" ),
3582
3623
OPT_BOOLEAN ('\0' , "show-round-events" , & script .show_round_events ,
0 commit comments