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

Matthew Dillon dillon at crater.dragonflybsd.org
Thu Oct 16 14:58:09 PDT 2014


commit 12081e8713d2b7fa4ca9082092d907c46b9a81f4
Author: Matthew Dillon <dillon at apollo.backplane.com>
Date:   Thu Oct 16 14:54:56 2014 -0700

    kernel - Add /dev/upmap and /dev/kpmap and sys/upmap.h (2)
    
    * Disallow writing to kpmap.
    
    * Handle cpu read/update races against ts_uptime and ts_realtime by
      making these arrays[2] and using kpmap->upticks to tell userland
      which one is stable.
    
      The procedure is as follows:
    
    	struct timespec ts_uptime;
    	struct timespec ts_realtime;
    	int w;
    
            do {
                    w = kpmap->upticks;
                    cpu_lfence();
                    ts_uptime = kpmap->ts_uptime[w & 1];
                    ts_realtime = kpmap->ts_realtime[w & 1];
                    cpu_lfence();
                    w = kpmap->upticks - w;
            } while (w > 1);
    
      This procedure avoids having to loop in all standard cases including
      the nominal kernel update / userland read race.  It will only loop if
      the kernel deschedules the user process for > 1 tick during the access
      sequence.

Summary of changes:
 sys/kern/kern_clock.c | 14 +++++++++++---
 sys/kern/kern_memio.c | 23 +++++++++++++++++++----
 sys/sys/upmap.h       | 21 +++++++++++++++++----
 3 files changed, 47 insertions(+), 11 deletions(-)

http://gitweb.dragonflybsd.org/dragonfly.git/commitdiff/12081e8713d2b7fa4ca9082092d907c46b9a81f4


-- 
DragonFly BSD source repository



More information about the Commits mailing list