From: "Michael Kerrisk (man-pages)" <mtk.manpages@gmail.com>
To: Vince Weaver <vincent.weaver@maine.edu>
Cc: mtk.manpages@gmail.com, linux-man@vger.kernel.org,
linux-kernel@vger.kernel.org,
Peter Zijlstra <a.p.zijlstra@chello.nl>,
Ingo Molnar <mingo@redhat.com>,
Arnaldo Carvalho de Melo <acme@kernel.org>,
Stephane Eranian <eranian@google.com>,
Andy Lutomirski <luto@amacapital.net>,
Kees Cook <keescook@chromium.org>,
Andrea Arcangeli <aarcange@redhat.com>,
"hillf.zj" <hillf.zj@alibaba-inc.com>,
Valdis Kletnieks <Valdis.Kletnieks@vt.edu>,
Linus Torvalds <torvalds@linux-foundation.org>
Subject: Re: [patch 10/11] perf_event_open.2: 4.0 update rdpmc documentation
Date: Wed, 14 Oct 2015 08:46:48 +0200 [thread overview]
Message-ID: <561DFA58.5000106@gmail.com> (raw)
In-Reply-To: <alpine.DEB.2.20.1507231315230.3742@vincent-weaver-1.umelst.maine.edu>
On 07/23/2015 07:16 PM, 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.
Thanks, Vince. Applied.
Cheers,
Michael
> 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 <luto@amacapital.net>
>
> perf/x86: Add /sys/devices/cpu/rdpmc=2 to allow rdpmc for all tasks
>
> commit 7911d3f7af14a614617e38245fedf98a724e46a9
> Author: Andy Lutomirski <luto@amacapital.net>
>
> perf/x86: Only allow rdpmc if a perf_event is mapped
>
> Signed-off-by: Andy Lutomirski <luto@amacapital.net>
> Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
> Cc: Paul Mackerras <paulus@samba.org>
> Cc: Arnaldo Carvalho de Melo <acme@kernel.org>
> Cc: Kees Cook <keescook@chromium.org>
> Cc: Andrea Arcangeli <aarcange@redhat.com>
> Cc: Vince Weaver <vince@deater.net>
> Cc: "hillf.zj" <hillf.zj@alibaba-inc.com>
> Cc: Valdis Kletnieks <Valdis.Kletnieks@vt.edu>
> Cc: Linus Torvalds <torvalds@linux-foundation.org>
> Link: http://lkml.kernel.org/r/caac3c1c707dcca48ecbc35f4def21495856f479.1414190806.git.luto@amacapital.net
> Signed-off-by: Ingo Molnar <mingo@kernel.org>
>
> Signed-off-by: Vince Weaver <vincent.weaver@maine.edu>
>
> diff --git a/man2/perf_event_open.2 b/man2/perf_event_open.2
> index 8ef9ec6..b3cd93f 100644
> --- a/man2/perf_event_open.2
> +++ b/man2/perf_event_open.2
> @@ -2595,6 +2595,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 allowed 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
> @@ -2783,11 +2793,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
>
--
Michael Kerrisk
Linux man-pages maintainer; http://www.kernel.org/doc/man-pages/
Linux/UNIX System Programming Training: http://man7.org/training/
prev parent reply other threads:[~2015-10-14 6:46 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-07-23 17:16 [patch 10/11] perf_event_open.2: 4.0 update rdpmc documentation Vince Weaver
2015-10-14 6:46 ` Michael Kerrisk (man-pages) [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=561DFA58.5000106@gmail.com \
--to=mtk.manpages@gmail.com \
--cc=Valdis.Kletnieks@vt.edu \
--cc=a.p.zijlstra@chello.nl \
--cc=aarcange@redhat.com \
--cc=acme@kernel.org \
--cc=eranian@google.com \
--cc=hillf.zj@alibaba-inc.com \
--cc=keescook@chromium.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-man@vger.kernel.org \
--cc=luto@amacapital.net \
--cc=mingo@redhat.com \
--cc=torvalds@linux-foundation.org \
--cc=vincent.weaver@maine.edu \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox