git: kernel - Add /dev/upmap and /dev/kpmap and sys/upmap.h (3)

Matthew Dillon dillon at
Thu Oct 16 19:33:39 PDT 2014

commit 8711651202bb750eb3b64529c2e2f10dee79cd55
Author: Matthew Dillon <dillon at>
Date:   Thu Oct 16 19:25:04 2014 -0700

    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
    * 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.

Summary of changes:
 lib/libc/             |   1 +
 lib/libc/gen/setproctitle.c       |   8 +-
 lib/libc/upmap/       |  10 +++
 lib/libc/upmap/         |   8 ++
 lib/libc/upmap/ukp_clock.c        | 111 +++++++++++++++++++++++
 lib/libc/upmap/ukp_getpid.c       |  86 ++++++++++++++++++
 lib/libc/upmap/ukp_setproctitle.c |  75 ++++++++++++++++
 lib/libc/upmap/upmap.c            | 184 ++++++++++++++++++++++++++++++++++++++
 lib/libc/upmap/upmap.h            |  47 ++++++++++
 sys/kern/kern_exec.c              |   2 +
 sys/kern/kern_exit.c              |   2 +
 sys/kern/kern_fork.c              |   6 +-
 sys/kern/kern_memio.c             |  31 ++++++-
 sys/kern/kern_proc.c              |   5 +-
 sys/sys/proc.h                    |   2 +-
 sys/sys/upmap.h                   |   6 +-
 16 files changed, 574 insertions(+), 10 deletions(-)
 create mode 100644 lib/libc/upmap/
 create mode 100644 lib/libc/upmap/
 create mode 100644 lib/libc/upmap/ukp_clock.c
 create mode 100644 lib/libc/upmap/ukp_getpid.c
 create mode 100644 lib/libc/upmap/ukp_setproctitle.c
 create mode 100644 lib/libc/upmap/upmap.c
 create mode 100644 lib/libc/upmap/upmap.h

DragonFly BSD source repository

More information about the Commits mailing list