Re: [patch 10/10] perf_event_open.2: 4.0 update rdpmc documentation

2015-04-20 Thread Vince Weaver
On Fri, 17 Apr 2015, Andy Lutomirski wrote:
> On 04/16/2015 11:20 AM, Vince Weaver wrote:
> > Probably a better change would have been to add "2" to mean per-process
> > and make that the default setting.  Probably too late to fix that now.
> 
> Good point.  I wish you'd thought of that sooner :(

Well it's been a busy semester and so I've had less time than normal to 
play perf_event ABI police.

I also was surprised this particular patch managed to get into 4.0 so 
quickly; I thought it was going to be a 4.1 change when I added it to my 
"changesets to look at more closely" list.

In any case most people won't notice this change.  It will be a minor 
inconvenience for HPC people doing complicated homebrew self monitoring
(especially if RHEL backports the patch and then suddenly things break and 
a simple "well are you running 4.0 or newer" is meaningless). Using
the value in /sys/devices/cpu/rdpmc to help debug the problem wouldn't
have worked anyway because it looks like non-root can't do that.

Vince
--
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 10/10] perf_event_open.2: 4.0 update rdpmc documentation

2015-04-20 Thread Vince Weaver
On Fri, 17 Apr 2015, Andy Lutomirski wrote:
 On 04/16/2015 11:20 AM, Vince Weaver wrote:
  Probably a better change would have been to add 2 to mean per-process
  and make that the default setting.  Probably too late to fix that now.
 
 Good point.  I wish you'd thought of that sooner :(

Well it's been a busy semester and so I've had less time than normal to 
play perf_event ABI police.

I also was surprised this particular patch managed to get into 4.0 so 
quickly; I thought it was going to be a 4.1 change when I added it to my 
changesets to look at more closely list.

In any case most people won't notice this change.  It will be a minor 
inconvenience for HPC people doing complicated homebrew self monitoring
(especially if RHEL backports the patch and then suddenly things break and 
a simple well are you running 4.0 or newer is meaningless). Using
the value in /sys/devices/cpu/rdpmc to help debug the problem wouldn't
have worked anyway because it looks like non-root can't do that.

Vince
--
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 10/10] perf_event_open.2: 4.0 update rdpmc documentation

2015-04-17 Thread Andy Lutomirski



On 04/16/2015 11:20 AM, Vince Weaver wrote:


The rdpmc instruction allows reading performance counters directly
from usersapce.  Prior to Linux 4.0 any process could use this
instruction when a perf event was running, even if the process itself
did not have any open.  The following changesets changed the default
behavior so that only processes with active events can use rdpmc.

Note this change broke the ABI.  Previously:
/sys/bus/event_source/devices/cpu/rdpmc
Set to "1" meant allow across whole system.

After the change "2" means the whole system, and "1" means per-process.

Probably a better change would have been to add "2" to mean per-process
and make that the default setting.  Probably too late to fix that now.


Good point.  I wish you'd thought of that sooner :(

--Andy



commit a66734297f78707ce39d756b656bfae861d53f62
Author: Andy Lutomirski 

perf/x86: Add /sys/devices/cpu/rdpmc=2 to allow rdpmc for all tasks

commit 7911d3f7af14a614617e38245fedf98a724e46a9
Author: Andy Lutomirski 

perf/x86: Only allow rdpmc if a perf_event is mapped

Signed-off-by: Andy Lutomirski 

Signed-off-by: Peter Zijlstra (Intel) 

Cc: Paul Mackerras 
Cc: Arnaldo Carvalho de Melo 

Cc: Kees Cook 
Cc: Andrea Arcangeli 
Cc: Vince Weaver 
Cc: "hillf.zj" 
Cc: Valdis Kletnieks 
Cc: Linus Torvalds 

Link: 
http://lkml.kernel.org/r/caac3c1c707dcca48ecbc35f4def21495856f479.1414190806.git.luto-klttt9wpgjjwatoyat5...@public.gmane.org
Signed-off-by: Ingo Molnar 


Signed-off-by: Vince Weaver 


diff --git a/man2/perf_event_open.2 b/man2/perf_event_open.2
index 01ee579..c854d21 100644
--- a/man2/perf_event_open.2
+++ b/man2/perf_event_open.2
@@ -2377,6 +2377,16 @@ Support for this can be detected with the
  .I cap_usr_rdpmc
  field in the mmap page; documentation on how
  to calculate event values can be found in that section.
+
+Originally when rdpmc support was enabled, any process (not just ones
+with an active perf event) could use the rdpmc instruction to access
+the counters.
+Starting with Linux 4.0
+.\" 7911d3f7af14a614617e38245fedf98a724e46a9
+rdpmc support is only enabled if an event is currently enabled
+in a process' context.
+To restore the old behavior, write the value 2 to
+.IR /sys/devices/cpu/rdpmc .
  .SS perf_event ioctl calls
  .PP
  Various ioctls act on
@@ -2552,11 +2562,18 @@ field of
  .I perf_event_attr
  to indicate that you wish to use this PMU.
  .TP
-.IR /sys/bus/event_source/devices/*/rdpmc " (since Linux 3.4)"
+.IR /sys/bus/event_source/devices/cpu/rdpmc " (since Linux 3.4)"
  .\" commit 0c9d42ed4cee2aa1dfc3a260b741baae8615744f
  If this file is 1, then direct user-space access to the
  performance counter registers is allowed via the rdpmc instruction.
  This can be disabled by echoing 0 to the file.
+
+As of Linux 4.0
+.\" a66734297f78707ce39d756b656bfae861d53f62
+.\" 7911d3f7af14a614617e38245fedf98a724e46a9
+the behavior has changed, so that 1 now means only allow access
+to processes with active perf events, with 2 indicating the old
+allow-anyone-access behavior.
  .TP
  .IR /sys/bus/event_source/devices/*/format/ " (since Linux 3.4)"
  .\" commit 641cc938815dfd09f8fa1ec72deb814f0938ac33
--
To unsubscribe from this list: send the line "unsubscribe linux-man" in
the body of a message to majordomo-u79uwxl29ty76z2rm5m...@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html




--
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 10/10] perf_event_open.2: 4.0 update rdpmc documentation

2015-04-17 Thread Andy Lutomirski



On 04/16/2015 11:20 AM, Vince Weaver wrote:


The rdpmc instruction allows reading performance counters directly
from usersapce.  Prior to Linux 4.0 any process could use this
instruction when a perf event was running, even if the process itself
did not have any open.  The following changesets changed the default
behavior so that only processes with active events can use rdpmc.

Note this change broke the ABI.  Previously:
/sys/bus/event_source/devices/cpu/rdpmc
Set to 1 meant allow across whole system.

After the change 2 means the whole system, and 1 means per-process.

Probably a better change would have been to add 2 to mean per-process
and make that the default setting.  Probably too late to fix that now.


Good point.  I wish you'd thought of that sooner :(

--Andy



commit a66734297f78707ce39d756b656bfae861d53f62
Author: Andy Lutomirski luto-klttt9wpgjjwatoyat5...@public.gmane.org

perf/x86: Add /sys/devices/cpu/rdpmc=2 to allow rdpmc for all tasks

commit 7911d3f7af14a614617e38245fedf98a724e46a9
Author: Andy Lutomirski luto-klttt9wpgjjwatoyat5...@public.gmane.org

perf/x86: Only allow rdpmc if a perf_event is mapped

Signed-off-by: Andy Lutomirski 
luto-klttt9wpgjjwatoyat5...@public.gmane.org
Signed-off-by: Peter Zijlstra (Intel) 
peterz-wegcikhe2lqwvfeawa7...@public.gmane.org
Cc: Paul Mackerras paulus-eunubhrolfbytjvyw6y...@public.gmane.org
Cc: Arnaldo Carvalho de Melo 
acme-dgejt+ai2ygdnm+yrof...@public.gmane.org
Cc: Kees Cook keescook-f7+t8e8rja9g9huczpv...@public.gmane.org
Cc: Andrea Arcangeli aarcange-h+wxahxf7alqt0dzr+a...@public.gmane.org
Cc: Vince Weaver vince-yfjdyhuqu3ostnjn9+b...@public.gmane.org
Cc: hillf.zj hillf.zj-gphfcixyaqcqndwcjwf...@public.gmane.org
Cc: Valdis Kletnieks valdis.kletnieks-pjaqau27...@public.gmane.org
Cc: Linus Torvalds 
torvalds-de/tnxtf+jlsfhdxvbkv3wd2fqjk+...@public.gmane.org
Link: 
http://lkml.kernel.org/r/caac3c1c707dcca48ecbc35f4def21495856f479.1414190806.git.luto-klttt9wpgjjwatoyat5...@public.gmane.org
Signed-off-by: Ingo Molnar 
mingo-dgejt+ai2ygdnm+yrof...@public.gmane.org

Signed-off-by: Vince Weaver 
vincent.weaver-e7x0jjdqjfghxe+lvdl...@public.gmane.org

diff --git a/man2/perf_event_open.2 b/man2/perf_event_open.2
index 01ee579..c854d21 100644
--- a/man2/perf_event_open.2
+++ b/man2/perf_event_open.2
@@ -2377,6 +2377,16 @@ Support for this can be detected with the
  .I cap_usr_rdpmc
  field in the mmap page; documentation on how
  to calculate event values can be found in that section.
