kernel - Add /dev/upmap and /dev/kpmap and sys/upmap.h (3)
authorMatthew Dillon <dillon@apollo.backplane.com>
Fri, 17 Oct 2014 02:25:04 +0000 (19:25 -0700)
committerMatthew Dillon <dillon@apollo.backplane.com>
Fri, 17 Oct 2014 02:25:04 +0000 (19:25 -0700)
commit8711651202bb750eb3b64529c2e2f10dee79cd55
tree5e4fcf84894c32ffbf9b1d42be3326bb9de5aba0
parent9e0d15726a7894d6d0589571897c5dfbf706c160
kernel - Add /dev/upmap and /dev/kpmap and sys/upmap.h (3)

* Add upmap->invfork.  When a vforked child is trying to access the upmap
  prior to exec we must still access the parent's map and not the child's,
  which means that the stored PID will be incorrect.

  To fix this issue we add the invfork field which allows userland to
  determine whether this is a vforked child accessing the parent's map.
  If it is, getpid() will use the system call.

* Fix a bug where a vfork()d child creates p->p_upmap for itself but then
  maps it into the parent's address space as a side effect of a getpid()
  or other call.  When this situation is detected, /dev/upmap will use
  the parent's p_upmap and not the child's, and also properly set the
  invfork flag.

* Implement system call overrides for getpid(), setproctitle(), and
  clock_gettime() (*_FAST and *_SECOND clock ids).  When more than 10 calls
  are made to one of these functions the new libc upmap/kpmap support is
  activated.  /dev/upmap and /dev/kpmap will be memory-mapped into the
  address space and further accesses will run through the maps instead of
  making system calls.

  This will obviously reduce overhead for these calls by a very significant
  multiplier.

* NOTE! gettimeofday() is still a system call and will likely remain a system
call in order to return a fine-grained time value.  Third-party code
that doesn't need a fine-grained time value must use clock_gettime()
to obtain the new performance efficiencies.
16 files changed:
lib/libc/Makefile.inc
lib/libc/gen/setproctitle.c
lib/libc/upmap/Makefile.inc [new file with mode: 0644]
lib/libc/upmap/Symbol.map [new file with mode: 0644]
lib/libc/upmap/ukp_clock.c [new file with mode: 0644]
lib/libc/upmap/ukp_getpid.c [new file with mode: 0644]
lib/libc/upmap/ukp_setproctitle.c [new file with mode: 0644]
lib/libc/upmap/upmap.c [new file with mode: 0644]
lib/libc/upmap/upmap.h [new file with mode: 0644]
sys/kern/kern_exec.c
sys/kern/kern_exit.c
sys/kern/kern_fork.c
sys/kern/kern_memio.c
sys/kern/kern_proc.c
sys/sys/proc.h
sys/sys/upmap.h