From: James Bottomley <jejb@linux.vnet.ibm.com>
To: Anjali Kulkarni <Anjali.K.Kulkarni@oracle.com>,
martin.petersen@oracle.com
Cc: linux-scsi@vger.kernel.org
Subject: Re: [PATCH] scsi: Avoid unnecessary iterations on __scsi_scan_target
Date: Fri, 26 Jun 2020 17:03:27 -0700 [thread overview]
Message-ID: <1593216207.10175.2.camel@linux.vnet.ibm.com> (raw)
In-Reply-To: <38cee464-7320-87a9-f55c-f0db4679fc0a@oracle.com>
On Fri, 2020-06-26 at 16:53 -0700, Anjali Kulkarni wrote:
> There is a loop in scsi_scan_channel(), which calls
> __scsi_scan_target() 255 times, even when it has found a
> target/device on a
> lun in the first iteration; this ends up adding a 2 secs delay to the
> boot
> time. The for loop in scsi_scan_channel() adding 2 secs to boot time
> is as
> follows:
>
> for (id = 0; id < shost->max_id; ++id) {
> ...
> __scsi_scan_target(&shost->shost_gendev, channel,
> order_id, lun, rescan);
> }
>
> __scsi_scan_target() calls scsi_probe_and_add_lun() which calls
> scsi_probe_lun(), hence scsi_probe_lun() ends up getting called 255
> times.
> Each call of scsi_probe_lun() takes 0.007865 secs.
> 0.007865 multiplied by 255 = 2.00557 secs.
> By adding a break in above for loop when a valid device on lun is
> found,
> we can avoid this 2 secs delay improving boot time by 2 secs.
>
> The flow of code is depicted in the following sequence of events:
>
> do_scan_async() ->
> do_scsi_scan_host()->
> scsi_scan_host_selected() ->
> scsi_scan_channel()
> __scsi_scan_target() -> this is called shost->max_id
> times
> (255 times)
> scsi_probe_and_add_lun-> this is called 255
> times
> scsi_probe_lun : called 255 times, each call
> takes 0.007865 secs.
What HBA is this? This code is for legacy scanning of busses which
require it, which is pretty much only SPI. The max_id of even the
latest SPI bus should only be 16, so where is 255 coming from?
James
next prev parent reply other threads:[~2020-06-27 0:03 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-06-26 23:53 [PATCH] scsi: Avoid unnecessary iterations on __scsi_scan_target Anjali Kulkarni
2020-06-27 0:03 ` James Bottomley [this message]
2020-06-27 0:17 ` Anjali Kulkarni
2020-06-27 0:21 ` James Bottomley
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=1593216207.10175.2.camel@linux.vnet.ibm.com \
--to=jejb@linux.vnet.ibm.com \
--cc=Anjali.K.Kulkarni@oracle.com \
--cc=jejb@linux.ibm.com \
--cc=linux-scsi@vger.kernel.org \
--cc=martin.petersen@oracle.com \
/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