* Recommended method of getting timestamps? @ 2013-09-05 18:01 Patrick Mahan [not found] ` <16BB02EF-879C-4DB1-804E-E5E6E08B935E-5dHXHCkEAVbYtjvyW6yDsg@public.gmane.org> 0 siblings, 1 reply; 4+ messages in thread From: Patrick Mahan @ 2013-09-05 18:01 UTC (permalink / raw) To: dev-VfR2kkLFssw I have a need to keep a timestamp on a piece of global data. When then timestamp grows too old I want to refresh that data. Is it safe to use, gettimeofday()? I thought about using an alarm, but I need to set an alarm from inside the alarm callback which doesn't look like it will work due to the spinlock on the alarm list. And since this is inside the driver I am working on, setting up a timer is not simple. So, I figure to timestamp the data, wait until I need to access it, check the timestamp and refresh if it is too old. Thoughts? Suggestions? Thanks, Patrick Coming to you from deep inside Fortress Mahan ^ permalink raw reply [flat|nested] 4+ messages in thread
[parent not found: <16BB02EF-879C-4DB1-804E-E5E6E08B935E-5dHXHCkEAVbYtjvyW6yDsg@public.gmane.org>]
* Re: Recommended method of getting timestamps? [not found] ` <16BB02EF-879C-4DB1-804E-E5E6E08B935E-5dHXHCkEAVbYtjvyW6yDsg@public.gmane.org> @ 2013-09-05 18:09 ` Daniel Cegiełka 2013-09-06 6:33 ` Dmitry Vyal 1 sibling, 0 replies; 4+ messages in thread From: Daniel Cegiełka @ 2013-09-05 18:09 UTC (permalink / raw) To: Patrick Mahan; +Cc: dev-VfR2kkLFssw@public.gmane.org http://en.wikipedia.org/wiki/Time_Stamp_Counter Daniel ^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Recommended method of getting timestamps? [not found] ` <16BB02EF-879C-4DB1-804E-E5E6E08B935E-5dHXHCkEAVbYtjvyW6yDsg@public.gmane.org> 2013-09-05 18:09 ` Daniel Cegiełka @ 2013-09-06 6:33 ` Dmitry Vyal [not found] ` <52297756.7060308-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> 1 sibling, 1 reply; 4+ messages in thread From: Dmitry Vyal @ 2013-09-06 6:33 UTC (permalink / raw) To: Patrick Mahan; +Cc: dev-VfR2kkLFssw Hello Patrick, I guess gettimeofday is too heavy if all you need is an abstract timestamp not related to any particular calendar. I think you should look at rte_rdtsc()? It returns a current value of CPU tick counter. So it's very cheap (just a few clocks) and has a great resolution (a fraction of nanosecond). Regards, Dmitry > I have a need to keep a timestamp on a piece of global data. When then timestamp grows too old I want to refresh that data. Is it safe to use, gettimeofday()? > > I thought about using an alarm, but I need to set an alarm from inside the alarm callback which doesn't look like it will work due to the spinlock on the alarm list. > > And since this is inside the driver I am working on, setting up a timer is not simple. > > So, I figure to timestamp the data, wait until I need to access it, check the timestamp and refresh if it is too old. > > Thoughts? Suggestions? > > Thanks, > > Patrick > > Coming to you from deep inside Fortress Mahan ^ permalink raw reply [flat|nested] 4+ messages in thread
[parent not found: <52297756.7060308-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>]
* Re: Recommended method of getting timestamps? [not found] ` <52297756.7060308-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> @ 2013-09-06 6:45 ` Stephen Hemminger 0 siblings, 0 replies; 4+ messages in thread From: Stephen Hemminger @ 2013-09-06 6:45 UTC (permalink / raw) To: Dmitry Vyal; +Cc: dev-VfR2kkLFssw On Fri, 06 Sep 2013 10:33:58 +0400 Dmitry Vyal <dmitryvyal-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > Hello Patrick, > > I guess gettimeofday is too heavy if all you need is an abstract > timestamp not related to any particular calendar. I think you should > look at rte_rdtsc()? It returns a current value of CPU tick counter. So > it's very cheap (just a few clocks) and has a great resolution (a > fraction of nanosecond). > > Regards, > Dmitry > > > I have a need to keep a timestamp on a piece of global data. When then timestamp grows too old I want to refresh that data. Is it safe to use, gettimeofday()? > > > > I thought about using an alarm, but I need to set an alarm from inside the alarm callback which doesn't look like it will work due to the spinlock on the alarm list. > > > > And since this is inside the driver I am working on, setting up a timer is not simple. > > > > So, I figure to timestamp the data, wait until I need to access it, check the timestamp and refresh if it is too old. > > > > Thoughts? Suggestions? > > > > Thanks, > > > > Patrick > > > > Coming to you from deep inside Fortress Mahan > DPDK has both HPET and TSC timers. HPET is slower to access non-cached, but has advantage of being same on all cores and unaffected by power management etc. TSC is faster but can vary in frequency on some processors. It is also not guaranteed sync'd on some systems with multiple sockets. See rte_rdtsc and rte_get_hpet_cycles. The latest DPDK 1.4.1 just released by Intel has common code rte_get_timer_cycles() to try and make decision at runtime. ^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2013-09-06 6:45 UTC | newest] Thread overview: 4+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2013-09-05 18:01 Recommended method of getting timestamps? Patrick Mahan [not found] ` <16BB02EF-879C-4DB1-804E-E5E6E08B935E-5dHXHCkEAVbYtjvyW6yDsg@public.gmane.org> 2013-09-05 18:09 ` Daniel Cegiełka 2013-09-06 6:33 ` Dmitry Vyal [not found] ` <52297756.7060308-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> 2013-09-06 6:45 ` Stephen Hemminger
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).