All of lore.kernel.org
 help / color / mirror / Atom feed
From: Olaf Kirch <okir@suse.de>
To: nfs@lists.sourceforge.net
Subject: [PATCH] prevent sunrpc deadlock with debug on
Date: Thu, 16 Dec 2004 17:57:14 +0100	[thread overview]
Message-ID: <20041216165714.GB2077@suse.de> (raw)

[-- Attachment #1: Type: text/plain, Size: 296 bytes --]

Here's a patch we added to our kernel a while ago, but which
I forgot to submit... here it is.

Olaf
-- 
Olaf Kirch     | Things that make Monday morning interesting, #2:
okir@suse.de   |        "We have 8,000 NFS mount points, why do we keep
---------------+ 	 running out of privileged ports?"

[-- Attachment #2: sunrpc-sched-deadlock --]
[-- Type: text/plain, Size: 1293 bytes --]

From: Shirly Ma <xma@us.ibm.com>
Subject: Prevent sunrpc deadlock with debugging turned on
References: 38960

This patch fixes a deadlock in the RPC code when debugging is enabled.

CPU 1:
	rpc_wake_up_task
		spin_lock_bh(&rpc_queue_lock);
		-> __rpc_wake_up_task
			-> rpc_show_tasks
				-> spin_lock(&rpc_sched_lock);

CPU 2:
	rpc_killall_tasks
		spin_lock(&rpc_sched_lock);
		-> rpc_wake_up_task()
			spin_lock_bh(&rpc_queue_lock);

This is a very rare condition, but it was actually observed several times
during test runs on ppc64.

Signed-off-by: Olaf Kirch <okir@suse.de>

diff -urN linux-2.6.5-7.13/net/sunrpc/sched.c linux-2.6.5-7.13p/net/sunrpc/sched.c
--- linux-2.6.5-7.13/net/sunrpc/sched.c	2004-04-30 10:46:58.000000000 -0500
+++ linux-2.6.5-7.13p/net/sunrpc/sched.c	2004-04-30 17:21:05.000000000 -0500
@@ -931,12 +931,16 @@
 	/*
 	 * Spin lock all_tasks to prevent changes...
 	 */
+again:
 	spin_lock(&rpc_sched_lock);
 	alltask_for_each(rovr, le, &all_tasks)
-		if (!clnt || rovr->tk_client == clnt) {
+		if (!(rovr->tk_flags & RPC_TASK_KILLED) && 
+		    (!clnt || rovr->tk_client == clnt)) {
 			rovr->tk_flags |= RPC_TASK_KILLED;
 			rpc_exit(rovr, -EIO);
+			spin_unlock(&rpc_sched_lock);
 			rpc_wake_up_task(rovr);
+			goto again;
 		}
 	spin_unlock(&rpc_sched_lock);
 }

             reply	other threads:[~2004-12-16 16:57 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-12-16 16:57 Olaf Kirch [this message]
2004-12-28 23:43 ` [PATCH] prevent sunrpc deadlock with debug on Trond Myklebust
2005-01-05 16:44   ` Olaf Kirch
2005-01-05 17:21     ` Trond Myklebust

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20041216165714.GB2077@suse.de \
    --to=okir@suse.de \
    --cc=nfs@lists.sourceforge.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.