# Re: \[PATCH v2 1/2\] perf: Add sampling of the raw monotonic clock

- From: David Ahern \<hidden\>
- Date: 2014-09-26 19:25:20 
- List: linux-api
- Page: https://ratatoskr.run/linux-api/2014/09/4342520
- Thread: https://ratatoskr.run/linux-api/2014/09/4342137/t.md

```text
On 9/26/14, 9:05 AM, Pawel Moll wrote:
> To do the correlation you need both timestamps to be "taken"
> simultaneously:
>
>          perf event     user event
>         -----O--------------+-------------O------> t_mono
>              :              |             :
>              :              V             :
>         -----O----------------------------O------> t_perf
>
> Of course it's not possible get both values literally at the same time,
> but placing them in a atomic context a couple of instructions from each
> other still gives pretty good results. The larger this distance is, the

An early patchset on this topic added the realtime clock as an event and an ioctl was used to push a sample into the event stream. In that case you have wall clock and perf-clock samples taken in the same kernel context and about as close together as you can get.

https://lkml.org/lkml/2011/2/27/158
https://lkml.org/lkml/2011/2/27/159

David
```
