From: Daniel Phillips <phillips@innominate.de>
To: Manfred Spraul <manfred@colorfullife.com>,
Rusty Russell <rusty@linuxcare.com.au>,
Andrew Morton <andrewm@uow.edu.au>
Cc: linux-kernel@vger.kernel.org
Subject: Re: [RFC] New Improved Stronger Whiter Timers (was: Kernel Janitor)
Date: Tue, 30 Jan 2001 22:22:01 +0100 [thread overview]
Message-ID: <0101302224070B.28895@gimli> (raw)
In-Reply-To: <E14NPEr-0005LR-00@halfway> <01013021114409.28895@gimli>
In-Reply-To: <01013021114409.28895@gimli>
On Tue, 30 Jan 2001, Manfred Spraul wrote:
> This one is an UP and SMP race:
>
> spin_unlock_irq(&timerlist_lock);
> + if (timer->event)
> + {
> + if ((requeue = timer->event(data)))
> + {
> + timer->expires += requeue;
> + internal_add_timer(timer);
> + }
> + }
> + else
> + timer->function(data); /* bad old way */
> spin_lock_irq(&timerlist_lock);
>
> internal_add_timer assumes that the timerlist_lock is acquired.
Yes, oops, here is the fix.
--- ../2.4.1.clean/include/linux/timer.h Tue Jan 30 08:24:55 2001
+++ ./include/linux/timer.h Tue Jan 30 21:52:58 2001
@@ -22,6 +22,7 @@
unsigned long expires;
unsigned long data;
void (*function)(unsigned long);
+ unsigned long (*event)(unsigned long data);
};
extern void add_timer(struct timer_list * timer);
@@ -49,6 +50,9 @@
static inline void init_timer(struct timer_list * timer)
{
timer->list.next = timer->list.prev = NULL;
+ timer->function = NULL;
+ timer->event = NULL;
+ timer->data = 0;
}
static inline int timer_pending (const struct timer_list * timer)
--- ../2.4.1.clean/kernel/timer.c Sun Dec 10 18:53:19 2000
+++ ./kernel/timer.c Tue Jan 30 22:09:09 2001
@@ -301,19 +301,30 @@
curr = head->next;
if (curr != head) {
struct timer_list *timer;
- void (*fn)(unsigned long);
- unsigned long data;
+ unsigned long data, requeue;
timer = list_entry(curr, struct timer_list, list);
- fn = timer->function;
data= timer->data;
detach_timer(timer);
timer->list.next = timer->list.prev = NULL;
timer_enter(timer);
spin_unlock_irq(&timerlist_lock);
- fn(data);
- spin_lock_irq(&timerlist_lock);
+ if (timer->event)
+ {
+ requeue = timer->event(data);
+ spin_lock_irq(&timerlist_lock);
+ if (requeue)
+ {
+ timer->expires += requeue;
+ internal_add_timer(timer);
+ }
+ }
+ else
+ {
+ timer->function(data); /* bad old way */
+ spin_lock_irq(&timerlist_lock);
+ }
timer_exit();
goto repeat;
}
--
Daniel
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
Please read the FAQ at http://www.tux.org/lkml/
prev parent reply other threads:[~2001-01-30 21:26 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2001-01-27 17:11 [ANNOUNCE] Kernel Janitor's TODO list Arnaldo Carvalho de Melo
2001-01-28 15:20 ` David Woodhouse
2001-01-28 14:03 ` Arnaldo Carvalho de Melo
2001-01-28 15:49 ` Michael H. Warfield
2001-01-28 16:13 ` Andrew Morton
2001-01-28 14:28 ` Arnaldo Carvalho de Melo
2001-01-28 14:33 ` Arnaldo Carvalho de Melo
2001-01-30 1:05 ` Rusty Russell
2001-01-30 11:19 ` Daniel Phillips
2001-01-30 17:49 ` Daniel Phillips
2001-01-30 19:37 ` [RFC] New Improved Stronger Whiter Timers (was: Kernel Janitor) Daniel Phillips
2001-01-30 21:22 ` Daniel Phillips [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=0101302224070B.28895@gimli \
--to=phillips@innominate.de \
--cc=andrewm@uow.edu.au \
--cc=linux-kernel@vger.kernel.org \
--cc=manfred@colorfullife.com \
--cc=rusty@linuxcare.com.au \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox