From: James Bottomley <James.Bottomley@suse.de>
To: Hillf Danton <dhillf@gmail.com>
Cc: linux-scsi@vger.kernel.org, Mike Christie <michaelc@cs.wisc.edu>,
FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
Subject: Re: [PATCH] SCSI: add check for host busy in scsi_run_queue()
Date: Mon, 20 Sep 2010 12:56:10 -0500 [thread overview]
Message-ID: <1285005370.2973.272.camel@mulgrave.site> (raw)
In-Reply-To: <AANLkTi=jMYEsMtTQmnMSKxwYNzpwCLLkgsEvHAxWj8ui@mail.gmail.com>
On Sun, 2010-09-19 at 20:53 +0800, Hillf Danton wrote:
> It seems that check for host busy is deserved before scanning the starved list.
> And list operation is simplified.
>
> Signed-off-by: Hillf Danton <dhillf@gmail.com>
> ---
>
> --- o/linux-2.6.36-rc4/drivers/scsi/scsi_lib.c 2010-09-13
> 07:07:38.000000000 +0800
> +++ m/linux-2.6.36-rc4/drivers/scsi/scsi_lib.c 2010-09-19
> 20:32:34.000000000 +0800
> @@ -399,18 +399,20 @@ static inline int scsi_host_is_busy(stru
> */
> static void scsi_run_queue(struct request_queue *q)
> {
> - struct scsi_device *sdev = q->queuedata;
> + struct scsi_device *sdev = q->queuedata, *safe;
> struct Scsi_Host *shost = sdev->host;
> - LIST_HEAD(starved_list);
> unsigned long flags;
>
> if (scsi_target(sdev)->single_lun)
> scsi_single_lun_run(sdev);
>
> spin_lock_irqsave(shost->host_lock, flags);
> - list_splice_init(&shost->starved_list, &starved_list);
> -
> - while (!list_empty(&starved_list)) {
> + if (scsi_host_is_busy(shost)) {
> + spin_unlock_irqrestore(shost->host_lock, flags);
> + return;
> + }
To be honest, there's no real gain from this micro-optimisation.
> + list_for_each_entry_safe(sdev, safe, &shost->starved_list,
> + starved_entry) {
And this is definitely wrong. The list is altered in flight so the
whole purpose of the static copy is to process only what existed before
we began; otherwise you can get a livelock.
James
next prev parent reply other threads:[~2010-09-20 17:56 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-09-19 12:53 [PATCH] SCSI: add check for host busy in scsi_run_queue() Hillf Danton
2010-09-20 17:56 ` James Bottomley [this message]
2010-09-21 15:06 ` Hillf Danton
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=1285005370.2973.272.camel@mulgrave.site \
--to=james.bottomley@suse.de \
--cc=dhillf@gmail.com \
--cc=fujita.tomonori@lab.ntt.co.jp \
--cc=linux-scsi@vger.kernel.org \
--cc=michaelc@cs.wisc.edu \
/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