Re: [perfmon2] [PATCH] Add an example program which translates an event string to a raw event code
Status: Beta
Brought to you by:
seranian
From: stephane e. <er...@go...> - 2010-09-29 07:33:52
|
Corey, Please note that once libpfm4-1.0 is released, I'll post a patch to link the perf tool directly with libpfm4. At that point, you will not need your little evt2raw program to access any event encoding. What's blocking release 1.0? 1- add support for OS-specific event attributes 2- add Pentium 4 (Netburst) support For 1, the idea is to allow you to pass attributes which come from the OS API and not the HW. For instance, the sampling period, the precise_ip mode. The list of OS attributes for each event depends on the OS and the event itself. Sometimes, there are several HW attributes which do overlap with OS attributes, for instance u, k, precise_ip. The latter is connected to PEBS on Intel processors. The u, k in perf_events override those set in HW. The reason 1- is delaying the release is because it may have some implications at the user level API of libpfm4. On Wed, Sep 29, 2010 at 9:27 AM, stephane eranian <er...@go...> wrote: > Corey, > > Patch applied. I tweaked the error messages a bit. > Thanks. > > On Mon, Sep 27, 2010 at 8:15 AM, Corey Ashford > <cja...@li...> wrote: >> Provide a small tool which translates an event string + modifiers to a raw >> event code for use with the perf tool. >> >> This example is very simple and takes a single event string as an argument. >> >> Signed-off-by: Corey Ashford <cja...@us...> >> --- >> perf_examples/Makefile | 2 +- >> perf_examples/evt2raw.c | 74 +++++++++++++++++++++++++++++++++++++++++++++++ >> 2 files changed, 75 insertions(+), 1 deletions(-) >> create mode 100644 perf_examples/evt2raw.c >> >> diff --git a/perf_examples/Makefile b/perf_examples/Makefile >> index 1d353d4..8ebb290 100644 >> --- a/perf_examples/Makefile >> +++ b/perf_examples/Makefile >> @@ -55,7 +55,7 @@ ifeq ($(SYS),Linux) >> LPC_UTILS=perf_util.o >> TARGETS+=self self_basic self_count task task_attach_timeout syst \ >> notify_self notify_group task_smpl self_smpl_multi \ >> - self_pipe syst_count task_cpu syst_smpl >> + self_pipe syst_count task_cpu syst_smpl evt2raw >> >> #XTRA += rtop >> endif >> diff --git a/perf_examples/evt2raw.c b/perf_examples/evt2raw.c >> new file mode 100644 >> index 0000000..917420f >> --- /dev/null >> +++ b/perf_examples/evt2raw.c >> @@ -0,0 +1,74 @@ >> +/* >> + * evt2raw.c - example which converts an event string (event + modifiers) to >> + * a raw event code usable by the perf tool. >> + * >> + * Copyright (c) 2010 IBM Corp. >> + * Contributed by Corey Ashford <cja...@us...> >> + * >> + * Permission is hereby granted, free of charge, to any person obtaining a copy >> + * of this software and associated documentation files (the "Software"), to deal >> + * in the Software without restriction, including without limitation the rights >> + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies >> + * of the Software, and to permit persons to whom the Software is furnished to do so, >> + * subject to the following conditions: >> + * >> + * The above copyright notice and this permission notice shall be included in all >> + * copies or substantial portions of the Software. >> + * >> + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, >> + * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A >> + * PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT >> + * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF >> + * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE >> + * OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. >> + */ >> +#include <stdio.h> >> +#include <stdlib.h> >> +#include <unistd.h> >> +#include <perfmon/pfmlib_perf_event.h> >> + >> +static void >> +usage(void) >> +{ >> + printf("usage: evt2raw <event>\n" >> + "<event> is the symbolic event, including modifiers, to " >> + "translate to a raw code.\n"); >> +} >> + >> +int >> +main(int argc, char **argv) >> +{ >> + int ret; >> + struct perf_event_attr pea; >> + char *event_str; >> + >> + if (argc != 2) { >> + usage(); >> + return 1; >> + } >> + event_str = argv[1]; >> + >> + ret = pfm_initialize(); >> + if (ret != PFM_SUCCESS) { >> + printf("Internal error: pfm_initialize returned %s\n", >> + pfm_strerror(ret)); >> + return 1; >> + } >> + >> + ret = pfm_get_perf_event_encoding(event_str, PFM_PLM0|PFM_PLM3, &pea, >> + NULL, NULL); >> + if (ret != PFM_SUCCESS) { >> + printf("Error: pfm_get_perf_encoding returned %s\n", >> + pfm_strerror(ret)); >> + return 1; >> + } >> + >> + if (pea.type != PERF_TYPE_RAW) { >> + printf("Error: %s is not a raw hardware event\n", event_str); >> + return 1; >> + } >> + >> + printf("r%llx\n", pea.config); >> + >> + return 0; >> +} >> -- >> 1.7.0.4 >> >> >> ------------------------------------------------------------------------------ >> Start uncovering the many advantages of virtual appliances >> and start using them to simplify application deployment and >> accelerate your shift to cloud computing. >> http://p.sf.net/sfu/novell-sfdev2dev >> _______________________________________________ >> perfmon2-devel mailing list >> per...@li... >> https://lists.sourceforge.net/lists/listinfo/perfmon2-devel >> > |