aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNamhyung Kim <namhyung.kim@lge.com>2012-09-24 04:15:03 -0400
committerArnaldo Carvalho de Melo <acme@redhat.com>2012-09-24 10:47:46 -0400
commit37e9d750e672d6fa8c25463bd76240410bbbc786 (patch)
treedecdd3c3c92e7a6b9e27e9213c5871b1da457183
parent2f9e97aa8b4c6220c0770a966fb99d7366679813 (diff)
perf header: Remove perf_header__read_feature
Because its only user builtin-kvm::get_cpu_isa() has gone, It can be removed safely. In general, we have the feature information in perf_session_env already, no need to read it again. Signed-off-by: Namhyung Kim <namhyung@kernel.org> Cc: David Ahern <dsahern@gmail.com> Cc: Dong Hao <haodong@linux.vnet.ibm.com> Cc: Ingo Molnar <mingo@kernel.org> Cc: Paul Mackerras <paulus@samba.org> Cc: Peter Zijlstra <a.p.zijlstra@chello.nl> Cc: Stephane Eranian <eranian@google.com> Cc: Xiao Guangrong <xiaoguangrong@linux.vnet.ibm.com> Link: http://lkml.kernel.org/r/1348474503-15070-7-git-send-email-namhyung@kernel.org Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
-rw-r--r--tools/perf/util/header.c60
-rw-r--r--tools/perf/util/header.h1
2 files changed, 1 insertions, 60 deletions
diff --git a/tools/perf/util/header.c b/tools/perf/util/header.c
index 4b028df83a4..6aae3290358 100644
--- a/tools/perf/util/header.c
+++ b/tools/perf/util/header.c
@@ -1690,11 +1690,6 @@ static int process_total_mem(struct perf_file_section *section __maybe_unused,
1690 return 0; 1690 return 0;
1691} 1691}
1692 1692
1693static char *read_cpuid(struct perf_header *ph, int fd)
1694{
1695 return do_read_string(fd, ph);
1696}
1697
1698static struct perf_evsel * 1693static struct perf_evsel *
1699perf_evlist__find_by_index(struct perf_evlist *evlist, int idx) 1694perf_evlist__find_by_index(struct perf_evlist *evlist, int idx)
1700{ 1695{
@@ -1952,7 +1947,6 @@ error:
1952struct feature_ops { 1947struct feature_ops {
1953 int (*write)(int fd, struct perf_header *h, struct perf_evlist *evlist); 1948 int (*write)(int fd, struct perf_header *h, struct perf_evlist *evlist);
1954 void (*print)(struct perf_header *h, int fd, FILE *fp); 1949 void (*print)(struct perf_header *h, int fd, FILE *fp);
1955 char *(*read)(struct perf_header *h, int fd);
1956 int (*process)(struct perf_file_section *section, 1950 int (*process)(struct perf_file_section *section,
1957 struct perf_header *h, int fd, void *data); 1951 struct perf_header *h, int fd, void *data);
1958 const char *name; 1952 const char *name;
@@ -1967,10 +1961,6 @@ struct feature_ops {
1967#define FEAT_OPF(n, func) \ 1961#define FEAT_OPF(n, func) \
1968 [n] = { .name = #n, .write = write_##func, .print = print_##func, \ 1962 [n] = { .name = #n, .write = write_##func, .print = print_##func, \
1969 .process = process_##func, .full_only = true } 1963 .process = process_##func, .full_only = true }
1970#define FEAT_OPA_R(n, func) \
1971 [n] = { .name = #n, .write = write_##func, .print = print_##func, \
1972 .read = read_##func, .process = process_##func, \
1973 .full_only = true }
1974 1964
1975/* feature_ops not implemented: */ 1965/* feature_ops not implemented: */
1976#define print_tracing_data NULL 1966#define print_tracing_data NULL
@@ -1985,7 +1975,7 @@ static const struct feature_ops feat_ops[HEADER_LAST_FEATURE] = {
1985 FEAT_OPP(HEADER_ARCH, arch), 1975 FEAT_OPP(HEADER_ARCH, arch),
1986 FEAT_OPP(HEADER_NRCPUS, nrcpus), 1976 FEAT_OPP(HEADER_NRCPUS, nrcpus),
1987 FEAT_OPP(HEADER_CPUDESC, cpudesc), 1977 FEAT_OPP(HEADER_CPUDESC, cpudesc),
1988 FEAT_OPA_R(HEADER_CPUID, cpuid), 1978 FEAT_OPP(HEADER_CPUID, cpuid),
1989 FEAT_OPP(HEADER_TOTAL_MEM, total_mem), 1979 FEAT_OPP(HEADER_TOTAL_MEM, total_mem),
1990 FEAT_OPP(HEADER_EVENT_DESC, event_desc), 1980 FEAT_OPP(HEADER_EVENT_DESC, event_desc),
1991 FEAT_OPP(HEADER_CMDLINE, cmdline), 1981 FEAT_OPP(HEADER_CMDLINE, cmdline),
@@ -2040,54 +2030,6 @@ int perf_header__fprintf_info(struct perf_session *session, FILE *fp, bool full)
2040 return 0; 2030 return 0;
2041} 2031}
2042 2032
2043struct header_read_data {
2044 int feat;
2045 char *result;
2046};
2047
2048static int perf_file_section__read_feature(struct perf_file_section *section,
2049 struct perf_header *ph,
2050 int feat, int fd, void *data)
2051{
2052 struct header_read_data *hd = data;
2053
2054 if (feat != hd->feat)
2055 return 0;
2056
2057 if (lseek(fd, section->offset, SEEK_SET) == (off_t)-1) {
2058 pr_debug("Failed to lseek to %" PRIu64 " offset for feature "
2059 "%d, continuing...\n", section->offset, feat);
2060 return 0;
2061 }
2062
2063 if (feat >= HEADER_LAST_FEATURE) {
2064 pr_warning("unknown feature %d\n", feat);
2065 return 0;
2066 }
2067
2068 if (!feat_ops[feat].read) {
2069 pr_warning("read is not supported for feature %d\n", feat);
2070 return 0;
2071 }
2072
2073 hd->result = feat_ops[feat].read(ph, fd);
2074 return 0;
2075}
2076
2077char *perf_header__read_feature(struct perf_session *session, int feat)
2078{
2079 struct perf_header *header = &session->header;
2080 struct header_read_data hd;
2081 int fd = session->fd;
2082
2083 hd.feat = feat;
2084 hd.result = NULL;
2085
2086 perf_header__process_sections(header, fd, &hd,
2087 perf_file_section__read_feature);
2088 return hd.result;
2089}
2090
2091static int do_write_feat(int fd, struct perf_header *h, int type, 2033static int do_write_feat(int fd, struct perf_header *h, int type,
2092 struct perf_file_section **p, 2034 struct perf_file_section **p,
2093 struct perf_evlist *evlist) 2035 struct perf_evlist *evlist)
diff --git a/tools/perf/util/header.h b/tools/perf/util/header.h
index 5867c7d74f9..99bdd3abce5 100644
--- a/tools/perf/util/header.h
+++ b/tools/perf/util/header.h
@@ -118,7 +118,6 @@ int perf_header__process_sections(struct perf_header *header, int fd,
118 int feat, int fd, void *data)); 118 int feat, int fd, void *data));
119 119
120int perf_header__fprintf_info(struct perf_session *s, FILE *fp, bool full); 120int perf_header__fprintf_info(struct perf_session *s, FILE *fp, bool full);
121char *perf_header__read_feature(struct perf_session *session, int feat);
122 121
123int build_id_cache__add_s(const char *sbuild_id, const char *debugdir, 122int build_id_cache__add_s(const char *sbuild_id, const char *debugdir,
124 const char *name, bool is_kallsyms, bool is_vdso); 123 const char *name, bool is_kallsyms, bool is_vdso);