On Wed, 2006-06-28 at 17:29 +0200, Fernando Apesteguía wrote: > Hi, > > I would like to take some time measurements for some functions from my > kernel module. In a first attempt, I tried to use current_kernel_time, > but this often returns the same value before and after the call I want > to measure (even, when I use the tv_nsec field.). > > ts1=current_kernel_time; > function(); > ts2=current_kernel_time; > > So now I'm using rdtscll instead of current_kernel_time and that's > fine.. but I would like to convert that cycle units to time units. I > don't know how to do it... Maybe with loops_per_jiffies and do_div but > I don't know how to combine them. What is a jiffie (4 ms as wikipedia > said in 2.6 kernel series) and how can I use them to convert the > rdtscll return value to time units? well there is no fixed way to do that... for example, cpu frequencies are not constant anymore since a few years, and on several cpus the rdtsc timer even stops entirely when in the idle loop... so.. correlating rdtsc to wallclock time is always going to be real iffy. there is a cpu_khz variable that you can use as best guestimate if you can live with all these problems..... which sort of is an estimate the number of clock ticks in kiloHertz. But again... what you'll get isn't going to be very accurate since your "clock" is too volatile for that. -- Kernelnewbies: Help each other learn about the Linux kernel. Archive: http://mail.nl.linux.org/kernelnewbies/ FAQ: http://kernelnewbies.org/faq/