Skip to content

Commit ad01423

Browse files
Sebastian Andrzej SiewiorKAGA-KOKO
authored andcommitted
kthread: Do not use TIMER_IRQSAFE
The TIMER_IRQSAFE usage was introduced in commit 22597dc ("kthread: initial support for delayed kthread work") which modelled the delayed kthread code after workqueue's code. The workqueue code requires the flag TIMER_IRQSAFE for synchronisation purpose. This is not true for kthread's delay timer since all operations occur under a lock. Remove TIMER_IRQSAFE from the timer initialisation and use timer_setup() for initialisation purpose which is the official function. Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de> Signed-off-by: Thomas Gleixner <tglx@linutronix.de> Reviewed-by: Petr Mladek <pmladek@suse.com> Link: https://lkml.kernel.org/r/20190212162554.19779-2-bigeasy@linutronix.de
1 parent fe99a4f commit ad01423

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

include/linux/kthread.h

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -164,9 +164,8 @@ extern void __kthread_init_worker(struct kthread_worker *worker,
164164
#define kthread_init_delayed_work(dwork, fn) \
165165
do { \
166166
kthread_init_work(&(dwork)->work, (fn)); \
167-
__init_timer(&(dwork)->timer, \
168-
kthread_delayed_work_timer_fn, \
169-
TIMER_IRQSAFE); \
167+
timer_setup(&(dwork)->timer, \
168+
kthread_delayed_work_timer_fn, 0); \
170169
} while (0)
171170

172171
int kthread_worker_fn(void *worker_ptr);

kernel/kthread.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -835,6 +835,7 @@ void kthread_delayed_work_timer_fn(struct timer_list *t)
835835
struct kthread_delayed_work *dwork = from_timer(dwork, t, timer);
836836
struct kthread_work *work = &dwork->work;
837837
struct kthread_worker *worker = work->worker;
838+
unsigned long flags;
838839

839840
/*
840841
* This might happen when a pending work is reinitialized.
@@ -843,7 +844,7 @@ void kthread_delayed_work_timer_fn(struct timer_list *t)
843844
if (WARN_ON_ONCE(!worker))
844845
return;
845846

846-
raw_spin_lock(&worker->lock);
847+
raw_spin_lock_irqsave(&worker->lock, flags);
847848
/* Work must not be used with >1 worker, see kthread_queue_work(). */
848849
WARN_ON_ONCE(work->worker != worker);
849850

@@ -852,7 +853,7 @@ void kthread_delayed_work_timer_fn(struct timer_list *t)
852853
list_del_init(&work->node);
853854
kthread_insert_work(worker, work, &worker->work_list);
854855

855-
raw_spin_unlock(&worker->lock);
856+
raw_spin_unlock_irqrestore(&worker->lock, flags);
856857
}
857858
EXPORT_SYMBOL(kthread_delayed_work_timer_fn);
858859

0 commit comments

Comments
 (0)