From: James Bottomley <James.Bottomley@suse.de>
To: va stg2010 <va.storage2010@gmail.com>
Cc: linux-scsi <linux-scsi@vger.kernel.org>
Subject: Re: scsi LLD implementation question
Date: Fri, 25 Feb 2011 08:37:05 -0500 [thread overview]
Message-ID: <1298641025.8617.63.camel@mulgrave.site> (raw)
In-Reply-To: <AANLkTi=+6z4qRS7MGSNTyomtyQTu5A20iBF-T92xAPMA@mail.gmail.com>
Cc to linux-scsi added because that's the list that best handles these
type of questions.
On Thu, 2011-02-24 at 20:13 -0800, va stg2010 wrote:
> Hi,
> I am working on a driver for scsi initiator HBA driver for linux.
> Have an implementation question. Once the commands are received
> into .queuecommand callback from linux-scsi, I insert them into a
> queue maintained locally in my driver until the responses comes back
> from target. The responses when posted later by an interrupt handler
> are eventually processed by a kthread which "iterates" through this
> queue to post responses back to linux-scsi.
Actually, doing actual internal queueing isn't a good idea: two queue
confuse the block elevators and only usually serve to increase latency.
If by "queue" you just mean a list of pending commands that have already
been issued to the driver which you need to find again by some
identifier again when the interrupt driven completion is posted, then
using the block tags for this is usually optimal (depending on how many
bits you have for the completion identifier).
> Question about this queue:
> Is it efficient to have one single queue for all the disks or its
> more efficient to have separate queue for each disk and separate
> response processing kthreads ?
Having a kthread process responses is generally not a good idea because
completions will come in at interrupt level ... you need a context
switch to get to a thread and this costs latency. The idea of done
processing in SCSI is to identify the scsi_cmnd as quickly as possible
and post it. All back end SCSI processing is done in the block softirq
(a level between hard interrupt and user context), again to keep latency
low. That also means that the kthread architecture is wrong because
it's difficult for the kernel to go hardirq->user->softirq without
adding an extra interrupt latency (usually a clock tick).
If you want a "threaded" response in a multiqueue card using MSIs, then
you bind the MSIs to CPU groups and use the hardware interrupt context
as the threading (I think drivers like lpfc already do this). The best
performance is actually observed when the MSI comes back in on the same
CPU that issued the I/O because the cache is still hot. The block keeps
an rq->cpu to tag this which internal HBA setup can use for programming
MSI completions.
James
next parent reply other threads:[~2011-02-25 13:37 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <AANLkTi=+6z4qRS7MGSNTyomtyQTu5A20iBF-T92xAPMA@mail.gmail.com>
2011-02-25 13:37 ` James Bottomley [this message]
2011-02-25 17:12 ` scsi LLD implementation question Bart Van Assche
2011-02-25 17:20 ` James Bottomley
2011-02-26 9:16 ` Bart Van Assche
[not found] ` <AANLkTikZqXCzJcRL3cL16w1O+MoDecy4N9XK14yzKd3D@mail.gmail.com>
2011-02-25 19:34 ` 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=1298641025.8617.63.camel@mulgrave.site \
--to=james.bottomley@suse.de \
--cc=linux-scsi@vger.kernel.org \
--cc=va.storage2010@gmail.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