* [PATCH][resend] perf x86 kvm-stat: support to analyze kvm msr
@ 2021-04-15 7:00 Li RongQing
2021-04-22 1:46 ` Li,Rongqing
0 siblings, 1 reply; 4+ messages in thread
From: Li RongQing @ 2021-04-15 7:00 UTC (permalink / raw)
To: linux-kernel, namhyung, jolsa, alexander.shishkin, mark.rutland,
acme, mingo, peterz, lirongqing
From: Lei Zhao <zhaolei27@baidu.com>
usage:
- kvm stat
run a command and gather performance counter statistics
- show the result:
perf kvm stat report --event=msr
See the msr events:
Analyze events for all VMs, all VCPUs:
MSR Access Samples Samples% Time% Min Time Max Time Avg time
0x6e0:W 67007 98.17% 98.31% 0.59us 10.69us 0.90us ( +- 0.10% )
0x830:W 1186 1.74% 1.60% 0.53us 108.34us 0.82us ( +- 11.02% )
0x3b:R 66 0.10% 0.09% 0.56us 1.26us 0.80us ( +- 3.24% )
Total Samples:68259, Total events handled time:61150.95us.
Signed-off-by: Li RongQing <lirongqing@baidu.com>
Signed-off-by: Lei Zhao <zhaolei27@baidu.com>
---
tools/perf/arch/x86/util/kvm-stat.c | 46 +++++++++++++++++++++++++++++++++++
1 files changed, 46 insertions(+), 0 deletions(-)
diff --git a/tools/perf/arch/x86/util/kvm-stat.c b/tools/perf/arch/x86/util/kvm-stat.c
index 0729204..c5dd54f 100644
--- a/tools/perf/arch/x86/util/kvm-stat.c
+++ b/tools/perf/arch/x86/util/kvm-stat.c
@@ -133,11 +133,56 @@ static void ioport_event_decode_key(struct perf_kvm_stat *kvm __maybe_unused,
.name = "IO Port Access"
};
+ /* The time of emulation msr is from kvm_msr to kvm_entry. */
+static void msr_event_get_key(struct evsel *evsel,
+ struct perf_sample *sample,
+ struct event_key *key)
+{
+ key->key = evsel__intval(evsel, sample, "ecx");
+ key->info = evsel__intval(evsel, sample, "write");
+}
+
+static bool msr_event_begin(struct evsel *evsel,
+ struct perf_sample *sample,
+ struct event_key *key)
+{
+ if (!strcmp(evsel->name, "kvm:kvm_msr")) {
+ msr_event_get_key(evsel, sample, key);
+ return true;
+ }
+
+ return false;
+}
+
+static bool msr_event_end(struct evsel *evsel,
+ struct perf_sample *sample __maybe_unused,
+ struct event_key *key __maybe_unused)
+{
+ return kvm_entry_event(evsel);
+}
+
+static void msr_event_decode_key(struct perf_kvm_stat *kvm __maybe_unused,
+ struct event_key *key,
+ char *decode)
+{
+ scnprintf(decode, decode_str_len, "%#llx:%s",
+ (unsigned long long)key->key,
+ key->info ? "W" : "R");
+}
+
+static struct kvm_events_ops msr_events = {
+ .is_begin_event = msr_event_begin,
+ .is_end_event = msr_event_end,
+ .decode_key = msr_event_decode_key,
+ .name = "MSR Access"
+};
+
const char *kvm_events_tp[] = {
"kvm:kvm_entry",
"kvm:kvm_exit",
"kvm:kvm_mmio",
"kvm:kvm_pio",
+ "kvm:kvm_msr",
NULL,
};
@@ -145,6 +190,7 @@ struct kvm_reg_events_ops kvm_reg_events_ops[] = {
{ .name = "vmexit", .ops = &exit_events },
{ .name = "mmio", .ops = &mmio_events },
{ .name = "ioport", .ops = &ioport_events },
+ { .name = "msr", .ops = &msr_events },
{ NULL, NULL },
};
--
1.7.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* RE: [PATCH][resend] perf x86 kvm-stat: support to analyze kvm msr
2021-04-15 7:00 [PATCH][resend] perf x86 kvm-stat: support to analyze kvm msr Li RongQing
@ 2021-04-22 1:46 ` Li,Rongqing
2021-04-23 17:05 ` Namhyung Kim
0 siblings, 1 reply; 4+ messages in thread
From: Li,Rongqing @ 2021-04-22 1:46 UTC (permalink / raw)
To: linux-kernel, namhyung, jolsa, alexander.shishkin, mark.rutland,
acme, mingo, peterz
Ping
-Li
> -----Original Message-----
> From: Li,Rongqing
> Sent: Thursday, April 15, 2021 3:00 PM
> To: linux-kernel@vger.kernel.org; namhyung@kernel.org; jolsa@redhat.com;
> alexander.shishkin@linux.intel.com; mark.rutland@arm.com;
> acme@kernel.org; mingo@redhat.com; peterz@infradead.org; Li,Rongqing
> <lirongqing@baidu.com>
> Subject: [PATCH][resend] perf x86 kvm-stat: support to analyze kvm msr
>
> From: Lei Zhao <zhaolei27@baidu.com>
>
> usage:
> - kvm stat
> run a command and gather performance counter statistics
>
> - show the result:
> perf kvm stat report --event=msr
>
> See the msr events:
>
> Analyze events for all VMs, all VCPUs:
>
> MSR Access Samples Samples% Time% Min Time Max Time Avg time
>
> 0x6e0:W 67007 98.17% 98.31% 0.59us 10.69us 0.90us ( +-
> 0.10% )
> 0x830:W 1186 1.74% 1.60% 0.53us 108.34us 0.82us ( +-
> 11.02% )
> 0x3b:R 66 0.10% 0.09% 0.56us 1.26us 0.80us ( +-
> 3.24% )
>
> Total Samples:68259, Total events handled time:61150.95us.
>
> Signed-off-by: Li RongQing <lirongqing@baidu.com>
> Signed-off-by: Lei Zhao <zhaolei27@baidu.com>
> ---
> tools/perf/arch/x86/util/kvm-stat.c | 46
> +++++++++++++++++++++++++++++++++++
> 1 files changed, 46 insertions(+), 0 deletions(-)
>
> diff --git a/tools/perf/arch/x86/util/kvm-stat.c
> b/tools/perf/arch/x86/util/kvm-stat.c
> index 0729204..c5dd54f 100644
> --- a/tools/perf/arch/x86/util/kvm-stat.c
> +++ b/tools/perf/arch/x86/util/kvm-stat.c
> @@ -133,11 +133,56 @@ static void ioport_event_decode_key(struct
> perf_kvm_stat *kvm __maybe_unused,
> .name = "IO Port Access"
> };
>
> + /* The time of emulation msr is from kvm_msr to kvm_entry. */ static
> +void msr_event_get_key(struct evsel *evsel,
> + struct perf_sample *sample,
> + struct event_key *key)
> +{
> + key->key = evsel__intval(evsel, sample, "ecx");
> + key->info = evsel__intval(evsel, sample, "write"); }
> +
> +static bool msr_event_begin(struct evsel *evsel,
> + struct perf_sample *sample,
> + struct event_key *key)
> +{
> + if (!strcmp(evsel->name, "kvm:kvm_msr")) {
> + msr_event_get_key(evsel, sample, key);
> + return true;
> + }
> +
> + return false;
> +}
> +
> +static bool msr_event_end(struct evsel *evsel,
> + struct perf_sample *sample __maybe_unused,
> + struct event_key *key __maybe_unused) {
> + return kvm_entry_event(evsel);
> +}
> +
> +static void msr_event_decode_key(struct perf_kvm_stat *kvm
> __maybe_unused,
> + struct event_key *key,
> + char *decode)
> +{
> + scnprintf(decode, decode_str_len, "%#llx:%s",
> + (unsigned long long)key->key,
> + key->info ? "W" : "R");
> +}
> +
> +static struct kvm_events_ops msr_events = {
> + .is_begin_event = msr_event_begin,
> + .is_end_event = msr_event_end,
> + .decode_key = msr_event_decode_key,
> + .name = "MSR Access"
> +};
> +
> const char *kvm_events_tp[] = {
> "kvm:kvm_entry",
> "kvm:kvm_exit",
> "kvm:kvm_mmio",
> "kvm:kvm_pio",
> + "kvm:kvm_msr",
> NULL,
> };
>
> @@ -145,6 +190,7 @@ struct kvm_reg_events_ops kvm_reg_events_ops[] = {
> { .name = "vmexit", .ops = &exit_events },
> { .name = "mmio", .ops = &mmio_events },
> { .name = "ioport", .ops = &ioport_events },
> + { .name = "msr", .ops = &msr_events },
> { NULL, NULL },
> };
>
> --
> 1.7.1
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH][resend] perf x86 kvm-stat: support to analyze kvm msr
2021-04-22 1:46 ` Li,Rongqing
@ 2021-04-23 17:05 ` Namhyung Kim
2021-05-09 13:44 ` Arnaldo Carvalho de Melo
0 siblings, 1 reply; 4+ messages in thread
From: Namhyung Kim @ 2021-04-23 17:05 UTC (permalink / raw)
To: Li,Rongqing
Cc: linux-kernel, jolsa, alexander.shishkin, mark.rutland, acme,
mingo, peterz
Hello,
On Thu, Apr 22, 2021 at 11:33 AM Li,Rongqing <lirongqing@baidu.com> wrote:
> > Subject: [PATCH][resend] perf x86 kvm-stat: support to analyze kvm msr
> >
> > From: Lei Zhao <zhaolei27@baidu.com>
> >
> > usage:
> > - kvm stat
> > run a command and gather performance counter statistics
> >
> > - show the result:
> > perf kvm stat report --event=msr
> >
> > See the msr events:
> >
> > Analyze events for all VMs, all VCPUs:
> >
> > MSR Access Samples Samples% Time% Min Time Max Time Avg time
> >
> > 0x6e0:W 67007 98.17% 98.31% 0.59us 10.69us 0.90us ( +-
> > 0.10% )
> > 0x830:W 1186 1.74% 1.60% 0.53us 108.34us 0.82us ( +-
> > 11.02% )
> > 0x3b:R 66 0.10% 0.09% 0.56us 1.26us 0.80us ( +-
> > 3.24% )
> >
> > Total Samples:68259, Total events handled time:61150.95us.
> >
> > Signed-off-by: Li RongQing <lirongqing@baidu.com>
> > Signed-off-by: Lei Zhao <zhaolei27@baidu.com>
Acked-by: Namhyung Kim <namhyung@kernel.org>
Thanks,
Namhyung
> > ---
> > tools/perf/arch/x86/util/kvm-stat.c | 46
> > +++++++++++++++++++++++++++++++++++
> > 1 files changed, 46 insertions(+), 0 deletions(-)
> >
> > diff --git a/tools/perf/arch/x86/util/kvm-stat.c
> > b/tools/perf/arch/x86/util/kvm-stat.c
> > index 0729204..c5dd54f 100644
> > --- a/tools/perf/arch/x86/util/kvm-stat.c
> > +++ b/tools/perf/arch/x86/util/kvm-stat.c
> > @@ -133,11 +133,56 @@ static void ioport_event_decode_key(struct
> > perf_kvm_stat *kvm __maybe_unused,
> > .name = "IO Port Access"
> > };
> >
> > + /* The time of emulation msr is from kvm_msr to kvm_entry. */ static
> > +void msr_event_get_key(struct evsel *evsel,
> > + struct perf_sample *sample,
> > + struct event_key *key)
> > +{
> > + key->key = evsel__intval(evsel, sample, "ecx");
> > + key->info = evsel__intval(evsel, sample, "write"); }
> > +
> > +static bool msr_event_begin(struct evsel *evsel,
> > + struct perf_sample *sample,
> > + struct event_key *key)
> > +{
> > + if (!strcmp(evsel->name, "kvm:kvm_msr")) {
> > + msr_event_get_key(evsel, sample, key);
> > + return true;
> > + }
> > +
> > + return false;
> > +}
> > +
> > +static bool msr_event_end(struct evsel *evsel,
> > + struct perf_sample *sample __maybe_unused,
> > + struct event_key *key __maybe_unused) {
> > + return kvm_entry_event(evsel);
> > +}
> > +
> > +static void msr_event_decode_key(struct perf_kvm_stat *kvm
> > __maybe_unused,
> > + struct event_key *key,
> > + char *decode)
> > +{
> > + scnprintf(decode, decode_str_len, "%#llx:%s",
> > + (unsigned long long)key->key,
> > + key->info ? "W" : "R");
> > +}
> > +
> > +static struct kvm_events_ops msr_events = {
> > + .is_begin_event = msr_event_begin,
> > + .is_end_event = msr_event_end,
> > + .decode_key = msr_event_decode_key,
> > + .name = "MSR Access"
> > +};
> > +
> > const char *kvm_events_tp[] = {
> > "kvm:kvm_entry",
> > "kvm:kvm_exit",
> > "kvm:kvm_mmio",
> > "kvm:kvm_pio",
> > + "kvm:kvm_msr",
> > NULL,
> > };
> >
> > @@ -145,6 +190,7 @@ struct kvm_reg_events_ops kvm_reg_events_ops[] = {
> > { .name = "vmexit", .ops = &exit_events },
> > { .name = "mmio", .ops = &mmio_events },
> > { .name = "ioport", .ops = &ioport_events },
> > + { .name = "msr", .ops = &msr_events },
> > { NULL, NULL },
> > };
> >
> > --
> > 1.7.1
>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH][resend] perf x86 kvm-stat: support to analyze kvm msr
2021-04-23 17:05 ` Namhyung Kim
@ 2021-05-09 13:44 ` Arnaldo Carvalho de Melo
0 siblings, 0 replies; 4+ messages in thread
From: Arnaldo Carvalho de Melo @ 2021-05-09 13:44 UTC (permalink / raw)
To: Namhyung Kim
Cc: Li,Rongqing, linux-kernel, jolsa, alexander.shishkin,
mark.rutland, mingo, peterz
Em Sat, Apr 24, 2021 at 02:05:51AM +0900, Namhyung Kim escreveu:
> Hello,
>
> On Thu, Apr 22, 2021 at 11:33 AM Li,Rongqing <lirongqing@baidu.com> wrote:
> > > Subject: [PATCH][resend] perf x86 kvm-stat: support to analyze kvm msr
> > >
> > > From: Lei Zhao <zhaolei27@baidu.com>
> > >
> > > usage:
> > > - kvm stat
> > > run a command and gather performance counter statistics
> > >
> > > - show the result:
> > > perf kvm stat report --event=msr
> > >
> > > See the msr events:
> > >
> > > Analyze events for all VMs, all VCPUs:
> > >
> > > MSR Access Samples Samples% Time% Min Time Max Time Avg time
> > >
> > > 0x6e0:W 67007 98.17% 98.31% 0.59us 10.69us 0.90us ( +-
> > > 0.10% )
> > > 0x830:W 1186 1.74% 1.60% 0.53us 108.34us 0.82us ( +-
> > > 11.02% )
> > > 0x3b:R 66 0.10% 0.09% 0.56us 1.26us 0.80us ( +-
> > > 3.24% )
> > >
> > > Total Samples:68259, Total events handled time:61150.95us.
> > >
> > > Signed-off-by: Li RongQing <lirongqing@baidu.com>
> > > Signed-off-by: Lei Zhao <zhaolei27@baidu.com>
>
> Acked-by: Namhyung Kim <namhyung@kernel.org>
Thanks, applied.
- Arnaldo
> Thanks,
> Namhyung
>
>
> > > ---
> > > tools/perf/arch/x86/util/kvm-stat.c | 46
> > > +++++++++++++++++++++++++++++++++++
> > > 1 files changed, 46 insertions(+), 0 deletions(-)
> > >
> > > diff --git a/tools/perf/arch/x86/util/kvm-stat.c
> > > b/tools/perf/arch/x86/util/kvm-stat.c
> > > index 0729204..c5dd54f 100644
> > > --- a/tools/perf/arch/x86/util/kvm-stat.c
> > > +++ b/tools/perf/arch/x86/util/kvm-stat.c
> > > @@ -133,11 +133,56 @@ static void ioport_event_decode_key(struct
> > > perf_kvm_stat *kvm __maybe_unused,
> > > .name = "IO Port Access"
> > > };
> > >
> > > + /* The time of emulation msr is from kvm_msr to kvm_entry. */ static
> > > +void msr_event_get_key(struct evsel *evsel,
> > > + struct perf_sample *sample,
> > > + struct event_key *key)
> > > +{
> > > + key->key = evsel__intval(evsel, sample, "ecx");
> > > + key->info = evsel__intval(evsel, sample, "write"); }
> > > +
> > > +static bool msr_event_begin(struct evsel *evsel,
> > > + struct perf_sample *sample,
> > > + struct event_key *key)
> > > +{
> > > + if (!strcmp(evsel->name, "kvm:kvm_msr")) {
> > > + msr_event_get_key(evsel, sample, key);
> > > + return true;
> > > + }
> > > +
> > > + return false;
> > > +}
> > > +
> > > +static bool msr_event_end(struct evsel *evsel,
> > > + struct perf_sample *sample __maybe_unused,
> > > + struct event_key *key __maybe_unused) {
> > > + return kvm_entry_event(evsel);
> > > +}
> > > +
> > > +static void msr_event_decode_key(struct perf_kvm_stat *kvm
> > > __maybe_unused,
> > > + struct event_key *key,
> > > + char *decode)
> > > +{
> > > + scnprintf(decode, decode_str_len, "%#llx:%s",
> > > + (unsigned long long)key->key,
> > > + key->info ? "W" : "R");
> > > +}
> > > +
> > > +static struct kvm_events_ops msr_events = {
> > > + .is_begin_event = msr_event_begin,
> > > + .is_end_event = msr_event_end,
> > > + .decode_key = msr_event_decode_key,
> > > + .name = "MSR Access"
> > > +};
> > > +
> > > const char *kvm_events_tp[] = {
> > > "kvm:kvm_entry",
> > > "kvm:kvm_exit",
> > > "kvm:kvm_mmio",
> > > "kvm:kvm_pio",
> > > + "kvm:kvm_msr",
> > > NULL,
> > > };
> > >
> > > @@ -145,6 +190,7 @@ struct kvm_reg_events_ops kvm_reg_events_ops[] = {
> > > { .name = "vmexit", .ops = &exit_events },
> > > { .name = "mmio", .ops = &mmio_events },
> > > { .name = "ioport", .ops = &ioport_events },
> > > + { .name = "msr", .ops = &msr_events },
> > > { NULL, NULL },
> > > };
> > >
> > > --
> > > 1.7.1
> >
--
- Arnaldo
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2021-05-09 13:44 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-04-15 7:00 [PATCH][resend] perf x86 kvm-stat: support to analyze kvm msr Li RongQing
2021-04-22 1:46 ` Li,Rongqing
2021-04-23 17:05 ` Namhyung Kim
2021-05-09 13:44 ` Arnaldo Carvalho de Melo
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.