From: Joerg Roedel <joerg.roedel@amd.com>
To: Peter Zijlstra <a.p.zijlstra@chello.nl>,
Paul Mackerras <paulus@samba.org>, Ingo Molnar <mingo@elte.hu>,
Arnaldo Carvalho de Melo <acme@ghostprotocols.net>
Cc: <linux-kernel@vger.kernel.org>, <kvm@vger.kernel.org>,
Joerg Roedel <joerg.roedel@amd.com>
Subject: [PATCH 1/3] perf, core: Introduce attrs to count in either host or guest mode
Date: Tue, 10 May 2011 16:35:30 +0200 [thread overview]
Message-ID: <1305038132-5080-2-git-send-email-joerg.roedel@amd.com> (raw)
In-Reply-To: <1305038132-5080-1-git-send-email-joerg.roedel@amd.com>
The two new attributes exclude_guest and exclude_host can
bes used by user-space to tell the kernel to setup
performance counter to either only count while the CPU is in
guest or in host mode.
An additional check is also introduced to make sure
user-space does not try to exclude guest and host mode from
counting.
Signed-off-by: Joerg Roedel <joerg.roedel@amd.com>
---
include/linux/perf_event.h | 5 ++++-
kernel/perf_event.c | 4 ++++
2 files changed, 8 insertions(+), 1 deletions(-)
diff --git a/include/linux/perf_event.h b/include/linux/perf_event.h
index ee9f1e7..3823f34 100644
--- a/include/linux/perf_event.h
+++ b/include/linux/perf_event.h
@@ -217,7 +217,10 @@ struct perf_event_attr {
mmap_data : 1, /* non-exec mmap data */
sample_id_all : 1, /* sample_type all events */
- __reserved_1 : 45;
+ exclude_host : 1, /* don't count in host */
+ exclude_guest : 1, /* don't count in guest */
+
+ __reserved_1 : 43;
union {
__u32 wakeup_events; /* wakeup every n events */
diff --git a/kernel/perf_event.c b/kernel/perf_event.c
index 8e81a98..1a9159b 100644
--- a/kernel/perf_event.c
+++ b/kernel/perf_event.c
@@ -6452,6 +6452,10 @@ SYSCALL_DEFINE5(perf_event_open,
return -EINVAL;
}
+ /* Can't exclude counting in guest and in host mode */
+ if (attr.exclude_host && attr.exclude_guest)
+ return -EINVAL;
+
/*
* In cgroup mode, the pid argument is used to pass the fd
* opened to the cgroup directory in cgroupfs. The cpu argument
--
1.7.4.1
next prev parent reply other threads:[~2011-05-10 14:35 UTC|newest]
Thread overview: 28+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-05-10 14:35 [RFC][PATCH 0/3] perf support for amd guest/host-only bits Joerg Roedel
2011-05-10 14:35 ` Joerg Roedel [this message]
2011-05-10 14:45 ` [PATCH 1/3] perf, core: Introduce attrs to count in either host or guest mode Peter Zijlstra
2011-05-10 14:59 ` Roedel, Joerg
2011-05-10 15:18 ` Peter Zijlstra
2011-05-10 15:38 ` Roedel, Joerg
2011-05-10 16:07 ` Peter Zijlstra
2011-05-10 16:25 ` Roedel, Joerg
2011-05-11 11:44 ` Avi Kivity
2011-05-11 11:45 ` Avi Kivity
2011-05-11 13:49 ` Peter Zijlstra
2011-05-11 13:52 ` Avi Kivity
2011-05-11 14:02 ` Ingo Molnar
2011-05-10 14:35 ` [PATCH 2/3] perf, x86: Use GO/HO bits in perf-ctr Joerg Roedel
2011-05-10 14:48 ` Peter Zijlstra
2011-05-10 15:04 ` Roedel, Joerg
2011-05-11 12:58 ` Avi Kivity
2011-05-12 9:21 ` Joerg Roedel
2011-05-10 14:35 ` [PATCH 3/3] perf, tools: Add support for guest/host-only profiling Joerg Roedel
2011-05-10 14:50 ` Peter Zijlstra
2011-05-10 15:08 ` Roedel, Joerg
2011-05-10 15:25 ` Peter Zijlstra
2011-05-10 15:46 ` Roedel, Joerg
2011-05-10 16:09 ` Peter Zijlstra
2011-05-10 15:21 ` [RFC][PATCH 0/3] perf support for amd guest/host-only bits Ingo Molnar
2011-05-10 15:50 ` Roedel, Joerg
2011-05-10 20:41 ` Ingo Molnar
2011-05-11 8:57 ` Joerg Roedel
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=1305038132-5080-2-git-send-email-joerg.roedel@amd.com \
--to=joerg.roedel@amd.com \
--cc=a.p.zijlstra@chello.nl \
--cc=acme@ghostprotocols.net \
--cc=kvm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@elte.hu \
--cc=paulus@samba.org \
/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
Powered by JetHome