From: David Ahern <dsahern@gmail.com>
To: Hemant Kumar <hemant@linux.vnet.ibm.com>, linuxppc-dev@lists.ozlabs.org
Cc: linux-kernel@vger.kernel.org, kvm-ppc@vger.kernel.org,
acme@kernel.org, mingo@kernel.org, sukadev@linux.vnet.ibm.com,
maddy@linux.vnet.ibm.com, srikar@linux.vnet.ibm.com,
paulus@samba.org, namhyung@kernel.org, jolsa@kernel.org,
peterz@infradead.org
Subject: Re: [RFC PATCH] perf/kvm: Guest Symbol Resolution for powerpc
Date: Tue, 16 Jun 2015 14:53:55 +0000 [thread overview]
Message-ID: <55803883.50504@gmail.com> (raw)
In-Reply-To: <1434423053-2173-1-git-send-email-hemant@linux.vnet.ibm.com>
On 6/15/15 8:50 PM, Hemant Kumar wrote:
> +/*
> + * Get the instruction pointer from the tracepoint data
> + */
> +u64 arch__get_ip(struct perf_evsel *evsel, struct perf_sample *data)
> +{
> + u64 tp_ip = data->ip;
> + int trap;
> +
> + if (!strcmp(KVMPPC_EXIT, evsel->name)) {
> + trap = raw_field_value(evsel->tp_format, "trap", data->raw_data);
> +
> + if (trap = HV_DECREMENTER)
> + tp_ip = raw_field_value(evsel->tp_format, "pc",
> + data->raw_data);
> + }
> + return tp_ip;
> +}
You can tie a handler to an event; see builtin-trace.c for example
(evsel->handler = handler). Then have the sample handler call it (e.g,
see trace__process_sample). Then you don't have to check event names on
each pass like this and just do event based processing.
> +
> +/*
> + * Get the HV and PR bits and accordingly, determine the cpumode
> + */
> +u8 arch__get_cpumode(union perf_event *event, struct perf_evsel *evsel,
> + struct perf_sample *data)
> +{
> + unsigned long hv, pr, msr;
> + u8 cpumode = event->header.misc & PERF_RECORD_MISC_CPUMODE_MASK;
> +
> + if (strcmp(KVMPPC_EXIT, evsel->name))
> + goto ret;
> +
> + if (data->raw_data)
> + msr = raw_field_value(evsel->tp_format, "msr", data->raw_data);
> + else
> + goto ret;
> +
> + hv = msr & ((long unsigned)1 << (PPC_MAX - HV_BIT));
> + pr = msr & ((long unsigned)1 << (PPC_MAX - PR_BIT));
> +
> + if (!hv && pr)
> + cpumode = PERF_RECORD_MISC_GUEST_USER;
> + else
> + cpumode = PERF_RECORD_MISC_GUEST_KERNEL;
> +ret:
> + return cpumode;
> +}
Why isn't that set properly kernel side when the sample is generated?
David
WARNING: multiple messages have this Message-ID (diff)
From: David Ahern <dsahern@gmail.com>
To: Hemant Kumar <hemant@linux.vnet.ibm.com>, linuxppc-dev@lists.ozlabs.org
Cc: linux-kernel@vger.kernel.org, kvm-ppc@vger.kernel.org,
acme@kernel.org, mingo@kernel.org, sukadev@linux.vnet.ibm.com,
maddy@linux.vnet.ibm.com, srikar@linux.vnet.ibm.com,
paulus@samba.org, namhyung@kernel.org, jolsa@kernel.org,
peterz@infradead.org
Subject: Re: [RFC PATCH] perf/kvm: Guest Symbol Resolution for powerpc
Date: Tue, 16 Jun 2015 08:53:55 -0600 [thread overview]
Message-ID: <55803883.50504@gmail.com> (raw)
In-Reply-To: <1434423053-2173-1-git-send-email-hemant@linux.vnet.ibm.com>
On 6/15/15 8:50 PM, Hemant Kumar wrote:
> +/*
> + * Get the instruction pointer from the tracepoint data
> + */
> +u64 arch__get_ip(struct perf_evsel *evsel, struct perf_sample *data)
> +{
> + u64 tp_ip = data->ip;
> + int trap;
> +
> + if (!strcmp(KVMPPC_EXIT, evsel->name)) {
> + trap = raw_field_value(evsel->tp_format, "trap", data->raw_data);
> +
> + if (trap == HV_DECREMENTER)
> + tp_ip = raw_field_value(evsel->tp_format, "pc",
> + data->raw_data);
> + }
> + return tp_ip;
> +}
You can tie a handler to an event; see builtin-trace.c for example
(evsel->handler = handler). Then have the sample handler call it (e.g,
see trace__process_sample). Then you don't have to check event names on
each pass like this and just do event based processing.
> +
> +/*
> + * Get the HV and PR bits and accordingly, determine the cpumode
> + */
> +u8 arch__get_cpumode(union perf_event *event, struct perf_evsel *evsel,
> + struct perf_sample *data)
> +{
> + unsigned long hv, pr, msr;
> + u8 cpumode = event->header.misc & PERF_RECORD_MISC_CPUMODE_MASK;
> +
> + if (strcmp(KVMPPC_EXIT, evsel->name))
> + goto ret;
> +
> + if (data->raw_data)
> + msr = raw_field_value(evsel->tp_format, "msr", data->raw_data);
> + else
> + goto ret;
> +
> + hv = msr & ((long unsigned)1 << (PPC_MAX - HV_BIT));
> + pr = msr & ((long unsigned)1 << (PPC_MAX - PR_BIT));
> +
> + if (!hv && pr)
> + cpumode = PERF_RECORD_MISC_GUEST_USER;
> + else
> + cpumode = PERF_RECORD_MISC_GUEST_KERNEL;
> +ret:
> + return cpumode;
> +}
Why isn't that set properly kernel side when the sample is generated?
David
next prev parent reply other threads:[~2015-06-16 14:53 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-06-16 2:50 [RFC PATCH] perf/kvm: Guest Symbol Resolution for powerpc Hemant Kumar
2015-06-16 2:52 ` Hemant Kumar
2015-06-16 14:53 ` David Ahern [this message]
2015-06-16 14:53 ` David Ahern
2015-06-17 1:24 ` Hemant Kumar
2015-06-17 1:36 ` Hemant Kumar
2015-06-17 2:27 ` David Ahern
2015-06-17 2:27 ` David Ahern
2015-06-16 15:38 ` Arnaldo Carvalho de Melo
2015-06-16 15:38 ` Arnaldo Carvalho de Melo
2015-06-18 0:03 ` Hemant Kumar
2015-06-18 0:15 ` Hemant Kumar
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=55803883.50504@gmail.com \
--to=dsahern@gmail.com \
--cc=acme@kernel.org \
--cc=hemant@linux.vnet.ibm.com \
--cc=jolsa@kernel.org \
--cc=kvm-ppc@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linuxppc-dev@lists.ozlabs.org \
--cc=maddy@linux.vnet.ibm.com \
--cc=mingo@kernel.org \
--cc=namhyung@kernel.org \
--cc=paulus@samba.org \
--cc=peterz@infradead.org \
--cc=srikar@linux.vnet.ibm.com \
--cc=sukadev@linux.vnet.ibm.com \
/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 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.