All of lore.kernel.org
 help / color / mirror / Atom feed
From: Mike Christie <michael.christie@oracle.com>
To: bostroesser@gmail.com, mst@redhat.com, stefanha@redhat.com,
	Chaitanya.Kulkarni@wdc.com, hch@lst.de, loberman@redhat.com,
	martin.petersen@oracle.com, linux-scsi@vger.kernel.org,
	target-devel@vger.kernel.org
Cc: Mike Christie <michael.christie@oracle.com>
Subject: [PATCH 23/25] target_core_user: add backend plug/unplug callouts
Date: Sat, 27 Feb 2021 11:00:04 -0600	[thread overview]
Message-ID: <20210227170006.5077-24-michael.christie@oracle.com> (raw)
In-Reply-To: <20210227170006.5077-1-michael.christie@oracle.com>

This patch adds plug/unplug callouts for tcmu, so we can avoid the
number of times we switch to userspace. Using this driver with tcm
loop is a common config, and dependng on the nr_hw_queues
(nr_hw_queues=1 performs much better) and fio jobs (lower num jobs
around 4) this patch can increase IOPs by only around 5-10% because
we hit other issues like the big per tcmu device mutex.

Signed-off-by: Mike Christie <michael.christie@oracle.com>
Reviewed-by: Bodo Stroesser <bostroesser@gmail.com> 
---
 drivers/target/target_core_user.c | 27 +++++++++++++++++++++++++--
 1 file changed, 25 insertions(+), 2 deletions(-)

