git://ftp.safe.ca
/
safe
/
jmp
/
linux-2.6
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
ocfs2: take mle reference during migration
[safe/jmp/linux-2.6]
/
kernel
/
hrtimer.c
diff --git
a/kernel/hrtimer.c
b/kernel/hrtimer.c
index
658d49f
..
55601b3
100644
(file)
--- a/
kernel/hrtimer.c
+++ b/
kernel/hrtimer.c
@@
-98,7
+98,6
@@
static DEFINE_PER_CPU(struct hrtimer_base, hrtimer_bases[MAX_HRTIMER_BASES]) =
/**
* ktime_get_ts - get the monotonic clock in timespec format
/**
* ktime_get_ts - get the monotonic clock in timespec format
- *
* @ts: pointer to timespec variable
*
* The function calculates the monotonic clock from the realtime
* @ts: pointer to timespec variable
*
* The function calculates the monotonic clock from the realtime
@@
-238,7
+237,6
@@
lock_hrtimer_base(const struct hrtimer *timer, unsigned long *flags)
# ifndef CONFIG_KTIME_SCALAR
/**
* ktime_add_ns - Add a scalar nanoseconds value to a ktime_t variable
# ifndef CONFIG_KTIME_SCALAR
/**
* ktime_add_ns - Add a scalar nanoseconds value to a ktime_t variable
- *
* @kt: addend
* @nsec: the scalar nsec value to add
*
* @kt: addend
* @nsec: the scalar nsec value to add
*
@@
-266,7
+264,7
@@
ktime_t ktime_add_ns(const ktime_t kt, u64 nsec)
/*
* Divide a ktime value by a nanosecond value
*/
/*
* Divide a ktime value by a nanosecond value
*/
-static unsigned long ktime_divns(const ktime_t kt,
nsec_t
div)
+static unsigned long ktime_divns(const ktime_t kt,
s64
div)
{
u64 dclc, inc, dns;
int sft = 0;
{
u64 dclc, inc, dns;
int sft = 0;
@@
-299,7
+297,6
@@
void unlock_hrtimer_base(const struct hrtimer *timer, unsigned long *flags)
/**
* hrtimer_forward - forward the timer expiry
/**
* hrtimer_forward - forward the timer expiry
- *
* @timer: hrtimer to forward
* @now: forward past this time
* @interval: the interval to forward
* @timer: hrtimer to forward
* @now: forward past this time
* @interval: the interval to forward
@@
-322,7
+319,7
@@
hrtimer_forward(struct hrtimer *timer, ktime_t now, ktime_t interval)
interval.tv64 = timer->base->resolution.tv64;
if (unlikely(delta.tv64 >= interval.tv64)) {
interval.tv64 = timer->base->resolution.tv64;
if (unlikely(delta.tv64 >= interval.tv64)) {
-
nsec_t
incr = ktime_to_ns(interval);
+
s64
incr = ktime_to_ns(interval);
orun = ktime_divns(delta, incr);
timer->expires = ktime_add_ns(timer->expires, incr * orun);
orun = ktime_divns(delta, incr);
timer->expires = ktime_add_ns(timer->expires, incr * orun);
@@
-393,7
+390,7
@@
static void __remove_hrtimer(struct hrtimer *timer, struct hrtimer_base *base)
if (base->first == &timer->node)
base->first = rb_next(&timer->node);
rb_erase(&timer->node, &base->active);
if (base->first == &timer->node)
base->first = rb_next(&timer->node);
rb_erase(&timer->node, &base->active);
-
timer->node.rb_parent = HRTIMER_INACTIVE
;
+
rb_set_parent(&timer->node, &timer->node)
;
}
/*
}
/*
@@
-411,7
+408,6
@@
remove_hrtimer(struct hrtimer *timer, struct hrtimer_base *base)
/**
* hrtimer_start - (re)start an relative timer on the current CPU
/**
* hrtimer_start - (re)start an relative timer on the current CPU
- *
* @timer: the timer to be added
* @tim: expiry time
* @mode: expiry mode: absolute (HRTIMER_ABS) or relative (HRTIMER_REL)
* @timer: the timer to be added
* @tim: expiry time
* @mode: expiry mode: absolute (HRTIMER_ABS) or relative (HRTIMER_REL)
@@
-456,17
+452,17
@@
hrtimer_start(struct hrtimer *timer, ktime_t tim, const enum hrtimer_mode mode)
return ret;
}
return ret;
}
+EXPORT_SYMBOL_GPL(hrtimer_start);
/**
* hrtimer_try_to_cancel - try to deactivate a timer
/**
* hrtimer_try_to_cancel - try to deactivate a timer
- *
* @timer: hrtimer to stop
*
* Returns:
* 0 when the timer was not active
* 1 when the timer was active
* -1 when the timer is currently excuting the callback function and
* @timer: hrtimer to stop
*
* Returns:
* 0 when the timer was not active
* 1 when the timer was active
* -1 when the timer is currently excuting the callback function and
- * can
not be stopped
+ * cannot be stopped
*/
int hrtimer_try_to_cancel(struct hrtimer *timer)
{
*/
int hrtimer_try_to_cancel(struct hrtimer *timer)
{
@@
-484,10
+480,10
@@
int hrtimer_try_to_cancel(struct hrtimer *timer)
return ret;
}
return ret;
}
+EXPORT_SYMBOL_GPL(hrtimer_try_to_cancel);
/**
* hrtimer_cancel - cancel a timer and wait for the handler to finish.
/**
* hrtimer_cancel - cancel a timer and wait for the handler to finish.
- *
* @timer: the timer to be cancelled
*
* Returns:
* @timer: the timer to be cancelled
*
* Returns:
@@
-501,12
+497,13
@@
int hrtimer_cancel(struct hrtimer *timer)
if (ret >= 0)
return ret;
if (ret >= 0)
return ret;
+ cpu_relax();
}
}
}
}
+EXPORT_SYMBOL_GPL(hrtimer_cancel);
/**
* hrtimer_get_remaining - get remaining time for the timer
/**
* hrtimer_get_remaining - get remaining time for the timer
- *
* @timer: the timer to read
*/
ktime_t hrtimer_get_remaining(const struct hrtimer *timer)
* @timer: the timer to read
*/
ktime_t hrtimer_get_remaining(const struct hrtimer *timer)
@@
-521,6
+518,7
@@
ktime_t hrtimer_get_remaining(const struct hrtimer *timer)
return rem;
}
return rem;
}
+EXPORT_SYMBOL_GPL(hrtimer_get_remaining);
#ifdef CONFIG_NO_IDLE_HZ
/**
#ifdef CONFIG_NO_IDLE_HZ
/**
@@
-559,7
+557,6
@@
ktime_t hrtimer_get_next_event(void)
/**
* hrtimer_init - initialize a timer to the given clock
/**
* hrtimer_init - initialize a timer to the given clock
- *
* @timer: the timer to be initialized
* @clock_id: the clock to be used
* @mode: timer mode abs/rel
* @timer: the timer to be initialized
* @clock_id: the clock to be used
* @mode: timer mode abs/rel
@@
-571,18
+568,18
@@
void hrtimer_init(struct hrtimer *timer, clockid_t clock_id,
memset(timer, 0, sizeof(struct hrtimer));
memset(timer, 0, sizeof(struct hrtimer));
- bases =
per_cpu(hrtimer_bases, raw_smp_processor_id()
);
+ bases =
__raw_get_cpu_var(hrtimer_bases
);
if (clock_id == CLOCK_REALTIME && mode != HRTIMER_ABS)
clock_id = CLOCK_MONOTONIC;
timer->base = &bases[clock_id];
if (clock_id == CLOCK_REALTIME && mode != HRTIMER_ABS)
clock_id = CLOCK_MONOTONIC;
timer->base = &bases[clock_id];
-
timer->node.rb_parent = HRTIMER_INACTIVE
;
+
rb_set_parent(&timer->node, &timer->node)
;
}
}
+EXPORT_SYMBOL_GPL(hrtimer_init);
/**
* hrtimer_get_res - get the timer resolution for a clock
/**
* hrtimer_get_res - get the timer resolution for a clock
- *
* @which_clock: which clock to query
* @tp: pointer to timespec variable to store the resolution
*
* @which_clock: which clock to query
* @tp: pointer to timespec variable to store the resolution
*
@@
-593,11
+590,12
@@
int hrtimer_get_res(const clockid_t which_clock, struct timespec *tp)
{
struct hrtimer_base *bases;
{
struct hrtimer_base *bases;
- bases =
per_cpu(hrtimer_bases, raw_smp_processor_id()
);
+ bases =
__raw_get_cpu_var(hrtimer_bases
);
*tp = ktime_to_timespec(bases[which_clock].resolution);
return 0;
}
*tp = ktime_to_timespec(bases[which_clock].resolution);
return 0;
}
+EXPORT_SYMBOL_GPL(hrtimer_get_res);
/*
* Expire the per base hrtimer-queue:
/*
* Expire the per base hrtimer-queue:
@@
-606,6
+604,9
@@
static inline void run_hrtimer_queue(struct hrtimer_base *base)
{
struct rb_node *node;
{
struct rb_node *node;
+ if (!base->first)
+ return;
+
if (base->get_softirq_time)
base->softirq_time = base->get_softirq_time();
if (base->get_softirq_time)
base->softirq_time = base->get_softirq_time();
@@
-613,21
+614,19
@@
static inline void run_hrtimer_queue(struct hrtimer_base *base)
while ((node = base->first)) {
struct hrtimer *timer;
while ((node = base->first)) {
struct hrtimer *timer;
- int (*fn)(
void
*);
+ int (*fn)(
struct hrtimer
*);
int restart;
int restart;
- void *data;
timer = rb_entry(node, struct hrtimer, node);
if (base->softirq_time.tv64 <= timer->expires.tv64)
break;
fn = timer->function;
timer = rb_entry(node, struct hrtimer, node);
if (base->softirq_time.tv64 <= timer->expires.tv64)
break;
fn = timer->function;
- data = timer->data;
set_curr_timer(base, timer);
__remove_hrtimer(timer, base);
spin_unlock_irq(&base->lock);
set_curr_timer(base, timer);
__remove_hrtimer(timer, base);
spin_unlock_irq(&base->lock);
- restart = fn(
data
);
+ restart = fn(
timer
);
spin_lock_irq(&base->lock);
spin_lock_irq(&base->lock);
@@
-657,29
+656,28
@@
void hrtimer_run_queues(void)
/*
* Sleep related functions:
*/
/*
* Sleep related functions:
*/
-
-struct sleep_hrtimer {
- struct hrtimer timer;
- struct task_struct *task;
- int expired;
-};
-
-static int nanosleep_wakeup(void *data)
+static int hrtimer_wakeup(struct hrtimer *timer)
{
{
- struct sleep_hrtimer *t = data;
+ struct hrtimer_sleeper *t =
+ container_of(timer, struct hrtimer_sleeper, timer);
+ struct task_struct *task = t->task;
- t->expired = 1;
- wake_up_process(t->task);
+ t->task = NULL;
+ if (task)
+ wake_up_process(task);
return HRTIMER_NORESTART;
}
return HRTIMER_NORESTART;
}
-
static int __sched do_nanosleep(struct sleep_hrtimer *t, enum hrtimer_mode mode
)
+
void hrtimer_init_sleeper(struct hrtimer_sleeper *sl, task_t *task
)
{
{
- t->timer.function = nanosleep_wakeup;
- t->timer.data = t;
- t->task = current;
- t->expired = 0;
+ sl->timer.function = hrtimer_wakeup;
+ sl->task = task;
+}
+
+static int __sched do_nanosleep(struct hrtimer_sleeper *t, enum hrtimer_mode mode)
+{
+ hrtimer_init_sleeper(t, current);
do {
set_current_state(TASK_INTERRUPTIBLE);
do {
set_current_state(TASK_INTERRUPTIBLE);
@@
-687,18
+685,17
@@
static int __sched do_nanosleep(struct sleep_hrtimer *t, enum hrtimer_mode mode)
schedule();
schedule();
- if (unlikely(!t->expired)) {
- hrtimer_cancel(&t->timer);
- mode = HRTIMER_ABS;
- }
- } while (!t->expired && !signal_pending(current));
+ hrtimer_cancel(&t->timer);
+ mode = HRTIMER_ABS;
+
+ } while (t->task && !signal_pending(current));
- return t->
expired
;
+ return t->
task == NULL
;
}
static long __sched nanosleep_restart(struct restart_block *restart)
{
}
static long __sched nanosleep_restart(struct restart_block *restart)
{
- struct
sleep_hrtim
er t;
+ struct
hrtimer_sleep
er t;
struct timespec __user *rmtp;
struct timespec tu;
ktime_t time;
struct timespec __user *rmtp;
struct timespec tu;
ktime_t time;
@@
-731,7
+728,7
@@
long hrtimer_nanosleep(struct timespec *rqtp, struct timespec __user *rmtp,
const enum hrtimer_mode mode, const clockid_t clockid)
{
struct restart_block *restart;
const enum hrtimer_mode mode, const clockid_t clockid)
{
struct restart_block *restart;
- struct
sleep_hrtim
er t;
+ struct
hrtimer_sleep
er t;
struct timespec tu;
ktime_t rem;
struct timespec tu;
ktime_t rem;
@@
-836,7
+833,7
@@
static void migrate_hrtimers(int cpu)
}
#endif /* CONFIG_HOTPLUG_CPU */
}
#endif /* CONFIG_HOTPLUG_CPU */
-static int
__devinit
hrtimer_cpu_notify(struct notifier_block *self,
+static int hrtimer_cpu_notify(struct notifier_block *self,
unsigned long action, void *hcpu)
{
long cpu = (long)hcpu;
unsigned long action, void *hcpu)
{
long cpu = (long)hcpu;
@@
-860,7
+857,7
@@
static int __devinit hrtimer_cpu_notify(struct notifier_block *self,
return NOTIFY_OK;
}
return NOTIFY_OK;
}
-static struct notifier_block
__devinitdata
hrtimers_nb = {
+static struct notifier_block hrtimers_nb = {
.notifier_call = hrtimer_cpu_notify,
};
.notifier_call = hrtimer_cpu_notify,
};