+
+Originally when rdpmc support was enabled, any process (not just ones
+with an active perf event) could use the rdpmc instruction to access
+the counters.
+Starting with Linux 4.0
+.\ 7911d3f7af14a614617e38245fedf98a724e46a9
+rdpmc support is only enabled if an event is currently enabled
+in a process' context.
+To restore the old behavior, write the value 2 to
+.IR /sys/devices/cpu/rdpmc .
  .SS perf_event ioctl calls
  .PP
  Various ioctls act on
@@ -2552,11 +2562,18 @@ field of
  .I perf_event_attr
  to indicate that you wish to use this PMU.
  .TP
-.IR /sys/bus/event_source/devices/*/rdpmc  (since Linux 3.4)
+.IR /sys/bus/event_source/devices/cpu/rdpmc  (since Linux 3.4)
  .\ commit 0c9d42ed4cee2aa1dfc3a260b741baae8615744f
  If this file is 1, then direct user-space access to the
  performance counter registers is allowed via the rdpmc instruction.
  This can be disabled by echoing 0 to the file.
+
+As of Linux 4.0
+.\ a66734297f78707ce39d756b656bfae861d53f62
+.\ 7911d3f7af14a614617e38245fedf98a724e46a9
+the behavior has changed, so that 1 now means only allow access
+to processes with active perf events, with 2 indicating the old
+allow-anyone-access behavior.
  .TP
  .IR /sys/bus/event_source/devices/*/format/  (since Linux 3.4)
  .\ commit 641cc938815dfd09f8fa1ec72deb814f0938ac33
--
To unsubscribe from this list: send the line unsubscribe linux-man in
the body of a message to majordomo-u79uwxl29ty76z2rm5m...@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html




--
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/


[patch 10/10] perf_event_open.2: 4.0 update rdpmc documentation

2015-04-16 Thread Vince Weaver

The rdpmc instruction allows reading performance counters directly
from usersapce.  Prior to Linux 4.0 any process could use this
instruction when a perf event was running, even if the process itself
did not have any open.  The following changesets changed the default
behavior so that only processes with active events can use rdpmc.

Note this change broke the ABI.  Previously:
/sys/bus/event_source/devices/cpu/rdpmc
Set to "1" meant allow across whole system.

After the change "2" means the whole system, and "1" means per-process.

Probably a better change would have been to add "2" to mean per-process
and make that the default setting.  Probably too late to fix that now.

commit a66734297f78707ce39d756b656bfae861d53f62
Author: Andy Lutomirski 

perf/x86: Add /sys/devices/cpu/rdpmc=2 to allow rdpmc for all tasks

commit 7911d3f7af14a614617e38245fedf98a724e46a9
Author: Andy Lutomirski 

perf/x86: Only allow rdpmc if a perf_event is mapped

Signed-off-by: Andy Lutomirski 
Signed-off-by: Peter Zijlstra (Intel) 
Cc: Paul Mackerras 
Cc: Arnaldo Carvalho de Melo 
Cc: Kees Cook 
Cc: Andrea Arcangeli 
Cc: Vince Weaver 
Cc: "hillf.zj" 
Cc: Valdis Kletnieks 
Cc: Linus Torvalds 
Link: 
http://lkml.kernel.org/r/caac3c1c707dcca48ecbc35f4def21495856f479.1414190806.git.l...@amacapital.net
Signed-off-by: Ingo Molnar 

Signed-off-by: Vince Weaver 

diff --git a/man2/perf_event_open.2 b/man2/perf_event_open.2
index 01ee579..c854d21 100644
--- a/man2/perf_event_open.2
+++ b/man2/perf_event_open.2
@@ -2377,6 +2377,16 @@ Support for this can be detected with the
 .I cap_usr_rdpmc
 field in the mmap page; documentation on how
 to calculate event values can be found in that section.
+
+Originally when rdpmc support was enabled, any process (not just ones
+with an active perf event) could use the rdpmc instruction to access
+the counters.
+Starting with Linux 4.0
+.\" 7911d3f7af14a614617e38245fedf98a724e46a9
+rdpmc support is only enabled if an event is currently enabled
+in a process' context.
+To restore the old behavior, write the value 2 to
+.IR /sys/devices/cpu/rdpmc .
 .SS perf_event ioctl calls
 .PP
 Various ioctls act on
@@ -2552,11 +2562,18 @@ field of
 .I perf_event_attr
 to indicate that you wish to use this PMU.
 .TP
