Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756448AbbFPOyG (ORCPT ); Tue, 16 Jun 2015 10:54:06 -0400 Received: from mail-ig0-f173.google.com ([209.85.213.173]:35651 "EHLO mail-ig0-f173.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754524AbbFPOx5 (ORCPT ); Tue, 16 Jun 2015 10:53:57 -0400 Message-ID: <55803883.50504@gmail.com> Date: Tue, 16 Jun 2015 08:53:55 -0600 From: David Ahern User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.10; rv:31.0) Gecko/20100101 Thunderbird/31.7.0 MIME-Version: 1.0 To: Hemant Kumar , 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 References: <1434423053-2173-1-git-send-email-hemant@linux.vnet.ibm.com> In-Reply-To: <1434423053-2173-1-git-send-email-hemant@linux.vnet.ibm.com> Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1845 Lines: 61 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 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/