linux-nvme.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: "Wunderlich, Mark" <mark.wunderlich@intel.com>
To: "linux-nvme@lists.infradead.org" <linux-nvme@lists.infradead.org>
Subject: [PATCH 1/2] nvmet-tcp: enable polling option in io_work
Date: Wed, 30 Oct 2019 22:27:07 +0000	[thread overview]
Message-ID: <B33B37937B7F3D4CB878107E305D4916D4AFC5@ORSMSX104.amr.corp.intel.com> (raw)

Move to a do/while loop terminate condition that is
time based and applicable for all modes of operation.
If the system is configured with busy polling the loop
period is set by the socket polling duration.  Allows
for full busy poll monitoring of recv/send activity
during this time period, not exiting if any loop has
no activity.

If busy polling not enabled, preserve default mode
behavior in that the do/while loop will exit early
if 'pending' is false indicating no activity during
that loop. Loop time period in this case defaults to
1000 usec, same as value used in io_work() for the
host side.

Outside loop add busy poll check if activity during
time period indicates more traffic may be 'pending'.

Re-queue the work item if any mode determines that
previous activity indicates there may be additional
'pending' work to process.

Signed-off-by: Sridhar Samudrala <sridhar.samudrala@intel.com>
Signed-off-by: Kiran Patil <kiran.patil@intel.com>
Signed-off-by: Mark Wunderlich <mark.wunderlich@intel.com>
---
 drivers/nvme/target/tcp.c |   26 +++++++++++++++++++++-----
 1 file changed, 21 insertions(+), 5 deletions(-)

diff --git a/drivers/nvme/target/tcp.c b/drivers/nvme/target/tcp.c
index d535080..4f79b77 100644
--- a/drivers/nvme/target/tcp.c
+++ b/drivers/nvme/target/tcp.c
@@ -11,6 +11,7 @@
 #include <linux/nvme-tcp.h>
 #include <net/sock.h>
 #include <net/tcp.h>
+#include <net/busy_poll.h>
 #include <linux/inet.h>
 #include <linux/llist.h>
 #include <crypto/hash.h>
@@ -21,7 +22,6 @@
 
 #define NVMET_TCP_RECV_BUDGET		8
 #define NVMET_TCP_SEND_BUDGET		8
-#define NVMET_TCP_IO_WORK_BUDGET	64
 
 enum nvmet_tcp_send_state {
 	NVMET_TCP_SEND_DATA_PDU,
@@ -1162,8 +1162,15 @@ static void nvmet_tcp_io_work(struct work_struct *w)
 {
 	struct nvmet_tcp_queue *queue =
 		container_of(w, struct nvmet_tcp_queue, io_work);
-	bool pending;
+	bool pending, busy_poll = false;
 	int ret, ops = 0;
+	unsigned long deadline, bp_usec = 1000;
+
+	if (sk_can_busy_loop(queue->sock->sk)) {
+		busy_poll = true;
+		bp_usec = queue->sock->sk->sk_ll_usec;
+	}
+	deadline = jiffies + usecs_to_jiffies(bp_usec);
 
 	do {
 		pending = false;
@@ -1191,10 +1198,19 @@ static void nvmet_tcp_io_work(struct work_struct *w)
 			return;
 		}
 
-	} while (pending && ops < NVMET_TCP_IO_WORK_BUDGET);
+		if (!busy_poll && !pending)
+			break;
 
-	/*
-	 * We exahusted our budget, requeue our selves
+	} while (!time_after(jiffies, deadline));
+
+	/* If busy polling active, any ops completed during
+	 * poll loop period justifies more may be pending.
+	 */
+	if (busy_poll && ops > 0)
+		pending = true;
+
+	/* We exhausted our budget, requeue if pending indicates
+	 * potential of more to process.
 	 */
 	if (pending)
 		queue_work_on(queue->cpu, nvmet_tcp_wq, &queue->io_work);


_______________________________________________
Linux-nvme mailing list
Linux-nvme@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-nvme

                 reply	other threads:[~2019-10-30 22:27 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=B33B37937B7F3D4CB878107E305D4916D4AFC5@ORSMSX104.amr.corp.intel.com \
    --to=mark.wunderlich@intel.com \
    --cc=linux-nvme@lists.infradead.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 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).