[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <5580CC69.2090200@linux.vnet.ibm.com>
Date: Wed, 17 Jun 2015 06:54:57 +0530
From: Hemant Kumar <hemant@...ux.vnet.ibm.com>
To: David Ahern <dsahern@...il.com>, linuxppc-dev@...ts.ozlabs.org
CC: linux-kernel@...r.kernel.org, kvm-ppc@...r.kernel.org,
acme@...nel.org, mingo@...nel.org, sukadev@...ux.vnet.ibm.com,
maddy@...ux.vnet.ibm.com, srikar@...ux.vnet.ibm.com,
paulus@...ba.org, namhyung@...nel.org, jolsa@...nel.org,
peterz@...radead.org
Subject: Re: [RFC PATCH] perf/kvm: Guest Symbol Resolution for powerpc
Hi David,
Thanks for the review.
On 06/16/2015 08:23 PM, David Ahern wrote:
> 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?
>
>
Because, this depends on the kernel tracepoint "kvm_hv:kvm_guest_exit".
perf_prepare_sample() in the kernel side sets the event->header.misc
field to
PERF_RECORD_MISC_KERNEL through perf_misc_flags(pt_regs). In case of
tracepoints which always get hit in the host kernel context, the
perf_misc_flags() will always return PERF_RECORD_MISC_KERNEL.
IMHO we will rather have to set the cpumode in the user space for this
tracepoint
and we can't depend on the event->header.misc field for this case.
What would you suggest?
--
Thanks,
Hemant Kumar
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists