Re: [PATCH 2/2] perf: SNB exclusive PMU access for INST_RETIRED:PREC_DIST
* Stephane Eranian wrote: > On Sun, Oct 21, 2012 at 8:03 PM, Ingo Molnar wrote: > > > > * Stephane Eranian wrote: > > > >> On Sun, Oct 21, 2012 at 6:55 PM, Ingo Molnar wrote: > >> > > >> > * Andi Kleen wrote: > >> > > >> >> > > > This isn't limited to admin, right? So the above turns into a DoS > >> >> > > > on the > >> >> > > > console. > >> >> > > > > >> >> > > Ok, so how about a WARN_ON_ONCE() instead? > >> >> > > >> >> > That should be fine I guess ;-) > >> >> > >> >> imho there is need for a generic mechanism to return an error > >> >> string to the user program without such hacks. > >> > > >> > Agreed - we could return an 'extended errno' long error return > >> > value, which in reality is a pointer to an error string (in > >> > perf_attr::error_str), and copy that string to user-space at > >> > perf syscall return time. > >> > > >> I assume by perf_attr:error_str, you actually mean: > >> > >> struct perf_event_attr { > >>char error_str[PERF_ERR_LEN]; > >> }; > >> > >> Right? > > > > I don't think we should allocate space in the attr, instead we > > should use something like: > > > > u8 __user *err_str; > > u32 err_str_len; > > > > which would be filled in by tooling with a string and a max_len > > value, and strncpy_to_user() could do the rest on the kernel > > side. [ A minor complication is that we don't have a > > strncpy_to_user() method at the moment. ] > > > > Static strings could be handled this way. > > > > [ Dynamic strings could be supported too with a few tricks, > > although I doubt it matters in practice. ] > > > > Ok, but this still limits returning error string to the > perf_event_open() syscall, not read(), ioctl() and such. Yes - but this should be enough to handle most of the cases in practice - because the richness of the various perf components is mostly exposed via the perf syscall. By the time we get to read() and ioctl() we are in a pretty well defined domain. Also, I don't think people want the (small but nonzero) overhead of extended error reporting for read or ioctl. > I am fine with this change. However, I think it should be > added separately from my inst_retired:prec_dist patch. It has > a broader impact. Most definitely. Thanks, Ingo -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [PATCH 2/2] perf: SNB exclusive PMU access for INST_RETIRED:PREC_DIST
* Stephane Eranian eran...@google.com wrote: On Sun, Oct 21, 2012 at 8:03 PM, Ingo Molnar mi...@kernel.org wrote: * Stephane Eranian eran...@google.com wrote: On Sun, Oct 21, 2012 at 6:55 PM, Ingo Molnar mi...@kernel.org wrote: * Andi Kleen a...@linux.intel.com wrote: This isn't limited to admin, right? So the above turns into a DoS on the console. Ok, so how about a WARN_ON_ONCE() instead? That should be fine I guess ;-) imho there is need for a generic mechanism to return an error string to the user program without such hacks. Agreed - we could return an 'extended errno' long error return value, which in reality is a pointer to an error string (in perf_attr::error_str), and copy that string to user-space at perf syscall return time. I assume by perf_attr:error_str, you actually mean: struct perf_event_attr { char error_str[PERF_ERR_LEN]; }; Right? I don't think we should allocate space in the attr, instead we should use something like: u8 __user *err_str; u32 err_str_len; which would be filled in by tooling with a string and a max_len value, and strncpy_to_user() could do the rest on the kernel side. [ A minor complication is that we don't have a strncpy_to_user() method at the moment. ] Static strings could be handled this way. [ Dynamic strings could be supported too with a few tricks, although I doubt it matters in practice. ] Ok, but this still limits returning error string to the perf_event_open() syscall, not read(), ioctl() and such. Yes - but this should be enough to handle most of the cases in practice - because the richness of the various perf components is mostly exposed via the perf syscall. By the time we get to read() and ioctl() we are in a pretty well defined domain. Also, I don't think people want the (small but nonzero) overhead of extended error reporting for read or ioctl. I am fine with this change. However, I think it should be added separately from my inst_retired:prec_dist patch. It has a broader impact. Most definitely. Thanks, Ingo -- To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [PATCH 2/2] perf: SNB exclusive PMU access for INST_RETIRED:PREC_DIST
On Sun, Oct 21, 2012 at 8:03 PM, Ingo Molnar wrote: > > * Stephane Eranian wrote: > >> On Sun, Oct 21, 2012 at 6:55 PM, Ingo Molnar wrote: >> > >> > * Andi Kleen wrote: >> > >> >> > > > This isn't limited to admin, right? So the above turns into a DoS >> >> > > > on the >> >> > > > console. >> >> > > > >> >> > > Ok, so how about a WARN_ON_ONCE() instead? >> >> > >> >> > That should be fine I guess ;-) >> >> >> >> imho there is need for a generic mechanism to return an error >> >> string to the user program without such hacks. >> > >> > Agreed - we could return an 'extended errno' long error return >> > value, which in reality is a pointer to an error string (in >> > perf_attr::error_str), and copy that string to user-space at >> > perf syscall return time. >> > >> I assume by perf_attr:error_str, you actually mean: >> >> struct perf_event_attr { >>char error_str[PERF_ERR_LEN]; >> }; >> >> Right? > > I don't think we should allocate space in the attr, instead we > should use something like: > > u8 __user *err_str; > u32 err_str_len; > > which would be filled in by tooling with a string and a max_len > value, and strncpy_to_user() could do the rest on the kernel > side. [ A minor complication is that we don't have a > strncpy_to_user() method at the moment. ] > > Static strings could be handled this way. > > [ Dynamic strings could be supported too with a few tricks, > although I doubt it matters in practice. ] > Ok, but this still limits returning error string to the perf_event_open() syscall, not read(), ioctl() and such. I am fine with this change. However, I think it should be added separately from my inst_retired:prec_dist patch. It has a broader impact. >> > Thus error-string aware tooling could print the error string. >> > >> > So PMU drivers could do something obvious like: >> > >> > return (long)"perf: INST_RETIRED.PREC_DIST only works in exclusive >> > mode"; >> > >> > The perf syscall notices these pointers by noticing that the >> > error code returned is outside the errno range. >> >> Is that always the case on all archs? > > I think yes - and if not then it can be solved via some trivial > offset value added to it on such an architecture, without > complicating the code on normal architectures. > > Thanks, > > Ingo -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [PATCH 2/2] perf: SNB exclusive PMU access for INST_RETIRED:PREC_DIST
On Sun, Oct 21, 2012 at 8:03 PM, Ingo Molnar mi...@kernel.org wrote: * Stephane Eranian eran...@google.com wrote: On Sun, Oct 21, 2012 at 6:55 PM, Ingo Molnar mi...@kernel.org wrote: * Andi Kleen a...@linux.intel.com wrote: This isn't limited to admin, right? So the above turns into a DoS on the console. Ok, so how about a WARN_ON_ONCE() instead? That should be fine I guess ;-) imho there is need for a generic mechanism to return an error string to the user program without such hacks. Agreed - we could return an 'extended errno' long error return value, which in reality is a pointer to an error string (in perf_attr::error_str), and copy that string to user-space at perf syscall return time. I assume by perf_attr:error_str, you actually mean: struct perf_event_attr { char error_str[PERF_ERR_LEN]; }; Right? I don't think we should allocate space in the attr, instead we should use something like: u8 __user *err_str; u32 err_str_len; which would be filled in by tooling with a string and a max_len value, and strncpy_to_user() could do the rest on the kernel side. [ A minor complication is that we don't have a strncpy_to_user() method at the moment. ] Static strings could be handled this way. [ Dynamic strings could be supported too with a few tricks, although I doubt it matters in practice. ] Ok, but this still limits returning error string to the perf_event_open() syscall, not read(), ioctl() and such. I am fine with this change. However, I think it should be added separately from my inst_retired:prec_dist patch. It has a broader impact. Thus error-string aware tooling could print the error string. So PMU drivers could do something obvious like: return (long)perf: INST_RETIRED.PREC_DIST only works in exclusive mode; The perf syscall notices these pointers by noticing that the error code returned is outside the errno range. Is that always the case on all archs? I think yes - and if not then it can be solved via some trivial offset value added to it on such an architecture, without complicating the code on normal architectures. Thanks, Ingo -- To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [PATCH 2/2] perf: SNB exclusive PMU access for INST_RETIRED:PREC_DIST
* Stephane Eranian wrote: > On Sun, Oct 21, 2012 at 6:55 PM, Ingo Molnar wrote: > > > > * Andi Kleen wrote: > > > >> > > > This isn't limited to admin, right? So the above turns into a DoS on > >> > > > the > >> > > > console. > >> > > > > >> > > Ok, so how about a WARN_ON_ONCE() instead? > >> > > >> > That should be fine I guess ;-) > >> > >> imho there is need for a generic mechanism to return an error > >> string to the user program without such hacks. > > > > Agreed - we could return an 'extended errno' long error return > > value, which in reality is a pointer to an error string (in > > perf_attr::error_str), and copy that string to user-space at > > perf syscall return time. > > > I assume by perf_attr:error_str, you actually mean: > > struct perf_event_attr { >char error_str[PERF_ERR_LEN]; > }; > > Right? I don't think we should allocate space in the attr, instead we should use something like: u8 __user *err_str; u32 err_str_len; which would be filled in by tooling with a string and a max_len value, and strncpy_to_user() could do the rest on the kernel side. [ A minor complication is that we don't have a strncpy_to_user() method at the moment. ] Static strings could be handled this way. [ Dynamic strings could be supported too with a few tricks, although I doubt it matters in practice. ] > > Thus error-string aware tooling could print the error string. > > > > So PMU drivers could do something obvious like: > > > > return (long)"perf: INST_RETIRED.PREC_DIST only works in exclusive > > mode"; > > > > The perf syscall notices these pointers by noticing that the > > error code returned is outside the errno range. > > Is that always the case on all archs? I think yes - and if not then it can be solved via some trivial offset value added to it on such an architecture, without complicating the code on normal architectures. Thanks, Ingo -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [PATCH 2/2] perf: SNB exclusive PMU access for INST_RETIRED:PREC_DIST
On Sun, Oct 21, 2012 at 6:55 PM, Ingo Molnar wrote: > > * Andi Kleen wrote: > >> > > > This isn't limited to admin, right? So the above turns into a DoS on >> > > > the >> > > > console. >> > > > >> > > Ok, so how about a WARN_ON_ONCE() instead? >> > >> > That should be fine I guess ;-) >> >> imho there is need for a generic mechanism to return an error >> string to the user program without such hacks. > > Agreed - we could return an 'extended errno' long error return > value, which in reality is a pointer to an error string (in > perf_attr::error_str), and copy that string to user-space at > perf syscall return time. > I assume by perf_attr:error_str, you actually mean: struct perf_event_attr { char error_str[PERF_ERR_LEN]; }; Right? > Thus error-string aware tooling could print the error string. > > So PMU drivers could do something obvious like: > > return (long)"perf: INST_RETIRED.PREC_DIST only works in exclusive > mode"; > > The perf syscall notices these pointers by noticing that the > error code returned is outside the errno range. > Is that always the case on all archs? > Old userspace will get a -EINVAL and no string copied into the > error string buffer. > > New userspace would get the error string copied into > perf_attr::error_str, plus a 'normal' -EINVAL error code. > > The only cost on the kernel side is to make sure all "string > errors" are returned as long. > > Thanks, > > Ingo -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [PATCH 2/2] perf: SNB exclusive PMU access for INST_RETIRED:PREC_DIST
* Andi Kleen wrote: > > > > This isn't limited to admin, right? So the above turns into a DoS on the > > > > console. > > > > > > > Ok, so how about a WARN_ON_ONCE() instead? > > > > That should be fine I guess ;-) > > imho there is need for a generic mechanism to return an error > string to the user program without such hacks. Agreed - we could return an 'extended errno' long error return value, which in reality is a pointer to an error string (in perf_attr::error_str), and copy that string to user-space at perf syscall return time. Thus error-string aware tooling could print the error string. So PMU drivers could do something obvious like: return (long)"perf: INST_RETIRED.PREC_DIST only works in exclusive mode"; The perf syscall notices these pointers by noticing that the error code returned is outside the errno range. Old userspace will get a -EINVAL and no string copied into the error string buffer. New userspace would get the error string copied into perf_attr::error_str, plus a 'normal' -EINVAL error code. The only cost on the kernel side is to make sure all "string errors" are returned as long. Thanks, Ingo -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [PATCH 2/2] perf: SNB exclusive PMU access for INST_RETIRED:PREC_DIST
* Andi Kleen a...@linux.intel.com wrote: This isn't limited to admin, right? So the above turns into a DoS on the console. Ok, so how about a WARN_ON_ONCE() instead? That should be fine I guess ;-) imho there is need for a generic mechanism to return an error string to the user program without such hacks. Agreed - we could return an 'extended errno' long error return value, which in reality is a pointer to an error string (in perf_attr::error_str), and copy that string to user-space at perf syscall return time. Thus error-string aware tooling could print the error string. So PMU drivers could do something obvious like: return (long)perf: INST_RETIRED.PREC_DIST only works in exclusive mode; The perf syscall notices these pointers by noticing that the error code returned is outside the errno range. Old userspace will get a -EINVAL and no string copied into the error string buffer. New userspace would get the error string copied into perf_attr::error_str, plus a 'normal' -EINVAL error code. The only cost on the kernel side is to make sure all string errors are returned as long. Thanks, Ingo -- To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [PATCH 2/2] perf: SNB exclusive PMU access for INST_RETIRED:PREC_DIST
On Sun, Oct 21, 2012 at 6:55 PM, Ingo Molnar mi...@kernel.org wrote: * Andi Kleen a...@linux.intel.com wrote: This isn't limited to admin, right? So the above turns into a DoS on the console. Ok, so how about a WARN_ON_ONCE() instead? That should be fine I guess ;-) imho there is need for a generic mechanism to return an error string to the user program without such hacks. Agreed - we could return an 'extended errno' long error return value, which in reality is a pointer to an error string (in perf_attr::error_str), and copy that string to user-space at perf syscall return time. I assume by perf_attr:error_str, you actually mean: struct perf_event_attr { char error_str[PERF_ERR_LEN]; }; Right? Thus error-string aware tooling could print the error string. So PMU drivers could do something obvious like: return (long)perf: INST_RETIRED.PREC_DIST only works in exclusive mode; The perf syscall notices these pointers by noticing that the error code returned is outside the errno range. Is that always the case on all archs? Old userspace will get a -EINVAL and no string copied into the error string buffer. New userspace would get the error string copied into perf_attr::error_str, plus a 'normal' -EINVAL error code. The only cost on the kernel side is to make sure all string errors are returned as long. Thanks, Ingo -- To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [PATCH 2/2] perf: SNB exclusive PMU access for INST_RETIRED:PREC_DIST
* Stephane Eranian eran...@google.com wrote: On Sun, Oct 21, 2012 at 6:55 PM, Ingo Molnar mi...@kernel.org wrote: * Andi Kleen a...@linux.intel.com wrote: This isn't limited to admin, right? So the above turns into a DoS on the console. Ok, so how about a WARN_ON_ONCE() instead? That should be fine I guess ;-) imho there is need for a generic mechanism to return an error string to the user program without such hacks. Agreed - we could return an 'extended errno' long error return value, which in reality is a pointer to an error string (in perf_attr::error_str), and copy that string to user-space at perf syscall return time. I assume by perf_attr:error_str, you actually mean: struct perf_event_attr { char error_str[PERF_ERR_LEN]; }; Right? I don't think we should allocate space in the attr, instead we should use something like: u8 __user *err_str; u32 err_str_len; which would be filled in by tooling with a string and a max_len value, and strncpy_to_user() could do the rest on the kernel side. [ A minor complication is that we don't have a strncpy_to_user() method at the moment. ] Static strings could be handled this way. [ Dynamic strings could be supported too with a few tricks, although I doubt it matters in practice. ] Thus error-string aware tooling could print the error string. So PMU drivers could do something obvious like: return (long)perf: INST_RETIRED.PREC_DIST only works in exclusive mode; The perf syscall notices these pointers by noticing that the error code returned is outside the errno range. Is that always the case on all archs? I think yes - and if not then it can be solved via some trivial offset value added to it on such an architecture, without complicating the code on normal architectures. Thanks, Ingo -- To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [PATCH 2/2] perf: SNB exclusive PMU access for INST_RETIRED:PREC_DIST
> > > This isn't limited to admin, right? So the above turns into a DoS on the > > > console. > > > > > Ok, so how about a WARN_ON_ONCE() instead? > > That should be fine I guess ;-) imho there is need for a generic mechanism to return an error string to the user program without such hacks. -Andi -- a...@linux.intel.com -- Speaking for myself only -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [PATCH 2/2] perf: SNB exclusive PMU access for INST_RETIRED:PREC_DIST
On Fri, 2012-10-19 at 18:31 +0200, Stephane Eranian wrote: > On Fri, Oct 19, 2012 at 6:27 PM, Peter Zijlstra wrote: > > On Fri, 2012-10-19 at 16:52 +0200, Stephane Eranian wrote: > >> +static int intel_pebs_aliases_snb(struct perf_event *event) > >> +{ > >> + u64 cfg = event->hw.config; > >> + /* > >> +* for INST_RETIRED.PREC_DIST to work correctly with PEBS, it must > >> +* be measured alone on SNB (exclusive PMU access) as per Intel > >> SDM. > >> +*/ > >> + if ((cfg & INTEL_ARCH_EVENT_MASK) == 0x01c0 && > >> !event->attr.exclusive) { > >> + pr_info("perf: INST_RETIRED.PREC_DIST only works in > >> exclusive mode\n"); > >> + return -EINVAL; > > > > This isn't limited to admin, right? So the above turns into a DoS on the > > console. > > > Ok, so how about a WARN_ON_ONCE() instead? That should be fine I guess ;-) -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [PATCH 2/2] perf: SNB exclusive PMU access for INST_RETIRED:PREC_DIST
On Fri, Oct 19, 2012 at 6:27 PM, Peter Zijlstra wrote: > On Fri, 2012-10-19 at 16:52 +0200, Stephane Eranian wrote: >> +static int intel_pebs_aliases_snb(struct perf_event *event) >> +{ >> + u64 cfg = event->hw.config; >> + /* >> +* for INST_RETIRED.PREC_DIST to work correctly with PEBS, it must >> +* be measured alone on SNB (exclusive PMU access) as per Intel SDM. >> +*/ >> + if ((cfg & INTEL_ARCH_EVENT_MASK) == 0x01c0 && >> !event->attr.exclusive) { >> + pr_info("perf: INST_RETIRED.PREC_DIST only works in >> exclusive mode\n"); >> + return -EINVAL; > > This isn't limited to admin, right? So the above turns into a DoS on the > console. > Ok, so how about a WARN_ON_ONCE() instead? -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [PATCH 2/2] perf: SNB exclusive PMU access for INST_RETIRED:PREC_DIST
On Fri, 2012-10-19 at 16:52 +0200, Stephane Eranian wrote: > +static int intel_pebs_aliases_snb(struct perf_event *event) > +{ > + u64 cfg = event->hw.config; > + /* > +* for INST_RETIRED.PREC_DIST to work correctly with PEBS, it must > +* be measured alone on SNB (exclusive PMU access) as per Intel SDM. > +*/ > + if ((cfg & INTEL_ARCH_EVENT_MASK) == 0x01c0 && > !event->attr.exclusive) { > + pr_info("perf: INST_RETIRED.PREC_DIST only works in exclusive > mode\n"); > + return -EINVAL; This isn't limited to admin, right? So the above turns into a DoS on the console. > + } > + > + return intel_pebs_aliases_ivb(event); > } -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [PATCH 2/2] perf: SNB exclusive PMU access for INST_RETIRED:PREC_DIST
On Fri, Oct 19, 2012 at 5:49 PM, Andi Kleen wrote: >> + /* >> + * for INST_RETIRED.PREC_DIST to work correctly with PEBS, it must >> + * be measured alone on SNB (exclusive PMU access) as per Intel SDM. >> + */ >> + if ((cfg & INTEL_ARCH_EVENT_MASK) == 0x01c0 && !event->attr.exclusive) >> { >> + pr_info("perf: INST_RETIRED.PREC_DIST only works in exclusive >> mode\n"); >> + return -EINVAL; >> + } > > > Strictly you have to check for precise too, right? > Yes, the restriction is enforced only when PEBS is active and this is what I do based on where pebs_aliases() is called. > -Andi -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [PATCH 2/2] perf: SNB exclusive PMU access for INST_RETIRED:PREC_DIST
> + /* > + * for INST_RETIRED.PREC_DIST to work correctly with PEBS, it must > + * be measured alone on SNB (exclusive PMU access) as per Intel SDM. > + */ > + if ((cfg & INTEL_ARCH_EVENT_MASK) == 0x01c0 && !event->attr.exclusive) { > + pr_info("perf: INST_RETIRED.PREC_DIST only works in exclusive > mode\n"); > + return -EINVAL; > + } Strictly you have to check for precise too, right? -Andi -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [PATCH 2/2] perf: SNB exclusive PMU access for INST_RETIRED:PREC_DIST
+ /* + * for INST_RETIRED.PREC_DIST to work correctly with PEBS, it must + * be measured alone on SNB (exclusive PMU access) as per Intel SDM. + */ + if ((cfg INTEL_ARCH_EVENT_MASK) == 0x01c0 !event-attr.exclusive) { + pr_info(perf: INST_RETIRED.PREC_DIST only works in exclusive mode\n); + return -EINVAL; + } Strictly you have to check for precise too, right? -Andi -- To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [PATCH 2/2] perf: SNB exclusive PMU access for INST_RETIRED:PREC_DIST
On Fri, Oct 19, 2012 at 5:49 PM, Andi Kleen a...@linux.intel.com wrote: + /* + * for INST_RETIRED.PREC_DIST to work correctly with PEBS, it must + * be measured alone on SNB (exclusive PMU access) as per Intel SDM. + */ + if ((cfg INTEL_ARCH_EVENT_MASK) == 0x01c0 !event-attr.exclusive) { + pr_info(perf: INST_RETIRED.PREC_DIST only works in exclusive mode\n); + return -EINVAL; + } Strictly you have to check for precise too, right? Yes, the restriction is enforced only when PEBS is active and this is what I do based on where pebs_aliases() is called. -Andi -- To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [PATCH 2/2] perf: SNB exclusive PMU access for INST_RETIRED:PREC_DIST
On Fri, 2012-10-19 at 16:52 +0200, Stephane Eranian wrote: +static int intel_pebs_aliases_snb(struct perf_event *event) +{ + u64 cfg = event-hw.config; + /* +* for INST_RETIRED.PREC_DIST to work correctly with PEBS, it must +* be measured alone on SNB (exclusive PMU access) as per Intel SDM. +*/ + if ((cfg INTEL_ARCH_EVENT_MASK) == 0x01c0 !event-attr.exclusive) { + pr_info(perf: INST_RETIRED.PREC_DIST only works in exclusive mode\n); + return -EINVAL; This isn't limited to admin, right? So the above turns into a DoS on the console. + } + + return intel_pebs_aliases_ivb(event); } -- To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [PATCH 2/2] perf: SNB exclusive PMU access for INST_RETIRED:PREC_DIST
On Fri, Oct 19, 2012 at 6:27 PM, Peter Zijlstra pet...@infradead.org wrote: On Fri, 2012-10-19 at 16:52 +0200, Stephane Eranian wrote: +static int intel_pebs_aliases_snb(struct perf_event *event) +{ + u64 cfg = event-hw.config; + /* +* for INST_RETIRED.PREC_DIST to work correctly with PEBS, it must +* be measured alone on SNB (exclusive PMU access) as per Intel SDM. +*/ + if ((cfg INTEL_ARCH_EVENT_MASK) == 0x01c0 !event-attr.exclusive) { + pr_info(perf: INST_RETIRED.PREC_DIST only works in exclusive mode\n); + return -EINVAL; This isn't limited to admin, right? So the above turns into a DoS on the console. Ok, so how about a WARN_ON_ONCE() instead? -- To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [PATCH 2/2] perf: SNB exclusive PMU access for INST_RETIRED:PREC_DIST
On Fri, 2012-10-19 at 18:31 +0200, Stephane Eranian wrote: On Fri, Oct 19, 2012 at 6:27 PM, Peter Zijlstra pet...@infradead.org wrote: On Fri, 2012-10-19 at 16:52 +0200, Stephane Eranian wrote: +static int intel_pebs_aliases_snb(struct perf_event *event) +{ + u64 cfg = event-hw.config; + /* +* for INST_RETIRED.PREC_DIST to work correctly with PEBS, it must +* be measured alone on SNB (exclusive PMU access) as per Intel SDM. +*/ + if ((cfg INTEL_ARCH_EVENT_MASK) == 0x01c0 !event-attr.exclusive) { + pr_info(perf: INST_RETIRED.PREC_DIST only works in exclusive mode\n); + return -EINVAL; This isn't limited to admin, right? So the above turns into a DoS on the console. Ok, so how about a WARN_ON_ONCE() instead? That should be fine I guess ;-) -- To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [PATCH 2/2] perf: SNB exclusive PMU access for INST_RETIRED:PREC_DIST
This isn't limited to admin, right? So the above turns into a DoS on the console. Ok, so how about a WARN_ON_ONCE() instead? That should be fine I guess ;-) imho there is need for a generic mechanism to return an error string to the user program without such hacks. -Andi -- a...@linux.intel.com -- Speaking for myself only -- To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/