From: Ming Lei <ming.lei@redhat.com>
To: John Garry <john.garry@huawei.com>
Cc: Jens Axboe <axboe@kernel.dk>,
"Martin K . Petersen" <martin.petersen@oracle.com>,
linux-block@vger.kernel.org,
James Bottomley <James.Bottomley@hansenpartnership.com>,
linux-scsi@vger.kernel.org, Bart Van Assche <bvanassche@acm.org>,
Hannes Reinecke <hare@suse.com>,
Keith Busch <keith.busch@intel.com>,
Thomas Gleixner <tglx@linutronix.de>,
Don Brace <don.brace@microsemi.com>,
Kashyap Desai <kashyap.desai@broadcom.com>,
Sathya Prakash <sathya.prakash@broadcom.com>,
Christoph Hellwig <hch@lst.de>
Subject: Re: [PATCH V2 1/5] scsi: select reply queue from request's CPU
Date: Wed, 29 May 2019 10:36:37 +0800 [thread overview]
Message-ID: <20190529023635.GB21398@ming.t460p> (raw)
In-Reply-To: <546f5060-d39a-3057-a181-fa3ff1b921d4@huawei.com>
On Tue, May 28, 2019 at 11:33:29AM +0100, John Garry wrote:
> On 27/05/2019 16:02, Ming Lei wrote:
> > Hisi_sas_v3_hw, hpsa, megaraid and mpt3sas use single blk-mq hw queue
> > to submit request, meantime apply multiple private reply queues served as
> > completion queue. The mapping between CPU and reply queue is setup via
> > pci_alloc_irq_vectors_affinity(PCI_IRQ_AFFINITY) just like the usual
> > blk-mq queue mapping.
> >
> > These drivers always use current CPU(raw_smp_processor_id) to figure out
> > the reply queue. Switch to use request's CPU to get the reply queue,
> > so we can drain in-flight request via blk-mq's API before the last CPU of
> > the reply queue becomes offline.
> >
> > Signed-off-by: Ming Lei <ming.lei@redhat.com>
> > ---
> > drivers/scsi/hisi_sas/hisi_sas_main.c | 5 +++--
> > drivers/scsi/hpsa.c | 2 +-
> > drivers/scsi/megaraid/megaraid_sas_fusion.c | 4 ++--
> > drivers/scsi/mpt3sas/mpt3sas_base.c | 16 ++++++++--------
> > include/scsi/scsi_cmnd.h | 11 +++++++++++
> > 5 files changed, 25 insertions(+), 13 deletions(-)
> >
> > diff --git a/drivers/scsi/hisi_sas/hisi_sas_main.c b/drivers/scsi/hisi_sas/hisi_sas_main.c
> > index 8a7feb8ed8d6..ab9d8e7bfc8e 100644
> > --- a/drivers/scsi/hisi_sas/hisi_sas_main.c
> > +++ b/drivers/scsi/hisi_sas/hisi_sas_main.c
> > @@ -471,9 +471,10 @@ static int hisi_sas_task_prep(struct sas_task *task,
> > return -ECOMM;
> > }
> >
> > + /* only V3 hardware setup .reply_map */
> > if (hisi_hba->reply_map) {
> > - int cpu = raw_smp_processor_id();
> > - unsigned int dq_index = hisi_hba->reply_map[cpu];
> > + unsigned int dq_index = hisi_hba->reply_map[
> > + scsi_cmnd_cpu(task->uldd_task)];
>
> Hi Ming,
>
> There is a problem here. For ATA commands in libsas, task->uldd_task is
> ata_queued_cmd *, and not a scsi_cmnd *. It comes from https://elixir.bootlin.com/linux/v5.2-rc2/source/drivers/scsi/libsas/sas_ata.c#L212
>
Yeah, that is one problem.
> Please see this later code, where we have this check:
> if (task->uldd_task) {
> struct ata_queued_cmd *qc;
>
> if (dev_is_sata(device)) {
> qc = task->uldd_task;
> scsi_cmnd = qc->scsicmd;
> } else {
> scsi_cmnd = task->uldd_task;
> }
> }
> rc = hisi_sas_slot_index_alloc(hisi_hba, scsi_cmnd);
>
> I suppose that we could solve by finding scsi_cmnd * earlier in
> hisi_sas_task_prep().
Yeah, it can be fixed easily, or move delivery queue selection
after .slot_index_alloc.
>
> >
> > *dq_pointer = dq = &hisi_hba->dq[dq_index];
> > } else {
> > diff --git a/drivers/scsi/hpsa.c b/drivers/scsi/hpsa.c
> > index 1bef1da273c2..72f9edb86752 100644
> > --- a/drivers/scsi/hpsa.c
> > +++ b/drivers/scsi/hpsa.c
> > @@ -1145,7 +1145,7 @@ static void __enqueue_cmd_and_start_io(struct ctlr_info *h,
>
> [snip]
>
> > diff --git a/include/scsi/scsi_cmnd.h b/include/scsi/scsi_cmnd.h
> > index 76ed5e4acd38..ab60883c2c40 100644
> > --- a/include/scsi/scsi_cmnd.h
> > +++ b/include/scsi/scsi_cmnd.h
> > @@ -332,4 +332,15 @@ static inline unsigned scsi_transfer_length(struct scsi_cmnd *scmd)
> > return xfer_len;
> > }
> >
> > +static inline int scsi_cmnd_cpu(struct scsi_cmnd *scmd)
> > +{
> > + if (!scmd || !scmd->request)
> > + return raw_smp_processor_id();
> > +
> > + if (!scmd->request->mq_ctx)
> > + return raw_smp_processor_id();
>
> nit: can we combine these tests? Or do you want a distinct check on
OK.
> scmd->request->mq_ctx, since blk_mq_rq_cpu() does not check it?
blk_mq_rq_cpu() needn't to check it, however SCSI has to run the check
because some request may not have .mq_ctx, such as reset request.
Thanks,
Ming
next prev parent reply other threads:[~2019-05-29 2:36 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-05-27 15:02 [PATCH V2 0/5] blk-mq: Wait for for hctx inflight requests on CPU unplug Ming Lei
2019-05-27 15:02 ` [PATCH V2 1/5] scsi: select reply queue from request's CPU Ming Lei
2019-05-28 5:43 ` Hannes Reinecke
2019-05-28 10:33 ` John Garry
2019-05-29 2:36 ` Ming Lei [this message]
2019-05-27 15:02 ` [PATCH V2 2/5] blk-mq: introduce .complete_queue_affinity Ming Lei
2019-05-27 15:02 ` [PATCH V2 3/5] scsi: core: implement callback of .complete_queue_affinity Ming Lei
2019-05-27 15:02 ` [PATCH V2 4/5] scsi: implement .complete_queue_affinity Ming Lei
2019-05-27 15:02 ` [PATCH V2 5/5] blk-mq: Wait for for hctx inflight requests on CPU unplug Ming Lei
2019-05-28 16:50 ` John Garry
2019-05-29 2:28 ` Ming Lei
2019-05-29 2:42 ` Ming Lei
2019-05-29 9:42 ` John Garry
2019-05-29 10:10 ` Ming Lei
2019-05-29 15:33 ` Ming Lei
2019-05-29 16:10 ` John Garry
2019-05-30 2:28 ` Ming Lei
2019-05-30 4:11 ` Ming Lei
2019-05-30 9:31 ` John Garry
2019-05-30 9:45 ` Ming Lei
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=20190529023635.GB21398@ming.t460p \
--to=ming.lei@redhat.com \
--cc=James.Bottomley@hansenpartnership.com \
--cc=axboe@kernel.dk \
--cc=bvanassche@acm.org \
--cc=don.brace@microsemi.com \
--cc=hare@suse.com \
--cc=hch@lst.de \
--cc=john.garry@huawei.com \
--cc=kashyap.desai@broadcom.com \
--cc=keith.busch@intel.com \
--cc=linux-block@vger.kernel.org \
--cc=linux-scsi@vger.kernel.org \
--cc=martin.petersen@oracle.com \
--cc=sathya.prakash@broadcom.com \
--cc=tglx@linutronix.de \
/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;
as well as URLs for NNTP newsgroup(s).