perf tools: More fixes and updates
cover perf tools: More fixes and updates
Some more fixes and updates for perf tools.
Robert Richter (4):
perf tools: Fix uninitialized memory access to struct perf_sample perf record: Make feature initialization generic
perf tools: Moving code in header.c
perf tools: Factor out feature op to process header sections
tools/perf/builtin-record.c | 28 +--- tools/perf/util/evsel.c | 2 +- tools/perf/util/header.c | 344 ++++++++++++++++++++++--------------------- tools/perf/util/header.h | 1 + 4 files changed, 190 insertions(+), 185 deletions(-)
Signature · 1 line
1.7.7
PATCH 1/4 perf tools: Fix uninitialized memory access to struct perf_sample
Memory in struct perf_sample is not fully initialized during parsing. Depending on sampling data some parts may left unchanged. Zero out struct perf_sample first to avoid access to uninitialized memory.
--- tools/perf/util/evsel.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
tools/perf/util/evsel.c +1 -1
@@ -457,7 +457,7 @@ int perf_event__parse_sample(const union perf_event *event, u64 type,u32 val32[2 ]; } u; - +memset (data,0 ,sizeof (*data)); data->cpu = data->pid = data->tid =-1 ; data->stream_id = data->id = data->time =-1ULL ;
Signature · 1 line
1.7.7
[tip:perf/core] perf evsel: Fix uninitialized memory access to struct perf_sample
Commit-ID: f3bda2c9a689b38c059f7cb2d761ff58a2996370 Gitweb: http://git.kernel.org/tip/f3bda2c9a689b38c059f7cb2d761ff58a2996370 Author: Robert Richter <[email protected]> AuthorDate: Thu, 15 Dec 2011 17:32:39 +0100 Committer: Arnaldo Carvalho de Melo <[email protected]> CommitDate: Tue, 20 Dec 2011 13:26:47 -0200
perf evsel: Fix uninitialized memory access to struct perf_sample
Memory in struct perf_sample is not fully initialized during parsing. Depending on sampling data some parts may left unchanged. Zero out struct perf_sample first to avoid access to uninitialized memory.
--- tools/perf/util/evsel.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
tools/perf/util/evsel.c +1 -1
@@ -460,7 +460,7 @@ int perf_event__parse_sample(const union perf_event *event, u64 type,u32 val32[2 ]; } u; - +memset (data,0 ,sizeof (*data)); data->cpu = data->pid = data->tid =-1 ; data->stream_id = data->id = data->time =-1ULL ;
PATCH 2/4 perf record: Make feature initialization generic
In reply to Robert RichterLoop 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.
--- tools/perf/builtin-record.c | 28 +++++++++------------------- tools/perf/util/header.h | 1 + 2 files changed, 10 insertions(+), 19 deletions(-)
tools/perf/builtin-record.c +9 -19
@@ -375,7 +375,7 @@ static int __cmd_record(struct perf_record *rec, int argc, const char **argv) {struct stat st;int flags; -int err, output; +int err, output, feat;unsigned long waking =0 ;const bool forks = argc >0 ;struct machine *machine;
@@ -442,8 +442,14 @@ static int __cmd_record(struct perf_record *rec, int argc, const char **argv) rec->session = session; -if (!rec->no_buildid) -perf_header__set_feat (&session->header,HEADER_BUILD_ID ); +for (feat =HEADER_FIRST_FEATURE ; feat <HEADER_LAST_FEATURE ; feat++) +perf_header__set_feat (&session->header, feat); + +if (rec->no_buildid) +perf_header__clear_feat (&session->header,HEADER_BUILD_ID ); + +if (!have_tracepoints (&evsel_list->entries)) +perf_header__clear_feat (&session->header,HEADER_TRACE_INFO );if (!rec->file_new) { err =perf_session__read_header (session, output);
@@ -451,22 +457,6 @@ static int __cmd_record(struct perf_record *rec, int argc, const char **argv) goto out_delete_session; } -if (have_tracepoints (&evsel_list->entries)) -perf_header__set_feat (&session->header,HEADER_TRACE_INFO ); - -perf_header__set_feat (&session->header,HEADER_HOSTNAME ); -perf_header__set_feat (&session->header,HEADER_OSRELEASE ); -perf_header__set_feat (&session->header,HEADER_ARCH ); -perf_header__set_feat (&session->header,HEADER_CPUDESC ); -perf_header__set_feat (&session->header,HEADER_NRCPUS ); -perf_header__set_feat (&session->header,HEADER_EVENT_DESC ); -perf_header__set_feat (&session->header,HEADER_CMDLINE ); -perf_header__set_feat (&session->header,HEADER_VERSION ); -perf_header__set_feat (&session->header,HEADER_CPU_TOPOLOGY ); -perf_header__set_feat (&session->header,HEADER_TOTAL_MEM ); -perf_header__set_feat (&session->header,HEADER_NUMA_TOPOLOGY ); -perf_header__set_feat (&session->header,HEADER_CPUID ); -if (forks) { err =perf_evlist__prepare_workload (evsel_list, opts, argv);if (err <0 ) {
tools/perf/util/header.h +1 -0
@@ -11,6 +11,7 @@enum {HEADER_RESERVED =0 ,/* always cleared */ +HEADER_FIRST_FEATURE =1 ,HEADER_TRACE_INFO =1 ,HEADER_BUILD_ID ,
Signature · 1 line
1.7.7
[tip:perf/core] perf record: Make feature initialization generic
Commit-ID: 781ba9d2ed9df07dbb413fb5ee80ef7d353841c9 Gitweb: http://git.kernel.org/tip/781ba9d2ed9df07dbb413fb5ee80ef7d353841c9 Author: Robert Richter <[email protected]> AuthorDate: Thu, 15 Dec 2011 17:32:40 +0100 Committer: Arnaldo Carvalho de Melo <[email protected]> CommitDate: Thu, 2 Feb 2012 17:41:17 -0200
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.
--- tools/perf/builtin-record.c | 28 +++++++++------------------- tools/perf/util/header.h | 1 + 2 files changed, 10 insertions(+), 19 deletions(-)
tools/perf/builtin-record.c +9 -19
@@ -386,7 +386,7 @@ static int __cmd_record(struct perf_record *rec, int argc, const char **argv) {struct stat st;int flags; -int err, output; +int err, output, feat;unsigned long waking =0 ;const bool forks = argc >0 ;struct machine *machine;
@@ -453,8 +453,14 @@ static int __cmd_record(struct perf_record *rec, int argc, const char **argv) rec->session = session; -if (!rec->no_buildid) -perf_header__set_feat (&session->header,HEADER_BUILD_ID ); +for (feat =HEADER_FIRST_FEATURE ; feat <HEADER_LAST_FEATURE ; feat++) +perf_header__set_feat (&session->header, feat); + +if (rec->no_buildid) +perf_header__clear_feat (&session->header,HEADER_BUILD_ID ); + +if (!have_tracepoints (&evsel_list->entries)) +perf_header__clear_feat (&session->header,HEADER_TRACE_INFO );if (!rec->file_new) { err =perf_session__read_header (session, output);
@@ -462,22 +468,6 @@ static int __cmd_record(struct perf_record *rec, int argc, const char **argv) goto out_delete_session; } -if (have_tracepoints (&evsel_list->entries)) -perf_header__set_feat (&session->header,HEADER_TRACE_INFO ); - -perf_header__set_feat (&session->header,HEADER_HOSTNAME ); -perf_header__set_feat (&session->header,HEADER_OSRELEASE ); -perf_header__set_feat (&session->header,HEADER_ARCH ); -perf_header__set_feat (&session->header,HEADER_CPUDESC ); -perf_header__set_feat (&session->header,HEADER_NRCPUS ); -perf_header__set_feat (&session->header,HEADER_EVENT_DESC ); -perf_header__set_feat (&session->header,HEADER_CMDLINE ); -perf_header__set_feat (&session->header,HEADER_VERSION ); -perf_header__set_feat (&session->header,HEADER_CPU_TOPOLOGY ); -perf_header__set_feat (&session->header,HEADER_TOTAL_MEM ); -perf_header__set_feat (&session->header,HEADER_NUMA_TOPOLOGY ); -perf_header__set_feat (&session->header,HEADER_CPUID ); -if (forks) { err =perf_evlist__prepare_workload (evsel_list, opts, argv);if (err <0 ) {
tools/perf/util/header.h +1 -0
@@ -11,6 +11,7 @@enum {HEADER_RESERVED =0 ,/* always cleared */ +HEADER_FIRST_FEATURE =1 ,HEADER_TRACE_INFO =1 ,HEADER_BUILD_ID ,
PATCH 3/4 perf tools: Moving code in header.c
In reply to Robert RichterNeeded for later changes. No modified functionality.
--- tools/perf/util/header.c | 300 +++++++++++++++++++++++----------------------- 1 files changed, 150 insertions(+), 150 deletions(-)
tools/perf/util/header.c +150 -150
@@ -1305,6 +1305,156 @@ static void print_cpuid(struct perf_header *ph, int fd, FILE *fp)free (str); } +static int __event_process_build_id (struct build_id_event *bev, +char *filename, +struct perf_session *session) +{ +int err =-1 ; +struct list_head *head; +struct machine *machine; +u16 misc; +struct dso *dso; +enum dso_kernel_type dso_type; + + machine =perf_session__findnew_machine (session, bev->pid); +if (!machine) + goto out; + + misc = bev->header.misc &PERF_RECORD_MISC_CPUMODE_MASK ; + +switch (misc) { +case PERF_RECORD_MISC_KERNEL : + dso_type =DSO_TYPE_KERNEL ; + head = &machine->kernel_dsos; +break ; +case PERF_RECORD_MISC_GUEST_KERNEL : + dso_type =DSO_TYPE_GUEST_KERNEL ; + head = &machine->kernel_dsos; +break ; +case PERF_RECORD_MISC_USER : +case PERF_RECORD_MISC_GUEST_USER : + dso_type =DSO_TYPE_USER ; + head = &machine->user_dsos; +break ; +default : + goto out; + } + + dso =__dsos__findnew (head, filename); +if (dso !=NULL ) { +char sbuild_id[BUILD_ID_SIZE *2 +1 ]; + +dso__set_build_id (dso, &bev->build_id); + +if (filename[0 ] =='[' ) + dso->kernel = dso_type; + +build_id__sprintf (dso->build_id,sizeof (dso->build_id), + sbuild_id); +pr_debug ("build id event received for %s: %s\n" , + dso->long_name, sbuild_id); + } + + err =0 ; +out: +return err; +} + +static int perf_header__read_build_ids_abi_quirk (struct perf_header *header, +int input,u64 offset,u64 size) +{ + struct perf_session *session = container_of(header, struct perf_session, header); +struct { +struct perf_event_header header; +u8 build_id[ALIGN (BUILD_ID_SIZE ,sizeof (u64))]; +char filename[0 ]; + } old_bev; +struct build_id_event bev; +char filename[PATH_MAX ]; +u64 limit = offset + size; + +while (offset < limit) { +ssize_t len; + +if (read (input, &old_bev,sizeof (old_bev)) !=sizeof (old_bev)) +return -1 ; + +if (header->needs_swap) +perf_event_header__bswap (&old_bev.header); + + len = old_bev.header.size -sizeof (old_bev); +if (read (input, filename, len) != len) +return -1 ; + + bev.header = old_bev.header; + +/* +* As the pid is the missing value, we need to fill +* it properly. The header.misc value give us nice hint. +*/ + bev.pid =HOST_KERNEL_ID ; +if (bev.header.misc ==PERF_RECORD_MISC_GUEST_USER || + bev.header.misc ==PERF_RECORD_MISC_GUEST_KERNEL ) + bev.pid =DEFAULT_GUEST_KERNEL_ID ; + +memcpy (bev.build_id, old_bev.build_id,sizeof (bev.build_id)); +__event_process_build_id (&bev, filename, session); + + offset += bev.header.size; + } + +return 0 ; +} + +static int perf_header__read_build_ids (struct perf_header *header, +int input,u64 offset,u64 size) +{ + struct perf_session *session = container_of(header, struct perf_session, header); +struct build_id_event bev; +char filename[PATH_MAX ]; +u64 limit = offset + size, orig_offset = offset; +int err =-1 ; + +while (offset < limit) { +ssize_t len; + +if (read (input, &bev,sizeof (bev)) !=sizeof (bev)) + goto out; + +if (header->needs_swap) +perf_event_header__bswap (&bev.header); + + len = bev.header.size -sizeof (bev); +if (read (input, filename, len) != len) + goto out; +/* +* The a1645ce1 changeset: +* +* "perf: 'perf kvm' tool for monitoring guest performance from host" +* +* Added a field to struct build_id_event that broke the file +* format. +* +* Since the kernel build-id is the first entry, process the +* table using the old format if the well known +* '[kernel.kallsyms]' string for the kernel build-id has the +* first 4 characters chopped off (where the pid_t sits). +*/ +if (memcmp (filename,"nel.kallsyms]" ,13 ) ==0 ) { +if (lseek (input, orig_offset,SEEK_SET ) == (off_t)-1 ) +return -1 ; +return perf_header__read_build_ids_abi_quirk (header, input, offset, size); + } + +__event_process_build_id (&bev, filename, session); + + offset += bev.header.size; + } + err =0 ; +out: +return err; +} +struct feature_ops {int (*write)(int fd,struct perf_header *h,struct perf_evlist *evlist);void (*print)(struct perf_header *h,int fd,FILE *fp);
@@ -1692,156 +1842,6 @@ int perf_file_header__read(struct perf_file_header *header,return 0 ; } -static int __event_process_build_id (struct build_id_event *bev, -char *filename, -struct perf_session *session) -{ -int err =-1 ; -struct list_head *head; -struct machine *machine; -u16 misc; -struct dso *dso; -enum dso_kernel_type dso_type; - - machine =perf_session__findnew_machine (session, bev->pid); -if (!machine) - goto out; - - misc = bev->header.misc &PERF_RECORD_MISC_CPUMODE_MASK ; - -switch (misc) { -case PERF_RECORD_MISC_KERNEL : - dso_type =DSO_TYPE_KERNEL ; - head = &machine->kernel_dsos; -break ; -case PERF_RECORD_MISC_GUEST_KERNEL : - dso_type =DSO_TYPE_GUEST_KERNEL ; - head = &machine->kernel_dsos; -break ; -case PERF_RECORD_MISC_USER : -case PERF_RECORD_MISC_GUEST_USER : - dso_type =DSO_TYPE_USER ; - head = &machine->user_dsos; -break ; -default : - goto out; - } - - dso =__dsos__findnew (head, filename); -if (dso !=NULL ) { -char sbuild_id[BUILD_ID_SIZE *2 +1 ]; - -dso__set_build_id (dso, &bev->build_id); - -if (filename[0 ] =='[' ) - dso->kernel = dso_type; - -build_id__sprintf (dso->build_id,sizeof (dso->build_id), - sbuild_id); -pr_debug ("build id event received for %s: %s\n" , - dso->long_name, sbuild_id); - } - - err =0 ; -out: -return err; -} - -static int perf_header__read_build_ids_abi_quirk (struct perf_header *header, -int input,u64 offset,u64 size) -{ - struct perf_session *session = container_of(header, struct perf_session, header); -struct { -struct perf_event_header header; -u8 build_id[ALIGN (BUILD_ID_SIZE ,sizeof (u64))]; -char filename[0 ]; - } old_bev; -struct build_id_event bev; -char filename[PATH_MAX ]; -u64 limit = offset + size; - -while (offset < limit) { -ssize_t len; - -if (read (input, &old_bev,sizeof (old_bev)) !=sizeof (old_bev)) -return -1 ; - -if (header->needs_swap) -perf_event_header__bswap (&old_bev.header); - - len = old_bev.header.size -sizeof (old_bev); -if (read (input, filename, len) != len) -return -1 ; - - bev.header = old_bev.header; - -/* -* As the pid is the missing value, we need to fill -* it properly. The header.misc value give us nice hint. -*/ - bev.pid =HOST_KERNEL_ID ; -if (bev.header.misc ==PERF_RECORD_MISC_GUEST_USER || - bev.header.misc ==PERF_RECORD_MISC_GUEST_KERNEL ) - bev.pid =DEFAULT_GUEST_KERNEL_ID ; - -memcpy (bev.build_id, old_bev.build_id,sizeof (bev.build_id)); -__event_process_build_id (&bev, filename, session); - - offset += bev.header.size; - } - -return 0 ; -} - -static int perf_header__read_build_ids (struct perf_header *header, -int input,u64 offset,u64 size) -{ - struct perf_session *session = container_of(header, struct perf_session, header); -struct build_id_event bev; -char filename[PATH_MAX ]; -u64 limit = offset + size, orig_offset = offset; -int err =-1 ; - -while (offset < limit) { -ssize_t len; - -if (read (input, &bev,sizeof (bev)) !=sizeof (bev)) - goto out; - -if (header->needs_swap) -perf_event_header__bswap (&bev.header); - - len = bev.header.size -sizeof (bev); -if (read (input, filename, len) != len) - goto out; -/* -* The a1645ce1 changeset: -* -* "perf: 'perf kvm' tool for monitoring guest performance from host" -* -* Added a field to struct build_id_event that broke the file -* format. -* -* Since the kernel build-id is the first entry, process the -* table using the old format if the well known -* '[kernel.kallsyms]' string for the kernel build-id has the -* first 4 characters chopped off (where the pid_t sits). -*/ -if (memcmp (filename,"nel.kallsyms]" ,13 ) ==0 ) { -if (lseek (input, orig_offset,SEEK_SET ) == (off_t)-1 ) -return -1 ; -return perf_header__read_build_ids_abi_quirk (header, input, offset, size); - } - -__event_process_build_id (&bev, filename, session); - - offset += bev.header.size; - } - err =0 ; -out: -return err; -} -static int perf_file_section__process (struct perf_file_section *section,struct perf_header *ph,int feat,int fd,void *data__used )
Signature · 1 line
1.7.7
PATCH 4/4 perf tools: Factor out feature op to process header sections
In reply to Robert RichterThere is individual code for each feature to process header sections. Adding a function pointer .process to struct feature_ops for keeping the implementation in separate functions. Code to process header sections is now a generic function.
--- tools/perf/util/header.c | 44 +++++++++++++++++++++++++++++--------------- 1 files changed, 29 insertions(+), 15 deletions(-)
tools/perf/util/header.c +29 -15
@@ -1455,25 +1455,48 @@ out:return err; } +static int process_trace_info(struct perf_file_section *section __unused, + struct perf_header *ph __unused, + int feat __unused, int fd) +{ +trace_report (fd, false); +return 0 ; +} + +static int process_build_id (struct perf_file_section *section, +struct perf_header *ph, + int feat __unused, int fd) +{ +if (perf_header__read_build_ids (ph, fd, section->offset, section->size)) +pr_debug ("Failed to read buildids, continuing...\n" ); +return 0 ; +} +struct feature_ops {int (*write)(int fd,struct perf_header *h,struct perf_evlist *evlist);void (*print)(struct perf_header *h,int fd,FILE *fp); +int (*process)(struct perf_file_section *section, +struct perf_header *h,int feat,int fd);const char *name;bool full_only; };#define FEAT_OPA (n, func) \ [n] = { .name = #n, .write = write_##func, .print = print_##func } +#define FEAT_OPP (n, func) \ + [n] = { .name = #n, .write = write_##func, .print = print_##func, \ + .process = process_##func }#define FEAT_OPF (n, func) \ - [n] = { .name = #n, .write = write_##func, .print = print_##func, .full_only = true } + [n] = { .name = #n, .write = write_##func, .print = print_##func, \ + .full_only = true }/* feature_ops not implemented: */ #define print_trace_info NULL#define print_build_id NULLstatic const struct feature_ops feat_ops[HEADER_LAST_FEATURE ] = { -FEAT_OPA (HEADER_TRACE_INFO , trace_info), -FEAT_OPA (HEADER_BUILD_ID , build_id), +FEAT_OPP (HEADER_TRACE_INFO , trace_info), +FEAT_OPP (HEADER_BUILD_ID , build_id),FEAT_OPA (HEADER_HOSTNAME , hostname),FEAT_OPA (HEADER_OSRELEASE , osrelease),FEAT_OPA (HEADER_VERSION , version),
@@ -1857,19 +1880,10 @@ static int perf_file_section__process(struct perf_file_section *section,return 0 ; } -switch (feat) { -case HEADER_TRACE_INFO : -trace_report (fd, false); -break ; -case HEADER_BUILD_ID : -if (perf_header__read_build_ids (ph, fd, section->offset, section->size)) -pr_debug ("Failed to read buildids, continuing...\n" ); -break ; -default : -break ; - } +if (!feat_ops[feat].process) +return 0 ; -return 0 ; +return feat_ops[feat].process (section, ph, feat, fd); } static int perf_file_header__read_pipe(struct perf_pipe_file_header *header,
Signature · 1 line
1.7.7
Quoted 7 lines · Robert Richter
Some more fixes and updates for perf tools.
Robert Richter (4):
perf tools: Fix uninitialized memory access to structperf_sampleperf record: Make feature initialization generic
perf tools: Moving code inheader.c
perf tools: Factor out feature op to process header sections
Arnaldo,
have you had the time to look at patches 2-4? They refactor the code without changing functionality, but makes implementation easier and more maintainable.
Thanks,
-Robert
Quoted 10 lines
tools/perf/builtin-record.c | 28 +--- tools/perf/util/evsel.c | 2 +- tools/perf/util/header.c | 344 ++++++++++++++++++++++--------------------- tools/perf/util/header.h | 1 + 4 files changed, 190 insertions(+), 185 deletions(-)Signature · 1 line
1.7.7
Signature · 2 lines
Advanced Micro Devices, Inc. Operating System Research Center
Em Tue, Jan 31, 2012 at 04:51:54PM +0100, Robert Richter escreveu:
Quoted 9 lines · Robert Richter
Quoted 7 lines
Some more fixes and updates for perf tools.
Robert Richter (4):
perf tools: Fix uninitialized memory access to structperf_sampleperf record: Make feature initialization generic
perf tools: Moving code inheader.c
perf tools: Factor out feature op to process header sections
Quoted 5 lines
Arnaldo,
have you had the time to look at patches 2-4? They refactor the code without changing functionality, but makes implementation easier and more maintainable.
Agreed, I applied both to my local repo, after some testing and reviewing some more patches I'll push it to Ingo, thanks,
- Arnaldo
Quoted 11 lines · Arnaldo Carvalho de Melo
Em Tue, Jan 31, 2012 at 04:51:54PM +0100, Robert Richter escreveu:
Quoted 7 lines · Robert Richter
Quoted 6 lines
Some more fixes and updates for perf tools.
Robert Richter (4):
perf tools: Moving code in
header.c
perf tools: Factor out feature op to process header sectionsAgreed, I applied both to my local repo, after some testing and reviewing some more patches I'll push it to Ingo, thanks,
Arnaldo, the two above are not yet applied. Should I drop them?
Thanks,
-Robert
Signature · 2 lines
Advanced Micro Devices, Inc. Operating System Research Center
Em Fri, Feb 10, 2012 at 12:31:40PM +0100, Robert Richter escreveu:
Quoted 7 lines · Arnaldo Carvalho de Melo
Quoted 5 lines
Em Tue, Jan 31, 2012 at 04:51:54PM +0100, Robert Richter escreveu:
Quoted 4 lines · Robert Richter
Quoted 3 lines
Some more fixes and updates for perf tools.
Robert Richter (4):
Quoted 7 lines
Quoted 5 lines
Quoted 2 lines
Quoted 2 lines
perf tools: Moving code in
header.c
perf tools: Factor out feature op to process header sectionsAgreed, I applied both to my local repo, after some testing and reviewing some more patches I'll push it to Ingo, thanks,
Arnaldo, the two above are not yet applied. Should I drop them?
IIRC they didn't applied, can you check that are resubmit?
Thanks,
- Arnaldo
PATCH 1/2 perf tools: Moving code in header.c
Needed for later changes. No modified functionality.
--- tools/perf/util/header.c | 300 +++++++++++++++++++++++----------------------- 1 files changed, 150 insertions(+), 150 deletions(-)
tools/perf/util/header.c +150 -150
@@ -1305,6 +1305,156 @@ static void print_cpuid(struct perf_header *ph, int fd, FILE *fp)free (str); } +static int __event_process_build_id (struct build_id_event *bev, +char *filename, +struct perf_session *session) +{ +int err =-1 ; +struct list_head *head; +struct machine *machine; +u16 misc; +struct dso *dso; +enum dso_kernel_type dso_type; + + machine =perf_session__findnew_machine (session, bev->pid); +if (!machine) + goto out; + + misc = bev->header.misc &PERF_RECORD_MISC_CPUMODE_MASK ; + +switch (misc) { +case PERF_RECORD_MISC_KERNEL : + dso_type =DSO_TYPE_KERNEL ; + head = &machine->kernel_dsos; +break ; +case PERF_RECORD_MISC_GUEST_KERNEL : + dso_type =DSO_TYPE_GUEST_KERNEL ; + head = &machine->kernel_dsos; +break ; +case PERF_RECORD_MISC_USER : +case PERF_RECORD_MISC_GUEST_USER : + dso_type =DSO_TYPE_USER ; + head = &machine->user_dsos; +break ; +default : + goto out; + } + + dso =__dsos__findnew (head, filename); +if (dso !=NULL ) { +char sbuild_id[BUILD_ID_SIZE *2 +1 ]; + +dso__set_build_id (dso, &bev->build_id); + +if (filename[0 ] =='[' ) + dso->kernel = dso_type; + +build_id__sprintf (dso->build_id,sizeof (dso->build_id), + sbuild_id); +pr_debug ("build id event received for %s: %s\n" , + dso->long_name, sbuild_id); + } + + err =0 ; +out: +return err; +} + +static int perf_header__read_build_ids_abi_quirk (struct perf_header *header, +int input,u64 offset,u64 size) +{ + struct perf_session *session = container_of(header, struct perf_session, header); +struct { +struct perf_event_header header; +u8 build_id[ALIGN (BUILD_ID_SIZE ,sizeof (u64))]; +char filename[0 ]; + } old_bev; +struct build_id_event bev; +char filename[PATH_MAX ]; +u64 limit = offset + size; + +while (offset < limit) { +ssize_t len; + +if (read (input, &old_bev,sizeof (old_bev)) !=sizeof (old_bev)) +return -1 ; + +if (header->needs_swap) +perf_event_header__bswap (&old_bev.header); + + len = old_bev.header.size -sizeof (old_bev); +if (read (input, filename, len) != len) +return -1 ; + + bev.header = old_bev.header; + +/* +* As the pid is the missing value, we need to fill +* it properly. The header.misc value give us nice hint. +*/ + bev.pid =HOST_KERNEL_ID ; +if (bev.header.misc ==PERF_RECORD_MISC_GUEST_USER || + bev.header.misc ==PERF_RECORD_MISC_GUEST_KERNEL ) + bev.pid =DEFAULT_GUEST_KERNEL_ID ; + +memcpy (bev.build_id, old_bev.build_id,sizeof (bev.build_id)); +__event_process_build_id (&bev, filename, session); + + offset += bev.header.size; + } + +return 0 ; +} + +static int perf_header__read_build_ids (struct perf_header *header, +int input,u64 offset,u64 size) +{ + struct perf_session *session = container_of(header, struct perf_session, header); +struct build_id_event bev; +char filename[PATH_MAX ]; +u64 limit = offset + size, orig_offset = offset; +int err =-1 ; + +while (offset < limit) { +ssize_t len; + +if (read (input, &bev,sizeof (bev)) !=sizeof (bev)) + goto out; + +if (header->needs_swap) +perf_event_header__bswap (&bev.header); + + len = bev.header.size -sizeof (bev); +if (read (input, filename, len) != len) + goto out; +/* +* The a1645ce1 changeset: +* +* "perf: 'perf kvm' tool for monitoring guest performance from host" +* +* Added a field to struct build_id_event that broke the file +* format. +* +* Since the kernel build-id is the first entry, process the +* table using the old format if the well known +* '[kernel.kallsyms]' string for the kernel build-id has the +* first 4 characters chopped off (where the pid_t sits). +*/ +if (memcmp (filename,"nel.kallsyms]" ,13 ) ==0 ) { +if (lseek (input, orig_offset,SEEK_SET ) == (off_t)-1 ) +return -1 ; +return perf_header__read_build_ids_abi_quirk (header, input, offset, size); + } + +__event_process_build_id (&bev, filename, session); + + offset += bev.header.size; + } + err =0 ; +out: +return err; +} +struct feature_ops {int (*write)(int fd,struct perf_header *h,struct perf_evlist *evlist);void (*print)(struct perf_header *h,int fd,FILE *fp);
@@ -1689,156 +1839,6 @@ int perf_file_header__read(struct perf_file_header *header,return 0 ; } -static int __event_process_build_id (struct build_id_event *bev, -char *filename, -struct perf_session *session) -{ -int err =-1 ; -struct list_head *head; -struct machine *machine; -u16 misc; -struct dso *dso; -enum dso_kernel_type dso_type; - - machine =perf_session__findnew_machine (session, bev->pid); -if (!machine) - goto out; - - misc = bev->header.misc &PERF_RECORD_MISC_CPUMODE_MASK ; - -switch (misc) { -case PERF_RECORD_MISC_KERNEL : - dso_type =DSO_TYPE_KERNEL ; - head = &machine->kernel_dsos; -break ; -case PERF_RECORD_MISC_GUEST_KERNEL : - dso_type =DSO_TYPE_GUEST_KERNEL ; - head = &machine->kernel_dsos; -break ; -case PERF_RECORD_MISC_USER : -case PERF_RECORD_MISC_GUEST_USER : - dso_type =DSO_TYPE_USER ; - head = &machine->user_dsos; -break ; -default : - goto out; - } - - dso =__dsos__findnew (head, filename); -if (dso !=NULL ) { -char sbuild_id[BUILD_ID_SIZE *2 +1 ]; - -dso__set_build_id (dso, &bev->build_id); - -if (filename[0 ] =='[' ) - dso->kernel = dso_type; - -build_id__sprintf (dso->build_id,sizeof (dso->build_id), - sbuild_id); -pr_debug ("build id event received for %s: %s\n" , - dso->long_name, sbuild_id); - } - - err =0 ; -out: -return err; -} - -static int perf_header__read_build_ids_abi_quirk (struct perf_header *header, -int input,u64 offset,u64 size) -{ - struct perf_session *session = container_of(header, struct perf_session, header); -struct { -struct perf_event_header header; -u8 build_id[ALIGN (BUILD_ID_SIZE ,sizeof (u64))]; -char filename[0 ]; - } old_bev; -struct build_id_event bev; -char filename[PATH_MAX ]; -u64 limit = offset + size; - -while (offset < limit) { -ssize_t len; - -if (read (input, &old_bev,sizeof (old_bev)) !=sizeof (old_bev)) -return -1 ; - -if (header->needs_swap) -perf_event_header__bswap (&old_bev.header); - - len = old_bev.header.size -sizeof (old_bev); -if (read (input, filename, len) != len) -return -1 ; - - bev.header = old_bev.header; - -/* -* As the pid is the missing value, we need to fill -* it properly. The header.misc value give us nice hint. -*/ - bev.pid =HOST_KERNEL_ID ; -if (bev.header.misc ==PERF_RECORD_MISC_GUEST_USER || - bev.header.misc ==PERF_RECORD_MISC_GUEST_KERNEL ) - bev.pid =DEFAULT_GUEST_KERNEL_ID ; - -memcpy (bev.build_id, old_bev.build_id,sizeof (bev.build_id)); -__event_process_build_id (&bev, filename, session); - - offset += bev.header.size; - } - -return 0 ; -} - -static int perf_header__read_build_ids (struct perf_header *header, -int input,u64 offset,u64 size) -{ - struct perf_session *session = container_of(header, struct perf_session, header); -struct build_id_event bev; -char filename[PATH_MAX ]; -u64 limit = offset + size, orig_offset = offset; -int err =-1 ; - -while (offset < limit) { -ssize_t len; - -if (read (input, &bev,sizeof (bev)) !=sizeof (bev)) - goto out; - -if (header->needs_swap) -perf_event_header__bswap (&bev.header); - - len = bev.header.size -sizeof (bev); -if (read (input, filename, len) != len) - goto out; -/* -* The a1645ce1 changeset: -* -* "perf: 'perf kvm' tool for monitoring guest performance from host" -* -* Added a field to struct build_id_event that broke the file -* format. -* -* Since the kernel build-id is the first entry, process the -* table using the old format if the well known -* '[kernel.kallsyms]' string for the kernel build-id has the -* first 4 characters chopped off (where the pid_t sits). -*/ -if (memcmp (filename,"nel.kallsyms]" ,13 ) ==0 ) { -if (lseek (input, orig_offset,SEEK_SET ) == (off_t)-1 ) -return -1 ; -return perf_header__read_build_ids_abi_quirk (header, input, offset, size); - } - -__event_process_build_id (&bev, filename, session); - - offset += bev.header.size; - } - err =0 ; -out: -return err; -} -static int perf_file_section__process (struct perf_file_section *section,struct perf_header *ph,int feat,int fd,void *data__used )
Signature · 1 line
1.7.8
PATCH 2/2 perf tools: Factor out feature op to process header sections
There is individual code for each feature to process header sections. Adding a function pointer .process to struct feature_ops for keeping the implementation in separate functions. Code to process header sections is now a generic function.
--- tools/perf/util/header.c | 44 +++++++++++++++++++++++++++++--------------- 1 files changed, 29 insertions(+), 15 deletions(-)
tools/perf/util/header.c +29 -15
@@ -1455,25 +1455,48 @@ out:return err; } +static int process_trace_info(struct perf_file_section *section __unused, + struct perf_header *ph __unused, + int feat __unused, int fd) +{ +trace_report (fd, false); +return 0 ; +} + +static int process_build_id (struct perf_file_section *section, +struct perf_header *ph, + int feat __unused, int fd) +{ +if (perf_header__read_build_ids (ph, fd, section->offset, section->size)) +pr_debug ("Failed to read buildids, continuing...\n" ); +return 0 ; +} +struct feature_ops {int (*write)(int fd,struct perf_header *h,struct perf_evlist *evlist);void (*print)(struct perf_header *h,int fd,FILE *fp); +int (*process)(struct perf_file_section *section, +struct perf_header *h,int feat,int fd);const char *name;bool full_only; };#define FEAT_OPA (n, func) \ [n] = { .name = #n, .write = write_##func, .print = print_##func } +#define FEAT_OPP (n, func) \ + [n] = { .name = #n, .write = write_##func, .print = print_##func, \ + .process = process_##func }#define FEAT_OPF (n, func) \ - [n] = { .name = #n, .write = write_##func, .print = print_##func, .full_only = true } + [n] = { .name = #n, .write = write_##func, .print = print_##func, \ + .full_only = true }/* feature_ops not implemented: */ #define print_trace_info NULL#define print_build_id NULLstatic const struct feature_ops feat_ops[HEADER_LAST_FEATURE ] = { -FEAT_OPA (HEADER_TRACE_INFO , trace_info), -FEAT_OPA (HEADER_BUILD_ID , build_id), +FEAT_OPP (HEADER_TRACE_INFO , trace_info), +FEAT_OPP (HEADER_BUILD_ID , build_id),FEAT_OPA (HEADER_HOSTNAME , hostname),FEAT_OPA (HEADER_OSRELEASE , osrelease),FEAT_OPA (HEADER_VERSION , version),
@@ -1854,19 +1877,10 @@ static int perf_file_section__process(struct perf_file_section *section,return 0 ; } -switch (feat) { -case HEADER_TRACE_INFO : -trace_report (fd, false); -break ; -case HEADER_BUILD_ID : -if (perf_header__read_build_ids (ph, fd, section->offset, section->size)) -pr_debug ("Failed to read buildids, continuing...\n" ); -break ; -default : -break ; - } +if (!feat_ops[feat].process) +return 0 ; -return 0 ; +return feat_ops[feat].process (section, ph, feat, fd); } static int perf_file_header__read_pipe(struct perf_pipe_file_header *header,
Signature · 1 line
1.7.8
[tip:perf/core] perf tools: Factor out feature op to process header sections
Commit-ID: f1c67db7e351bf9fd328e368ba045cbeca11d513 Gitweb: http://git.kernel.org/tip/f1c67db7e351bf9fd328e368ba045cbeca11d513 Author: Robert Richter <[email protected]> AuthorDate: Fri, 10 Feb 2012 15:41:56 +0100 Committer: Arnaldo Carvalho de Melo <[email protected]> CommitDate: Mon, 13 Feb 2012 23:33:36 -0200
perf tools: Factor out feature op to process header sections
There is individual code for each feature to process header sections.
Adding a function pointer .process to struct feature_ops for keeping the implementation in separate functions. Code to process header sections is now a generic function.
--- tools/perf/util/header.c | 44 +++++++++++++++++++++++++++++--------------- 1 files changed, 29 insertions(+), 15 deletions(-)
tools/perf/util/header.c +29 -15
@@ -1466,25 +1466,48 @@ out:return err; } +static int process_trace_info(struct perf_file_section *section __unused, + struct perf_header *ph __unused, + int feat __unused, int fd) +{ +trace_report (fd, false); +return 0 ; +} + +static int process_build_id (struct perf_file_section *section, +struct perf_header *ph, + int feat __unused, int fd) +{ +if (perf_header__read_build_ids (ph, fd, section->offset, section->size)) +pr_debug ("Failed to read buildids, continuing...\n" ); +return 0 ; +} +struct feature_ops {int (*write)(int fd,struct perf_header *h,struct perf_evlist *evlist);void (*print)(struct perf_header *h,int fd,FILE *fp); +int (*process)(struct perf_file_section *section, +struct perf_header *h,int feat,int fd);const char *name;bool full_only; };#define FEAT_OPA (n, func) \ [n] = { .name = #n, .write = write_##func, .print = print_##func } +#define FEAT_OPP (n, func) \ + [n] = { .name = #n, .write = write_##func, .print = print_##func, \ + .process = process_##func }#define FEAT_OPF (n, func) \ - [n] = { .name = #n, .write = write_##func, .print = print_##func, .full_only = true } + [n] = { .name = #n, .write = write_##func, .print = print_##func, \ + .full_only = true }/* feature_ops not implemented: */ #define print_trace_info NULL#define print_build_id NULLstatic const struct feature_ops feat_ops[HEADER_LAST_FEATURE ] = { -FEAT_OPA (HEADER_TRACE_INFO , trace_info), -FEAT_OPA (HEADER_BUILD_ID , build_id), +FEAT_OPP (HEADER_TRACE_INFO , trace_info), +FEAT_OPP (HEADER_BUILD_ID , build_id),FEAT_OPA (HEADER_HOSTNAME , hostname),FEAT_OPA (HEADER_OSRELEASE , osrelease),FEAT_OPA (HEADER_VERSION , version),
@@ -1900,19 +1923,10 @@ static int perf_file_section__process(struct perf_file_section *section,return 0 ; } -switch (feat) { -case HEADER_TRACE_INFO : -trace_report (fd, false); -break ; -case HEADER_BUILD_ID : -if (perf_header__read_build_ids (ph, fd, section->offset, section->size)) -pr_debug ("Failed to read buildids, continuing...\n" ); -break ; -default : -break ; - } +if (!feat_ops[feat].process) +return 0 ; -return 0 ; +return feat_ops[feat].process (section, ph, feat, fd); } static int perf_file_header__read_pipe(struct perf_pipe_file_header *header,
[tip:perf/core] perf tools: Moving code in header.c
In reply to Robert RichterCommit-ID: 08d95bd256277f914e525aeb292da52f15173e7d Gitweb: http://git.kernel.org/tip/08d95bd256277f914e525aeb292da52f15173e7d Author: Robert Richter <[email protected]> AuthorDate: Fri, 10 Feb 2012 15:41:55 +0100 Committer: Arnaldo Carvalho de Melo <[email protected]> CommitDate: Mon, 13 Feb 2012 23:32:32 -0200
perf tools: Moving code in header.c
Needed for later changes. No modified functionality.
--- tools/perf/util/header.c | 300 +++++++++++++++++++++++----------------------- 1 files changed, 150 insertions(+), 150 deletions(-)
tools/perf/util/header.c +150 -150
@@ -1316,6 +1316,156 @@ static void print_cpuid(struct perf_header *ph, int fd, FILE *fp)free (str); } +static int __event_process_build_id (struct build_id_event *bev, +char *filename, +struct perf_session *session) +{ +int err =-1 ; +struct list_head *head; +struct machine *machine; +u16 misc; +struct dso *dso; +enum dso_kernel_type dso_type; + + machine =perf_session__findnew_machine (session, bev->pid); +if (!machine) + goto out; + + misc = bev->header.misc &PERF_RECORD_MISC_CPUMODE_MASK ; + +switch (misc) { +case PERF_RECORD_MISC_KERNEL : + dso_type =DSO_TYPE_KERNEL ; + head = &machine->kernel_dsos; +break ; +case PERF_RECORD_MISC_GUEST_KERNEL : + dso_type =DSO_TYPE_GUEST_KERNEL ; + head = &machine->kernel_dsos; +break ; +case PERF_RECORD_MISC_USER : +case PERF_RECORD_MISC_GUEST_USER : + dso_type =DSO_TYPE_USER ; + head = &machine->user_dsos; +break ; +default : + goto out; + } + + dso =__dsos__findnew (head, filename); +if (dso !=NULL ) { +char sbuild_id[BUILD_ID_SIZE *2 +1 ]; + +dso__set_build_id (dso, &bev->build_id); + +if (filename[0 ] =='[' ) + dso->kernel = dso_type; + +build_id__sprintf (dso->build_id,sizeof (dso->build_id), + sbuild_id); +pr_debug ("build id event received for %s: %s\n" , + dso->long_name, sbuild_id); + } + + err =0 ; +out: +return err; +} + +static int perf_header__read_build_ids_abi_quirk (struct perf_header *header, +int input,u64 offset,u64 size) +{ + struct perf_session *session = container_of(header, struct perf_session, header); +struct { +struct perf_event_header header; +u8 build_id[ALIGN (BUILD_ID_SIZE ,sizeof (u64))]; +char filename[0 ]; + } old_bev; +struct build_id_event bev; +char filename[PATH_MAX ]; +u64 limit = offset + size; + +while (offset < limit) { +ssize_t len; + +if (read (input, &old_bev,sizeof (old_bev)) !=sizeof (old_bev)) +return -1 ; + +if (header->needs_swap) +perf_event_header__bswap (&old_bev.header); + + len = old_bev.header.size -sizeof (old_bev); +if (read (input, filename, len) != len) +return -1 ; + + bev.header = old_bev.header; + +/* +* As the pid is the missing value, we need to fill +* it properly. The header.misc value give us nice hint. +*/ + bev.pid =HOST_KERNEL_ID ; +if (bev.header.misc ==PERF_RECORD_MISC_GUEST_USER || + bev.header.misc ==PERF_RECORD_MISC_GUEST_KERNEL ) + bev.pid =DEFAULT_GUEST_KERNEL_ID ; + +memcpy (bev.build_id, old_bev.build_id,sizeof (bev.build_id)); +__event_process_build_id (&bev, filename, session); + + offset += bev.header.size; + } + +return 0 ; +} + +static int perf_header__read_build_ids (struct perf_header *header, +int input,u64 offset,u64 size) +{ + struct perf_session *session = container_of(header, struct perf_session, header); +struct build_id_event bev; +char filename[PATH_MAX ]; +u64 limit = offset + size, orig_offset = offset; +int err =-1 ; + +while (offset < limit) { +ssize_t len; + +if (read (input, &bev,sizeof (bev)) !=sizeof (bev)) + goto out; + +if (header->needs_swap) +perf_event_header__bswap (&bev.header); + + len = bev.header.size -sizeof (bev); +if (read (input, filename, len) != len) + goto out; +/* +* The a1645ce1 changeset: +* +* "perf: 'perf kvm' tool for monitoring guest performance from host" +* +* Added a field to struct build_id_event that broke the file +* format. +* +* Since the kernel build-id is the first entry, process the +* table using the old format if the well known +* '[kernel.kallsyms]' string for the kernel build-id has the +* first 4 characters chopped off (where the pid_t sits). +*/ +if (memcmp (filename,"nel.kallsyms]" ,13 ) ==0 ) { +if (lseek (input, orig_offset,SEEK_SET ) == (off_t)-1 ) +return -1 ; +return perf_header__read_build_ids_abi_quirk (header, input, offset, size); + } + +__event_process_build_id (&bev, filename, session); + + offset += bev.header.size; + } + err =0 ; +out: +return err; +} +struct feature_ops {int (*write)(int fd,struct perf_header *h,struct perf_evlist *evlist);void (*print)(struct perf_header *h,int fd,FILE *fp);
@@ -1735,156 +1885,6 @@ int perf_file_header__read(struct perf_file_header *header,return 0 ; } -static int __event_process_build_id (struct build_id_event *bev, -char *filename, -struct perf_session *session) -{ -int err =-1 ; -struct list_head *head; -struct machine *machine; -u16 misc; -struct dso *dso; -enum dso_kernel_type dso_type; - - machine =perf_session__findnew_machine (session, bev->pid); -if (!machine) - goto out; - - misc = bev->header.misc &PERF_RECORD_MISC_CPUMODE_MASK ; - -switch (misc) { -case PERF_RECORD_MISC_KERNEL : - dso_type =DSO_TYPE_KERNEL ; - head = &machine->kernel_dsos; -break ; -case PERF_RECORD_MISC_GUEST_KERNEL : - dso_type =DSO_TYPE_GUEST_KERNEL ; - head = &machine->kernel_dsos; -break ; -case PERF_RECORD_MISC_USER : -case PERF_RECORD_MISC_GUEST_USER : - dso_type =DSO_TYPE_USER ; - head = &machine->user_dsos; -break ; -default : - goto out; - } - - dso =__dsos__findnew (head, filename); -if (dso !=NULL ) { -char sbuild_id[BUILD_ID_SIZE *2 +1 ]; - -dso__set_build_id (dso, &bev->build_id); - -if (filename[0 ] =='[' ) - dso->kernel = dso_type; - -build_id__sprintf (dso->build_id,sizeof (dso->build_id), - sbuild_id); -pr_debug ("build id event received for %s: %s\n" , - dso->long_name, sbuild_id); - } - - err =0 ; -out: -return err; -} - -static int perf_header__read_build_ids_abi_quirk (struct perf_header *header, -int input,u64 offset,u64 size) -{ - struct perf_session *session = container_of(header, struct perf_session, header); -struct { -struct perf_event_header header; -u8 build_id[ALIGN (BUILD_ID_SIZE ,sizeof (u64))]; -char filename[0 ]; - } old_bev; -struct build_id_event bev; -char filename[PATH_MAX ]; -u64 limit = offset + size; - -while (offset < limit) { -ssize_t len; - -if (read (input, &old_bev,sizeof (old_bev)) !=sizeof (old_bev)) -return -1 ; - -if (header->needs_swap) -perf_event_header__bswap (&old_bev.header); - - len = old_bev.header.size -sizeof (old_bev); -if (read (input, filename, len) != len) -return -1 ; - - bev.header = old_bev.header; - -/* -* As the pid is the missing value, we need to fill -* it properly. The header.misc value give us nice hint. -*/ - bev.pid =HOST_KERNEL_ID ; -if (bev.header.misc ==PERF_RECORD_MISC_GUEST_USER || - bev.header.misc ==PERF_RECORD_MISC_GUEST_KERNEL ) - bev.pid =DEFAULT_GUEST_KERNEL_ID ; - -memcpy (bev.build_id, old_bev.build_id,sizeof (bev.build_id)); -__event_process_build_id (&bev, filename, session); - - offset += bev.header.size; - } - -return 0 ; -} - -static int perf_header__read_build_ids (struct perf_header *header, -int input,u64 offset,u64 size) -{ - struct perf_session *session = container_of(header, struct perf_session, header); -struct build_id_event bev; -char filename[PATH_MAX ]; -u64 limit = offset + size, orig_offset = offset; -int err =-1 ; - -while (offset < limit) { -ssize_t len; - -if (read (input, &bev,sizeof (bev)) !=sizeof (bev)) - goto out; - -if (header->needs_swap) -perf_event_header__bswap (&bev.header); - - len = bev.header.size -sizeof (bev); -if (read (input, filename, len) != len) - goto out; -/* -* The a1645ce1 changeset: -* -* "perf: 'perf kvm' tool for monitoring guest performance from host" -* -* Added a field to struct build_id_event that broke the file -* format. -* -* Since the kernel build-id is the first entry, process the -* table using the old format if the well known -* '[kernel.kallsyms]' string for the kernel build-id has the -* first 4 characters chopped off (where the pid_t sits). -*/ -if (memcmp (filename,"nel.kallsyms]" ,13 ) ==0 ) { -if (lseek (input, orig_offset,SEEK_SET ) == (off_t)-1 ) -return -1 ; -return perf_header__read_build_ids_abi_quirk (header, input, offset, size); - } - -__event_process_build_id (&bev, filename, session); - - offset += bev.header.size; - } - err =0 ; -out: -return err; -} -static int perf_file_section__process (struct perf_file_section *section,struct perf_header *ph,int feat,int fd,void *data__used )