diff options
author | Robert Richter <robert.richter@amd.com> | 2011-12-07 04:02:55 -0500 |
---|---|---|
committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2011-12-23 14:02:22 -0500 |
commit | e20960c0271f91aead94746872fd976326a703b3 (patch) | |
tree | fdc1b932114df3a9e155e9f36cda93a4c11537ad /tools/perf | |
parent | efad14150a0b4429f37da7245001a8096ef7ee38 (diff) |
perf tools: Unify handling of features when writing feature section
The features HEADER_TRACE_INFO and HEADER_BUILD_ID are handled
different when writing the feature section. All other features are
simply disabled on failure and writing the section goes on without
returning an error. There is no reason for these special cases. This
patch unifies handling of the features.
This should be ok since all features can be parsed independently.
Offset and size of a feature's block is stored in struct perf_file_
section right after the data block of perf.data (see perf_session__
write_header()). Thus, if a feature does not exist then other features
can be processed anyway.
Also moving special code for HEADER_BUILD_ID out to write_build_id().
v2:
* perf record throws an error now if buildids may not be generated,
which can be disabled with the --no-buildid option.
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Stephane Eranian <eranian@google.com>
Link: http://lkml.kernel.org/r/1323248577-11268-6-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>
Diffstat (limited to 'tools/perf')
-rw-r--r-- | tools/perf/builtin-record.c | 7 | ||||
-rw-r--r-- | tools/perf/util/header.c | 14 |
2 files changed, 12 insertions, 9 deletions
diff --git a/tools/perf/builtin-record.c b/tools/perf/builtin-record.c index e873ae2dd54c..0abfb18b911f 100644 --- a/tools/perf/builtin-record.c +++ b/tools/perf/builtin-record.c | |||
@@ -503,6 +503,13 @@ static int __cmd_record(struct perf_record *rec, int argc, const char **argv) | |||
503 | return err; | 503 | return err; |
504 | } | 504 | } |
505 | 505 | ||
506 | if (!!rec->no_buildid | ||
507 | && !perf_header__has_feat(&session->header, HEADER_BUILD_ID)) { | ||
508 | pr_err("Couldn't generating buildids. " | ||
509 | "Use --no-buildid to profile anyway.\n"); | ||
510 | return -1; | ||
511 | } | ||
512 | |||
506 | rec->post_processing_offset = lseek(output, 0, SEEK_CUR); | 513 | rec->post_processing_offset = lseek(output, 0, SEEK_CUR); |
507 | 514 | ||
508 | machine = perf_session__find_host_machine(session); | 515 | machine = perf_session__find_host_machine(session); |
diff --git a/tools/perf/util/header.c b/tools/perf/util/header.c index 609d79b5fb5e..71326836921b 100644 --- a/tools/perf/util/header.c +++ b/tools/perf/util/header.c | |||
@@ -445,6 +445,9 @@ static int write_build_id(int fd, struct perf_header *h, | |||
445 | 445 | ||
446 | session = container_of(h, struct perf_session, header); | 446 | session = container_of(h, struct perf_session, header); |
447 | 447 | ||
448 | if (!perf_session__read_build_ids(session, true)) | ||
449 | return -1; | ||
450 | |||
448 | err = dsos__write_buildid_table(h, fd); | 451 | err = dsos__write_buildid_table(h, fd); |
449 | if (err < 0) { | 452 | if (err < 0) { |
450 | pr_debug("failed to write buildid table\n"); | 453 | pr_debug("failed to write buildid table\n"); |
@@ -1417,10 +1420,6 @@ static int perf_header__adds_write(struct perf_header *header, | |||
1417 | 1420 | ||
1418 | session = container_of(header, struct perf_session, header); | 1421 | session = container_of(header, struct perf_session, header); |
1419 | 1422 | ||
1420 | if (perf_header__has_feat(header, HEADER_BUILD_ID && | ||
1421 | !perf_session__read_build_ids(session, true))) | ||
1422 | perf_header__clear_feat(header, HEADER_BUILD_ID); | ||
1423 | |||
1424 | nr_sections = bitmap_weight(header->adds_features, HEADER_FEAT_BITS); | 1423 | nr_sections = bitmap_weight(header->adds_features, HEADER_FEAT_BITS); |
1425 | if (!nr_sections) | 1424 | if (!nr_sections) |
1426 | return 0; | 1425 | return 0; |
@@ -1436,13 +1435,11 @@ static int perf_header__adds_write(struct perf_header *header, | |||
1436 | 1435 | ||
1437 | err = do_write_feat(fd, header, HEADER_TRACE_INFO, &p, evlist); | 1436 | err = do_write_feat(fd, header, HEADER_TRACE_INFO, &p, evlist); |
1438 | if (err) | 1437 | if (err) |
1439 | goto out_free; | 1438 | perf_header__clear_feat(header, HEADER_TRACE_INFO); |
1440 | 1439 | ||
1441 | err = do_write_feat(fd, header, HEADER_BUILD_ID, &p, evlist); | 1440 | err = do_write_feat(fd, header, HEADER_BUILD_ID, &p, evlist); |
1442 | if (err) { | 1441 | if (err) |
1443 | perf_header__clear_feat(header, HEADER_BUILD_ID); | 1442 | perf_header__clear_feat(header, HEADER_BUILD_ID); |
1444 | goto out_free; | ||
1445 | } | ||
1446 | 1443 | ||
1447 | err = do_write_feat(fd, header, HEADER_HOSTNAME, &p, evlist); | 1444 | err = do_write_feat(fd, header, HEADER_HOSTNAME, &p, evlist); |
1448 | if (err) | 1445 | if (err) |
@@ -1500,7 +1497,6 @@ static int perf_header__adds_write(struct perf_header *header, | |||
1500 | err = do_write(fd, feat_sec, sec_size); | 1497 | err = do_write(fd, feat_sec, sec_size); |
1501 | if (err < 0) | 1498 | if (err < 0) |
1502 | pr_debug("failed to write feature section\n"); | 1499 | pr_debug("failed to write feature section\n"); |
1503 | out_free: | ||
1504 | free(feat_sec); | 1500 | free(feat_sec); |
1505 | return err; | 1501 | return err; |
1506 | } | 1502 | } |