Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 143389
b: refs/heads/master
c: b6ecfa9
h: refs/heads/master
i:
  143387: 16a32ef
v: v3
  • Loading branch information
Jan Glauber authored and Martin Schwidefsky committed Apr 14, 2009
1 parent 746ded6 commit 5561645
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 25 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 0436230148c55e3afbe5c57775a1fb44ba4834ac
refs/heads/master: b6ecfa9273e27b5c7ba04655eb44f78bf4db5b64
1 change: 1 addition & 0 deletions trunk/arch/s390/include/asm/timer.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ extern void init_virt_timer(struct vtimer_list *timer);
extern void add_virt_timer(void *new);
extern void add_virt_timer_periodic(void *new);
extern int mod_virt_timer(struct vtimer_list *timer, __u64 expires);
extern int mod_virt_timer_periodic(struct vtimer_list *timer, __u64 expires);
extern int del_virt_timer(struct vtimer_list *timer);

extern void init_cpu_vtimer(void);
Expand Down
57 changes: 33 additions & 24 deletions trunk/arch/s390/kernel/vtime.c
Original file line number Diff line number Diff line change
Expand Up @@ -425,17 +425,7 @@ void add_virt_timer_periodic(void *new)
}
EXPORT_SYMBOL(add_virt_timer_periodic);

/*
* If we change a pending timer the function must be called on the CPU
* where the timer is running on, e.g. by smp_call_function_single()
*
* The original mod_timer adds the timer if it is not pending. For
* compatibility we do the same. The timer will be added on the current
* CPU as a oneshot timer.
*
* returns whether it has modified a pending timer (1) or not (0)
*/
int mod_virt_timer(struct vtimer_list *timer, __u64 expires)
int __mod_vtimer(struct vtimer_list *timer, __u64 expires, int periodic)
{
struct vtimer_queue *vq;
unsigned long flags;
Expand All @@ -444,48 +434,67 @@ int mod_virt_timer(struct vtimer_list *timer, __u64 expires)
BUG_ON(!timer->function);
BUG_ON(!expires || expires > VTIMER_MAX_SLICE);

/*
* This is a common optimization triggered by the
* networking code - if the timer is re-modified
* to be the same thing then just return:
*/
if (timer->expires == expires && vtimer_pending(timer))
return 1;

cpu = get_cpu();
vq = &per_cpu(virt_cpu_timer, cpu);

/* check if we run on the right CPU */
BUG_ON(timer->cpu != cpu);

/* disable interrupts before test if timer is pending */
spin_lock_irqsave(&vq->lock, flags);

/* if timer isn't pending add it on the current CPU */
if (!vtimer_pending(timer)) {
spin_unlock_irqrestore(&vq->lock, flags);
/* we do not activate an interval timer with mod_virt_timer */
timer->interval = 0;

if (periodic)
timer->interval = expires;
else
timer->interval = 0;
timer->expires = expires;
timer->cpu = cpu;
internal_add_vtimer(timer);
return 0;
}

/* check if we run on the right CPU */
BUG_ON(timer->cpu != cpu);

list_del_init(&timer->entry);
timer->expires = expires;

/* also change the interval if we have an interval timer */
if (timer->interval)
if (periodic)
timer->interval = expires;

/* the timer can't expire anymore so we can release the lock */
spin_unlock_irqrestore(&vq->lock, flags);
internal_add_vtimer(timer);
return 1;
}

/*
* If we change a pending timer the function must be called on the CPU
* where the timer is running on.
*
* returns whether it has modified a pending timer (1) or not (0)
*/
int mod_virt_timer(struct vtimer_list *timer, __u64 expires)
{
return __mod_vtimer(timer, expires, 0);
}
EXPORT_SYMBOL(mod_virt_timer);

/*
* If we change a pending timer the function must be called on the CPU
* where the timer is running on.
*
* returns whether it has modified a pending timer (1) or not (0)
*/
int mod_virt_timer_periodic(struct vtimer_list *timer, __u64 expires)
{
return __mod_vtimer(timer, expires, 1);
}
EXPORT_SYMBOL(mod_virt_timer_periodic);

/*
* delete a virtual timer
*
Expand Down

0 comments on commit 5561645

Please sign in to comment.