diff --git a/drivers/target/target_core_user.c b/drivers/target/target_core_user.c
index a5991df23581..a433bda56b89 100644
--- a/drivers/target/target_core_user.c
+++ b/drivers/target/target_core_user.c
@@ -111,6 +111,7 @@ struct tcmu_dev {
 	struct kref kref;
 
 	struct se_device se_dev;
+	struct se_dev_plug se_plug;
 
 	char *name;
 	struct se_hba *hba;
@@ -119,6 +120,7 @@ struct tcmu_dev {
 #define TCMU_DEV_BIT_BROKEN 1
 #define TCMU_DEV_BIT_BLOCKED 2
 #define TCMU_DEV_BIT_TMR_NOTIFY 3
+#define TCM_DEV_BIT_PLUGGED 4
 	unsigned long flags;
 
 	struct uio_info uio_info;
@@ -959,6 +961,25 @@ static uint32_t ring_insert_padding(struct tcmu_dev *udev, size_t cmd_size)
 	return cmd_head;
 }
 
+static void tcmu_unplug_device(struct se_dev_plug *se_plug)
+{
+	struct se_device *se_dev = se_plug->se_dev;
+	struct tcmu_dev *udev = TCMU_DEV(se_dev);
+
+	clear_bit(TCM_DEV_BIT_PLUGGED, &udev->flags);
+	uio_event_notify(&udev->uio_info);
+}
+
+static struct se_dev_plug *tcmu_plug_device(struct se_device *se_dev)
+{
+	struct tcmu_dev *udev = TCMU_DEV(se_dev);
+
+	if (!test_and_set_bit(TCM_DEV_BIT_PLUGGED, &udev->flags))
+		return &udev->se_plug;
+
+	return NULL;
+}
+
 /**
  * queue_cmd_ring - queue cmd to ring or internally
  * @tcmu_cmd: cmd to queue
@@ -1086,8 +1107,8 @@ static int queue_cmd_ring(struct tcmu_cmd *tcmu_cmd, sense_reason_t *scsi_err)
 
 	list_add_tail(&tcmu_cmd->queue_entry, &udev->inflight_queue);
 
-	/* TODO: only if FLUSH and FUA? */
-	uio_event_notify(&udev->uio_info);
+	if (!test_bit(TCM_DEV_BIT_PLUGGED, &udev->flags))
+		uio_event_notify(&udev->uio_info);
 
 	return 0;
 
@@ -2840,6 +2861,8 @@ static struct target_backend_ops tcmu_ops = {
 	.configure_device	= tcmu_configure_device,
 	.destroy_device		= tcmu_destroy_device,
 	.free_device		= tcmu_free_device,
+	.unplug_device		= tcmu_unplug_device,
+	.plug_device		= tcmu_plug_device,
 	.parse_cdb		= tcmu_parse_cdb,
 	.tmr_notify		= tcmu_tmr_notify,
 	.set_configfs_dev_params = tcmu_set_configfs_dev_params,
-- 
2.25.1


  parent reply	other threads:[~2021-02-27 17:11 UTC|newest]

Thread overview: 31+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-02-27 16:59 [PATCH 00/25 V5] target: fix cmd plugging and submission Mike Christie
2021-02-27 16:59 ` [PATCH 01/25] target: move t_task_cdb initialization Mike Christie
2021-03-04  4:15   ` Martin K. Petersen
2021-02-27 16:59 ` [PATCH 02/25] target: drop kref_get_unless_zero in target_get_sess_cmd Mike Christie
2021-02-27 16:59 ` [PATCH 03/25] target: rename transport_init_se_cmd Mike Christie
2021-02-27 16:59 ` [PATCH 04/25] target: break up target_submit_cmd_map_sgls Mike Christie
2021-02-27 16:59 ` [PATCH 05/25] srpt: Convert to new submission API Mike Christie
2021-02-27 16:59 ` [PATCH 06/25] ibmvscsi_tgt: " Mike Christie
2021-02-27 16:59 ` [PATCH 07/25] qla2xxx: " Mike Christie
2021-02-27 16:59 ` [PATCH 08/25] tcm_loop: " Mike Christie
2021-02-27 16:59 ` [PATCH 09/25] sbp_target: " Mike Christie
2021-02-27 16:59 ` [PATCH 10/25] usb gadget: " Mike Christie
2021-02-27 16:59 ` [PATCH 11/25] vhost-scsi: " Mike Christie
2021-02-27 16:59 ` [PATCH 12/25] xen-scsiback: " Mike Christie
2021-02-27 16:59 ` [PATCH 13/25] tcm_fc: " Mike Christie
2021-02-27 16:59 ` [PATCH 14/25] target: remove target_submit_cmd_map_sgls Mike Christie
2021-02-27 16:59 ` [PATCH 15/25] target: add gfp_t arg to target_cmd_init_cdb Mike Christie
2021-02-27 16:59 ` [PATCH 16/25] target: add workqueue based cmd submission Mike Christie
2021-02-27 16:59 ` [PATCH 17/25] vhost scsi: use lio wq cmd submission helper Mike Christie
2021-02-27 16:59 ` [PATCH 18/25] tcm loop: use blk cmd allocator for se_cmds Mike Christie
2021-02-27 17:00 ` [PATCH 19/25] tcm loop: use lio wq cmd submission helper Mike Christie
2021-02-27 17:00 ` [PATCH 20/25] target: cleanup cmd flag bits Mike Christie
2021-02-27 17:00 ` [PATCH 21/25] target: fix backend plugging Mike Christie
2021-02-27 17:00 ` [PATCH 22/25] target iblock: add backend plug/unplug callouts Mike Christie
2021-02-27 17:00 ` Mike Christie [this message]
2021-02-27 17:00 ` [PATCH 24/25] target: flush submission work during TMR processing Mike Christie
2021-02-27 17:00 ` [PATCH 25/25] target: make completion affinity configurable Mike Christie
2021-03-01 10:01 ` [PATCH 00/25 V5] target: fix cmd plugging and submission Stefan Hajnoczi
  -- strict thread matches above, loose matches on Subject: below --
2021-02-17 20:27 Mike Christie
2021-02-17 20:28 ` [PATCH 23/25] target_core_user: add backend plug/unplug callouts Mike Christie
2021-02-19 19:45   ` Bodo Stroesser
2021-02-12  7:26 PATCH 00/25 V4] target: fix cmd plugging and submission Mike Christie
2021-02-12  7:26 ` [PATCH 23/25] target_core_user: add backend plug/unplug callouts Mike Christie

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=20210227170006.5077-24-michael.christie@oracle.com \
    --to=michael.christie@oracle.com \
    --cc=Chaitanya.Kulkarni@wdc.com \
    --cc=bostroesser@gmail.com \
    --cc=hch@lst.de \
    --cc=linux-scsi@vger.kernel.org \
    --cc=loberman@redhat.com \
    --cc=martin.petersen@oracle.com \
    --cc=mst@redhat.com \
    --cc=stefanha@redhat.com \
    --cc=target-devel@vger.kernel.org \
    /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.