Skip to contentSkip to conversation

perf tools: Use sysctl__read_int instead of ad-hoc copies

tip:perf/urgent tip-bot for Arnaldo Carvalho de Melo 1 participant 1 message Dec 12, 2014 perf events

lore
Share & tools
lore
#0 lore raw
Commit-ID:  ce27309f67c347e6e49ebd45042f5362b0ccbdcc
Gitweb:     http://git.kernel.org/tip/ce27309f67c347e6e49ebd45042f5362b0ccbdcc
Author:     Arnaldo Carvalho de Melo <[email protected]>
AuthorDate: Thu, 11 Dec 2014 13:37:59 -0300
Committer:  Arnaldo Carvalho de Melo <[email protected]>
CommitDate: Thu, 11 Dec 2014 17:53:04 -0300

perf tools: Use sysctl__read_int instead of ad-hoc copies

Cc Adrian Hunter <[email protected]>
Cc Borislav Petkov <[email protected]>
Cc David Ahern <[email protected]>
Cc Don Zickus <[email protected]>
Cc Frederic Weisbecker <[email protected]>
Cc Jiri Olsa <[email protected]>
Cc Mike Galbraith <[email protected]>
Cc Namhyung Kim <[email protected]>
Cc Paul Mackerras <[email protected]>
Cc Peter Zijlstra <[email protected]>
Cc Stephane Eranian <[email protected]>
---
 tools/perf/util/record.c | 11 +----------
 tools/perf/util/util.c   |  9 +--------
 2 files changed, 2 insertions(+), 18 deletions(-)
tools/perf/util/record.c +1 -10
index cf69325..8acd0df 100644
@@ -137,16 +137,7 @@ void perf_evlist__config(struct perf_evlist *evlist, struct record_opts *opts)
 
 static int get_max_rate(unsigned int *rate)
 {
-	char path[PATH_MAX];
-	const char *procfs = procfs__mountpoint();
-
-	if (!procfs)
-		return -1;
-
-	snprintf(path, PATH_MAX,
-		 "%s/sys/kernel/perf_event_max_sample_rate", procfs);
-
-	return filename__read_int(path, (int *) rate);
+	return sysctl__read_int("kernel/perf_event_max_sample_rate", (int *)rate);
 }
 
 static int record_opts__config_freq(struct record_opts *opts)
tools/perf/util/util.c +1 -8
index 41125e5..b86744f 100644
@@ -506,16 +506,9 @@ const char *get_filename_for_perf_kvm(void)
 
 int perf_event_paranoid(void)
 {
-	char path[PATH_MAX];
-	const char *procfs = procfs__mountpoint();
 	int value;
 
-	if (!procfs)
-		return INT_MAX;
-
-	scnprintf(path, PATH_MAX, "%s/sys/kernel/perf_event_paranoid", procfs);
-
-	if (filename__read_int(path, &value))
+	if (sysctl__read_int("kernel/perf_event_paranoid", &value))
 		return INT_MAX;
 
 	return value;