Stefane, thanks for the details. This helps greatly. Phil
On Tue, 2007-01-09 at 09:42 -0800, Stephane Eranian wrote: > Phil, > > On Tue, Jan 09, 2007 at 05:21:29PM +0100, Philip J. Mucci wrote: > > Hi Stefane, > > > > I would like to define a new sample format for some hardware on the > > SC1000. The sample contains 2 data items, the virtual IP and the > > physical address of the data miss. I want the format handler to convert > > the physical address to virtual address. I have the hook to do that. > > > You get to the format handler on PMU overflow. > I assume you need to copy out those registers into the buffer. So you > need to have a function to return the buffer size. It could be hardcoded > or passed by the user when the context is created (in the sampling format > argument). > > The handler callback is mandatory. All others are optional. > > > I was wondering, what functions do I need to be able to use this > > feature? The pebs and dfl sample formats appear quite complex...What > > should I use as a starting point? > > > The simplest of all is the IA64 Oprofile module in > arch/ia64/oprofile/perfmon.c > but it does not quite do what you want, i.e., deal with buffer allocation. > I would started with the dfl format as it is the closest to what you want > to do. Let's look at dfl in more details. > > First of all you need to pick a name for your format. We now use a simple > string. > > * int pfm_dfl_fmt_validate(u32 flags, u16 npmds, void *data) > > if you do not have user argument to the sampling format, then you do not > need > this callback. Otherwise, the function is used to check the validity of the > sampling format argument passed in data. For instance, if you were to pass > the > user requested size, you'd have to check that the size is reasonable, i.e., > at least > one sample. Return 0 for sucess, errno value otherwise. > > * int pfm_dfl_fmt_get_size(unsigned int flags, void *data, size_t *size) > > Return the desired buffer size in bytes in *size argument. 0 means does not > need > memory allocation and therefore user level mmap() will fail. Return 0 on > success, > errno value otherwise. > > * int pfm_dfl_fmt_init(struct pfm_context *ctx, void *buf, u32 flags, u16 > npmds, void *data) > > Function called just after the buffer is allocated during the > pfm_create_context() call. > This is where you can initialize the buffer. Return 0 on success, errno > value otherwise. > > > * int int pfm_dfl_fmt_handler(void *buf, struct pfm_ovfl_arg *arg, unsigned > long ip, u64 tstamp, void *data) > > This is the handler function, called on PMU interrupt. PMU is guaranteed > stopped and interrupts are masked. > buf is the base address of the sampling buffer, arg is used to control > behavior upon return from this function. > The ip argument points to the instruction that was executing when we got > the interrupt. The tstamp is a unique > per-cpu timestamp guaranteed to increase monotonesouly. The data argument > contains the pt_regs. > > When buffer is full, you must return -ENOBUS, 0 otherwise > > arg->ovfl_ctrl is a bitmask which you can use to control notification, > counter reset: > - PFM_OVFL_CTRL_NOTIFY: a user level notification is sent (via a message) > - PFM_OVFL_CTRL_MASK: monitoring is masked, i.e., stopped (remains stopped > upon return from interrupt handler) > - PFM_OVFL_CTRL_RESET: rest overflowed PMD upon return from function > > * int pfm_dfl_fmt_restart(int is_active, u32 *ovfl_ctrl, void *buf) > > This function is invoked on pfm_restart() by the user. It typically follows > a user level notification. > This is where you would reset the buffer to resume sampling. > > The ovfl_ctrl argument operates just like the arg->ovfl_ctrl parameter for > the handler function > > * int pfm_dfl_fmt_exit(void *buf) > > Called when the context is destroyed, i.e., when the last user closes the > file descriptor. > > Hope this helps. Let me know if you have problems. > > _______________________________________________ perfmon mailing list [email protected] http://www.hpl.hp.com/hosted/linux/mail-archives/perfmon/
