Skip to contentSkip to conversation

kthread: Mark timer used by delayed kthread works as IRQ safe

PATCH Applied Petr Mladek 3 participants 4 messages Feb 17, 2020 – Mar 24, 2020

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 kthread: Mark timer used by delayed kthread works as IRQ safe

The timer used by delayed kthread works are IRQ safe because the used kthread_delayed_work_timer_fn() is IRQ safe.

It is properly marked when initialized by KTHREAD_DELAYED_WORK_INIT(). But TIMER_IRQSAFE flag is missing when initialized by kthread_init_delayed_work().

The missing flag might trigger invalid warning from del_timer_sync() when kthread_mod_delayed_work() is called with interrupts disabled.

---
This patch is result of a discussion about using the API, see
https://lkml.kernel.org/r/[email protected]

 include/linux/kthread.h | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
include/linux/kthread.h +2 -1
index 0f9da966934e..8bbcaad7ef0f 100644
@@ -165,7 +165,8 @@ extern void __kthread_init_worker(struct kthread_worker *worker,
 	do {								\
 		kthread_init_work(&(dwork)->work, (fn));		\
 		timer_setup(&(dwork)->timer,				\
-			     kthread_delayed_work_timer_fn, 0);		\
+			     kthread_delayed_work_timer_fn,		\
+			     TIMER_IRQSAFE);				\
 	} while (0)
 
 int kthread_worker_fn(void *worker_ptr);
Signature · 1 line
2.16.4
Acked-by on v1 1/1
#1 lore raw
Quoted 7 lines · Petr Mladek

The timer used by delayed kthread works are IRQ safe because the used kthread_delayed_work_timer_fn() is IRQ safe.

It is properly marked when initialized by KTHREAD_DELAYED_WORK_INIT(). But TIMER_IRQSAFE flag is missing when initialized by kthread_init_delayed_work().

Quoted 6 lines

The missing flag might trigger invalid warning from del_timer_sync() when kthread_mod_delayed_work() is called with interrupts disabled.

Thanks.

Signature · 1 line
tejun
#2 lore raw

Hi Petr,

Quoted 8 lines · Tejun Heo
Quoted 7 lines · Petr Mladek

The timer used by delayed kthread works are IRQ safe because the used kthread_delayed_work_timer_fn() is IRQ safe.

It is properly marked when initialized by KTHREAD_DELAYED_WORK_INIT(). But TIMER_IRQSAFE flag is missing when initialized by kthread_init_delayed_work().

Quoted 8 lines
Quoted 6 lines

The missing flag might trigger invalid warning from del_timer_sync() when kthread_mod_delayed_work() is called with interrupts disabled.

I'm worry shouldn't this patch have "fixes" tag?

Signature · 7 lines
Best regards,
grygorii

_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
#3 lore raw

Hi All,

Quoted 14 lines · Grygorii Strashko

Hi Petr,

Quoted 11 lines · Tejun Heo
Quoted 10 lines · Petr Mladek

The timer used by delayed kthread works are IRQ safe because the used kthread_delayed_work_timer_fn() is IRQ safe.

It is properly marked when initialized by KTHREAD_DELAYED_WORK_INIT(). But TIMER_IRQSAFE flag is missing when initialized by kthread_init_delayed_work().

The missing flag might trigger invalid warning from del_timer_sync() when kthread_mod_delayed_work() is called with interrupts disabled.

Quoted 8 lines
Quoted 5 lines
Quoted 3 lines

I'm worry shouldn't this patch have "fixes" tag?

Sorry, the I'm disturbing you, but I have dependency from this path [1]. I can see it in -next: commit d7c8c7de96de ("kthread: mark timer used by delayed kthread works as IRQ safe"), but it does not present in net-next.

Any way this can be resolved?

[1] https://patchwork.ozlabs.org/cover/1259207/

Signature · 2 lines
Best regards,
grygorii