lkml.org 
[lkml]   [2015]   [Mar]   [30]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH] perf, record: Add clockid parameter
On 3/28/15 1:55 AM, Peter Zijlstra wrote:
> @@ -1085,6 +1093,8 @@ static int __perf_evsel__open(struct per
> }
>
> fallback_missing_features:
> + if (perf_missing_features.clockid)
> + evsel->attr.use_clockid = 0;
> if (perf_missing_features.cloexec)
> flags &= ~(unsigned long)PERF_FLAG_FD_CLOEXEC;
> if (perf_missing_features.mmap2)
> @@ -1122,6 +1132,16 @@ static int __perf_evsel__open(struct per
> goto try_fallback;
> }
> set_rlimit = NO_CHANGE;
> +
> + /*
> + * If we succeeded but had to kill clockid, fail and
> + * have perf_evsel__open_strerror() print us a nice
> + * error.
> + */
> + if (perf_missing_features.clockid) {
> + err = -EINVAL;
> + goto out_close;
> + }
> }
> }
>
> @@ -1155,7 +1175,10 @@ static int __perf_evsel__open(struct per
> if (err != -EINVAL || cpu > 0 || thread > 0)
> goto out_close;
>
> - if (!perf_missing_features.cloexec && (flags & PERF_FLAG_FD_CLOEXEC)) {
> + if (!perf_missing_features.clockid && evsel->attr.use_clockid) {
> + perf_missing_features.clockid = true;
> + goto fallback_missing_features;
> + } else if (!perf_missing_features.cloexec && (flags & PERF_FLAG_FD_CLOEXEC)) {
> perf_missing_features.cloexec = true;
> goto fallback_missing_features;
> } else if (!perf_missing_features.mmap2 && evsel->attr.mmap2) {

...

> @@ -2158,6 +2188,12 @@ int perf_evsel__open_strerror(struct per
> "The PMU counters are busy/taken by another profiler.\n"
> "We found oprofile daemon running, please stop it and try again.");
> break;
> +
> + case EINVAL:
> + if (perf_missing_features.clockid)
> + return scnprintf(msg, size, "%s", "clockid not supported.");
> + break;
> +
> default:
> break;
> }
>

This works but the result is not always intuitive as to why it failed.

On a kernel that does not support the clock id you get:
$ perf sched record -k mono -- sleep 1
Error:
clockid not supported.

And on a kernel that supports clockid but not for NMI:

$ perf record -k realtime -a -- sleep 1
Error:
clockid not supported.

--> H/W counters so realtime is not allowed

Same message though different root causes.


\
 
 \ /
  Last update: 2015-03-30 20:01    [W:0.171 / U:0.468 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site