Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 28 Oct 2005 15:20:46 +0200
From:      "Poul-Henning Kamp" <phk@phk.freebsd.dk>
To:        Robert Watson <rwatson@FreeBSD.org>
Cc:        Pertti Kosunen <pertti.kosunen@pp.nic.fi>, David Xu <davidxu@freebsd.org>, "Yuriy N. Shkandybin" <jura@networks.ru>, current@freebsd.org
Subject:   Re: Timers and timing, was: MySQL Performance 6.0rc1 
Message-ID:  <32412.1130505646@critter.freebsd.dk>
In-Reply-To: Your message of "Fri, 28 Oct 2005 14:08:01 BST." <20051028140556.W20147@fledge.watson.org> 

next in thread | previous in thread | raw e-mail | index | archive | help
In message <20051028140556.W20147@fledge.watson.org>, Robert Watson writes:
>
>On Fri, 28 Oct 2005, David Xu wrote:
>
>> Poul-Henning Kamp wrote:
>>> In message <4361FDBE.7000500@freebsd.org>, David Xu writes:
>>> 
>>> the correct way to optimize this would be to add a time(2) systemcall 
>>> which returns the value of the kernel global time_second.
>>
>> Can we make a page in kernel address space which is readable my user 
>> code? put the variable in the page, I know read an integer is atomic-op, 
>> needn't lock, so syscall is not needed.
>
>This approach has a lot of merit, as we can also potentially export other 
>information there (such as kernel preferences for system call mechanisms). 

Yes, there are many advantages to this approach, but we need a solution
to the API versioning problem before we head that way.

For anyone wanting to look at this, three are a number of nasties
to remember:

1. How does userland get hold of the page ?  Does it open a magic
   device ?  Use a magic syscall ?  Or does all processes just get
   the page by default ?

2. Where in the address space do we put it ?

3. Layout and alignment issues.  Remember that things change size
   over time. (Version numbers for each element ?)  And that cross-
   arch support is desirable (32bit i386 binaries on 64bit amd64 arch)

4. Do guarantee a syscall fallback for all facilities if there is version
   skew, or do we abort the program ?

5. Do we want a global system page and a per process page while we
   are at it.  There is plenty of stuff we could put in the per-proc
   page:  pid, ppid, resource usage, proctitle etc.


>On the other hand, a lower risk change might be to simply add a new CLOCK_ 
>type for lower resolution, and have a timer synchronize a variable to the 
>system clock once every 1/10 of a second.  This avoids having to muck with 
>VM layout, etc.

Is the CLOCK_* namespace ours to muck about with in the first place ?

-- 
Poul-Henning Kamp       | UNIX since Zilog Zeus 3.20
phk@FreeBSD.ORG         | TCP/IP since RFC 956
FreeBSD committer       | BSD since 4.3-tahoe    
Never attribute to malice what can adequately be explained by incompetence.



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?32412.1130505646>