From: David Carrillo-Cisneros <davidcc@google.com>
To: linux-kernel@vger.kernel.org
Cc: Peter Zijlstra <peterz@infradead.org>,
Ingo Molnar <mingo@redhat.com>,
Arnaldo Carvalho de Melo <acme@kernel.org>,
Alexander Shishkin <alexander.shishkin@linux.intel.com>,
Andi Kleen <ak@linux.intel.com>, Simon Que <sque@chromium.org>,
Wang Nan <wangnan0@huawei.com>, Jiri Olsa <jolsa@kernel.org>,
He Kuang <hekuang@huawei.com>,
Masami Hiramatsu <mhiramat@kernel.org>,
David Ahern <dsa@cumulusnetworks.com>,
Namhyung Kim <namhyung@kernel.org>,
Stephane Eranian <eranian@google.com>,
Paul Turner <pjt@google.com>,
David Carrillo-Cisneros <davidcc@google.com>
Subject: [PATCH v2 07/13] perf header: use struct feat_fd for print
Date: Tue, 23 May 2017 00:48:47 -0700 [thread overview]
Message-ID: <20170523074853.54892-8-davidcc@google.com> (raw)
In-Reply-To: <20170523074853.54892-1-davidcc@google.com>
As preparation for using header records in pipe mode, replace
int fd with struct feat_fd fd in print functions for all header
record types.
Add offset and size to struct feat_fd to provide pipe-mode with
variables for offset and size that in file-mode are stored
in struct perf_file_section.
Signed-off-by: David Carrillo-Cisneros <davidcc@google.com>
---
| 106 +++++++++++++++++++++++------------------------
1 file changed, 51 insertions(+), 55 deletions(-)
--git a/tools/perf/util/header.c b/tools/perf/util/header.c
index 4934ef543aef..3d0c61027170 100644
--- a/tools/perf/util/header.c
+++ b/tools/perf/util/header.c
@@ -60,6 +60,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)
@@ -1114,62 +1116,56 @@ static int write_stat(struct feat_fd *fd __maybe_unused,
return 0;
}
-static void print_hostname(struct perf_header *ph, int fd __maybe_unused,
- FILE *fp)
+static void print_hostname(struct feat_fd *fd, FILE *fp)
{
- fprintf(fp, "# hostname : %s\n", ph->env.hostname);
+ fprintf(fp, "# hostname : %s\n", fd->ph->env.hostname);
}
-static void print_osrelease(struct perf_header *ph, int fd __maybe_unused,
- FILE *fp)
+static void print_osrelease(struct feat_fd *fd, FILE *fp)
{
- fprintf(fp, "# os release : %s\n", ph->env.os_release);
+ fprintf(fp, "# os release : %s\n", fd->ph->env.os_release);
}
-static void print_arch(struct perf_header *ph, int fd __maybe_unused, FILE *fp)
+static void print_arch(struct feat_fd *fd, FILE *fp)
{
- fprintf(fp, "# arch : %s\n", ph->env.arch);
+ fprintf(fp, "# arch : %s\n", fd->ph->env.arch);
}
-static void print_cpudesc(struct perf_header *ph, int fd __maybe_unused,
- FILE *fp)
+static void print_cpudesc(struct feat_fd *fd, FILE *fp)
{
- fprintf(fp, "# cpudesc : %s\n", ph->env.cpu_desc);
+ fprintf(fp, "# cpudesc : %s\n", fd->ph->env.cpu_desc);
}
-static void print_nrcpus(struct perf_header *ph, int fd __maybe_unused,
- FILE *fp)
+static void print_nrcpus(struct feat_fd *fd, FILE *fp)
{
- fprintf(fp, "# nrcpus online : %u\n", ph->env.nr_cpus_online);
- fprintf(fp, "# nrcpus avail : %u\n", ph->env.nr_cpus_avail);
+ fprintf(fp, "# nrcpus online : %u\n", fd->ph->env.nr_cpus_online);
+ fprintf(fp, "# nrcpus avail : %u\n", fd->ph->env.nr_cpus_avail);
}
-static void print_version(struct perf_header *ph, int fd __maybe_unused,
- FILE *fp)
+static void print_version(struct feat_fd *fd, FILE *fp)
{
- fprintf(fp, "# perf version : %s\n", ph->env.version);
+ fprintf(fp, "# perf version : %s\n", fd->ph->env.version);
}
-static void print_cmdline(struct perf_header *ph, int fd __maybe_unused,
- FILE *fp)
+static void print_cmdline(struct feat_fd *fd, FILE *fp)
{
int nr, i;
- nr = ph->env.nr_cmdline;
+ nr = fd->ph->env.nr_cmdline;
fprintf(fp, "# cmdline : ");
for (i = 0; i < nr; i++)
- fprintf(fp, "%s ", ph->env.cmdline_argv[i]);
+ fprintf(fp, "%s ", fd->ph->env.cmdline_argv[i]);
fputc('\n', fp);
}
-static void print_cpu_topology(struct perf_header *ph, int fd __maybe_unused,
- FILE *fp)
+static void print_cpu_topology(struct feat_fd *fd, FILE *fp)
{
+ struct perf_header *ph = fd->ph;
+ int cpu_nr = ph->env.nr_cpus_avail;
int nr, i;
char *str;
- int cpu_nr = ph->env.nr_cpus_avail;
nr = ph->env.nr_sibling_cores;
str = ph->env.sibling_cores;
@@ -1295,9 +1291,9 @@ static int __desc_attr__fprintf(FILE *fp, const char *name, const char *val,
return fprintf(fp, ", %s = %s", name, val);
}
-static void print_event_desc(struct perf_header *ph, int fd, FILE *fp)
+static void print_event_desc(struct feat_fd *fd, FILE *fp)
{
- struct perf_evsel *evsel, *events = read_event_desc(ph, fd);
+ struct perf_evsel *evsel, *events = read_event_desc(fd->ph, fd->fd);
u32 j;
u64 *id;
@@ -1327,20 +1323,18 @@ static void print_event_desc(struct perf_header *ph, int fd, FILE *fp)
free_event_desc(events);
}
-static void print_total_mem(struct perf_header *ph, int fd __maybe_unused,
- FILE *fp)
+static void print_total_mem(struct feat_fd *fd, FILE *fp)
{
- fprintf(fp, "# total memory : %Lu kB\n", ph->env.total_mem);
+ fprintf(fp, "# total memory : %llu kB\n", fd->ph->env.total_mem);
}
-static void print_numa_topology(struct perf_header *ph, int fd __maybe_unused,
- FILE *fp)
+static void print_numa_topology(struct feat_fd *fd, FILE *fp)
{
int i;
struct numa_node *n;
- for (i = 0; i < ph->env.nr_numa_nodes; i++) {
- n = &ph->env.numa_nodes[i];
+ for (i = 0; i < fd->ph->env.nr_numa_nodes; i++) {
+ n = &fd->ph->env.numa_nodes[i];
fprintf(fp, "# node%u meminfo : total = %"PRIu64" kB,"
" free = %"PRIu64" kB\n",
@@ -1351,56 +1345,51 @@ static void print_numa_topology(struct perf_header *ph, int fd __maybe_unused,
}
}
-static void print_cpuid(struct perf_header *ph, int fd __maybe_unused, FILE *fp)
+static void print_cpuid(struct feat_fd *fd, FILE *fp)
{
- fprintf(fp, "# cpuid : %s\n", ph->env.cpuid);
+ fprintf(fp, "# cpuid : %s\n", fd->ph->env.cpuid);
}
-static void print_branch_stack(struct perf_header *ph __maybe_unused,
- int fd __maybe_unused, FILE *fp)
+static void print_branch_stack(struct feat_fd *fd __maybe_unused, FILE *fp)
{
fprintf(fp, "# contains samples with branch stack\n");
}
-static void print_auxtrace(struct perf_header *ph __maybe_unused,
- int fd __maybe_unused, FILE *fp)
+static void print_auxtrace(struct feat_fd *fd __maybe_unused, FILE *fp)
{
fprintf(fp, "# contains AUX area data (e.g. instruction trace)\n");
}
-static void print_stat(struct perf_header *ph __maybe_unused,
- int fd __maybe_unused, FILE *fp)
+static void print_stat(struct feat_fd *fd __maybe_unused, FILE *fp)
{
fprintf(fp, "# contains stat data\n");
}
-static void print_cache(struct perf_header *ph __maybe_unused,
- int fd __maybe_unused, FILE *fp __maybe_unused)
+static void print_cache(struct feat_fd *fd, FILE *fp __maybe_unused)
{
int i;
fprintf(fp, "# CPU cache info:\n");
- for (i = 0; i < ph->env.caches_cnt; i++) {
+ for (i = 0; i < fd->ph->env.caches_cnt; i++) {
fprintf(fp, "# ");
- cpu_cache_level__fprintf(fp, &ph->env.caches[i]);
+ cpu_cache_level__fprintf(fp, &fd->ph->env.caches[i]);
}
}
-static void print_pmu_mappings(struct perf_header *ph, int fd __maybe_unused,
- FILE *fp)
+static void print_pmu_mappings(struct feat_fd *fd, FILE *fp)
{
const char *delimiter = "# pmu mappings: ";
char *str, *tmp;
u32 pmu_num;
u32 type;
- pmu_num = ph->env.nr_pmu_mappings;
+ pmu_num = fd->ph->env.nr_pmu_mappings;
if (!pmu_num) {
fprintf(fp, "# pmu mappings: not available\n");
return;
}
- str = ph->env.pmu_mappings;
+ str = fd->ph->env.pmu_mappings;
while (pmu_num) {
type = strtoul(str, &tmp, 0);
@@ -1423,14 +1412,13 @@ static void print_pmu_mappings(struct perf_header *ph, int fd __maybe_unused,
fprintf(fp, "# pmu mappings: unable to read\n");
}
-static void print_group_desc(struct perf_header *ph, int fd __maybe_unused,
- FILE *fp)
+static void print_group_desc(struct feat_fd *fd, FILE *fp)
{
struct perf_session *session;
struct perf_evsel *evsel;
u32 nr = 0;
- session = container_of(ph, struct perf_session, header);
+ session = container_of(fd->ph, struct perf_session, header);
evlist__for_each_entry(session->evlist, evsel) {
if (perf_evsel__is_group_leader(evsel) &&
@@ -2095,7 +2083,7 @@ static int process_cache(struct perf_file_section *section __maybe_unused,
struct feature_ops {
int (*write)(struct feat_fd *fd, struct perf_evlist *evlist);
- void (*print)(struct perf_header *h, int fd, FILE *fp);
+ void (*print)(struct feat_fd *fd, FILE *fp);
int (*process)(struct perf_file_section *section,
struct perf_header *h, int fd, void *data);
const char *name;
@@ -2148,6 +2136,7 @@ static int perf_file_section__fprintf_info(struct perf_file_section *section,
int feat, int fd, void *data)
{
struct header_print_data *hd = data;
+ struct feat_fd fdd;
if (lseek(fd, section->offset, SEEK_SET) == (off_t)-1) {
pr_debug("Failed to lseek to %" PRIu64 " offset for feature "
@@ -2161,8 +2150,15 @@ static int perf_file_section__fprintf_info(struct perf_file_section *section,
if (!feat_ops[feat].print)
return 0;
+ fdd = (struct feat_fd) {
+ .fd = fd,
+ .ph = ph,
+ .size = section->size,
+ .offset = section->offset,
+ };
+
if (!feat_ops[feat].full_only || hd->full)
- feat_ops[feat].print(ph, fd, hd->fp);
+ feat_ops[feat].print(&fdd, hd->fp);
else
fprintf(hd->fp, "# %s info available, use -I to display\n",
feat_ops[feat].name);
--
2.13.0.219.gdb65acc882-goog
next prev parent reply other threads:[~2017-05-23 7:51 UTC|newest]
Thread overview: 43+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-05-23 7:48 [PATCH v2 00/13] perf tool: add meta-data header support for pipe-mode David Carrillo-Cisneros
2017-05-23 7:48 ` [PATCH v2 01/13] perf header: encapsulate read and swap David Carrillo-Cisneros
2017-05-24 15:35 ` Namhyung Kim
2017-06-04 23:09 ` David Carrillo-Cisneros
2017-05-25 8:07 ` Jiri Olsa
2017-06-04 23:22 ` David Carrillo-Cisneros
2017-05-23 7:48 ` [PATCH v2 02/13] perf header: add PROCESS_STR_FUN macro David Carrillo-Cisneros
2017-05-23 7:48 ` [PATCH v2 03/13] perf header: fail on write_padded error David Carrillo-Cisneros
2017-05-23 7:48 ` [PATCH v2 04/13] perf util: add const modifier to buf in "writen" function David Carrillo-Cisneros
2017-05-23 7:48 ` [PATCH v2 05/13] perf header: revamp do_write David Carrillo-Cisneros
2017-05-25 8:08 ` Jiri Olsa
2017-06-05 2:25 ` David Carrillo-Cisneros
2017-05-23 7:48 ` [PATCH v2 06/13] perf header: add struct feat_fd for write David Carrillo-Cisneros
2017-05-25 8:07 ` Jiri Olsa
2017-06-05 1:50 ` David Carrillo-Cisneros
2017-05-23 7:48 ` David Carrillo-Cisneros [this message]
2017-05-25 8:09 ` [PATCH v2 07/13] perf header: use struct feat_fd for print Jiri Olsa
2017-06-05 2:37 ` David Carrillo-Cisneros
2017-06-05 3:01 ` David Carrillo-Cisneros
2017-05-23 7:48 ` [PATCH v2 08/13] perf header: use struct feat_fd to process header records David Carrillo-Cisneros
2017-05-23 7:48 ` [PATCH v2 09/13] perf header: use struct feat_fd in read " David Carrillo-Cisneros
2017-05-23 7:48 ` [PATCH v2 10/13] perf header: add a buffer to struct feat_fd David Carrillo-Cisneros
2017-05-25 8:07 ` Jiri Olsa
2017-05-25 8:08 ` Jiri Olsa
2017-05-25 8:09 ` Jiri Olsa
2017-05-25 8:10 ` Jiri Olsa
2017-05-23 7:48 ` [PATCH v2 11/13] perf header: change FEAT_OP* macros David Carrillo-Cisneros
2017-05-25 8:08 ` Jiri Olsa
2017-05-25 8:08 ` Jiri Olsa
2017-06-05 2:13 ` David Carrillo-Cisneros
2017-05-23 7:48 ` [PATCH v2 12/13] perf tool: add show_feature_header to perf_tool David Carrillo-Cisneros
2017-05-23 7:48 ` [PATCH v2 13/13] perf tools: add feature header record to pipe-mode David Carrillo-Cisneros
2017-05-24 15:40 ` Namhyung Kim
2017-05-25 8:08 ` Jiri Olsa
2017-05-25 8:09 ` Jiri Olsa
2017-05-25 8:09 ` Jiri Olsa
2017-05-25 8:09 ` Jiri Olsa
[not found] ` <CALcN6mhWWDbnGkDP5unmbB3GPi8+LRoKW8DFAse-KMUy85Fpew@mail.gmail.com>
2017-06-06 11:03 ` Jiri Olsa
2017-05-25 8:09 ` Jiri Olsa
2017-05-25 8:10 ` Jiri Olsa
2017-06-06 1:32 ` David Carrillo-Cisneros
2017-06-06 11:04 ` Jiri Olsa
2017-06-06 18:13 ` David Carrillo-Cisneros
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=20170523074853.54892-8-davidcc@google.com \
--to=davidcc@google.com \
--cc=acme@kernel.org \
--cc=ak@linux.intel.com \
--cc=alexander.shishkin@linux.intel.com \
--cc=dsa@cumulusnetworks.com \
--cc=eranian@google.com \
--cc=hekuang@huawei.com \
--cc=jolsa@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mhiramat@kernel.org \
--cc=mingo@redhat.com \
--cc=namhyung@kernel.org \
--cc=peterz@infradead.org \
--cc=pjt@google.com \
--cc=sque@chromium.org \
--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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox