Commit 3e13ab2d authored by Frederic Weisbecker's avatar Frederic Weisbecker Committed by Ingo Molnar

perf tools: Use perf_header__set/has_feat whenever possible

And drop the alternate checks/sets using set_bit or other kind
of helpers.
Signed-off-by: default avatarFrederic Weisbecker <fweisbec@gmail.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Mike Galbraith <efault@gmx.de>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Hitoshi Mitake <mitake@dcl.info.waseda.ac.jp>
LKML-Reference: <1257911467-28276-5-git-send-email-fweisbec@gmail.com>
Signed-off-by: default avatarIngo Molnar <mingo@elte.hu>
parent 4778d2e4
...@@ -431,11 +431,11 @@ static int __cmd_record(int argc, const char **argv) ...@@ -431,11 +431,11 @@ static int __cmd_record(int argc, const char **argv)
header = perf_header__new(); header = perf_header__new();
if (raw_samples) { if (raw_samples) {
perf_header__feat_trace_info(header); perf_header__set_feat(header, HEADER_TRACE_INFO);
} else { } else {
for (i = 0; i < nr_counters; i++) { for (i = 0; i < nr_counters; i++) {
if (attrs[i].sample_type & PERF_SAMPLE_RAW) { if (attrs[i].sample_type & PERF_SAMPLE_RAW) {
perf_header__feat_trace_info(header); perf_header__set_feat(header, HEADER_TRACE_INFO);
break; break;
} }
} }
......
...@@ -148,11 +148,6 @@ struct perf_file_header { ...@@ -148,11 +148,6 @@ struct perf_file_header {
DECLARE_BITMAP(adds_features, HEADER_FEAT_BITS); DECLARE_BITMAP(adds_features, HEADER_FEAT_BITS);
}; };
void perf_header__feat_trace_info(struct perf_header *header)
{
set_bit(HEADER_TRACE_INFO, header->adds_features);
}
void perf_header__set_feat(struct perf_header *self, int feat) void perf_header__set_feat(struct perf_header *self, int feat)
{ {
set_bit(feat, self->adds_features); set_bit(feat, self->adds_features);
...@@ -195,9 +190,8 @@ perf_header__adds_write(struct perf_header *self, int fd, bool at_exit) ...@@ -195,9 +190,8 @@ perf_header__adds_write(struct perf_header *self, int fd, bool at_exit)
{ {
struct perf_file_section trace_sec; struct perf_file_section trace_sec;
u64 cur_offset = lseek(fd, 0, SEEK_CUR); u64 cur_offset = lseek(fd, 0, SEEK_CUR);
unsigned long *feat_mask = self->adds_features;
if (test_bit(HEADER_TRACE_INFO, feat_mask)) { if (perf_header__has_feat(self, HEADER_TRACE_INFO)) {
/* Write trace info */ /* Write trace info */
trace_sec.offset = lseek(fd, sizeof(trace_sec), SEEK_CUR); trace_sec.offset = lseek(fd, sizeof(trace_sec), SEEK_CUR);
read_tracing_data(fd, attrs, nr_counters); read_tracing_data(fd, attrs, nr_counters);
...@@ -314,9 +308,7 @@ static void do_read(int fd, void *buf, size_t size) ...@@ -314,9 +308,7 @@ static void do_read(int fd, void *buf, size_t size)
static void perf_header__adds_read(struct perf_header *self, int fd) static void perf_header__adds_read(struct perf_header *self, int fd)
{ {
const unsigned long *feat_mask = self->adds_features; if (perf_header__has_feat(self, HEADER_TRACE_INFO)) {
if (test_bit(HEADER_TRACE_INFO, feat_mask)) {
struct perf_file_section trace_sec; struct perf_file_section trace_sec;
do_read(fd, &trace_sec, sizeof(trace_sec)); do_read(fd, &trace_sec, sizeof(trace_sec));
......
...@@ -49,7 +49,6 @@ void perf_header_attr__add_id(struct perf_header_attr *self, u64 id); ...@@ -49,7 +49,6 @@ void perf_header_attr__add_id(struct perf_header_attr *self, u64 id);
u64 perf_header__sample_type(struct perf_header *header); u64 perf_header__sample_type(struct perf_header *header);
struct perf_event_attr * struct perf_event_attr *
perf_header__find_attr(u64 id, struct perf_header *header); perf_header__find_attr(u64 id, struct perf_header *header);
void perf_header__feat_trace_info(struct perf_header *header);
void perf_header__set_feat(struct perf_header *self, int feat); void perf_header__set_feat(struct perf_header *self, int feat);
bool perf_header__has_feat(const struct perf_header *self, int feat); bool perf_header__has_feat(const struct perf_header *self, int feat);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment