mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Stefan Richter <stefanr@s5r6.in-berlin.de>
To: Andrew Morton <akpm@osdl.org>
Cc: torvalds@osdl.org, stable@kernel.org,
	linux-kernel@vger.kernel.org,
	linux1394-devel@lists.sourceforge.net, scjody@modernduck.com
Subject: Re: [PATCH] sbp2: fix spinlock recursion
Date: Sun, 02 Apr 2006 11:35:42 +0200	[thread overview]
Message-ID: <442F9AEE.3000209@s5r6.in-berlin.de> (raw)
In-Reply-To: <20060401165241.5989d67f.akpm@osdl.org>

Andrew Morton wrote:
> Stefan Richter <stefanr@s5r6.in-berlin.de> wrote:
> 
>>@@ -2540,6 +2537,7 @@ static int sbp2scsi_abort(struct scsi_cm
>>  				command->Current_done(command->Current_SCpnt);
>>  			}
>>  		}
>> +		spin_unlock_irqrestore(&scsi_id->sbp2_command_orb_lock, flags);
> 
> 
> This changes the call environment for all implementations of
> ->Current_done().  Are they all safe to call under this lock?

Short answer: Yes, trust me. ;-) Long answer:

The done() callbacks are passed on to sbp2 from the SCSI stack along 
with each SCSI command via the queuecommand hook. The done() callback is 
safe to call in atomic context. So does 
Documentation/scsi/scsi_mid_low_api.txt say, and many if not all SCSI 
low-level handlers rely on this fact. So whatever this callback does, it 
is "self-contained" and it won't conflict with sbp2's internal ORB list 
handling. In particular, it won't race with the sbp2_command_orb_lock.

Moreover, sbp2 already calls the done() handler with 
sbp2_command_orb_lock taken in sbp2scsi_complete_all_commands(). I admit 
this is ultimately no proof of correctness, especially since this 
portion of code introduced the spinlock recursion in the first place and 
we didn't realize it since this code's submission before 2.6.15 until 
now. (I have learned a lesson from this.)

I stress-tested my patch on x86 uniprocessor with a preemptible SMP 
kernel (alas I have no SMP machine yet) and made sure that all code 
paths which involve the sbp2_command_orb_lock were gone through multiple 
times. Which is of course also no proof.
-- 
Stefan Richter
-=====-=-==- -=-- ---=-
http://arcgraph.de/sr/

  reply	other threads:[~2006-04-02  9:36 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-04-01 19:11 Stefan Richter
2006-04-02  0:52 ` Andrew Morton
2006-04-02  9:35   ` Stefan Richter [this message]
2006-04-04 22:13 ` [stable] " Greg KH

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=442F9AEE.3000209@s5r6.in-berlin.de \
    --to=stefanr@s5r6.in-berlin.de \
    --cc=akpm@osdl.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux1394-devel@lists.sourceforge.net \
    --cc=scjody@modernduck.com \
    --cc=stable@kernel.org \
    --cc=torvalds@osdl.org \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

Powered by JetHome