From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753422AbbC3RYT (ORCPT ); Mon, 30 Mar 2015 13:24:19 -0400 Received: from mail-ie0-f178.google.com ([209.85.223.178]:33146 "EHLO mail-ie0-f178.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753106AbbC3RYO (ORCPT ); Mon, 30 Mar 2015 13:24:14 -0400 Message-ID: <551986BC.3000409@gmail.com> Date: Mon, 30 Mar 2015 11:24:12 -0600 From: David Ahern User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.10; rv:31.0) Gecko/20100101 Thunderbird/31.5.0 MIME-Version: 1.0 To: Peter Zijlstra , Stephane Eranian CC: Arnaldo Carvalho de Melo , Thomas Gleixner , Jiri Olsa , Linus Torvalds , LKML , John Stultz , "H. Peter Anvin" , Andrew Morton , Ingo Molnar Subject: Re: [PATCH] perf, record: Add clockid parameter References: <20150327143201.GG21418@twins.programming.kicks-ass.net> <55158F25.9040100@gmail.com> <20150327172059.GK23123@twins.programming.kicks-ass.net> <551594DD.7050705@gmail.com> <20150327201534.GD6291@redhat.com> <20150327215942.GL23123@twins.programming.kicks-ass.net> <20150328075549.GG27490@worktop.programming.kicks-ass.net> In-Reply-To: <20150328075549.GG27490@worktop.programming.kicks-ass.net> Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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.