Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 652d78fd authored by Ingo Molnar's avatar Ingo Molnar
Browse files

Merge commits 'ca6a4258' and 'c286c419' into perf/urgent



Pick up these two commits from Arnaldo's perf/core tree:

  ca6a4258: perf tools: Emit clearer message for sys_perf_event_open ENOENT return
  c286c419: perf tools: Fixup exit path when not able to open events

As they are really fixes we want to have sooner than laer.

Signed-off-by: default avatarIngo Molnar <mingo@elte.hu>
parents 9f644c4b ca6a4258
Loading
Loading
Loading
Loading
+13 −6
Original line number Diff line number Diff line
@@ -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) {
@@ -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));
+30 −14
Original line number Diff line number Diff line
@@ -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
@@ -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)
+10 −0
Original line number Diff line number Diff line
@@ -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;
+1 −0
Original line number Diff line number Diff line
@@ -36,5 +36,6 @@ int ui_helpline__show_help(const char *format, va_list ap);
#endif

void ui__warning(const char *format, ...) __attribute__((format(printf, 1, 2)));
void ui__warning_paranoid(void);

#endif	/* __PERF_DEBUG_H */