-.IR /sys/bus/event_source/devices/*/rdpmc " (since Linux 3.4)"
+.IR /sys/bus/event_source/devices/cpu/rdpmc " (since Linux 3.4)"
 .\" commit 0c9d42ed4cee2aa1dfc3a260b741baae8615744f
 If this file is 1, then direct user-space access to the
 performance counter registers is allowed via the rdpmc instruction.
 This can be disabled by echoing 0 to the file.
+
+As of Linux 4.0
+.\" a66734297f78707ce39d756b656bfae861d53f62
+.\" 7911d3f7af14a614617e38245fedf98a724e46a9
+the behavior has changed, so that 1 now means only allow access
+to processes with active perf events, with 2 indicating the old
+allow-anyone-access behavior.
 .TP
 .IR /sys/bus/event_source/devices/*/format/ " (since Linux 3.4)"
 .\" commit 641cc938815dfd09f8fa1ec72deb814f0938ac33
--
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/


[patch 10/10] perf_event_open.2: 4.0 update rdpmc documentation

2015-04-16 Thread Vince Weaver

The rdpmc instruction allows reading performance counters directly
from usersapce.  Prior to Linux 4.0 any process could use this
instruction when a perf event was running, even if the process itself
did not have any open.  The following changesets changed the default
behavior so that only processes with active events can use rdpmc.

Note this change broke the ABI.  Previously:
/sys/bus/event_source/devices/cpu/rdpmc
Set to 1 meant allow across whole system.

After the change 2 means the whole system, and 1 means per-process.

Probably a better change would have been to add 2 to mean per-process
and make that the default setting.  Probably too late to fix that now.

commit a66734297f78707ce39d756b656bfae861d53f62
Author: Andy Lutomirski l...@amacapital.net

perf/x86: Add /sys/devices/cpu/rdpmc=2 to allow rdpmc for all tasks

commit 7911d3f7af14a614617e38245fedf98a724e46a9
Author: Andy Lutomirski l...@amacapital.net

perf/x86: Only allow rdpmc if a perf_event is mapped

Signed-off-by: Andy Lutomirski l...@amacapital.net
Signed-off-by: Peter Zijlstra (Intel) pet...@infradead.org
Cc: Paul Mackerras pau...@samba.org
Cc: Arnaldo Carvalho de Melo a...@kernel.org
Cc: Kees Cook keesc...@chromium.org
Cc: Andrea Arcangeli aarca...@redhat.com
Cc: Vince Weaver vi...@deater.net
Cc: hillf.zj hillf...@alibaba-inc.com
Cc: Valdis Kletnieks valdis.kletni...@vt.edu
Cc: Linus Torvalds torva...@linux-foundation.org
Link: 
http://lkml.kernel.org/r/caac3c1c707dcca48ecbc35f4def21495856f479.1414190806.git.l...@amacapital.net
Signed-off-by: Ingo Molnar mi...@kernel.org

Signed-off-by: Vince Weaver vincent.wea...@maine.edu

diff --git a/man2/perf_event_open.2 b/man2/perf_event_open.2
index 01ee579..c854d21 100644
--- a/man2/perf_event_open.2
+++ b/man2/perf_event_open.2
@@ -2377,6 +2377,16 @@ Support for this can be detected with the
 .I cap_usr_rdpmc
 field in the mmap page; documentation on how
 to calculate event values can be found in that section.
+
+Originally when rdpmc support was enabled, any process (not just ones
+with an active perf event) could use the rdpmc instruction to access
+the counters.
+Starting with Linux 4.0
+.\ 7911d3f7af14a614617e38245fedf98a724e46a9
+rdpmc support is only enabled if an event is currently enabled
+in a process' context.
+To restore the old behavior, write the value 2 to
+.IR /sys/devices/cpu/rdpmc .
 .SS perf_event ioctl calls
 .PP
 Various ioctls act on
@@ -2552,11 +2562,18 @@ field of
 .I perf_event_attr
 to indicate that you wish to use this PMU.
 .TP
-.IR /sys/bus/event_source/devices/*/rdpmc  (since Linux 3.4)
+.IR /sys/bus/event_source/devices/cpu/rdpmc  (since Linux 3.4)
 .\ commit 0c9d42ed4cee2aa1dfc3a260b741baae8615744f
 If this file is 1, then direct user-space access to the
 performance counter registers is allowed via the rdpmc instruction.
 This can be disabled by echoing 0 to the file.
+
+As of Linux 4.0
+.\ a66734297f78707ce39d756b656bfae861d53f62
+.\ 7911d3f7af14a614617e38245fedf98a724e46a9
+the behavior has changed, so that 1 now means only allow access
+to processes with active perf events, with 2 indicating the old
+allow-anyone-access behavior.
 .TP
 .IR /sys/bus/event_source/devices/*/format/  (since Linux 3.4)
 .\ commit 641cc938815dfd09f8fa1ec72deb814f0938ac33
--
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/