From: tip-bot for David Carrillo-Cisneros <tipbot@zytor.com>
To: linux-tip-commits@vger.kernel.org
Cc: jolsa@kernel.org, hpa@zytor.com, mhiramat@kernel.org,
wangnan0@huawei.com, alexander.shishkin@linux.intel.com,
pjt@google.com, sque@chromium.org, peterz@infradead.org,
mingo@kernel.org, davidcc@google.com, hekuang@huawei.com,
acme@redhat.com, namhyung@kernel.org,
linux-kernel@vger.kernel.org, eranian@google.com,
ak@linux.intel.com, dsahern@gmail.com, tglx@linutronix.de
Subject: [tip:perf/core] perf header: Don't pass struct perf_file_section to process_##_feat
Date: Thu, 20 Jul 2017 02:01:09 -0700 [thread overview]
Message-ID: <tip-625524572391326b83f906efe02abbaac9debce6@git.kernel.org> (raw)
In-Reply-To: <20170718042549.145161-10-davidcc@google.com>
Commit-ID: 625524572391326b83f906efe02abbaac9debce6
Gitweb: http://git.kernel.org/tip/625524572391326b83f906efe02abbaac9debce6
Author: David Carrillo-Cisneros <davidcc@google.com>
AuthorDate: Mon, 17 Jul 2017 21:25:42 -0700
Committer: Arnaldo Carvalho de Melo <acme@redhat.com>
CommitDate: Tue, 18 Jul 2017 23:14:33 -0300
perf header: Don't pass struct perf_file_section to process_##_feat
struct perf_file_section is used in process_##_feat as container for
size and offset in the file descriptor. These attributes are meaninful
in pipe-mode but struct perf_file_section is not.
Add offset and size variables to struct feat_fd to store
perf_file_section's values in file-mode. Later on, the same variables
can be reused for pipe-mode.
This patch does not change behavior.
Signed-off-by: David Carrillo-Cisneros <davidcc@google.com>
Acked-by: David Ahern <dsahern@gmail.com>
Acked-by: Jiri Olsa <jolsa@kernel.org>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Andi Kleen <ak@linux.intel.com>
Cc: He Kuang <hekuang@huawei.com>
Cc: Masami Hiramatsu <mhiramat@kernel.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Paul Turner <pjt@google.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Simon Que <sque@chromium.org>
Cc: Stephane Eranian <eranian@google.com>
Cc: Wang Nan <wangnan0@huawei.com>
Link: http://lkml.kernel.org/r/20170718042549.145161-10-davidcc@google.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
| 58 ++++++++++++++++++++----------------------------
1 file changed, 24 insertions(+), 34 deletions(-)
--git a/tools/perf/util/header.c b/tools/perf/util/header.c
index 22b52e5..60394d2 100644
--- a/tools/perf/util/header.c
+++ b/tools/perf/util/header.c
@@ -62,6 +62,8 @@ struct perf_file_attr {
struct feat_fd {
struct perf_header *ph;
int fd;
+ ssize_t offset;
+ size_t size;
};
void perf_header__set_feat(struct perf_header *header, int feat)
@@ -1593,8 +1595,7 @@ out:
/* Macro for features that simply need to read and store a string. */
#define FEAT_PROCESS_STR_FUN(__feat, __feat_env) \
-static int process_##__feat(struct perf_file_section *section __maybe_unused, \
- struct feat_fd *ff, void *data __maybe_unused) \
+static int process_##__feat(struct feat_fd *ff, void *data __maybe_unused) \
{\
ff->ph->env.__feat_env = do_read_string(ff->fd, ff->ph); \
return ff->ph->env.__feat_env ? 0 : -ENOMEM; \
@@ -1607,24 +1608,21 @@ FEAT_PROCESS_STR_FUN(arch, arch);
FEAT_PROCESS_STR_FUN(cpudesc, cpu_desc);
FEAT_PROCESS_STR_FUN(cpuid, cpuid);
-static int process_tracing_data(struct perf_file_section *section __maybe_unused,
- struct feat_fd *ff, void *data)
+static int process_tracing_data(struct feat_fd *ff, void *data)
{
ssize_t ret = trace_report(ff->fd, data, false);
return ret < 0 ? -1 : 0;
}
-static int process_build_id(struct perf_file_section *section,
- struct feat_fd *ff, void *data __maybe_unused)
+static int process_build_id(struct feat_fd *ff, void *data __maybe_unused)
{
- if (perf_header__read_build_ids(ff->ph, ff->fd, section->offset, section->size))
+ if (perf_header__read_build_ids(ff->ph, ff->fd, ff->offset, ff->size))
pr_debug("Failed to read buildids, continuing...\n");
return 0;
}
-static int process_nrcpus(struct perf_file_section *section __maybe_unused,
- struct feat_fd *ff, void *data __maybe_unused)
+static int process_nrcpus(struct feat_fd *ff, void *data __maybe_unused)
{
int ret;
u32 nr_cpus_avail, nr_cpus_online;
@@ -1641,8 +1639,7 @@ static int process_nrcpus(struct perf_file_section *section __maybe_unused,
return 0;
}
-static int process_total_mem(struct perf_file_section *section __maybe_unused,
- struct feat_fd *ff, void *data __maybe_unused)
+static int process_total_mem(struct feat_fd *ff, void *data __maybe_unused)
{
u64 total_mem;
int ret;
@@ -1687,8 +1684,7 @@ perf_evlist__set_event_name(struct perf_evlist *evlist,
}
static int
-process_event_desc(struct perf_file_section *section __maybe_unused,
- struct feat_fd *ff, void *data __maybe_unused)
+process_event_desc(struct feat_fd *ff, void *data __maybe_unused)
{
struct perf_session *session;
struct perf_evsel *evsel, *events = read_event_desc(ff->ph, ff->fd);
@@ -1705,8 +1701,7 @@ process_event_desc(struct perf_file_section *section __maybe_unused,
return 0;
}
-static int process_cmdline(struct perf_file_section *section __maybe_unused,
- struct feat_fd *ff, void *data __maybe_unused)
+static int process_cmdline(struct feat_fd *ff, void *data __maybe_unused)
{
char *str, *cmdline = NULL, **argv = NULL;
u32 nr, i, len = 0;
@@ -1716,7 +1711,7 @@ static int process_cmdline(struct perf_file_section *section __maybe_unused,
ff->ph->env.nr_cmdline = nr;
- cmdline = zalloc(section->size + nr + 1);
+ cmdline = zalloc(ff->size + nr + 1);
if (!cmdline)
return -1;
@@ -1744,8 +1739,7 @@ error:
return -1;
}
-static int process_cpu_topology(struct perf_file_section *section __maybe_unused,
- struct feat_fd *ff, void *data __maybe_unused)
+static int process_cpu_topology(struct feat_fd *ff, void *data __maybe_unused)
{
u32 nr, i;
char *str;
@@ -1802,7 +1796,7 @@ static int process_cpu_topology(struct perf_file_section *section __maybe_unused
* The header may be from old perf,
* which doesn't include core id and socket id information.
*/
- if (section->size <= size) {
+ if (ff->size <= size) {
zfree(&ph->env.cpu);
return 0;
}
@@ -1834,8 +1828,7 @@ free_cpu:
return -1;
}
-static int process_numa_topology(struct perf_file_section *section __maybe_unused,
- struct feat_fd *ff, void *data __maybe_unused)
+static int process_numa_topology(struct feat_fd *ff, void *data __maybe_unused)
{
struct numa_node *nodes, *n;
u32 nr, i;
@@ -1881,8 +1874,7 @@ error:
return -1;
}
-static int process_pmu_mappings(struct perf_file_section *section __maybe_unused,
- struct feat_fd *ff, void *data __maybe_unused)
+static int process_pmu_mappings(struct feat_fd *ff, void *data __maybe_unused)
{
char *name;
u32 pmu_num;
@@ -1929,8 +1921,7 @@ error:
return -1;
}
-static int process_group_desc(struct perf_file_section *section __maybe_unused,
- struct feat_fd *ff, void *data __maybe_unused)
+static int process_group_desc(struct feat_fd *ff, void *data __maybe_unused)
{
size_t ret = -1;
u32 i, nr, nr_groups;
@@ -2014,23 +2005,21 @@ out_free:
return ret;
}
-static int process_auxtrace(struct perf_file_section *section __maybe_unused,
- struct feat_fd *ff, void *data __maybe_unused)
+static int process_auxtrace(struct feat_fd *ff, void *data __maybe_unused)
{
struct perf_session *session;
int err;
session = container_of(ff->ph, struct perf_session, header);
- err = auxtrace_index__process(ff->fd, section->size, session,
+ err = auxtrace_index__process(ff->fd, ff->size, session,
ff->ph->needs_swap);
if (err < 0)
pr_err("Failed to process auxtrace index\n");
return err;
}
-static int process_cache(struct perf_file_section *section __maybe_unused,
- struct feat_fd *ff, void *data __maybe_unused)
+static int process_cache(struct feat_fd *ff, void *data __maybe_unused)
{
struct cpu_cache_level *caches;
u32 cnt, i, version;
@@ -2085,8 +2074,7 @@ out_free_caches:
struct feature_ops {
int (*write)(struct feat_fd *ff, struct perf_evlist *evlist);
void (*print)(struct feat_fd *ff, FILE *fp);
- int (*process)(struct perf_file_section *section,
- struct feat_fd *ff, void *data);
+ int (*process)(struct feat_fd *ff, void *data);
const char *name;
bool full_only;
};
@@ -2617,9 +2605,11 @@ static int perf_file_section__process(struct perf_file_section *section,
struct perf_header *ph,
int feat, int fd, void *data)
{
- struct feat_fd ff = {
+ struct feat_fd fdd = {
.fd = fd,
.ph = ph,
+ .size = section->size,
+ .offset = section->offset,
};
if (lseek(fd, section->offset, SEEK_SET) == (off_t)-1) {
@@ -2636,7 +2626,7 @@ static int perf_file_section__process(struct perf_file_section *section,
if (!feat_ops[feat].process)
return 0;
- return feat_ops[feat].process(section, &ff, data);
+ return feat_ops[feat].process(&fdd, data);
}
static int perf_file_header__read_pipe(struct perf_pipe_file_header *header,
next prev parent reply other threads:[~2017-07-20 9:05 UTC|newest]
Thread overview: 34+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-07-18 4:25 [PATCH v6 00/16] perf tool: add meta-data header support for pipe-mode David Carrillo-Cisneros
2017-07-18 4:25 ` [PATCH v6 01/16] perf header: encapsulate read and swap David Carrillo-Cisneros
2017-07-20 8:58 ` [tip:perf/core] perf header: Encapsulate " tip-bot for David Carrillo-Cisneros
2017-07-18 4:25 ` [PATCH v6 02/16] perf header: add PROCESS_STR_FUN macro David Carrillo-Cisneros
2017-07-20 8:58 ` [tip:perf/core] perf header: Add " tip-bot for David Carrillo-Cisneros
2017-07-18 4:25 ` [PATCH v6 03/16] perf header: fail on write_padded error David Carrillo-Cisneros
2017-07-20 8:59 ` [tip:perf/core] perf header: Fail " tip-bot for David Carrillo-Cisneros
2017-07-18 4:25 ` [PATCH v6 04/16] perf util: add const modifier to buf in "writen" function David Carrillo-Cisneros
2017-07-20 8:59 ` [tip:perf/core] perf util: Add " tip-bot for David Carrillo-Cisneros
2017-07-18 4:25 ` [PATCH v6 05/16] perf header: revamp do_write David Carrillo-Cisneros
2017-07-20 8:59 ` [tip:perf/core] perf header: Revamp do_write() tip-bot for David Carrillo-Cisneros
2017-07-18 4:25 ` [PATCH v6 06/16] perf header: add struct feat_fd for write David Carrillo-Cisneros
2017-07-20 9:00 ` [tip:perf/core] perf header: Add " tip-bot for David Carrillo-Cisneros
2017-07-18 4:25 ` [PATCH v6 07/16] perf header: use struct feat_fd for print David Carrillo-Cisneros
2017-07-20 9:00 ` [tip:perf/core] perf header: Use " tip-bot for David Carrillo-Cisneros
2017-07-18 4:25 ` [PATCH v6 08/16] perf header: use struct feat_fd to process header records David Carrillo-Cisneros
2017-07-20 9:00 ` [tip:perf/core] perf header: Use " tip-bot for David Carrillo-Cisneros
2017-07-18 4:25 ` [PATCH v6 09/16] perf header: don't pass struct perf_file_section to process_##_feat David Carrillo-Cisneros
2017-07-20 9:01 ` tip-bot for David Carrillo-Cisneros [this message]
2017-07-18 4:25 ` [PATCH v6 10/16] perf header: use struct feat_fd in read header records David Carrillo-Cisneros
2017-07-20 9:01 ` [tip:perf/core] perf header: Use " tip-bot for David Carrillo-Cisneros
2017-07-18 4:25 ` [PATCH v6 11/16] perf header: make write_pmu_mappings pipe-mode friendly David Carrillo-Cisneros
2017-07-20 9:01 ` [tip:perf/core] perf header: Make " tip-bot for David Carrillo-Cisneros
2017-07-18 4:25 ` [PATCH v6 12/16] perf header: add a buffer to struct feat_fd David Carrillo-Cisneros
2017-07-20 9:02 ` [tip:perf/core] perf header: Add " tip-bot for David Carrillo-Cisneros
2017-07-18 4:25 ` [PATCH v6 13/16] perf header: change FEAT_OP* macros David Carrillo-Cisneros
2017-07-20 9:02 ` [tip:perf/core] perf header: Change " tip-bot for David Carrillo-Cisneros
2017-07-18 4:25 ` [PATCH v6 14/16] perf tool: add show_feature_header to perf_tool David Carrillo-Cisneros
2017-07-20 9:02 ` [tip:perf/core] perf tool: Add " tip-bot for David Carrillo-Cisneros
2017-07-18 4:25 ` [PATCH v6 15/16] perf tools: add feature header record to pipe-mode David Carrillo-Cisneros
2017-07-20 9:03 ` [tip:perf/core] perf tools: Add " tip-bot for David Carrillo-Cisneros
2017-07-18 4:25 ` [PATCH v6 16/16] perf header: add event desc to pipe-mode header David Carrillo-Cisneros
2017-07-20 9:03 ` [tip:perf/core] perf header: Add " tip-bot for David Carrillo-Cisneros
2017-07-18 7:28 ` [PATCH v6 00/16] perf tool: add meta-data header support for pipe-mode Jiri Olsa
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=tip-625524572391326b83f906efe02abbaac9debce6@git.kernel.org \
--to=tipbot@zytor.com \
--cc=acme@redhat.com \
--cc=ak@linux.intel.com \
--cc=alexander.shishkin@linux.intel.com \
--cc=davidcc@google.com \
--cc=dsahern@gmail.com \
--cc=eranian@google.com \
--cc=hekuang@huawei.com \
--cc=hpa@zytor.com \
--cc=jolsa@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-tip-commits@vger.kernel.org \
--cc=mhiramat@kernel.org \
--cc=mingo@kernel.org \
--cc=namhyung@kernel.org \
--cc=peterz@infradead.org \
--cc=pjt@google.com \
--cc=sque@chromium.org \
--cc=tglx@linutronix.de \
--cc=wangnan0@huawei.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.