Re: [perfmon2] How to reset sampling buffer before it overflows?
Status: Beta
Brought to you by:
seranian
From: <xu...@ic...> - 2010-11-23 13:40:37
|
> 2010/11/22 <xu...@ic...>: >> hi, >> >> I am writing my own app using the libpfm 3.10 API (interface v2.x) on a >> X86 system. >> >> I setup a sampling context for the target-process to sample every 1 >> million insts retired. Traditionally, I should wait for the buffer >> overflow message and process with the sampling buffer and then restart. >> But I use another different mechanism (I will explain why, later) that I >> setup another timer to count for a while (1s) and then stop the >> target-process with PTRACE_ATTACH. I set the buffer big enough to ensure >> it would not overflow before the timer expires. After reading the >> sampling >> entries, I try to reset the buffer using pfm_restart(), but it failed >> with >> error EBUSY (hdr_count field in the buffer header didn't reset). >> >> So, how to reset sampling buffer before it overflows? >> > Are you doing this with the kernel code in the GIT tree or a released > patch? > I am using the official kernel 2.6.29 and the kernel patch from http://sourceforge.net/projects/perfmon2/files/ > I looked at the code in __pfm_restart() and you cannot call pfm_restart() > if you did not get a notification (can_restart> 0), unfortunately. I think > this > is because pfm_restart() does more than just reset the buffer. It also > reloads > the sampling periods. > Yes, I checked the kernel code too. So can I just add another syscall which only re-writes the hdr_count (=0) and hdr_cur_off (=sizeof(*header)) field to reset the buffer? Will it be correct for my simple case where the buffer never overflows? Sorry I have little knowledge about the perfmon kernel. Thanks for you help. >> I do this because actually I am monitoring multiple processes that run >> concurrently, I would like a inst-based sampling for each process. >> However, due to their IPC difference, their sampling buffers won't >> overflow simultaneously. That would involves CPU fragment if I wait for >> all the buffers to overflow in my single-threaded program. >> >> Thanks very much! >> >> >> >> > > |