On Tue, 04 May 2021 23:59:12 +0900, Hyeonggon Yoo said: > Does del_timer work well for timers that re-registers itself? > what if the timer is currently running, and del_timer is called, > and the running timer re-registers itself?
Minor nit: while the timer is running, there's no problem.
When the timer has *expired* and timer_callback() is running
is when you have a race condition.
So who's going to call del_timer()? The only thing that does that is
timer_exit. Soo... Apply some silly locking:
static int exiting = 0;
void timer_callback(struct timer_list *timer) {
struct timer_data *data = from_timer(data, timer, timer);
data->value++;
printk(KERN_INFO "[%s] value is = %d\n", __func__, data->value);
if (!exiting)
mod_timer(timer, jiffies + DELAY);
}
void __exit timer_exit(void) {
exiting = 1;
int ret = del_timer(&data.timer);
printk("[%s] deleting timer..., ret = %d\n", __func__, ret);
}
pgpIl7hjIOhNH.pgp
Description: PGP signature
_______________________________________________ Kernelnewbies mailing list [email protected] https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
