Commit ddc5057c authored by Linus Torvalds's avatar Linus Torvalds

Merge branch 'timers-urgent-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip

Pull timer fixes from Ingo Molnar:
 "One regression fix, and a couple of cleanups that clean up the code
  flow in areas that had high-profile bugs recently."

* 'timers-urgent-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip:
  time: Remove all direct references to timekeeper
  time: Clean up offs_real/wall_to_mono and offs_boot/total_sleep_time updates
  time: Clean up stray newlines
  time/jiffies: Rename ACTHZ to SHIFTED_HZ
  time/jiffies: Allow CLOCK_TICK_RATE to be undefined
  time: Fix casting issue in tk_set_xtime and tk_xtime_add
parents fcc1d2a9 4e250fdd
...@@ -39,9 +39,6 @@ ...@@ -39,9 +39,6 @@
# error Invalid value of HZ. # error Invalid value of HZ.
#endif #endif
/* LATCH is used in the interval timer and ftape setup. */
#define LATCH ((CLOCK_TICK_RATE + HZ/2) / HZ) /* For divider */
/* Suppose we want to divide two numbers NOM and DEN: NOM/DEN, then we can /* Suppose we want to divide two numbers NOM and DEN: NOM/DEN, then we can
* improve accuracy by shifting LSH bits, hence calculating: * improve accuracy by shifting LSH bits, hence calculating:
* (NOM << LSH) / DEN * (NOM << LSH) / DEN
...@@ -54,18 +51,30 @@ ...@@ -54,18 +51,30 @@
#define SH_DIV(NOM,DEN,LSH) ( (((NOM) / (DEN)) << (LSH)) \ #define SH_DIV(NOM,DEN,LSH) ( (((NOM) / (DEN)) << (LSH)) \
+ ((((NOM) % (DEN)) << (LSH)) + (DEN) / 2) / (DEN)) + ((((NOM) % (DEN)) << (LSH)) + (DEN) / 2) / (DEN))
/* HZ is the requested value. ACTHZ is actual HZ ("<< 8" is for accuracy) */ #ifdef CLOCK_TICK_RATE
#define ACTHZ (SH_DIV (CLOCK_TICK_RATE, LATCH, 8)) /* LATCH is used in the interval timer and ftape setup. */
# define LATCH ((CLOCK_TICK_RATE + HZ/2) / HZ) /* For divider */
/*
* HZ is the requested value. However the CLOCK_TICK_RATE may not allow
* for exactly HZ. So SHIFTED_HZ is high res HZ ("<< 8" is for accuracy)
*/
# define SHIFTED_HZ (SH_DIV(CLOCK_TICK_RATE, LATCH, 8))
#else
# define SHIFTED_HZ (HZ << 8)
#endif
/* TICK_NSEC is the time between ticks in nsec assuming real ACTHZ */ /* TICK_NSEC is the time between ticks in nsec assuming SHIFTED_HZ */
#define TICK_NSEC (SH_DIV (1000000UL * 1000, ACTHZ, 8)) #define TICK_NSEC (SH_DIV(1000000UL * 1000, SHIFTED_HZ, 8))
/* TICK_USEC is the time between ticks in usec assuming fake USER_HZ */ /* TICK_USEC is the time between ticks in usec assuming fake USER_HZ */
#define TICK_USEC ((1000000UL + USER_HZ/2) / USER_HZ) #define TICK_USEC ((1000000UL + USER_HZ/2) / USER_HZ)
/* TICK_USEC_TO_NSEC is the time between ticks in nsec assuming real ACTHZ and */ /*
/* a value TUSEC for TICK_USEC (can be set bij adjtimex) */ * TICK_USEC_TO_NSEC is the time between ticks in nsec assuming SHIFTED_HZ and
#define TICK_USEC_TO_NSEC(TUSEC) (SH_DIV (TUSEC * USER_HZ * 1000, ACTHZ, 8)) * a value TUSEC for TICK_USEC (can be set bij adjtimex)
*/
#define TICK_USEC_TO_NSEC(TUSEC) (SH_DIV(TUSEC * USER_HZ * 1000, SHIFTED_HZ, 8))
/* some arch's have a small-data section that can be accessed register-relative /* some arch's have a small-data section that can be accessed register-relative
* but that can only take up to, say, 4-byte variables. jiffies being part of * but that can only take up to, say, 4-byte variables. jiffies being part of
......
...@@ -232,7 +232,7 @@ struct timex { ...@@ -232,7 +232,7 @@ struct timex {
* estimated error = NTP dispersion. * estimated error = NTP dispersion.
*/ */
extern unsigned long tick_usec; /* USER_HZ period (usec) */ extern unsigned long tick_usec; /* USER_HZ period (usec) */
extern unsigned long tick_nsec; /* ACTHZ period (nsec) */ extern unsigned long tick_nsec; /* SHIFTED_HZ period (nsec) */
extern void ntp_init(void); extern void ntp_init(void);
extern void ntp_clear(void); extern void ntp_clear(void);
......
...@@ -37,7 +37,7 @@ ...@@ -37,7 +37,7 @@
* requested HZ value. It is also not recommended * requested HZ value. It is also not recommended
* for "tick-less" systems. * for "tick-less" systems.
*/ */
#define NSEC_PER_JIFFY ((u32)((((u64)NSEC_PER_SEC)<<8)/ACTHZ)) #define NSEC_PER_JIFFY ((u32)((((u64)NSEC_PER_SEC)<<8)/SHIFTED_HZ))
/* Since jiffies uses a simple NSEC_PER_JIFFY multiplier /* Since jiffies uses a simple NSEC_PER_JIFFY multiplier
* conversion, the .shift value could be zero. However * conversion, the .shift value could be zero. However
......
...@@ -28,7 +28,7 @@ DEFINE_SPINLOCK(ntp_lock); ...@@ -28,7 +28,7 @@ DEFINE_SPINLOCK(ntp_lock);
/* USER_HZ period (usecs): */ /* USER_HZ period (usecs): */
unsigned long tick_usec = TICK_USEC; unsigned long tick_usec = TICK_USEC;
/* ACTHZ period (nsecs): */ /* SHIFTED_HZ period (nsecs): */
unsigned long tick_nsec; unsigned long tick_nsec;
static u64 tick_length; static u64 tick_length;
......
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment