~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/arch/x86/entry/vsyscall/vsyscall_gtod.c

Version: ~ [ linux-5.5-rc1 ] ~ [ linux-5.4.2 ] ~ [ linux-5.3.15 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.88 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.158 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.206 ] ~ [ linux-4.8.17 ] ~ [ linux-4.7.10 ] ~ [ linux-4.6.7 ] ~ [ linux-4.5.7 ] ~ [ linux-4.4.206 ] ~ [ linux-4.3.6 ] ~ [ linux-4.2.8 ] ~ [ linux-4.1.52 ] ~ [ linux-4.0.9 ] ~ [ linux-3.19.8 ] ~ [ linux-3.18.140 ] ~ [ linux-3.17.8 ] ~ [ linux-3.16.78 ] ~ [ linux-3.15.10 ] ~ [ linux-3.14.79 ] ~ [ linux-3.13.11 ] ~ [ linux-3.12.74 ] ~ [ linux-3.11.10 ] ~ [ linux-3.10.108 ] ~ [ linux-3.9.11 ] ~ [ linux-3.8.13 ] ~ [ linux-3.7.10 ] ~ [ linux-3.6.11 ] ~ [ linux-3.5.7 ] ~ [ linux-3.4.113 ] ~ [ linux-3.3.8 ] ~ [ linux-3.2.102 ] ~ [ linux-3.1.10 ] ~ [ linux-3.0.101 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.5 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  1 /*
  2  *  Copyright (C) 2001 Andrea Arcangeli <andrea@suse.de> SuSE
  3  *  Copyright 2003 Andi Kleen, SuSE Labs.
  4  *
  5  *  Modified for x86 32 bit architecture by
  6  *  Stefani Seibold <stefani@seibold.net>
  7  *  sponsored by Rohde & Schwarz GmbH & Co. KG Munich/Germany
  8  *
  9  *  Thanks to hpa@transmeta.com for some useful hint.
 10  *  Special thanks to Ingo Molnar for his early experience with
 11  *  a different vsyscall implementation for Linux/IA32 and for the name.
 12  *
 13  */
 14 
 15 #include <linux/timekeeper_internal.h>
 16 #include <asm/vgtod.h>
 17 #include <asm/vvar.h>
 18 
 19 int vclocks_used __read_mostly;
 20 
 21 DEFINE_VVAR(struct vsyscall_gtod_data, vsyscall_gtod_data);
 22 
 23 void update_vsyscall_tz(void)
 24 {
 25         vsyscall_gtod_data.tz_minuteswest = sys_tz.tz_minuteswest;
 26         vsyscall_gtod_data.tz_dsttime = sys_tz.tz_dsttime;
 27 }
 28 
 29 void update_vsyscall(struct timekeeper *tk)
 30 {
 31         int vclock_mode = tk->tkr_mono.clock->archdata.vclock_mode;
 32         struct vsyscall_gtod_data *vdata = &vsyscall_gtod_data;
 33 
 34         /* Mark the new vclock used. */
 35         BUILD_BUG_ON(VCLOCK_MAX >= 32);
 36         WRITE_ONCE(vclocks_used, READ_ONCE(vclocks_used) | (1 << vclock_mode));
 37 
 38         gtod_write_begin(vdata);
 39 
 40         /* copy vsyscall data */
 41         vdata->vclock_mode      = vclock_mode;
 42         vdata->cycle_last       = tk->tkr_mono.cycle_last;
 43         vdata->mask             = tk->tkr_mono.mask;
 44         vdata->mult             = tk->tkr_mono.mult;
 45         vdata->shift            = tk->tkr_mono.shift;
 46 
 47         vdata->wall_time_sec            = tk->xtime_sec;
 48         vdata->wall_time_snsec          = tk->tkr_mono.xtime_nsec;
 49 
 50         vdata->monotonic_time_sec       = tk->xtime_sec
 51                                         + tk->wall_to_monotonic.tv_sec;
 52         vdata->monotonic_time_snsec     = tk->tkr_mono.xtime_nsec
 53                                         + ((u64)tk->wall_to_monotonic.tv_nsec
 54                                                 << tk->tkr_mono.shift);
 55         while (vdata->monotonic_time_snsec >=
 56                                         (((u64)NSEC_PER_SEC) << tk->tkr_mono.shift)) {
 57                 vdata->monotonic_time_snsec -=
 58                                         ((u64)NSEC_PER_SEC) << tk->tkr_mono.shift;
 59                 vdata->monotonic_time_sec++;
 60         }
 61 
 62         vdata->wall_time_coarse_sec     = tk->xtime_sec;
 63         vdata->wall_time_coarse_nsec    = (long)(tk->tkr_mono.xtime_nsec >>
 64                                                  tk->tkr_mono.shift);
 65 
 66         vdata->monotonic_time_coarse_sec =
 67                 vdata->wall_time_coarse_sec + tk->wall_to_monotonic.tv_sec;
 68         vdata->monotonic_time_coarse_nsec =
 69                 vdata->wall_time_coarse_nsec + tk->wall_to_monotonic.tv_nsec;
 70 
 71         while (vdata->monotonic_time_coarse_nsec >= NSEC_PER_SEC) {
 72                 vdata->monotonic_time_coarse_nsec -= NSEC_PER_SEC;
 73                 vdata->monotonic_time_coarse_sec++;
 74         }
 75 
 76         gtod_write_end(vdata);
 77 }
 78 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | Wiki (Japanese) | Wiki (English) | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

osdn.jp