Commit 0903b016 authored by Patrick McHardy's avatar Patrick McHardy

[PKT_SCHED]: Use get_cycles() for PSCHED_CPU clock source

Signed-off-by: default avatarPatrick McHardy <kaber@trash.net>
Signed-off-by: default avatarDavid S. Miller <davem@redhat.com>
parent 9f56f64c
...@@ -16,11 +16,6 @@ ...@@ -16,11 +16,6 @@
#include <linux/module.h> #include <linux/module.h>
#include <linux/rtnetlink.h> #include <linux/rtnetlink.h>
#ifdef CONFIG_X86_TSC
#include <asm/msr.h>
#endif
struct rtattr; struct rtattr;
struct Qdisc; struct Qdisc;
...@@ -235,41 +230,27 @@ typedef long psched_tdiff_t; ...@@ -235,41 +230,27 @@ typedef long psched_tdiff_t;
#define PSCHED_JIFFIE2US(delay) ((delay)<<PSCHED_JSCALE) #define PSCHED_JIFFIE2US(delay) ((delay)<<PSCHED_JSCALE)
#elif PSCHED_CLOCK_SOURCE == PSCHED_CPU #elif PSCHED_CLOCK_SOURCE == PSCHED_CPU
#include <asm/timex.h>
extern psched_tdiff_t psched_clock_per_hz; extern psched_tdiff_t psched_clock_per_hz;
extern int psched_clock_scale; extern int psched_clock_scale;
#define PSCHED_US2JIFFIE(delay) (((delay)+psched_clock_per_hz-1)/psched_clock_per_hz)
#define PSCHED_JIFFIE2US(delay) ((delay)*psched_clock_per_hz)
#ifdef CONFIG_X86_TSC
#define PSCHED_GET_TIME(stamp) \
({ u64 __cur; \
rdtscll(__cur); \
(stamp) = __cur>>psched_clock_scale; \
})
#elif defined (__alpha__)
#define PSCHED_WATCHER u32
extern psched_time_t psched_time_base; extern psched_time_t psched_time_base;
extern PSCHED_WATCHER psched_time_mark; extern cycles_t psched_time_mark;
#define PSCHED_GET_TIME(stamp) \ #define PSCHED_GET_TIME(stamp) \
({ u32 __res; \ do { \
__asm__ __volatile__ ("rpcc %0" : "r="(__res)); \ cycles_t cur = get_cycles(); \
if (__res <= psched_time_mark) psched_time_base += 0x100000000UL; \ if (sizeof(cycles_t) == sizeof(u32)) { \
psched_time_mark = __res; \ if (cur <= psched_time_mark) \
(stamp) = (psched_time_base + __res)>>psched_clock_scale; \ psched_time_base += 0x100000000ULL; \
}) psched_time_mark = cur; \
(stamp) = (psched_time_base + cur)>>psched_clock_scale; \
#else } else { \
(stamp) = cur>>psched_clock_scale; \
#error PSCHED_CLOCK_SOURCE=PSCHED_CPU is not supported on this arch. } \
} while (0)
#endif /* ARCH */ #define PSCHED_US2JIFFIE(delay) (((delay)+psched_clock_per_hz-1)/psched_clock_per_hz)
#define PSCHED_JIFFIE2US(delay) ((delay)*psched_clock_per_hz)
#endif /* PSCHED_CLOCK_SOURCE == PSCHED_JIFFIES */ #endif /* PSCHED_CLOCK_SOURCE == PSCHED_JIFFIES */
......
...@@ -1109,25 +1109,27 @@ int psched_clock_scale; ...@@ -1109,25 +1109,27 @@ int psched_clock_scale;
EXPORT_SYMBOL(psched_clock_per_hz); EXPORT_SYMBOL(psched_clock_per_hz);
EXPORT_SYMBOL(psched_clock_scale); EXPORT_SYMBOL(psched_clock_scale);
#ifdef PSCHED_WATCHER
psched_time_t psched_time_base; psched_time_t psched_time_base;
PSCHED_WATCHER psched_time_mark; cycles_t psched_time_mark;
EXPORT_SYMBOL(psched_time_mark); EXPORT_SYMBOL(psched_time_mark);
EXPORT_SYMBOL(psched_time_base); EXPORT_SYMBOL(psched_time_base);
/*
* Periodically adjust psched_time_base to avoid overflow
* with 32-bit get_cycles(). Safe up to 4GHz CPU.
*/
static void psched_tick(unsigned long); static void psched_tick(unsigned long);
static struct timer_list psched_timer = TIMER_INITIALIZER(psched_tick, 0, 0); static struct timer_list psched_timer = TIMER_INITIALIZER(psched_tick, 0, 0);
static void psched_tick(unsigned long dummy) static void psched_tick(unsigned long dummy)
{ {
if (sizeof(cycles_t) == sizeof(u32)) {
psched_time_t dummy_stamp; psched_time_t dummy_stamp;
PSCHED_GET_TIME(dummy_stamp); PSCHED_GET_TIME(dummy_stamp);
/* It is OK up to 4GHz cpu */
psched_timer.expires = jiffies + 1*HZ; psched_timer.expires = jiffies + 1*HZ;
add_timer(&psched_timer); add_timer(&psched_timer);
}
} }
#endif
int __init psched_calibrate_clock(void) int __init psched_calibrate_clock(void)
{ {
...@@ -1137,9 +1139,7 @@ int __init psched_calibrate_clock(void) ...@@ -1137,9 +1139,7 @@ int __init psched_calibrate_clock(void)
long rdelay; long rdelay;
unsigned long stop; unsigned long stop;
#ifdef PSCHED_WATCHER
psched_tick(0); psched_tick(0);
#endif
stop = jiffies + HZ/10; stop = jiffies + HZ/10;
PSCHED_GET_TIME(stamp); PSCHED_GET_TIME(stamp);
do_gettimeofday(&tv); do_gettimeofday(&tv);
......
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