diff options
author | Ingo Molnar <mingo@kernel.org> | 2014-12-12 03:09:52 -0500 |
---|---|---|
committer | Ingo Molnar <mingo@kernel.org> | 2014-12-12 03:09:52 -0500 |
commit | 41e950c033b7df997d4b38653efe6554be9b96a7 (patch) | |
tree | b8ffe779d47c768a9652ce9166f4878cee41f2ca /tools/lib | |
parent | 3459f0d78ffe27a1b341c22eb158b622eaaea3fc (diff) | |
parent | e09b18d4907992d3d615b215c1abf585721b2810 (diff) |
Merge tag 'perf-core-for-mingo' of git://git.kernel.org/pub/scm/linux/kernel/git/acme/linux into perf/urgent
Pull perf/core improvements and fixes from Arnaldo Carvalho de Melo:
User visible changes:
- Mark events as (x86 only) in help output for 'perf kvm stat live" (Alexander Yarygin)
- Provide a better explanation when mmap fails in 'trace' (Arnaldo Carvalho de Melo)
- Add --buildid-dir option to set cache directory, i.e. use:
$ perf --buildid-dir /path/to/dir tool --tool-options
(Jiri Olsa)
- Fix memcpy/memset 'perf bench' output (Rabin Vicent)
- Fix 'perf test' attr tests size values to cope with machine state on
interrupt ABI changes (Jiri Olsa)
- Fixup callchain type parameter handling error message (Kan Liang)
Infrastructure changes and cleanups:
- calloc/xcalloc: Fix argument order (Arjun Sreedharan)
- Move filename__read_int from tools/perf/ to tools/lib, add sysctl__read_int
there and use it in place of ad-hoc copies (Arnaldo Carvalho de Melo)
- Use single strcmp call instead of two (Jiri Olsa)
- Remove extra debugdir variables in 'perf buildid-cache' (Jiri Olsa)
- Fix -a segfault related to kcore handling in 'perf buildid-cache' (Jiri Olsa)
- Move cpumode resolve code to add_callchain_ip (Kan Liang)
- Merge memset into memcpy 'perf bench' (Rabin Vincent)
- Change print format from %lu to %PRIu64 in the hists browser (Tom Huynh)
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Diffstat (limited to 'tools/lib')
-rw-r--r-- | tools/lib/api/fs/fs.c | 34 | ||||
-rw-r--r-- | tools/lib/api/fs/fs.h | 3 |
2 files changed, 37 insertions, 0 deletions
diff --git a/tools/lib/api/fs/fs.c b/tools/lib/api/fs/fs.c index c1b49c36a951..65d9be3f9887 100644 --- a/tools/lib/api/fs/fs.c +++ b/tools/lib/api/fs/fs.c | |||
@@ -7,6 +7,10 @@ | |||
7 | #include <stdlib.h> | 7 | #include <stdlib.h> |
8 | #include <string.h> | 8 | #include <string.h> |
9 | #include <sys/vfs.h> | 9 | #include <sys/vfs.h> |
10 | #include <sys/types.h> | ||
11 | #include <sys/stat.h> | ||
12 | #include <fcntl.h> | ||
13 | #include <unistd.h> | ||
10 | 14 | ||
11 | #include "debugfs.h" | 15 | #include "debugfs.h" |
12 | #include "fs.h" | 16 | #include "fs.h" |
@@ -163,3 +167,33 @@ const char *name##__mountpoint(void) \ | |||
163 | 167 | ||
164 | FS__MOUNTPOINT(sysfs, FS__SYSFS); | 168 | FS__MOUNTPOINT(sysfs, FS__SYSFS); |
165 | FS__MOUNTPOINT(procfs, FS__PROCFS); | 169 | FS__MOUNTPOINT(procfs, FS__PROCFS); |
170 | |||
171 | int filename__read_int(const char *filename, int *value) | ||
172 | { | ||
173 | char line[64]; | ||
174 | int fd = open(filename, O_RDONLY), err = -1; | ||
175 | |||
176 | if (fd < 0) | ||
177 | return -1; | ||
178 | |||
179 | if (read(fd, line, sizeof(line)) > 0) { | ||
180 | *value = atoi(line); | ||
181 | err = 0; | ||
182 | } | ||
183 | |||
184 | close(fd); | ||
185 | return err; | ||
186 | } | ||
187 | |||
188 | int sysctl__read_int(const char *sysctl, int *value) | ||
189 | { | ||
190 | char path[PATH_MAX]; | ||
191 | const char *procfs = procfs__mountpoint(); | ||
192 | |||
193 | if (!procfs) | ||
194 | return -1; | ||
195 | |||
196 | snprintf(path, sizeof(path), "%s/sys/%s", procfs, sysctl); | ||
197 | |||
198 | return filename__read_int(path, value); | ||
199 | } | ||
diff --git a/tools/lib/api/fs/fs.h b/tools/lib/api/fs/fs.h index cb7049551f33..6caa2bbc6cec 100644 --- a/tools/lib/api/fs/fs.h +++ b/tools/lib/api/fs/fs.h | |||
@@ -11,4 +11,7 @@ | |||
11 | 11 | ||
12 | const char *sysfs__mountpoint(void); | 12 | const char *sysfs__mountpoint(void); |
13 | const char *procfs__mountpoint(void); | 13 | const char *procfs__mountpoint(void); |
14 | |||
15 | int filename__read_int(const char *filename, int *value); | ||
16 | int sysctl__read_int(const char *sysctl, int *value); | ||
14 | #endif /* __API_FS__ */ | 17 | #endif /* __API_FS__ */ |