diff options
author | Arnaldo Carvalho de Melo <acme@redhat.com> | 2014-12-11 11:37:59 -0500 |
---|---|---|
committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2014-12-11 15:53:04 -0500 |
commit | ce27309f67c347e6e49ebd45042f5362b0ccbdcc (patch) | |
tree | 5ca6a4d73f1a41f8104cc558582478c6206cd42f /tools | |
parent | 42e3c4a1274d49b42e9d4306ec096b282a6e14aa (diff) |
perf tools: Use sysctl__read_int instead of ad-hoc copies
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Borislav Petkov <bp@suse.de>
Cc: David Ahern <dsahern@gmail.com>
Cc: Don Zickus <dzickus@redhat.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Mike Galbraith <efault@gmx.de>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Stephane Eranian <eranian@google.com>
Link: http://lkml.kernel.org/n/tip-pt2u7a3b50oddggecx7rwq2n@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools')
-rw-r--r-- | tools/perf/util/record.c | 11 | ||||
-rw-r--r-- | tools/perf/util/util.c | 9 |
2 files changed, 2 insertions, 18 deletions
diff --git a/tools/perf/util/record.c b/tools/perf/util/record.c index cf69325b985f..8acd0df88b5c 100644 --- a/tools/perf/util/record.c +++ b/tools/perf/util/record.c | |||
@@ -137,16 +137,7 @@ void perf_evlist__config(struct perf_evlist *evlist, struct record_opts *opts) | |||
137 | 137 | ||
138 | static int get_max_rate(unsigned int *rate) | 138 | static int get_max_rate(unsigned int *rate) |
139 | { | 139 | { |
140 | char path[PATH_MAX]; | 140 | return sysctl__read_int("kernel/perf_event_max_sample_rate", (int *)rate); |
141 | const char *procfs = procfs__mountpoint(); | ||
142 | |||
143 | if (!procfs) | ||
144 | return -1; | ||
145 | |||
146 | snprintf(path, PATH_MAX, | ||
147 | "%s/sys/kernel/perf_event_max_sample_rate", procfs); | ||
148 | |||
149 | return filename__read_int(path, (int *) rate); | ||
150 | } | 141 | } |
151 | 142 | ||
152 | static int record_opts__config_freq(struct record_opts *opts) | 143 | static int record_opts__config_freq(struct record_opts *opts) |
diff --git a/tools/perf/util/util.c b/tools/perf/util/util.c index 41125e5b011e..b86744f29eef 100644 --- a/tools/perf/util/util.c +++ b/tools/perf/util/util.c | |||
@@ -506,16 +506,9 @@ const char *get_filename_for_perf_kvm(void) | |||
506 | 506 | ||
507 | int perf_event_paranoid(void) | 507 | int perf_event_paranoid(void) |
508 | { | 508 | { |
509 | char path[PATH_MAX]; | ||
510 | const char *procfs = procfs__mountpoint(); | ||
511 | int value; | 509 | int value; |
512 | 510 | ||
513 | if (!procfs) | 511 | if (sysctl__read_int("kernel/perf_event_paranoid", &value)) |
514 | return INT_MAX; | ||
515 | |||
516 | scnprintf(path, PATH_MAX, "%s/sys/kernel/perf_event_paranoid", procfs); | ||
517 | |||
518 | if (filename__read_int(path, &value)) | ||
519 | return INT_MAX; | 512 | return INT_MAX; |
520 | 513 | ||
521 | return value; | 514 | return value; |