aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--tools/perf/util/hist.c89
1 files changed, 29 insertions, 60 deletions
diff --git a/tools/perf/util/hist.c b/tools/perf/util/hist.c
index 1d8c8eab9daa..81ce0aff69d1 100644
--- a/tools/perf/util/hist.c
+++ b/tools/perf/util/hist.c
@@ -1254,25 +1254,6 @@ static bool hists__filter_entry_by_dso(struct hists *hists,
1254 return false; 1254 return false;
1255} 1255}
1256 1256
1257void hists__filter_by_dso(struct hists *hists)
1258{
1259 struct rb_node *nd;
1260
1261 hists->stats.nr_non_filtered_samples = 0;
1262
1263 hists__reset_filter_stats(hists);
1264 hists__reset_col_len(hists);
1265
1266 for (nd = rb_first(&hists->entries); nd; nd = rb_next(nd)) {
1267 struct hist_entry *h = rb_entry(nd, struct hist_entry, rb_node);
1268
1269 if (hists__filter_entry_by_dso(hists, h))
1270 continue;
1271
1272 hists__remove_entry_filter(hists, h, HIST_FILTER__DSO);
1273 }
1274}
1275
1276static bool hists__filter_entry_by_thread(struct hists *hists, 1257static bool hists__filter_entry_by_thread(struct hists *hists,
1277 struct hist_entry *he) 1258 struct hist_entry *he)
1278{ 1259{
@@ -1285,25 +1266,6 @@ static bool hists__filter_entry_by_thread(struct hists *hists,
1285 return false; 1266 return false;
1286} 1267}
1287 1268
1288void hists__filter_by_thread(struct hists *hists)
1289{
1290 struct rb_node *nd;
1291
1292 hists->stats.nr_non_filtered_samples = 0;
1293
1294 hists__reset_filter_stats(hists);
1295 hists__reset_col_len(hists);
1296
1297 for (nd = rb_first(&hists->entries); nd; nd = rb_next(nd)) {
1298 struct hist_entry *h = rb_entry(nd, struct hist_entry, rb_node);
1299
1300 if (hists__filter_entry_by_thread(hists, h))
1301 continue;
1302
1303 hists__remove_entry_filter(hists, h, HIST_FILTER__THREAD);
1304 }
1305}
1306
1307static bool hists__filter_entry_by_symbol(struct hists *hists, 1269static bool hists__filter_entry_by_symbol(struct hists *hists,
1308 struct hist_entry *he) 1270 struct hist_entry *he)
1309{ 1271{
@@ -1317,25 +1279,6 @@ static bool hists__filter_entry_by_symbol(struct hists *hists,
1317 return false; 1279 return false;
1318} 1280}
1319 1281
1320void hists__filter_by_symbol(struct hists *hists)
1321{
1322 struct rb_node *nd;
1323
1324 hists->stats.nr_non_filtered_samples = 0;
1325
1326 hists__reset_filter_stats(hists);
1327 hists__reset_col_len(hists);
1328
1329 for (nd = rb_first(&hists->entries); nd; nd = rb_next(nd)) {
1330 struct hist_entry *h = rb_entry(nd, struct hist_entry, rb_node);
1331
1332 if (hists__filter_entry_by_symbol(hists, h))
1333 continue;
1334
1335 hists__remove_entry_filter(hists, h, HIST_FILTER__SYMBOL);
1336 }
1337}
1338
1339static bool hists__filter_entry_by_socket(struct hists *hists, 1282static bool hists__filter_entry_by_socket(struct hists *hists,
1340 struct hist_entry *he) 1283 struct hist_entry *he)
1341{ 1284{
@@ -1348,7 +1291,9 @@ static bool hists__filter_entry_by_socket(struct hists *hists,
1348 return false; 1291 return false;
1349} 1292}
1350 1293
1351void hists__filter_by_socket(struct hists *hists) 1294typedef bool (*filter_fn_t)(struct hists *hists, struct hist_entry *he);
1295
1296static void hists__filter_by_type(struct hists *hists, int type, filter_fn_t filter)
1352{ 1297{
1353 struct rb_node *nd; 1298 struct rb_node *nd;
1354 1299
@@ -1360,13 +1305,37 @@ void hists__filter_by_socket(struct hists *hists)
1360 for (nd = rb_first(&hists->entries); nd; nd = rb_next(nd)) { 1305 for (nd = rb_first(&hists->entries); nd; nd = rb_next(nd)) {
1361 struct hist_entry *h = rb_entry(nd, struct hist_entry, rb_node); 1306 struct hist_entry *h = rb_entry(nd, struct hist_entry, rb_node);
1362 1307
1363 if (hists__filter_entry_by_socket(hists, h)) 1308 if (filter(hists, h))
1364 continue; 1309 continue;
1365 1310
1366 hists__remove_entry_filter(hists, h, HIST_FILTER__SOCKET); 1311 hists__remove_entry_filter(hists, h, type);
1367 } 1312 }
1368} 1313}
1369 1314
1315void hists__filter_by_thread(struct hists *hists)
1316{
1317 hists__filter_by_type(hists, HIST_FILTER__THREAD,
1318 hists__filter_entry_by_thread);
1319}
1320
1321void hists__filter_by_dso(struct hists *hists)
1322{
1323 hists__filter_by_type(hists, HIST_FILTER__DSO,
1324 hists__filter_entry_by_dso);
1325}
1326
1327void hists__filter_by_symbol(struct hists *hists)
1328{
1329 hists__filter_by_type(hists, HIST_FILTER__SYMBOL,
1330 hists__filter_entry_by_symbol);
1331}
1332
1333void hists__filter_by_socket(struct hists *hists)
1334{
1335 hists__filter_by_type(hists, HIST_FILTER__SOCKET,
1336 hists__filter_entry_by_socket);
1337}
1338
1370void events_stats__inc(struct events_stats *stats, u32 type) 1339void events_stats__inc(struct events_stats *stats, u32 type)
1371{ 1340{
1372 ++stats->nr_events[0]; 1341 ++stats->nr_events[0];