@@ -1246,13 +1246,26 @@ static int __cmd_top(struct perf_top *top)
1246
1246
1247
1247
if (opts -> record_namespaces )
1248
1248
top -> tool .namespace_events = true;
1249
+ if (opts -> record_cgroup ) {
1250
+ #ifdef HAVE_FILE_HANDLE
1251
+ top -> tool .cgroup_events = true;
1252
+ #else
1253
+ pr_err ("cgroup tracking is not supported.\n" );
1254
+ return -1 ;
1255
+ #endif
1256
+ }
1249
1257
1250
1258
ret = perf_event__synthesize_bpf_events (top -> session , perf_event__process ,
1251
1259
& top -> session -> machines .host ,
1252
1260
& top -> record_opts );
1253
1261
if (ret < 0 )
1254
1262
pr_debug ("Couldn't synthesize BPF events: Pre-existing BPF programs won't have symbols resolved.\n" );
1255
1263
1264
+ ret = perf_event__synthesize_cgroups (& top -> tool , perf_event__process ,
1265
+ & top -> session -> machines .host );
1266
+ if (ret < 0 )
1267
+ pr_debug ("Couldn't synthesize cgroup events.\n" );
1268
+
1256
1269
machine__synthesize_threads (& top -> session -> machines .host , & opts -> target ,
1257
1270
top -> evlist -> core .threads , false,
1258
1271
top -> nr_threads_synthesize );
@@ -1545,6 +1558,8 @@ int cmd_top(int argc, const char **argv)
1545
1558
"number of thread to run event synthesize" ),
1546
1559
OPT_BOOLEAN (0 , "namespaces" , & opts -> record_namespaces ,
1547
1560
"Record namespaces events" ),
1561
+ OPT_BOOLEAN (0 , "all-cgroups" , & opts -> record_cgroup ,
1562
+ "Record cgroup events" ),
1548
1563
OPTS_EVSWITCH (& top .evswitch ),
1549
1564
OPT_END ()
1550
1565
};
0 commit comments