Loading arch/x86/oprofile/nmi_int.c +5 −0 Original line number Diff line number Diff line Loading @@ -49,6 +49,10 @@ u64 op_x86_get_ctrl(struct op_x86_model_spec const *model, val |= counter_config->user ? ARCH_PERFMON_EVENTSEL_USR : 0; val |= counter_config->kernel ? ARCH_PERFMON_EVENTSEL_OS : 0; val |= (counter_config->unit_mask & 0xFF) << 8; counter_config->extra &= (ARCH_PERFMON_EVENTSEL_INV | ARCH_PERFMON_EVENTSEL_EDGE | ARCH_PERFMON_EVENTSEL_CMASK); val |= counter_config->extra; event &= model->event_mask ? model->event_mask : 0xFF; val |= event & 0xFF; val |= (event & 0x0F00) << 24; Loading Loading @@ -440,6 +444,7 @@ static int nmi_create_files(struct super_block *sb, struct dentry *root) oprofilefs_create_ulong(sb, dir, "unit_mask", &counter_config[i].unit_mask); oprofilefs_create_ulong(sb, dir, "kernel", &counter_config[i].kernel); oprofilefs_create_ulong(sb, dir, "user", &counter_config[i].user); oprofilefs_create_ulong(sb, dir, "extra", &counter_config[i].extra); } return 0; Loading arch/x86/oprofile/op_counter.h +1 −0 Original line number Diff line number Diff line Loading @@ -22,6 +22,7 @@ struct op_counter_config { unsigned long kernel; unsigned long user; unsigned long unit_mask; unsigned long extra; }; extern struct op_counter_config counter_config[]; Loading tools/perf/builtin-record.c +13 −6 Original line number Diff line number Diff line Loading @@ -275,11 +275,10 @@ static void open_counters(struct perf_evlist *evlist) !no_inherit) < 0) { int err = errno; if (err == EPERM || err == EACCES) die("Permission error - are you root?\n" "\t Consider tweaking" " /proc/sys/kernel/perf_event_paranoid.\n"); else if (err == ENODEV && cpu_list) { if (err == EPERM || err == EACCES) { ui__warning_paranoid(); exit(EXIT_FAILURE); } else if (err == ENODEV && cpu_list) { die("No such device - did you specify" " an out-of-range profile CPU?\n"); } else if (err == EINVAL && sample_id_all_avail) { Loading @@ -302,11 +301,19 @@ static void open_counters(struct perf_evlist *evlist) && attr->config == PERF_COUNT_HW_CPU_CYCLES) { if (verbose) warning(" ... trying to fall back to cpu-clock-ticks\n"); ui__warning("The cycles event is not supported, " "trying to fall back to cpu-clock-ticks\n"); attr->type = PERF_TYPE_SOFTWARE; attr->config = PERF_COUNT_SW_CPU_CLOCK; goto try_again; } if (err == ENOENT) { ui__warning("The %s event is not supported.\n", event_name(pos)); exit(EXIT_FAILURE); } printf("\n"); error("sys_perf_event_open() syscall returned with %d (%s). /bin/dmesg may provide additional information.\n", err, strerror(err)); Loading tools/perf/builtin-top.c +30 −14 Original line number Diff line number Diff line Loading @@ -850,10 +850,10 @@ static void start_counters(struct perf_evlist *evlist) top.evlist->threads, group, inherit) < 0) { int err = errno; if (err == EPERM || err == EACCES) die("Permission error - are you root?\n" "\t Consider tweaking" " /proc/sys/kernel/perf_event_paranoid.\n"); if (err == EPERM || err == EACCES) { ui__warning_paranoid(); goto out_err; } /* * If it's cycles then fall back to hrtimer * based cpu-clock-tick sw counter, which Loading @@ -861,25 +861,41 @@ static void start_counters(struct perf_evlist *evlist) */ if (attr->type == PERF_TYPE_HARDWARE && attr->config == PERF_COUNT_HW_CPU_CYCLES) { if (verbose) warning(" ... trying to fall back to cpu-clock-ticks\n"); ui__warning("Cycles event not supported,\n" "trying to fall back to cpu-clock-ticks\n"); attr->type = PERF_TYPE_SOFTWARE; attr->config = PERF_COUNT_SW_CPU_CLOCK; goto try_again; } printf("\n"); error("sys_perf_event_open() syscall returned with %d " "(%s). /bin/dmesg may provide additional information.\n", err, strerror(err)); die("No CONFIG_PERF_EVENTS=y kernel support configured?\n"); exit(-1); if (err == ENOENT) { ui__warning("The %s event is not supported.\n", event_name(counter)); goto out_err; } ui__warning("The sys_perf_event_open() syscall " "returned with %d (%s). /bin/dmesg " "may provide additional information.\n" "No CONFIG_PERF_EVENTS=y kernel support " "configured?\n", err, strerror(err)); goto out_err; } } if (perf_evlist__mmap(evlist, mmap_pages, false) < 0) die("failed to mmap with %d (%s)\n", errno, strerror(errno)); if (perf_evlist__mmap(evlist, mmap_pages, false) < 0) { ui__warning("Failed to mmap with %d (%s)\n", errno, strerror(errno)); goto out_err; } return; out_err: exit_browser(0); exit(0); } static int __cmd_top(void) Loading tools/perf/util/debug.c +10 −0 Original line number Diff line number Diff line Loading @@ -57,6 +57,16 @@ void ui__warning(const char *format, ...) } #endif void ui__warning_paranoid(void) { ui__warning("Permission error - are you root?\n" "Consider tweaking /proc/sys/kernel/perf_event_paranoid:\n" " -1 - Not paranoid at all\n" " 0 - Disallow raw tracepoint access for unpriv\n" " 1 - Disallow cpu events for unpriv\n" " 2 - Disallow kernel profiling for unpriv\n"); } void trace_event(union perf_event *event) { unsigned char *raw_event = (void *)event; Loading Loading
arch/x86/oprofile/nmi_int.c +5 −0 Original line number Diff line number Diff line Loading @@ -49,6 +49,10 @@ u64 op_x86_get_ctrl(struct op_x86_model_spec const *model, val |= counter_config->user ? ARCH_PERFMON_EVENTSEL_USR : 0; val |= counter_config->kernel ? ARCH_PERFMON_EVENTSEL_OS : 0; val |= (counter_config->unit_mask & 0xFF) << 8; counter_config->extra &= (ARCH_PERFMON_EVENTSEL_INV | ARCH_PERFMON_EVENTSEL_EDGE | ARCH_PERFMON_EVENTSEL_CMASK); val |= counter_config->extra; event &= model->event_mask ? model->event_mask : 0xFF; val |= event & 0xFF; val |= (event & 0x0F00) << 24; Loading Loading @@ -440,6 +444,7 @@ static int nmi_create_files(struct super_block *sb, struct dentry *root) oprofilefs_create_ulong(sb, dir, "unit_mask", &counter_config[i].unit_mask); oprofilefs_create_ulong(sb, dir, "kernel", &counter_config[i].kernel); oprofilefs_create_ulong(sb, dir, "user", &counter_config[i].user); oprofilefs_create_ulong(sb, dir, "extra", &counter_config[i].extra); } return 0; Loading
arch/x86/oprofile/op_counter.h +1 −0 Original line number Diff line number Diff line Loading @@ -22,6 +22,7 @@ struct op_counter_config { unsigned long kernel; unsigned long user; unsigned long unit_mask; unsigned long extra; }; extern struct op_counter_config counter_config[]; Loading
tools/perf/builtin-record.c +13 −6 Original line number Diff line number Diff line Loading @@ -275,11 +275,10 @@ static void open_counters(struct perf_evlist *evlist) !no_inherit) < 0) { int err = errno; if (err == EPERM || err == EACCES) die("Permission error - are you root?\n" "\t Consider tweaking" " /proc/sys/kernel/perf_event_paranoid.\n"); else if (err == ENODEV && cpu_list) { if (err == EPERM || err == EACCES) { ui__warning_paranoid(); exit(EXIT_FAILURE); } else if (err == ENODEV && cpu_list) { die("No such device - did you specify" " an out-of-range profile CPU?\n"); } else if (err == EINVAL && sample_id_all_avail) { Loading @@ -302,11 +301,19 @@ static void open_counters(struct perf_evlist *evlist) && attr->config == PERF_COUNT_HW_CPU_CYCLES) { if (verbose) warning(" ... trying to fall back to cpu-clock-ticks\n"); ui__warning("The cycles event is not supported, " "trying to fall back to cpu-clock-ticks\n"); attr->type = PERF_TYPE_SOFTWARE; attr->config = PERF_COUNT_SW_CPU_CLOCK; goto try_again; } if (err == ENOENT) { ui__warning("The %s event is not supported.\n", event_name(pos)); exit(EXIT_FAILURE); } printf("\n"); error("sys_perf_event_open() syscall returned with %d (%s). /bin/dmesg may provide additional information.\n", err, strerror(err)); Loading
tools/perf/builtin-top.c +30 −14 Original line number Diff line number Diff line Loading @@ -850,10 +850,10 @@ static void start_counters(struct perf_evlist *evlist) top.evlist->threads, group, inherit) < 0) { int err = errno; if (err == EPERM || err == EACCES) die("Permission error - are you root?\n" "\t Consider tweaking" " /proc/sys/kernel/perf_event_paranoid.\n"); if (err == EPERM || err == EACCES) { ui__warning_paranoid(); goto out_err; } /* * If it's cycles then fall back to hrtimer * based cpu-clock-tick sw counter, which Loading @@ -861,25 +861,41 @@ static void start_counters(struct perf_evlist *evlist) */ if (attr->type == PERF_TYPE_HARDWARE && attr->config == PERF_COUNT_HW_CPU_CYCLES) { if (verbose) warning(" ... trying to fall back to cpu-clock-ticks\n"); ui__warning("Cycles event not supported,\n" "trying to fall back to cpu-clock-ticks\n"); attr->type = PERF_TYPE_SOFTWARE; attr->config = PERF_COUNT_SW_CPU_CLOCK; goto try_again; } printf("\n"); error("sys_perf_event_open() syscall returned with %d " "(%s). /bin/dmesg may provide additional information.\n", err, strerror(err)); die("No CONFIG_PERF_EVENTS=y kernel support configured?\n"); exit(-1); if (err == ENOENT) { ui__warning("The %s event is not supported.\n", event_name(counter)); goto out_err; } ui__warning("The sys_perf_event_open() syscall " "returned with %d (%s). /bin/dmesg " "may provide additional information.\n" "No CONFIG_PERF_EVENTS=y kernel support " "configured?\n", err, strerror(err)); goto out_err; } } if (perf_evlist__mmap(evlist, mmap_pages, false) < 0) die("failed to mmap with %d (%s)\n", errno, strerror(errno)); if (perf_evlist__mmap(evlist, mmap_pages, false) < 0) { ui__warning("Failed to mmap with %d (%s)\n", errno, strerror(errno)); goto out_err; } return; out_err: exit_browser(0); exit(0); } static int __cmd_top(void) Loading
tools/perf/util/debug.c +10 −0 Original line number Diff line number Diff line Loading @@ -57,6 +57,16 @@ void ui__warning(const char *format, ...) } #endif void ui__warning_paranoid(void) { ui__warning("Permission error - are you root?\n" "Consider tweaking /proc/sys/kernel/perf_event_paranoid:\n" " -1 - Not paranoid at all\n" " 0 - Disallow raw tracepoint access for unpriv\n" " 1 - Disallow cpu events for unpriv\n" " 2 - Disallow kernel profiling for unpriv\n"); } void trace_event(union perf_event *event) { unsigned char *raw_event = (void *)event; Loading