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 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/

