linux-rt-users.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] kthread: Mark timer used by delayed kthread works as IRQ safe
@ 2020-02-17 12:07 Petr Mladek
  2020-02-19 15:22 ` Tejun Heo
  0 siblings, 1 reply; 4+ messages in thread
From: Petr Mladek @ 2020-02-17 12:07 UTC (permalink / raw)
  To: Andrew Morton
  Cc: Tejun Heo, Grygorii Strashko, linux-rt-users, linux-arm-kernel,
	netdev, Richard Cochran, Thomas Gleixner, linux-kernel,
	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.

Reported-by: Grygorii Strashko <grygorii.strashko@ti.com>
Signed-off-by: Petr Mladek <pmladek@suse.com>
Tested-by: Grygorii Strashko <grygorii.strashko@ti.com>
---
This patch is result of a discussion about using the API, see
https://lkml.kernel.org/r/cfa886ad-e3b7-c0d2-3ff8-58d94170eab5@ti.com

 include/linux/kthread.h | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/include/linux/kthread.h b/include/linux/kthread.h
index 0f9da966934e..8bbcaad7ef0f 100644
--- a/include/linux/kthread.h
+++ b/include/linux/kthread.h
@@ -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);
-- 
2.16.4


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] kthread: Mark timer used by delayed kthread works as IRQ safe
  2020-02-17 12:07 [PATCH] kthread: Mark timer used by delayed kthread works as IRQ safe Petr Mladek
@ 2020-02-19 15:22 ` Tejun Heo
  2020-03-16 12:23   ` Grygorii Strashko
  0 siblings, 1 reply; 4+ messages in thread
From: Tejun Heo @ 2020-02-19 15:22 UTC (permalink / raw)
  To: Petr Mladek
  Cc: Andrew Morton, Grygorii Strashko, linux-rt-users,
	linux-arm-kernel, netdev, Richard Cochran, Thomas Gleixner,
	linux-kernel

On Mon, Feb 17, 2020 at 01:07:09PM +0100, Petr Mladek wrote:
> 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.
> 
> Reported-by: Grygorii Strashko <grygorii.strashko@ti.com>
> Signed-off-by: Petr Mladek <pmladek@suse.com>
> Tested-by: Grygorii Strashko <grygorii.strashko@ti.com>

Acked-by: Tejun Heo <tj@kernel.org>

Thanks.

-- 
tejun

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] kthread: Mark timer used by delayed kthread works as IRQ safe
  2020-02-19 15:22 ` Tejun Heo
@ 2020-03-16 12:23   ` Grygorii Strashko
  2020-03-24 10:46     ` Grygorii Strashko
  0 siblings, 1 reply; 4+ messages in thread
From: Grygorii Strashko @ 2020-03-16 12:23 UTC (permalink / raw)
  To: Tejun Heo, Petr Mladek
  Cc: Andrew Morton, linux-rt-users, linux-arm-kernel, netdev,
	Richard Cochran, Thomas Gleixner, linux-kernel

Hi Petr,

On 19/02/2020 17:22, Tejun Heo wrote:
> On Mon, Feb 17, 2020 at 01:07:09PM +0100, Petr Mladek wrote:
>> 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.
>>
>> Reported-by: Grygorii Strashko <grygorii.strashko@ti.com>
>> Signed-off-by: Petr Mladek <pmladek@suse.com>
>> Tested-by: Grygorii Strashko <grygorii.strashko@ti.com>
> 
> Acked-by: Tejun Heo <tj@kernel.org>

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

-- 
Best regards,
grygorii

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] kthread: Mark timer used by delayed kthread works as IRQ safe
  2020-03-16 12:23   ` Grygorii Strashko
@ 2020-03-24 10:46     ` Grygorii Strashko
  0 siblings, 0 replies; 4+ messages in thread
From: Grygorii Strashko @ 2020-03-24 10:46 UTC (permalink / raw)
  To: Tejun Heo, Petr Mladek
  Cc: linux-rt-users, netdev, Richard Cochran, linux-kernel,
	Andrew Morton, Thomas Gleixner, linux-arm-kernel

Hi All,

On 16/03/2020 14:23, Grygorii Strashko wrote:
> Hi Petr,
> 
> On 19/02/2020 17:22, Tejun Heo wrote:
>> On Mon, Feb 17, 2020 at 01:07:09PM +0100, Petr Mladek wrote:
>>> 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.
>>>
>>> Reported-by: Grygorii Strashko <grygorii.strashko@ti.com>
>>> Signed-off-by: Petr Mladek <pmladek@suse.com>
>>> Tested-by: Grygorii Strashko <grygorii.strashko@ti.com>
>>
>> Acked-by: Tejun Heo <tj@kernel.org>
> 
> 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/
-- 
Best regards,
grygorii

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2020-03-24 10:47 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-02-17 12:07 [PATCH] kthread: Mark timer used by delayed kthread works as IRQ safe Petr Mladek
2020-02-19 15:22 ` Tejun Heo
2020-03-16 12:23   ` Grygorii Strashko
2020-03-24 10:46     ` Grygorii Strashko

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).