public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH -mm] workqueue: debug possible endless loop in cancel_rearming_delayed_work
@ 2007-04-19  6:54 Jarek Poplawski
  2007-04-19  7:32 ` Ingo Molnar
                   ` (2 more replies)
  0 siblings, 3 replies; 15+ messages in thread
From: Jarek Poplawski @ 2007-04-19  6:54 UTC (permalink / raw)
  To: linux-kernel; +Cc: Ingo Molnar

Hi,

IMHO cancel_rearming_delayed_work is dangerous place:

- it assumes a work function always rearms (with no exception),
which probably isn't explained enough now (but anyway should
be checked in such loops);

- probably possible (theoretical) scenario: a few work
functions rearm themselves with very short, equal times;
before flush_workqueue ends, their timers are already
fired, so cancel_delayed_work has nothing to do.

Maybe this patch could check, if I'm not dreaming...

PS: of course the counter value below is a question of taste

Signed-off-by: Jarek Poplawski <jarkao2@o2.pl>

---

diff -Nurp 2.6.21-rc6-mm1-/kernel/workqueue.c 2.6.21-rc6-mm1/kernel/workqueue.c
--- 2.6.21-rc6-mm1-/kernel/workqueue.c	2007-04-18 20:07:45.000000000 +0200
+++ 2.6.21-rc6-mm1/kernel/workqueue.c	2007-04-18 20:15:44.000000000 +0200
@@ -557,9 +557,12 @@ void cancel_rearming_delayed_work(struct
 	/* Was it ever queued ? */
 	if (cwq != NULL) {
 		struct workqueue_struct *wq = cwq->wq;
+		int i = 1000;
 
-		while (!cancel_delayed_work(dwork))
+		while (!cancel_delayed_work(dwork)) {
 			flush_workqueue(wq);
+			BUG_ON(!i--);
+		}
 	}
 }
 EXPORT_SYMBOL(cancel_rearming_delayed_work);

^ permalink raw reply	[flat|nested] 15+ messages in thread
* [PATCH -mm] workqueue: debug possible endless loop in cancel_rearming_delayed_work
@ 2007-04-20 11:09 Jarek Poplawski
  0 siblings, 0 replies; 15+ messages in thread
From: Jarek Poplawski @ 2007-04-20 11:09 UTC (permalink / raw)
  To: linux-kernel; +Cc: Ingo Molnar, Oleg Nesterov

(take 2)

I'm not sure we've agreed enough, who'll resubmit, so here
it is with WARN_ON. If it was submited already - forget it.

Jarek P.

--->
IMHO cancel_rearming_delayed_work is dangerous place:

- it assumes a work function always rearms (with no exception),
which probably isn't explained enough now (but anyway should
be checked in such loops);

- probably possible (theoretical) scenario: a few work
functions rearm themselves with very short, equal times;
before flush_workqueue ends, their timers are already
fired, so cancel_delayed_work has nothing to do.

Maybe this patch could check, if I'm not dreaming...

PS: of course the counter value below is a question of taste

Signed-off-by: Jarek Poplawski <jarkao2@o2.pl>

---

diff -Nurp 2.6.21-rc6-mm1-/kernel/workqueue.c 2.6.21-rc6-mm1/kernel/workqueue.c
--- 2.6.21-rc6-mm1-/kernel/workqueue.c	2007-04-18 20:07:45.000000000 +0200
+++ 2.6.21-rc6-mm1/kernel/workqueue.c	2007-04-18 20:15:44.000000000 +0200
@@ -557,9 +557,12 @@ void cancel_rearming_delayed_work(struct
 	/* Was it ever queued ? */
 	if (cwq != NULL) {
 		struct workqueue_struct *wq = cwq->wq;
+		int i = 1000;
 
-		while (!cancel_delayed_work(dwork))
+		while (!cancel_delayed_work(dwork)) {
 			flush_workqueue(wq);
+			WARN_ON(!i--);
+		}
 	}
 }
 EXPORT_SYMBOL(cancel_rearming_delayed_work);


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

end of thread, other threads:[~2007-04-23  9:35 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-04-19  6:54 [PATCH -mm] workqueue: debug possible endless loop in cancel_rearming_delayed_work Jarek Poplawski
2007-04-19  7:32 ` Ingo Molnar
2007-04-19  8:28   ` Jarek Poplawski
2007-04-19 14:48   ` David Chinner
2007-04-19 14:46 ` David Chinner
2007-04-20  8:13   ` Jarek Poplawski
2007-04-20  8:53     ` David Chinner
2007-04-20 10:21       ` Jarek Poplawski
2007-04-20 11:01         ` David Chinner
2007-04-20 12:12           ` [PATCH] workqueue: cancel_rearming_delayed_work/workqueue usage warning Jarek Poplawski
2007-04-20 17:23             ` Oleg Nesterov
2007-04-23  9:41               ` Jarek Poplawski
2007-04-19 17:07 ` [PATCH -mm] workqueue: debug possible endless loop in cancel_rearming_delayed_work Chuck Ebbert
2007-04-20  7:14   ` Jarek Poplawski
  -- strict thread matches above, loose matches on Subject: below --
2007-04-20 11:09 Jarek Poplawski

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox