aboutsummaryrefslogtreecommitdiffstats
path: root/tools/perf/util/util.c
diff options
context:
space:
mode:
Diffstat (limited to 'tools/perf/util/util.c')
-rw-r--r--tools/perf/util/util.c26
1 files changed, 1 insertions, 25 deletions
diff --git a/tools/perf/util/util.c b/tools/perf/util/util.c
index d5eab3f3323f..b86744f29eef 100644
--- a/tools/perf/util/util.c
+++ b/tools/perf/util/util.c
@@ -442,23 +442,6 @@ unsigned long parse_tag_value(const char *str, struct parse_tag *tags)
442 return (unsigned long) -1; 442 return (unsigned long) -1;
443} 443}
444 444
445int filename__read_int(const char *filename, int *value)
446{
447 char line[64];
448 int fd = open(filename, O_RDONLY), err = -1;
449
450 if (fd < 0)
451 return -1;
452
453 if (read(fd, line, sizeof(line)) > 0) {
454 *value = atoi(line);
455 err = 0;
456 }
457
458 close(fd);
459 return err;
460}
461
462int filename__read_str(const char *filename, char **buf, size_t *sizep) 445int filename__read_str(const char *filename, char **buf, size_t *sizep)
463{ 446{
464 size_t size = 0, alloc_size = 0; 447 size_t size = 0, alloc_size = 0;
@@ -523,16 +506,9 @@ const char *get_filename_for_perf_kvm(void)
523 506
524int perf_event_paranoid(void) 507int perf_event_paranoid(void)
525{ 508{
526 char path[PATH_MAX];
527 const char *procfs = procfs__mountpoint();
528 int value; 509 int value;
529 510
530 if (!procfs) 511 if (sysctl__read_int("kernel/perf_event_paranoid", &value))
531 return INT_MAX;
532
533 scnprintf(path, PATH_MAX, "%s/sys/kernel/perf_event_paranoid", procfs);
534
535 if (filename__read_int(path, &value))
536 return INT_MAX; 512 return INT_MAX;
537 513
538 return value; 514 return value;