Subject: Shared page idea Re: Pulling simple syscalls out from the giant lock
To: Thor Lancelot Simon <tls@rek.tjls.com>
From: Reinoud Zandijk <reinoud@netbsd.org>
List: tech-kern
Date: 06/27/2005 01:41:58
--7JfCtLOvnd9MIVvH
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline

On Tue, Jun 07, 2005 at 02:08:12PM -0400, Thor Lancelot Simon wrote:
> > Well, gettimeofday() is so easy that in Linux it is done entirely in userland;
> > the kernel is mapping a shared page to some place, and every process that does
> > gettimeofday() reads the variable and returns, with no context switching
> 
> I think this technique actually originally comes from either Darwin or
> Solaris.  In any event, it's something we've been talking about doing
> for some time.

true... maybe we ought to summise all potential variables, timers etc. etc. 
We could use this method too in a slightly different way to implement say a 
couple of page types :

1) a read-only no privalidged page that every process has mappped in

2) a read-only page that reflects global/process state that is checked to 
   only include state that is acceptable given the processes access 
   permissions.

3) a read/write page like 2 though optionally with writes that are page 
   faulting so its updating can be monitored/double checked.
   (prolly not wanted)

Offsets and sizes could be reflected as a header or in another shared 
page...

   struct shared_page_header {
           uint32_t   num_recs;
           struct rec_var {
                  uint32_t var_num;
                  uint32_t offset;
                  uint32_t length;
           } recs[1];
           /* data follows */
   };

   struct shared_record {
           uint32_t var_num;
           uint32_t struct_version;
           uint32_t rec_length;
           uint8_t  data[1];
   };

a gettimeofday() f.e. could check its var in the tuple list, and fetch the 
var at the offset. The record header is optional i agree though it might be 
handy for paranoia checking.

The lists could (/should?) be static at runtime or appendable by syscalls 
variable requests where libc and friends assure that no reading of vars is 
done concurrently with changes in layout.

Comments?

Cheers,
Reinoud

--7JfCtLOvnd9MIVvH
Content-Type: application/pgp-signature
Content-Disposition: inline

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.6 (NetBSD)

iQEVAwUBQr89P4KcNwBDyKpoAQJXxAgAlNZTJ9saoh3XiQmouUN7meFJ8rkOWkqn
NQ322n5d0SL69DnMKhlR/Wt1NrpYkOwrnA7zHFl25xuuz4wsE/gDMpSPlSz0w7hp
wgJNDKa7iJSpADJuBavtTeQYIogHGytvY6T422BlzwZ2bYKKy+bsLxgNwB6FalUK
X9s53kd0Ll4b+fe8SXiRiF8v8bpdo1gyNELb66boB59CW+qRq0smWtOSTuAgQwAU
1JAfHA6gKb6pioJM5DAZb5d1wJdfs5v5b9joesqbk72DM4oOeiJU0cpNk2L+rgjW
wGmEYPs7RGsDtYRwhUtF3raN7319KOlFOCkVKYxtorEkxGi2/hT27Q==
=JqL2
-----END PGP SIGNATURE-----

--7JfCtLOvnd9MIVvH--