Skip to contentSkip to conversation

+ fix-soft-lockup-when-removing-netconsole-module.patch added to -mm tree

DISCUSSION Oleg Nesterov 2 participants 3 messages May 30, 2007 Networking

lore
Share & tools
lore
#0 lore raw
Quoted 4 lines · Jason Wessel

The netpoll_cleanup handler can hang the kernel if there is no work in the work queue because a call to cancel_rearming_delayed_work() with no work goes into an infinite loop.

This should not be true any longer, cancel_rearming_delayed_work() should work correctly in any case.

Could you please clarify?

Review void netpoll_cleanup(struct netpoll *np)

Quoted 10 lines
(quoted diff) +4 -0
@@ -771,30 +771,32 @@ void netpoll_cleanup(struct netpoll *np)
 
[...snip...]
 
+		if (atomic_dec_and_test(&npinfo->refcnt)) {
+			skb_queue_purge(&npinfo->arp_tx);
+			skb_queue_purge(&npinfo->txq);
+			if (delayed_work_pending(&npinfo->tx_work)) {
 				cancel_rearming_delayed_work(&npinfo->tx_work);
 				flush_scheduled_work();

But this "if (delayed_work_pending())" is racy anyway?

Oleg.

#1 lore raw
Quoted 10 lines · On Thu, 31 May 2007 01:01:37 +0400 Oleg Nesterov <[email protected]> wrote:
Quoted 4 lines · Jason Wessel

The netpoll_cleanup handler can hang the kernel if there is no work in the work queue because a call to cancel_rearming_delayed_work() with no work goes into an infinite loop.

This should not be true any longer, cancel_rearming_delayed_work() should work correctly in any case.

Could you please clarify?

We need a 2.6.21.x fix.

Quoted 4 lines
Quoted 4 lines
(quoted diff) +0 -0
@@ -771,30 +771,32 @@ void netpoll_cleanup(struct netpoll *np)
 
[...snip...]
Quoted 9 lines

Review

Quoted 6 lines
(quoted diff) +4 -0
+		if (atomic_dec_and_test(&npinfo->refcnt)) {
+			skb_queue_purge(&npinfo->arp_tx);
+			skb_queue_purge(&npinfo->txq);
+			if (delayed_work_pending(&npinfo->tx_work)) {
 				cancel_rearming_delayed_work(&npinfo->tx_work);
 				flush_scheduled_work();

But this "if (delayed_work_pending())" is racy anyway?

I guess so, a bit.

#2 lore raw
Quoted 10 lines · Andrew Morton
Quoted 6 lines · On Thu, 31 May 2007 01:01:37 +0400 Oleg Nesterov <[email protected]> wrote:
Quoted 4 lines · Jason Wessel

The netpoll_cleanup handler can hang the kernel if there is no work in the work queue because a call to cancel_rearming_delayed_work() with no work goes into an infinite loop.

Quoted 6 lines
Quoted 4 lines

This should not be true any longer, cancel_rearming_delayed_work() should work correctly in any case.

Could you please clarify?

We need a 2.6.21.x fix.

Ah, OK, sorry for noise.

Quoted 14 lines
Quoted 4 lines
Quoted 4 lines
(quoted diff) +0 -0
@@ -771,30 +771,32 @@ void netpoll_cleanup(struct netpoll *np)
 
[...snip...]
Quoted 9 lines

Review

Quoted 6 lines
(quoted diff) +4 -0
+		if (atomic_dec_and_test(&npinfo->refcnt)) {
+			skb_queue_purge(&npinfo->arp_tx);
+			skb_queue_purge(&npinfo->txq);
+			if (delayed_work_pending(&npinfo->tx_work)) {
 				cancel_rearming_delayed_work(&npinfo->tx_work);
 				flush_scheduled_work();

But this "if (delayed_work_pending())" is racy anyway?

Quoted 1 line

I guess so, a bit.

How about this COMPLETELY UNTESTED patch? (it borrows Tejun's double flush trick).

net/core/netpoll.c renamed from net/core/netpoll.c~ +9 -1
@@ -773,8 +773,16 @@ void netpoll_cleanup(struct netpoll *np)
 			if (atomic_dec_and_test(&npinfo->refcnt)) {
 				skb_queue_purge(&npinfo->arp_tx);
 				skb_queue_purge(&npinfo->txq);
-				cancel_rearming_delayed_work(&npinfo->tx_work);
+
 				flush_scheduled_work();
+				/*
+				 * the next invocation of queue_process() can't
+				 * re-schedule ->tx_work because ->txq is empty
+				 */
+				if (!cancel_delayed_work(&npinfo->tx_work)) {
+					/* may be queued, wait for completion */
+					flush_scheduled_work();
+				}
 
 				kfree(npinfo);
 			}