aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRobert Richter <robert.richter@amd.com>2011-12-15 11:32:40 -0500
committerArnaldo Carvalho de Melo <acme@redhat.com>2012-02-02 14:41:17 -0500
commit781ba9d2ed9df07dbb413fb5ee80ef7d353841c9 (patch)
tree1e3ce400e28b684a03237d5b3c5e4007e8f37566
parent4eced2347c447c9409877368fc52478c356b4767 (diff)
perf record: Make feature initialization generic
Loop over all features to enable it instead of explicitly enabling every single feature. Reducing duplicate code and making it more robust to later changes e.g. when adding more features. Cc: Ingo Molnar <mingo@elte.hu> Link: http://lkml.kernel.org/r/1323966762-8574-3-git-send-email-robert.richter@amd.com Signed-off-by: Robert Richter <robert.richter@amd.com> Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
-rw-r--r--tools/perf/builtin-record.c28
-rw-r--r--tools/perf/util/header.h1
2 files changed, 10 insertions, 19 deletions
diff --git a/tools/perf/builtin-record.c b/tools/perf/builtin-record.c
index 32870eef952f..f8d9a545dd6e 100644
--- a/tools/perf/builtin-record.c
+++ b/tools/perf/builtin-record.c
@@ -386,7 +386,7 @@ static int __cmd_record(struct perf_record *rec, int argc, const char **argv)
386{ 386{
387 struct stat st; 387 struct stat st;
388 int flags; 388 int flags;
389 int err, output; 389 int err, output, feat;
390 unsigned long waking = 0; 390 unsigned long waking = 0;
391 const bool forks = argc > 0; 391 const bool forks = argc > 0;
392 struct machine *machine; 392 struct machine *machine;
@@ -453,8 +453,14 @@ static int __cmd_record(struct perf_record *rec, int argc, const char **argv)
453 453
454 rec->session = session; 454 rec->session = session;
455 455
456 if (!rec->no_buildid) 456 for (feat = HEADER_FIRST_FEATURE; feat < HEADER_LAST_FEATURE; feat++)
457 perf_header__set_feat(&session->header, HEADER_BUILD_ID); 457 perf_header__set_feat(&session->header, feat);
458
459 if (rec->no_buildid)
460 perf_header__clear_feat(&session->header, HEADER_BUILD_ID);
461
462 if (!have_tracepoints(&evsel_list->entries))
463 perf_header__clear_feat(&session->header, HEADER_TRACE_INFO);
458 464
459 if (!rec->file_new) { 465 if (!rec->file_new) {
460 err = perf_session__read_header(session, output); 466 err = perf_session__read_header(session, output);
@@ -462,22 +468,6 @@ static int __cmd_record(struct perf_record *rec, int argc, const char **argv)
462 goto out_delete_session; 468 goto out_delete_session;
463 } 469 }
464 470
465 if (have_tracepoints(&evsel_list->entries))
466 perf_header__set_feat(&session->header, HEADER_TRACE_INFO);
467
468 perf_header__set_feat(&session->header, HEADER_HOSTNAME);
469 perf_header__set_feat(&session->header, HEADER_OSRELEASE);
470 perf_header__set_feat(&session->header, HEADER_ARCH);
471 perf_header__set_feat(&session->header, HEADER_CPUDESC);
472 perf_header__set_feat(&session->header, HEADER_NRCPUS);
473 perf_header__set_feat(&session->header, HEADER_EVENT_DESC);
474 perf_header__set_feat(&session->header, HEADER_CMDLINE);
475 perf_header__set_feat(&session->header, HEADER_VERSION);
476 perf_header__set_feat(&session->header, HEADER_CPU_TOPOLOGY);
477 perf_header__set_feat(&session->header, HEADER_TOTAL_MEM);
478 perf_header__set_feat(&session->header, HEADER_NUMA_TOPOLOGY);
479 perf_header__set_feat(&session->header, HEADER_CPUID);
480
481 if (forks) { 471 if (forks) {
482 err = perf_evlist__prepare_workload(evsel_list, opts, argv); 472 err = perf_evlist__prepare_workload(evsel_list, opts, argv);
483 if (err < 0) { 473 if (err < 0) {
diff --git a/tools/perf/util/header.h b/tools/perf/util/header.h
index ac4ec956024e..e68f617d082f 100644
--- a/tools/perf/util/header.h
+++ b/tools/perf/util/header.h
@@ -11,6 +11,7 @@
11 11
12enum { 12enum {
13 HEADER_RESERVED = 0, /* always cleared */ 13 HEADER_RESERVED = 0, /* always cleared */
14 HEADER_FIRST_FEATURE = 1,
14 HEADER_TRACE_INFO = 1, 15 HEADER_TRACE_INFO = 1,
15 HEADER_BUILD_ID, 16 HEADER_BUILD_ID,
16 17