lkml.org 
[lkml]   [2013]   [Feb]   [18]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [RFC] perf: need to expose sched_clock to correlate user samples with kernel samples
On 2/18/13 8:16 AM, Stephane Eranian wrote:
> Hi,
>
>
> I think the advantage of the ioctl() is that is reuses existing infrastructure.
> The downside is that to get the timestamp you need at a minimum:
>
> uint64_t get_perf_timestamp(void)
> {
> struct perf_event_attr attr;
> uint64_t ts = 0;
> int fd;
>
> memset(&attr, 0, sizeof(attr));
>
> /* pick a dummy SW event (no PMU HW resource allocated), keep it disabled */
> attr.type = PERF_TYPE_SOFTWARE;
> attr.config = PERF_COUNT_SW_CPU_CLOCK; /* dummy event */
> attr.disabled = 1;
>
> /* attach to self in per-thread mode */
> fd = perf_event_open(&attr, 0, -1, -1, 0);
> if (fd == -1)
> return 0;
>
> ioctl(fd, PERF_EVENT_IOC_GET_TIME, &ts);
> close(fd);
>
> return ts;
> }
>

That's the approach I took with an update to my perf_clock to
time-of-day series. Specific patch:

https://github.com/dsahern/linux/commit/7e6f40fca5f8cdbee1cd46d42b11aee71d0ffd34

and series:
https://github.com/dsahern/linux/commits/perf-time-of-day-3.7

David


\
 
 \ /
  Last update: 2013-02-18 20:41    [W:0.257 / U:0.204 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site