All of lore.kernel.org
 help / color / mirror / Atom feed
From: Xiaoguang Wang <xiaoguang.wang@linux.alibaba.com>
To: linux-scsi@vger.kernel.org, target-devel@vger.kernel.org
Cc: martin.petersen@oracle.com, bostroesser@gmail.com,
	kanie@linux.alibaba.com
Subject: [PATCH 2/2] scsi: target: tcm_loop: use scsi_done_direct()
Date: Tue,  8 Feb 2022 14:37:07 +0800	[thread overview]
Message-ID: <20220208063707.4781-2-xiaoguang.wang@linux.alibaba.com> (raw)
In-Reply-To: <20220208063707.4781-1-xiaoguang.wang@linux.alibaba.com>

Tcm_loop uses workqueue to end requests, which is non-interrupt context,
then we can complete request directly instead deferring it to softirq.
The call graph likes below:
    blk_mq_complete_request_remote+1
    blk_mq_complete_request+14
    target_put_sess_cmd+294
    transport_generic_free_cmd+93
    target_complete_ok_work+251
    process_one_work+482
    worker_thread+80
    kthread+361
    ret_from_fork+31

Use tcm_loop and tcmu(backstore is file) to evaluate performance, fio
job:
  [global]
  filename=/dev/sdb
  direct=1
  runtime=30
  thread=1
  norandommap=1
  time_based
  numjobs=1
  rw=randread
  iodepth=32
  ioengine=libaio

Without this patch:
bs 4k
  READ: bw=319MiB/s (334MB/s), 319MiB/s-319MiB/s (334MB/s-334MB/s),
io=9563MiB (10.0GB), run=30001-30001msec

bs 8k:
   READ: bw=611MiB/s (641MB/s), 611MiB/s-611MiB/s (641MB/s-641MB/s),
io=17.9GiB (19.2GB), run=30001-30001msec

bs 16k:
   READ: bw=1109MiB/s (1163MB/s), 1109MiB/s-1109MiB/s (1163MB/s-1163MB/s),
io=32.5GiB (34.9GB), run=30001-30001msec

bs 32k:
   READ: bw=2200MiB/s (2306MB/s), 2200MiB/s-2200MiB/s (2306MB/s-2306MB/s),
io=64.4GiB (69.2GB), run=30001-30001msec

With this patch:
bs 4k:
   READ: bw=344MiB/s (361MB/s), 344MiB/s-344MiB/s (361MB/s-361MB/s),
io=10.1GiB (10.8GB), run=30001-30001msec

bs 8k:
   READ: bw=651MiB/s (682MB/s), 651MiB/s-651MiB/s (682MB/s-682MB/s),
io=19.1GiB (20.5GB), run=30001-30001msec

bs 16k:
   READ: bw=1248MiB/s (1308MB/s), 1248MiB/s-1248MiB/s (1308MB/s-1308MB/s),
io=36.6GiB (39.3GB), run=30001-30001msec

bs 32k:
   READ: bw=2456MiB/s (2576MB/s), 2456MiB/s-2456MiB/s (2576MB/s-2576MB/s),
io=71.0GiB (77.3GB), run=30001-30001msec

We can get throughput improvement.

Signed-off-by: Xiaoguang Wang <xiaoguang.wang@linux.alibaba.com>
---
 drivers/target/loopback/tcm_loop.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/drivers/target/loopback/tcm_loop.c b/drivers/target/loopback/tcm_loop.c
index 4407b56aa6d1..ce414fbdbae6 100644
--- a/drivers/target/loopback/tcm_loop.c
+++ b/drivers/target/loopback/tcm_loop.c
@@ -70,8 +70,12 @@ static void tcm_loop_release_cmd(struct se_cmd *se_cmd)
 
 	if (se_cmd->se_cmd_flags & SCF_SCSI_TMR_CDB)
 		kmem_cache_free(tcm_loop_cmd_cache, tl_cmd);
-	else
-		scsi_done(sc);
+	else {
+		if (unlikely(in_interrupt()))
+			scsi_done(sc);
+		else
+			scsi_done_direct(sc);
+	}
 }
 
 static int tcm_loop_show_info(struct seq_file *m, struct Scsi_Host *host)
-- 
2.14.4.44.g2045bb6


  reply	other threads:[~2022-02-08  6:37 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-02-08  6:37 [PATCH 1/2] scsi: add scsi_done_direct() helper Xiaoguang Wang
2022-02-08  6:37 ` Xiaoguang Wang [this message]
2022-02-11 21:49 ` Martin K. Petersen

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=20220208063707.4781-2-xiaoguang.wang@linux.alibaba.com \
    --to=xiaoguang.wang@linux.alibaba.com \
    --cc=bostroesser@gmail.com \
    --cc=kanie@linux.alibaba.com \
    --cc=linux-scsi@vger.kernel.org \
    --cc=martin.petersen@oracle.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.