* [PATCH 1/2]kvmtrace: add event mask support (kernel part)
@ 2008-04-15 7:19 Liu, Eric E
2008-04-22 12:52 ` Avi Kivity
0 siblings, 1 reply; 2+ messages in thread
From: Liu, Eric E @ 2008-04-15 7:19 UTC (permalink / raw)
To: kvm-devel; +Cc: Avi Kivity
[-- Attachment #1: Type: text/plain, Size: 3105 bytes --]
>From a1b062cfd4d1a91c447b680ac9a2250fe55119ec Mon Sep 17 00:00:00 2001
From: Feng (Eric) Liu <eric.e.liu@intel.com>
Date: Wed, 16 Apr 2008 05:29:37 -0400
Subject: [PATCH] KVM: trace: Add event mask support.
Allow user space application to specify one or more
filter masks to limit the events being captured via it.
Signed-off-by: Feng (Eric) Liu <eric.e.liu@intel.com>
---
include/linux/kvm.h | 6 ++++++
virt/kvm/kvm_trace.c | 24 ++++++++++++++++++++++++
2 files changed, 30 insertions(+), 0 deletions(-)
diff --git a/include/linux/kvm.h b/include/linux/kvm.h
index c5675e8..12ec084 100644
--- a/include/linux/kvm.h
+++ b/include/linux/kvm.h
@@ -18,6 +18,8 @@
struct kvm_user_trace_setup {
__u32 buf_size; /* sub_buffer size of each per-cpu */
__u32 buf_nr; /* the number of sub_buffers of each per-cpu */
+ __u16 cat_mask; /* the tracing categories are enabled */
+ __u64 act_bitmap[16]; /* the actions are enabled for each
category */
};
/* for KVM_CREATE_MEMORY_REGION */
@@ -261,6 +263,7 @@ struct kvm_s390_interrupt {
};
#define KVM_TRC_SHIFT 16
+#define KVM_TRC_CAT_NR_BITS 12
/*
* kvm trace categories
*/
@@ -274,6 +277,9 @@ struct kvm_s390_interrupt {
#define KVM_TRC_VMEXIT (KVM_TRC_ENTRYEXIT + 0x02)
#define KVM_TRC_PAGE_FAULT (KVM_TRC_HANDLER + 0x01)
+#define KVM_TRC_CAT(evt) (((evt) >> KVM_TRC_SHIFT) & 0x0fff)
+#define KVM_TRC_ACT(evt) ((evt) & (~0u >> KVM_TRC_SHIFT))
+
#define KVM_TRC_HEAD_SIZE 12
#define KVM_TRC_CYCLE_SIZE 8
#define KVM_TRC_EXTRA_MAX 7
diff --git a/virt/kvm/kvm_trace.c b/virt/kvm/kvm_trace.c
index 5425440..dfa4162 100644
--- a/virt/kvm/kvm_trace.c
+++ b/virt/kvm/kvm_trace.c
@@ -26,6 +26,8 @@
struct kvm_trace {
int trace_state;
+ u16 cat_mask;
+ u64 act_bitmap[16];
struct rchan *rchan;
struct dentry *lost_file;
atomic_t lost_records;
@@ -39,6 +41,23 @@ struct kvm_trace_probe {
marker_probe_func *probe_func;
};
+static inline int check_event_mask(struct kvm_trace *kt, u32 event)
+{
+ unsigned long category;
+ int i;
+
+ category = KVM_TRC_CAT(event);
+ if (!(category & kt->cat_mask))
+ return 1;
+
+ i = find_first_bit(&category, KVM_TRC_CAT_NR_BITS);
+
+ if (!test_bit(KVM_TRC_ACT(event), &kt->act_bitmap[i]))
+ return 1;
+
+ return 0;
+}
+
static inline int calc_rec_size(int cycle, int extra)
{
int rec_size = KVM_TRC_HEAD_SIZE;
@@ -60,6 +79,9 @@ static void kvm_add_trace(void *probe_private, void
*call_data,
return;
rec.event = va_arg(*args, u32);
+ if (check_event_mask(kt, rec.event))
+ return;
+
vcpu = va_arg(*args, struct kvm_vcpu *);
rec.pid = current->tgid;
rec.vcpu_id = vcpu->vcpu_id;
@@ -169,6 +191,8 @@ static int do_kvm_trace_enable(struct
kvm_user_trace_setup *kuts)
if (!kt->rchan)
goto err;
+ kt->cat_mask = kuts->cat_mask;
+ memcpy(kt->act_bitmap, kuts->act_bitmap,
sizeof(kuts->act_bitmap));
kvm_trace = kt;
for (i = 0; i < ARRAY_SIZE(kvm_trace_probes); i++) {
--Eric (Liu, Feng)
[-- Attachment #2: 0001-KVM-trace-Add-event-mask-support.patch --]
[-- Type: application/octet-stream, Size: 2986 bytes --]
From a1b062cfd4d1a91c447b680ac9a2250fe55119ec Mon Sep 17 00:00:00 2001
From: Feng (Eric) Liu <eric.e.liu@intel.com>
Date: Wed, 16 Apr 2008 05:29:37 -0400
Subject: [PATCH] KVM: trace: Add event mask support.
Allow user space application to specify one or more
filter masks to limit the events being captured via it.
Signed-off-by: Feng (Eric) Liu <eric.e.liu@intel.com>
---
include/linux/kvm.h | 6 ++++++
virt/kvm/kvm_trace.c | 24 ++++++++++++++++++++++++
2 files changed, 30 insertions(+), 0 deletions(-)
diff --git a/include/linux/kvm.h b/include/linux/kvm.h
index c5675e8..12ec084 100644
--- a/include/linux/kvm.h
+++ b/include/linux/kvm.h
@@ -18,6 +18,8 @@
struct kvm_user_trace_setup {
__u32 buf_size; /* sub_buffer size of each per-cpu */
__u32 buf_nr; /* the number of sub_buffers of each per-cpu */
+ __u16 cat_mask; /* the tracing categories are enabled */
+ __u64 act_bitmap[16]; /* the actions are enabled for each category */
};
/* for KVM_CREATE_MEMORY_REGION */
@@ -261,6 +263,7 @@ struct kvm_s390_interrupt {
};
#define KVM_TRC_SHIFT 16
+#define KVM_TRC_CAT_NR_BITS 12
/*
* kvm trace categories
*/
@@ -274,6 +277,9 @@ struct kvm_s390_interrupt {
#define KVM_TRC_VMEXIT (KVM_TRC_ENTRYEXIT + 0x02)
#define KVM_TRC_PAGE_FAULT (KVM_TRC_HANDLER + 0x01)
+#define KVM_TRC_CAT(evt) (((evt) >> KVM_TRC_SHIFT) & 0x0fff)
+#define KVM_TRC_ACT(evt) ((evt) & (~0u >> KVM_TRC_SHIFT))
+
#define KVM_TRC_HEAD_SIZE 12
#define KVM_TRC_CYCLE_SIZE 8
#define KVM_TRC_EXTRA_MAX 7
diff --git a/virt/kvm/kvm_trace.c b/virt/kvm/kvm_trace.c
index 5425440..dfa4162 100644
--- a/virt/kvm/kvm_trace.c
+++ b/virt/kvm/kvm_trace.c
@@ -26,6 +26,8 @@
struct kvm_trace {
int trace_state;
+ u16 cat_mask;
+ u64 act_bitmap[16];
struct rchan *rchan;
struct dentry *lost_file;
atomic_t lost_records;
@@ -39,6 +41,23 @@ struct kvm_trace_probe {
marker_probe_func *probe_func;
};
+static inline int check_event_mask(struct kvm_trace *kt, u32 event)
+{
+ unsigned long category;
+ int i;
+
+ category = KVM_TRC_CAT(event);
+ if (!(category & kt->cat_mask))
+ return 1;
+
+ i = find_first_bit(&category, KVM_TRC_CAT_NR_BITS);
+
+ if (!test_bit(KVM_TRC_ACT(event), &kt->act_bitmap[i]))
+ return 1;
+
+ return 0;
+}
+
static inline int calc_rec_size(int cycle, int extra)
{
int rec_size = KVM_TRC_HEAD_SIZE;
@@ -60,6 +79,9 @@ static void kvm_add_trace(void *probe_private, void *call_data,
return;
rec.event = va_arg(*args, u32);
+ if (check_event_mask(kt, rec.event))
+ return;
+
vcpu = va_arg(*args, struct kvm_vcpu *);
rec.pid = current->tgid;
rec.vcpu_id = vcpu->vcpu_id;
@@ -169,6 +191,8 @@ static int do_kvm_trace_enable(struct kvm_user_trace_setup *kuts)
if (!kt->rchan)
goto err;
+ kt->cat_mask = kuts->cat_mask;
+ memcpy(kt->act_bitmap, kuts->act_bitmap, sizeof(kuts->act_bitmap));
kvm_trace = kt;
for (i = 0; i < ARRAY_SIZE(kvm_trace_probes); i++) {
--
1.5.1
[-- Attachment #3: Type: text/plain, Size: 320 bytes --]
-------------------------------------------------------------------------
This SF.net email is sponsored by the 2008 JavaOne(SM) Conference
Don't miss this year's exciting event. There's still time to save $100.
Use priority code J8TL2D2.
http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone
[-- Attachment #4: Type: text/plain, Size: 158 bytes --]
_______________________________________________
kvm-devel mailing list
kvm-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/kvm-devel
^ permalink raw reply related [flat|nested] 2+ messages in thread* Re: [PATCH 1/2]kvmtrace: add event mask support (kernel part)
2008-04-15 7:19 [PATCH 1/2]kvmtrace: add event mask support (kernel part) Liu, Eric E
@ 2008-04-22 12:52 ` Avi Kivity
0 siblings, 0 replies; 2+ messages in thread
From: Avi Kivity @ 2008-04-22 12:52 UTC (permalink / raw)
To: Liu, Eric E; +Cc: kvm-devel
Liu, Eric E wrote:
> >From a1b062cfd4d1a91c447b680ac9a2250fe55119ec Mon Sep 17 00:00:00 2001
> From: Feng (Eric) Liu <eric.e.liu@intel.com>
> Date: Wed, 16 Apr 2008 05:29:37 -0400
> Subject: [PATCH] KVM: trace: Add event mask support.
>
> Allow user space application to specify one or more
> filter masks to limit the events being captured via it.
>
>
Sorry about the late review.
> --- a/include/linux/kvm.h
> +++ b/include/linux/kvm.h
> @@ -18,6 +18,8 @@
> struct kvm_user_trace_setup {
> __u32 buf_size; /* sub_buffer size of each per-cpu */
> __u32 buf_nr; /* the number of sub_buffers of each per-cpu */
> + __u16 cat_mask; /* the tracing categories are enabled */
> + __u64 act_bitmap[16]; /* the actions are enabled for each
> category */
> };
>
The structures will be laid out differently on 32-bit and 64-bit. This
is important since we'd like 32-bit userspace to work correctly with a
64-bit kernel. The usual solution is to insert a "__u16 pad1[3];"
between the two fields.
Otherwise, the patch seems fine.
--
error compiling committee.c: too many arguments to function
-------------------------------------------------------------------------
This SF.net email is sponsored by the 2008 JavaOne(SM) Conference
Don't miss this year's exciting event. There's still time to save $100.
Use priority code J8TL2D2.
http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2008-04-22 12:52 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-04-15 7:19 [PATCH 1/2]kvmtrace: add event mask support (kernel part) Liu, Eric E
2008-04-22 12:52 ` Avi Kivity
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox