All of lore.kernel.org
 help / color / mirror / Atom feed
From: Avri Altman <Avri.Altman@wdc.com>
To: Bart Van Assche <bvanassche@acm.org>,
	"Martin K . Petersen" <martin.petersen@oracle.com>
Cc: "linux-scsi@vger.kernel.org" <linux-scsi@vger.kernel.org>,
	Jaegeuk Kim <jaegeuk@kernel.org>,
	Adrian Hunter <adrian.hunter@intel.com>,
	"James E.J. Bottomley" <jejb@linux.ibm.com>,
	Bean Huo <beanhuo@micron.com>, Can Guo <cang@codeaurora.org>,
	Stanley Chu <stanley.chu@mediatek.com>,
	Asutosh Das <asutoshd@codeaurora.org>
Subject: RE: [PATCH 11/11] scsi: ufs: Implement polling support
Date: Thu, 11 Nov 2021 08:11:56 +0000	[thread overview]
Message-ID: <DM6PR04MB6575F4155E19B2D08A4EFB94FC949@DM6PR04MB6575.namprd04.prod.outlook.com> (raw)
In-Reply-To: <20211110004440.3389311-12-bvanassche@acm.org>

> 
> The time spent in io_schedule() is significant when submitting direct I/O to a
> UFS device. Hence this patch that implements polling support.
> User space software can enable polling by passing the RWF_HIPRI flag to the
> preadv2() system call or the IORING_SETUP_IOPOLL flag to the io_uring
> interface.
Do you expect that this will fix, or at least to some extent, the queue drainage that is so noticeable in direct benchmarks?
Can you share some early estimations?

Also I think this should be a separate patch as well.

> 
> Signed-off-by: Bart Van Assche <bvanassche@acm.org>
> ---
>  drivers/scsi/ufs/ufshcd.c | 45 +++++++++++++++++++++++----------------
>  1 file changed, 27 insertions(+), 18 deletions(-)
> 
> diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c index
> 36df89e8a575..70f128f12445 100644
> --- a/drivers/scsi/ufs/ufshcd.c
> +++ b/drivers/scsi/ufs/ufshcd.c
> @@ -5250,6 +5250,31 @@ static void __ufshcd_transfer_req_compl(struct
> ufs_hba *hba,
>         }
>  }
> 
> +/*
> + * Returns > 0 if one or more commands have been completed or 0 if no
> + * requests have been completed.
> + */
> +static int ufshcd_poll(struct Scsi_Host *shost, unsigned int queue_num)
> +{
> +       struct ufs_hba *hba = shost_priv(shost);
> +       unsigned long completed_reqs, flags;
> +       u32 tr_doorbell;
> +
> +       spin_lock_irqsave(&hba->outstanding_lock, flags);
> +       tr_doorbell = ufshcd_readl(hba, REG_UTP_TRANSFER_REQ_DOOR_BELL);
> +       completed_reqs = ~tr_doorbell & hba->outstanding_reqs;
> +       WARN_ONCE(completed_reqs & ~hba->outstanding_reqs,
> +                 "completed: %#lx; outstanding: %#lx\n", completed_reqs,
> +                 hba->outstanding_reqs);
> +       hba->outstanding_reqs &= ~completed_reqs;
> +       spin_unlock_irqrestore(&hba->outstanding_lock, flags);
> +
> +       if (completed_reqs)
> +               __ufshcd_transfer_req_compl(hba, completed_reqs);
> +
> +       return completed_reqs;
> +}
> +
>  /**
>   * ufshcd_transfer_req_compl - handle SCSI and query command completion
>   * @hba: per adapter instance
> @@ -5260,9 +5285,6 @@ static void __ufshcd_transfer_req_compl(struct
> ufs_hba *hba,
>   */
>  static irqreturn_t ufshcd_transfer_req_compl(struct ufs_hba *hba)  {
> -       unsigned long completed_reqs, flags;
> -       u32 tr_doorbell;
> -
>         /* Resetting interrupt aggregation counters first and reading the
>          * DOOR_BELL afterward allows us to handle all the completed requests.
>          * In order to prevent other interrupts starvation the DB is read once @@ -
> 5277,21 +5299,7 @@ static irqreturn_t ufshcd_transfer_req_compl(struct
> ufs_hba *hba)
>         if (ufs_fail_completion())
>                 return IRQ_HANDLED;
> 
> -       spin_lock_irqsave(&hba->outstanding_lock, flags);
> -       tr_doorbell = ufshcd_readl(hba, REG_UTP_TRANSFER_REQ_DOOR_BELL);
> -       completed_reqs = ~tr_doorbell & hba->outstanding_reqs;
> -       WARN_ONCE(completed_reqs & ~hba->outstanding_reqs,
> -                 "completed: %#lx; outstanding: %#lx\n", completed_reqs,
> -                 hba->outstanding_reqs);
> -       hba->outstanding_reqs &= ~completed_reqs;
> -       spin_unlock_irqrestore(&hba->outstanding_lock, flags);
> -
> -       if (completed_reqs) {
> -               __ufshcd_transfer_req_compl(hba, completed_reqs);
> -               return IRQ_HANDLED;
> -       } else {
> -               return IRQ_NONE;
> -       }
> +       return ufshcd_poll(hba->host, 0) ? IRQ_HANDLED : IRQ_NONE;
>  }
> 
>  int __ufshcd_write_ee_control(struct ufs_hba *hba, u32 ee_ctrl_mask) @@ -
> 8112,6 +8120,7 @@ static struct scsi_host_template ufshcd_driver_template =
> {
>         .name                   = UFSHCD,
>         .proc_name              = UFSHCD,
>         .queuecommand           = ufshcd_queuecommand,
> +       .mq_poll                = ufshcd_poll,
Did you consider to use some form blk_mq_tagset_busy_iter,
And return nutrs - busy?

Thanks,
Avri

>         .slave_alloc            = ufshcd_slave_alloc,
>         .slave_configure        = ufshcd_slave_configure,
>         .slave_destroy          = ufshcd_slave_destroy,

  parent reply	other threads:[~2021-11-11  8:12 UTC|newest]

Thread overview: 50+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-11-10  0:44 [PATCH 00/11] UFS patches for kernel v5.17 Bart Van Assche
2021-11-10  0:44 ` [PATCH 01/11] scsi: ufs: Rename a function argument Bart Van Assche
2021-11-10  1:28   ` Chanho Park
2021-11-11 16:59   ` Alim Akhtar
2021-11-10  0:44 ` [PATCH 02/11] scsi: ufs: Remove is_rpmb_wlun() Bart Van Assche
2021-11-10 17:47   ` Asutosh Das (asd)
2021-11-11 16:52   ` Alim Akhtar
2021-11-10  0:44 ` [PATCH 03/11] scsi: ufs: Remove the sdev_rpmb member Bart Van Assche
2021-11-10 17:50   ` Asutosh Das (asd)
2021-11-11 16:47   ` Alim Akhtar
2021-11-10  0:44 ` [PATCH 04/11] scsi: ufs: Remove dead code Bart Van Assche
2021-11-11  7:06   ` Avri Altman
2021-11-15 15:58   ` Bean Huo
2021-11-15 16:01   ` Bean Huo
2021-11-10  0:44 ` [PATCH 05/11] scsi: core: Add support for reserved tags Bart Van Assche
2021-11-10  0:44 ` [PATCH 06/11] scsi: ufs: Rework ufshcd_change_queue_depth() Bart Van Assche
2021-11-11  7:22   ` Avri Altman
2021-11-15 18:27     ` Bart Van Assche
2021-11-10  0:44 ` [PATCH 07/11] scsi: ufs: Fix a deadlock in the error handler Bart Van Assche
2021-11-10  6:42   ` Christoph Hellwig
2021-11-15 18:28     ` Bart Van Assche
2021-11-11  7:33   ` Avri Altman
2021-11-15 18:29     ` Bart Van Assche
2021-11-10  0:44 ` [PATCH 08/11] scsi: ufs: Improve SCSI abort handling further Bart Van Assche
2021-11-10  8:57   ` Adrian Hunter
2021-11-10 18:56     ` Bart Van Assche
2021-11-12 10:56       ` Adrian Hunter
2021-11-15 23:09         ` Bart Van Assche
2021-11-16  9:03           ` Adrian Hunter
2021-11-16 16:07             ` Bart Van Assche
2021-11-11  9:17   ` Peter Wang
2021-11-16  9:07     ` Peter Wang
2021-11-16 16:08       ` Bart Van Assche
2021-11-16 20:16         ` Adrian Hunter
2021-11-16 21:53           ` Bart Van Assche
2021-11-17  7:37             ` Adrian Hunter
2021-11-10  0:44 ` [PATCH 09/11] scsi: ufs: Fix a kernel crash during shutdown Bart Van Assche
2021-11-11  7:48   ` Avri Altman
2021-11-15 18:45     ` Bart Van Assche
2021-11-10  0:44 ` [PATCH 10/11] scsi: ufs: Optimize the command queueing code Bart Van Assche
2021-11-10  8:04   ` Adrian Hunter
2021-11-10 18:57     ` Bart Van Assche
2021-11-11  7:51     ` Avri Altman
2021-11-12 23:40   ` Asutosh Das (asd)
2021-11-10  0:44 ` [PATCH 11/11] scsi: ufs: Implement polling support Bart Van Assche
2021-11-10  1:36   ` Douglas Gilbert
2021-11-19 19:39     ` Bart Van Assche
2021-11-11  8:11   ` Avri Altman [this message]
2021-11-19 19:01     ` Bart Van Assche
     [not found] ` <CGME20211110004503epcas2p420544000401f38525f70bac1528623ee@epcms2p4>
2021-11-10  9:48   ` [PATCH 01/11] scsi: ufs: Rename a function argument Keoseong Park

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=DM6PR04MB6575F4155E19B2D08A4EFB94FC949@DM6PR04MB6575.namprd04.prod.outlook.com \
    --to=avri.altman@wdc.com \
    --cc=adrian.hunter@intel.com \
    --cc=asutoshd@codeaurora.org \
    --cc=beanhuo@micron.com \
    --cc=bvanassche@acm.org \
    --cc=cang@codeaurora.org \
    --cc=jaegeuk@kernel.org \
    --cc=jejb@linux.ibm.com \
    --cc=linux-scsi@vger.kernel.org \
    --cc=martin.petersen@oracle.com \
    --cc=stanley.chu@mediatek.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.