5

I am using getnstimeofday in console_unlock function, which gets called very early during initialization. So early that even timekeeping will not be initialized so as to use getnstimeofday.

Is there any way to identify the precise moment to start using getnstimeofday. I mean, is there any global variable or any macro to check if timekeeping is initialized, so that I can start using getnstimeofday.

Vilhelm Gray
  • 11,516
  • 10
  • 61
  • 114
prasanna
  • 51
  • 5
  • Are you trying to profile the kernel boot-up? maybe you can try [**getrawmonotonic()**](http://lxr.free-electrons.com/ident?i=getrawmonotonic). A bunch of macros designed as wrappers around it are available for reference [**here**](http://wiki.attie.co.uk/wiki/C/timer). – TheCodeArtist Jul 07 '13 at 11:54
  • No, my intention is not profiling boot-up. I got solution for this problem by continuously looping over current_kernel_time function until it gives some valid value which indicates, timekeeping has initialized. Anyways, thanks for the reply. – prasanna Jul 08 '13 at 12:05
  • 1
    @user2067709 If you post your solution as an Answer to this Question page, I can award you the bounty. – Vilhelm Gray Jul 08 '13 at 12:35
  • 1
    I think that http://www.cs.fsu.edu/~baker/devices/lxr/http/source/linux/kernel/time/timekeeping.c#L50 could be usefull. If time keeping isn't suspended then you can start. – Galigator Jul 09 '13 at 10:32
  • @VilhelmGray - Sorry but i needed a solution for this issue long time back and unfortunately didn't get any responses for long time and i only figured out a possible solution (may not be the best) and continued the development. I thought, it will be helpful to post my workaround if someone faces same issue. Thats why posted. – prasanna Jul 09 '13 at 13:18
  • @MrK - Thanks, this is really a good way to do. But i followed a workaround and developed the code which is tested and released already. There was a deadline! But i appreciate your link. – prasanna Jul 09 '13 at 13:21
  • @user2067709 Yes, I'm personally curious if someone can find the section of code in the Linux kernel that performs the actual initialization of the timekeeping functionality. Hopefully, another user will drop by and describe what actually happens in the kernel. – Vilhelm Gray Jul 09 '13 at 13:33
  • 3
    i think you can check the global variable jiffies. This variable is starting from 0 and added by the timer interrupt per HZ. Once the timer interrupt is UP, the gettimeofday also works. For description about timer mechanism, here is a good article but in chinese http://www.bluezd.info/archives/%E6%97%B6%E9%92%9F%E6%BA%90%E7%9A%84%E6%B3%A8%E5%86%8C – Houcheng Mar 06 '14 at 14:44

0 Answers0