Skip to contentSkip to conversation

SUNRPC: Remove rpc_xprt::tsh_size

PATCH In review Chuck Lever 2 participants 11 messages Jan 3, 2019 – Jan 10, 2019

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 SUNRPC: Remove rpc_xprt::tsh_size

tsh_size was added to accommodate transports that send a pre-amble before each RPC message. However, this assumes the pre-amble is fixed in size, which isn't true for some transports. That makes tsh_size not very generic.

Also I'd like to make the estimation of RPC send and receive buffer sizes more precise. tsh_size doesn't currently appear to be accounted for at all by call_allocate.

Therefore let's just remove the tsh_size concept, and make the only transports that have a non-zero tsh_size employ a direct approach.

---

I've taken an approach where only the transports that need a record marker need to pay the expense. I don't want to add another indirect call in the generic path.

However, I've found that during heavy multi-threaded workloads, occasionally this mechanism inserts a record marker in the middle of a Call message.

 include/linux/sunrpc/xprt.h                |    7 ---
 net/sunrpc/auth_gss/auth_gss.c             |    3 -
 net/sunrpc/clnt.c                          |    1 
 net/sunrpc/xprtrdma/svc_rdma_backchannel.c |    1 
 net/sunrpc/xprtrdma/transport.c            |    1 
 net/sunrpc/xprtsock.c                      |   69 +++++++++++++++++-----------
 6 files changed, 43 insertions(+), 39 deletions(-)
include/linux/sunrpc/xprt.h +0 -7
index a4ab4f8..17fc651 100644
@@ -197,8 +197,6 @@ struct rpc_xprt {
 
 	size_t			max_payload;	/* largest RPC payload size,
 						   in bytes */
-	unsigned int		tsh_size;	/* size of transport specific
-						   header */
 
 	struct rpc_wait_queue	binding;	/* requests waiting on rpcbind */
 	struct rpc_wait_queue	sending;	/* requests waiting to send */
@@ -363,11 +361,6 @@ struct rpc_xprt *	xprt_alloc(struct net *net, size_t size,
 				unsigned int max_req);
 void			xprt_free(struct rpc_xprt *);
 
-static inline __be32 *xprt_skip_transport_header(struct rpc_xprt *xprt, __be32 *p)
-{
-	return p + xprt->tsh_size;
-}
-
 static inline int
 xprt_enable_swap(struct rpc_xprt *xprt)
 {
net/sunrpc/auth_gss/auth_gss.c +1 -2
index 4735a06..13508e4 100644
@@ -1577,8 +1577,7 @@ static void gss_pipe_free(struct gss_pipe *p)
 
 	/* We compute the checksum for the verifier over the xdr-encoded bytes
 	 * starting with the xid and ending at the end of the credential: */
-	iov.iov_base = xprt_skip_transport_header(req->rq_xprt,
-					req->rq_snd_buf.head[0].iov_base);
+	iov.iov_base = req->rq_snd_buf.head[0].iov_base;
 	iov.iov_len = (u8 *)p - (u8 *)iov.iov_base;
 	xdr_buf_from_iov(&iov, &verf_buf);
 
net/sunrpc/clnt.c +0 -1
index 1ee04e0..4f88062 100644
@@ -2330,7 +2330,6 @@ void rpc_force_rebind(struct rpc_clnt *clnt)
 
 	/* FIXME: check buffer size? */
 
-	p = xprt_skip_transport_header(req->rq_xprt, p);
 	*p++ = req->rq_xid;		/* XID */
 	*p++ = htonl(RPC_CALL);		/* CALL */
 	*p++ = htonl(RPC_VERSION);	/* RPC version */
net/sunrpc/xprtrdma/svc_rdma_backchannel.c +0 -1
index b908f2c..907464c 100644
@@ -304,7 +304,6 @@ static int svc_rdma_bc_sendto(struct svcxprt_rdma *rdma,
 	xprt->idle_timeout = RPCRDMA_IDLE_DISC_TO;
 
 	xprt->prot = XPRT_TRANSPORT_BC_RDMA;
-	xprt->tsh_size = 0;
 	xprt->ops = &xprt_rdma_bc_procs;
 
 	memcpy(&xprt->addr, args->dstaddr, args->addrlen);
net/sunrpc/xprtrdma/transport.c +0 -1
index 9a7bb58..2a704d5 100644
@@ -332,7 +332,6 @@
 	xprt->idle_timeout = RPCRDMA_IDLE_DISC_TO;
 
 	xprt->resvport = 0;		/* privileged port not needed */
-	xprt->tsh_size = 0;		/* RPC-RDMA handles framing */
 	xprt->ops = &xprt_rdma_procs;
 
 	/*
net/sunrpc/xprtsock.c +42 -27

154 lines not on this page · raw message

#1 lore raw
Quoted 18 lines · Chuck Lever
net/sunrpc/xprtsock.c +9 -0
index d5ce1a8..66b08aa 100644
@@ -678,6 +678,31 @@ static void xs_stream_data_receive_workfn(struct
 work_struct *work)
 
 #define XS_SENDMSG_FLAGS	(MSG_DONTWAIT | MSG_NOSIGNAL)
 
+static int xs_send_record_marker(struct sock_xprt *transport,
+				 const struct rpc_rqst *req)
+{
+	static struct msghdr msg = {
+		.msg_name	= NULL,
+		.msg_namelen	= 0,
+		.msg_flags	= (XS_SENDMSG_FLAGS | MSG_MORE),
+	};
+	rpc_fraghdr marker;

net/sunrpc/xprtsock.c static void xs_stream_data_receive_workfn(struct · line 700

Quoted 10 lines
net/sunrpc/xprtsock.c +10 -0
+	struct kvec iov = {
+		.iov_base	= &marker,
+		.iov_len	= sizeof(marker),
+	};
+	u32 reclen;
+
+	if (unlikely(!transport->sock))
+		return -ENOTSOCK;
+	if (req->rq_bytes_sent)
+		return 0;

The test needs to use transport->xmit.offset, not req->rq_bytes_sent You also need to update transport->xmit.offset on success, and be prepared to handle the case where < sizeof(marker) bytes get transmitted due to a write_space condition.

net/sunrpc/xprtsock.c static void xs_stream_data_receive_workfn(struct work_struct *work)

Quoted 5 lines
net/sunrpc/xprtsock.c +4 -0
+
+	reclen = req->rq_snd_buf.len;
+	marker = cpu_to_be32(RPC_LAST_STREAM_FRAGMENT | reclen);
+	return kernel_sendmsg(transport->sock, &msg, &iov, 1,
 iov.iov_len);

So what does this do for performance? I'd expect that adding another dive into the socket layer will come with penalties.

Signature · 3 lines
Trond Myklebust
Linux NFS client maintainer, Hammerspace
[email protected]
#2 lore raw
Quoted 27 lines · Trond Myklebust
Quoted 22 lines · Chuck Lever
net/sunrpc/xprtsock.c +13 -0
index d5ce1a8..66b08aa 100644
@@ -678,6 +678,31 @@ static void xs_stream_data_receive_workfn(struct
 work_struct *work)
 
 #define XS_SENDMSG_FLAGS	(MSG_DONTWAIT | MSG_NOSIGNAL)
 
+static int xs_send_record_marker(struct sock_xprt *transport,
+				 const struct rpc_rqst *req)
+{
+	static struct msghdr msg = {
+		.msg_name	= NULL,
+		.msg_namelen	= 0,
+		.msg_flags	= (XS_SENDMSG_FLAGS | MSG_MORE),
+	};
+	rpc_fraghdr marker;
+	struct kvec iov = {
+		.iov_base	= &marker,
+		.iov_len	= sizeof(marker),
+	};
Quoted 8 lines

net/sunrpc/xprtsock.c static void xs_stream_data_receive_workfn(struct work_struct *work) · line 699

Quoted 6 lines
net/sunrpc/xprtsock.c +6 -0
+	u32 reclen;
+
+	if (unlikely(!transport->sock))
+		return -ENOTSOCK;
+	if (req->rq_bytes_sent)
+		return 0;

The test needs to use transport->xmit.offset, not req->rq_bytes_sent.

OK, that seems to work better.

Quoted 1 line

You also need to update transport->xmit.offset on success,

That causes the first 4 bytes of the rq_snd_buf to not be sent. Not updating xmit.offset seems more correct.

Quoted 3 lines

and be
prepared to handle the case where < sizeof(marker) bytes get transmitted due to a write_space condition.

Probably the only recourse is to break the connection.

Quoted 9 lines

net/sunrpc/xprtsock.c static void xs_stream_data_receive_workfn(struct work_struct *work)

Quoted 5 lines
net/sunrpc/xprtsock.c +4 -0
+
+	reclen = req->rq_snd_buf.len;
+	marker = cpu_to_be32(RPC_LAST_STREAM_FRAGMENT | reclen);
+	return kernel_sendmsg(transport->sock, &msg, &iov, 1,
 iov.iov_len);

So what does this do for performance? I'd expect that adding another dive into the socket layer will come with penalties.

NFSv3 on TCP, sec=sys, 56Gbs IBoIP, v4.20 + my v4.21 patches fio, 8KB random, 70% read, 30% write, 16 threads, iodepth=16

Without this patch:

read: IOPS=28.7k, BW=224MiB/s (235MB/s)(11.2GiB/51092msec)
write: IOPS=12.3k, BW=96.3MiB/s (101MB/s)(4918MiB/51092msec)

With this patch:

read: IOPS=28.6k, BW=224MiB/s (235MB/s)(11.2GiB/51276msec)
write: IOPS=12.3k, BW=95.8MiB/s (100MB/s)(4914MiB/51276msec)

Seems like that's in the noise.

--
Chuck Lever

#3 lore raw
Quoted 24 lines · Chuck Lever
Quoted 13 lines · Trond Myklebust
Quoted 5 lines · Chuck Lever
net/sunrpc/xprtsock.c +3 -0
+	reclen = req->rq_snd_buf.len;
+	marker = cpu_to_be32(RPC_LAST_STREAM_FRAGMENT | reclen);
+	return kernel_sendmsg(transport->sock, &msg, &iov, 1,

iov.iov_len);

So what does this do for performance? I'd expect that adding another dive into the socket layer will come with penalties.

NFSv3 on TCP, sec=sys, 56Gbs IBoIP, v4.20 + my v4.21 patches fio, 8KB random, 70% read, 30% write, 16 threads, iodepth=16

Without this patch:

read: IOPS=28.7k, BW=224MiB/s (235MB/s)(11.2GiB/51092msec)
write: IOPS=12.3k, BW=96.3MiB/s (101MB/s)(4918MiB/51092msec)

Quoted 6 lines

With this patch:

read: IOPS=28.6k, BW=224MiB/s (235MB/s)(11.2GiB/51276msec)
write: IOPS=12.3k, BW=95.8MiB/s (100MB/s)(4914MiB/51276msec)

Seems like that's in the noise.

Sigh. That's because it was the same kernel. Again, with feeling:

4.20.0-rc7-00048-g9274254:
read: IOPS=28.6k, BW=224MiB/s (235MB/s)(11.2GiB/51276msec)
write: IOPS=12.3k, BW=95.8MiB/s (100MB/s)(4914MiB/51276msec)

4.20.0-rc7-00049-ga4dea15:
read: IOPS=27.2k, BW=212MiB/s (223MB/s)(11.2GiB/53979msec)
write: IOPS=11.7k, BW=91.1MiB/s (95.5MB/s)(4917MiB/53979msec)

--
Chuck Lever

#4 lore raw
Quoted 34 lines · Chuck Lever
Quoted 25 lines
Quoted 4 lines · Chuck Lever

On Jan 3, 2019, at 1:47 PM, Trond Myklebust <
[email protected]> wrote:

On Thu, 2019-01-03 at 13:29 -0500, Chuck Lever wrote:

Quoted 9 lines
Quoted 5 lines
(quoted diff) +2 -0
+	reclen = req->rq_snd_buf.len;
+	marker = cpu_to_be32(RPC_LAST_STREAM_FRAGMENT |

reclen);

(quoted diff) +1 -0
+	return kernel_sendmsg(transport->sock, &msg, &iov, 1,

iov.iov_len);

So what does this do for performance? I'd expect that adding another
dive into the socket layer will come with penalties.

NFSv3 on TCP, sec=sys, 56Gbs IBoIP, v4.20 + my v4.21 patches fio, 8KB random, 70% read, 30% write, 16 threads, iodepth=16

Without this patch:

read: IOPS=28.7k, BW=224MiB/s (235MB/s)(11.2GiB/51092msec)
write: IOPS=12.3k, BW=96.3MiB/s (101MB/s)(4918MiB/51092msec)

Quoted 6 lines

With this patch:

read: IOPS=28.6k, BW=224MiB/s (235MB/s)(11.2GiB/51276msec)
write: IOPS=12.3k, BW=95.8MiB/s (100MB/s)(4914MiB/51276msec)

Seems like that's in the noise.

Sigh. That's because it was the same kernel. Again, with feeling:

Quoted 8 lines

4.20.0-rc7-00048-g9274254:

   read: IOPS=28.6k, BW=224MiB/s (235MB/s)(11.2GiB/51276msec)

write: IOPS=12.3k, BW=95.8MiB/s (100MB/s)(4914MiB/51276msec)

4.20.0-rc7-00049-ga4dea15:

   read: IOPS=27.2k, BW=212MiB/s (223MB/s)(11.2GiB/53979msec)

write: IOPS=11.7k, BW=91.1MiB/s (95.5MB/s)(4917MiB/53979msec)

So about a 5% reduction in performance?

Signature · 3 lines
Trond Myklebust
Linux NFS client maintainer, Hammerspace
[email protected]
#5 lore raw
Quoted 43 lines · Trond Myklebust
Quoted 38 lines · Chuck Lever
Quoted 25 lines
Quoted 4 lines · Chuck Lever

On Jan 3, 2019, at 1:47 PM, Trond Myklebust <
[email protected]> wrote:

On Thu, 2019-01-03 at 13:29 -0500, Chuck Lever wrote:

Quoted 9 lines
Quoted 5 lines
(quoted diff) +2 -0
+	reclen = req->rq_snd_buf.len;
+	marker = cpu_to_be32(RPC_LAST_STREAM_FRAGMENT |

reclen);

(quoted diff) +1 -0
+	return kernel_sendmsg(transport->sock, &msg, &iov, 1,

iov.iov_len);

So what does this do for performance? I'd expect that adding another
dive into the socket layer will come with penalties.

NFSv3 on TCP, sec=sys, 56Gbs IBoIP, v4.20 + my v4.21 patches fio, 8KB random, 70% read, 30% write, 16 threads, iodepth=16

Without this patch:

read: IOPS=28.7k, BW=224MiB/s (235MB/s)(11.2GiB/51092msec)
write: IOPS=12.3k, BW=96.3MiB/s (101MB/s)(4918MiB/51092msec)

Quoted 6 lines

With this patch:

read: IOPS=28.6k, BW=224MiB/s (235MB/s)(11.2GiB/51276msec)
write: IOPS=12.3k, BW=95.8MiB/s (100MB/s)(4914MiB/51276msec)

Seems like that's in the noise.

Sigh. That's because it was the same kernel. Again, with feeling:

4.20.0-rc7-00048-g9274254:
read: IOPS=28.6k, BW=224MiB/s (235MB/s)(11.2GiB/51276msec)
write: IOPS=12.3k, BW=95.8MiB/s (100MB/s)(4914MiB/51276msec)

Quoted 6 lines
Quoted 4 lines

4.20.0-rc7-00049-ga4dea15:
read: IOPS=27.2k, BW=212MiB/s (223MB/s)(11.2GiB/53979msec)
write: IOPS=11.7k, BW=91.1MiB/s (95.5MB/s)(4917MiB/53979msec)

So about a 5% reduction in performance?

On this workload, yes.

Could send the record marker in xs_send_kvec with the head[0] iovec. I'm going to try that next.

--
Chuck Lever

#6 lore raw
Quoted 49 lines · Chuck Lever
Quoted 47 lines · Trond Myklebust
Quoted 42 lines · Chuck Lever
Quoted 25 lines
Quoted 4 lines · Chuck Lever

On Jan 3, 2019, at 1:47 PM, Trond Myklebust <
[email protected]> wrote:

On Thu, 2019-01-03 at 13:29 -0500, Chuck Lever wrote:

Quoted 9 lines
Quoted 5 lines
(quoted diff) +2 -0
+	reclen = req->rq_snd_buf.len;
+	marker = cpu_to_be32(RPC_LAST_STREAM_FRAGMENT |

reclen);

(quoted diff) +1 -0
+	return kernel_sendmsg(transport->sock, &msg, &iov, 1,

iov.iov_len);

So what does this do for performance? I'd expect that adding another
dive into the socket layer will come with penalties.

NFSv3 on TCP, sec=sys, 56Gbs IBoIP, v4.20 + my v4.21 patches fio, 8KB random, 70% read, 30% write, 16 threads, iodepth=16

Without this patch:

read: IOPS=28.7k, BW=224MiB/s (235MB/s)(11.2GiB/51092msec)
write: IOPS=12.3k, BW=96.3MiB/s (101MB/s)(4918MiB/51092msec)

Quoted 6 lines

With this patch:

read: IOPS=28.6k, BW=224MiB/s (235MB/s)(11.2GiB/51276msec)
write: IOPS=12.3k, BW=95.8MiB/s (100MB/s)(4914MiB/51276msec)

Seems like that's in the noise.

Sigh. That's because it was the same kernel. Again, with feeling:

4.20.0-rc7-00048-g9274254:
read: IOPS=28.6k, BW=224MiB/s (235MB/s)(11.2GiB/51276msec)
write: IOPS=12.3k, BW=95.8MiB/s (100MB/s)(4914MiB/51276msec)

4.20.0-rc7-00049-ga4dea15:
read: IOPS=27.2k, BW=212MiB/s (223MB/s)(11.2GiB/53979msec)
write: IOPS=11.7k, BW=91.1MiB/s (95.5MB/s)(4917MiB/53979msec)

Quoted 6 lines
Quoted 1 line

So about a 5% reduction in performance?

On this workload, yes.

Could send the record marker in xs_send_kvec with the head[0] iovec. I'm going to try that next.

That helps:

Linux 4.20.0-rc7-00049-g664f679 #651 SMP Thu Jan 3 17:35:26 EST 2019

read: IOPS=28.7k, BW=224MiB/s (235MB/s)(11.2GiB/51185msec)
write: IOPS=12.3k, BW=96.1MiB/s (101MB/s)(4919MiB/51185msec)

--
Chuck Lever

#7 lore raw
Quoted 61 lines · Chuck Lever
Quoted 53 lines
Quoted 50 lines · Chuck Lever

On Jan 3, 2019, at 4:28 PM, Trond Myklebust <
[email protected]> wrote:

Quoted 45 lines · Chuck Lever
Quoted 27 lines
Quoted 4 lines · Chuck Lever

On Jan 3, 2019, at 1:47 PM, Trond Myklebust <
[email protected]> wrote:

On Thu, 2019-01-03 at 13:29 -0500, Chuck Lever wrote:

Quoted 10 lines
Quoted 5 lines
(quoted diff) +2 -0
+	reclen = req->rq_snd_buf.len;
+	marker = cpu_to_be32(RPC_LAST_STREAM_FRAGMENT |

reclen);

(quoted diff) +1 -0
+	return kernel_sendmsg(transport->sock, &msg, &iov, 1,

iov.iov_len);

So what does this do for performance? I'd expect that adding
another
dive into the socket layer will come with penalties.

NFSv3 on TCP, sec=sys, 56Gbs IBoIP, v4.20 + my v4.21 patches fio, 8KB random, 70% read, 30% write, 16 threads, iodepth=16

Without this patch:

read: IOPS=28.7k, BW=224MiB/s (235MB/s)(11.2GiB/51092msec)
write: IOPS=12.3k, BW=96.3MiB/s (101MB/s)(4918MiB/51092msec)

Quoted 6 lines

With this patch:

read: IOPS=28.6k, BW=224MiB/s (235MB/s)(11.2GiB/51276msec)
write: IOPS=12.3k, BW=95.8MiB/s (100MB/s)(4914MiB/51276msec)

Seems like that's in the noise.

Sigh. That's because it was the same kernel. Again, with feeling:

4.20.0-rc7-00048-g9274254:
read: IOPS=28.6k, BW=224MiB/s (235MB/s)(11.2GiB/51276msec)
write: IOPS=12.3k, BW=95.8MiB/s (100MB/s)(4914MiB/51276msec)

4.20.0-rc7-00049-ga4dea15:
read: IOPS=27.2k, BW=212MiB/s (223MB/s)(11.2GiB/53979msec)
write: IOPS=11.7k, BW=91.1MiB/s (95.5MB/s)(4917MiB/53979msec)

Quoted 7 lines
Quoted 1 line

So about a 5% reduction in performance?

On this workload, yes.

Could send the record marker in xs_send_kvec with the head[0] iovec.
I'm going to try that next.

Quoted 7 lines

That helps:

Linux 4.20.0-rc7-00049-g664f679 #651 SMP Thu Jan 3 17:35:26 EST 2019

   read: IOPS=28.7k, BW=224MiB/s (235MB/s)(11.2GiB/51185msec)

write: IOPS=12.3k, BW=96.1MiB/s (101MB/s)(4919MiB/51185msec)

Interesting... Perhaps we might be able to eke out a few more percent performance on file writes by also converting xs_send_pagedata() to use a single sock_sendmsg() w/ iov_iter rather than looping through several calls to sendpage()?

Signature · 3 lines
Trond Myklebust
Linux NFS client maintainer, Hammerspace
[email protected]
#8 lore raw
Quoted 70 lines · Trond Myklebust
Quoted 65 lines · Chuck Lever
Quoted 53 lines
Quoted 50 lines · Chuck Lever

On Jan 3, 2019, at 4:28 PM, Trond Myklebust <
[email protected]> wrote:

Quoted 45 lines · Chuck Lever
Quoted 27 lines
Quoted 4 lines · Chuck Lever

On Jan 3, 2019, at 1:47 PM, Trond Myklebust <
[email protected]> wrote:

On Thu, 2019-01-03 at 13:29 -0500, Chuck Lever wrote:

Quoted 10 lines
Quoted 5 lines
(quoted diff) +2 -0
+	reclen = req->rq_snd_buf.len;
+	marker = cpu_to_be32(RPC_LAST_STREAM_FRAGMENT |

reclen);

(quoted diff) +1 -0
+	return kernel_sendmsg(transport->sock, &msg, &iov, 1,

iov.iov_len);

So what does this do for performance? I'd expect that adding
another
dive into the socket layer will come with penalties.

NFSv3 on TCP, sec=sys, 56Gbs IBoIP, v4.20 + my v4.21 patches fio, 8KB random, 70% read, 30% write, 16 threads, iodepth=16

Without this patch:

read: IOPS=28.7k, BW=224MiB/s (235MB/s)(11.2GiB/51092msec)
write: IOPS=12.3k, BW=96.3MiB/s (101MB/s)(4918MiB/51092msec)

Quoted 6 lines

With this patch:

read: IOPS=28.6k, BW=224MiB/s (235MB/s)(11.2GiB/51276msec)
write: IOPS=12.3k, BW=95.8MiB/s (100MB/s)(4914MiB/51276msec)

Seems like that's in the noise.

Sigh. That's because it was the same kernel. Again, with feeling:

4.20.0-rc7-00048-g9274254:
read: IOPS=28.6k, BW=224MiB/s (235MB/s)(11.2GiB/51276msec)
write: IOPS=12.3k, BW=95.8MiB/s (100MB/s)(4914MiB/51276msec)

4.20.0-rc7-00049-ga4dea15:
read: IOPS=27.2k, BW=212MiB/s (223MB/s)(11.2GiB/53979msec)
write: IOPS=11.7k, BW=91.1MiB/s (95.5MB/s)(4917MiB/53979msec)

Quoted 7 lines
Quoted 1 line

So about a 5% reduction in performance?

On this workload, yes.

Could send the record marker in xs_send_kvec with the head[0] iovec.
I'm going to try that next.

That helps:

Linux 4.20.0-rc7-00049-g664f679 #651 SMP Thu Jan 3 17:35:26 EST 2019

Quoted 8 lines
Quoted 3 lines

read: IOPS=28.7k, BW=224MiB/s (235MB/s)(11.2GiB/51185msec)
write: IOPS=12.3k, BW=96.1MiB/s (101MB/s)(4919MiB/51185msec)

Interesting... Perhaps we might be able to eke out a few more percent performance on file writes by also converting xs_send_pagedata() to use a single sock_sendmsg() w/ iov_iter rather than looping through several calls to sendpage()?

IMO...

For small requests (say, smaller than 17 pages), packing the head, pagevec, and tail into an iov_iter and sending them all via a single sock_sendmsg call would likely be efficient.

For larger requests, other overheads would dominate. And you'd have to keep around an iter array that held 257 entries... You could pass a large pagevec to sock_sendmsg in smaller chunks.

Are you thinking of converting xs_sendpages (or even xdr_bufs) to use iov_iter directly?

--
Chuck Lever

#9 lore raw
Quoted 100 lines · Chuck Lever
Quoted 84 lines

On Jan 3, 2019, at 11:00 PM, Trond Myklebust <
[email protected]> wrote:

Quoted 71 lines · Chuck Lever
Quoted 63 lines

On Jan 3, 2019, at 4:35 PM, Chuck Lever <[email protected]

Quoted 1 line
Quoted 59 lines · wrote:

On Jan 3, 2019, at 4:28 PM, Trond Myklebust <
[email protected]> wrote:

Quoted 54 lines · Chuck Lever
Quoted 32 lines
Quoted 4 lines · Chuck Lever

On Jan 3, 2019, at 1:47 PM, Trond Myklebust <
[email protected]> wrote:

On Thu, 2019-01-03 at 13:29 -0500, Chuck Lever wrote:

Quoted 11 lines
Quoted 6 lines
(quoted diff) +2 -0
+	reclen = req->rq_snd_buf.len;
+	marker = cpu_to_be32(RPC_LAST_STREAM_FRAGMENT |

reclen);

(quoted diff) +1 -0
+	return kernel_sendmsg(transport->sock, &msg,

&iov, 1,
iov.iov_len);

So what does this do for performance? I'd expect that adding
another
dive into the socket layer will come with penalties.

NFSv3 on TCP, sec=sys, 56Gbs IBoIP, v4.20 + my v4.21 patches
fio, 8KB random, 70% read, 30% write, 16 threads, iodepth=16

Without this patch:

read: IOPS=28.7k, BW=224MiB/s
(235MB/s)(11.2GiB/51092msec)
write: IOPS=12.3k, BW=96.3MiB/s
(101MB/s)(4918MiB/51092msec)

Quoted 8 lines

With this patch:

read: IOPS=28.6k, BW=224MiB/s
(235MB/s)(11.2GiB/51276msec)
write: IOPS=12.3k, BW=95.8MiB/s
(100MB/s)(4914MiB/51276msec)

Seems like that's in the noise.

Sigh. That's because it was the same kernel. Again, with feeling:

4.20.0-rc7-00048-g9274254:
read: IOPS=28.6k, BW=224MiB/s (235MB/s)(11.2GiB/51276msec)
write: IOPS=12.3k, BW=95.8MiB/s (100MB/s)(4914MiB/51276msec)

4.20.0-rc7-00049-ga4dea15:
read: IOPS=27.2k, BW=212MiB/s (223MB/s)(11.2GiB/53979msec)
write: IOPS=11.7k, BW=91.1MiB/s (95.5MB/s)(4917MiB/53979msec)

Quoted 7 lines
Quoted 1 line

So about a 5% reduction in performance?

On this workload, yes.

Could send the record marker in xs_send_kvec with the head[0] iovec.
I'm going to try that next.

Quoted 8 lines

That helps:

Linux 4.20.0-rc7-00049-g664f679 #651 SMP Thu Jan 3 17:35:26 EST 2019

read: IOPS=28.7k, BW=224MiB/s (235MB/s)(11.2GiB/51185msec)
write: IOPS=12.3k, BW=96.1MiB/s (101MB/s)(4919MiB/51185msec)

Quoted 7 lines

Interesting... Perhaps we might be able to eke out a few more percent
performance on file writes by also converting xs_send_pagedata() to use
a single sock_sendmsg() w/ iov_iter rather than looping through several
calls to sendpage()?

IMO...

For small requests (say, smaller than 17 pages), packing the head, pagevec,
and tail into an iov_iter and sending them all via a single sock_sendmsg
call would likely be efficient.

Quoted 7 lines

For larger requests, other overheads would dominate. And you'd have to keep around an iter array that held 257 entries... You could pass a
large pagevec to sock_sendmsg in smaller chunks.

Are you thinking of converting xs_sendpages (or even xdr_bufs) to use iov_iter directly?

For now, I was thinking of just converting xs_sendpages to call xdr_alloc_bvec(), and then do the equivalent of what xs_read_bvec() does for receives today.

The next step is to convert xdr_bufs to use bvecs natively instead of having to allocate them to shadow the array of pages. I believe someone was working on allowing a single bvec to take an array of pages (containing contiguous data), which would make that conversion almost trivial.

The final step would be to do as you say, to pack the kvecs into the same call to sock_sendmsg() as the bvecs. We might imagine adding a new type of iov_iter that can iterate over an array of struct iov_iter in order to deal with this case?

Signature · 3 lines
Trond Myklebust
Linux NFS client maintainer, Hammerspace
[email protected]
#10 lore raw
Quoted 123 lines · Trond Myklebust
Quoted 100 lines · Chuck Lever
Quoted 84 lines

On Jan 3, 2019, at 11:00 PM, Trond Myklebust <
[email protected]> wrote:

Quoted 71 lines · Chuck Lever
Quoted 63 lines

On Jan 3, 2019, at 4:35 PM, Chuck Lever <[email protected]

Quoted 1 line
Quoted 59 lines · wrote:

On Jan 3, 2019, at 4:28 PM, Trond Myklebust <
[email protected]> wrote:

Quoted 54 lines · Chuck Lever
Quoted 32 lines
Quoted 4 lines · Chuck Lever

On Jan 3, 2019, at 1:47 PM, Trond Myklebust <
[email protected]> wrote:

On Thu, 2019-01-03 at 13:29 -0500, Chuck Lever wrote:

Quoted 11 lines
Quoted 6 lines
(quoted diff) +2 -0
+	reclen = req->rq_snd_buf.len;
+	marker = cpu_to_be32(RPC_LAST_STREAM_FRAGMENT |

reclen);

(quoted diff) +1 -0
+	return kernel_sendmsg(transport->sock, &msg,

&iov, 1,
iov.iov_len);

So what does this do for performance? I'd expect that adding
another
dive into the socket layer will come with penalties.

NFSv3 on TCP, sec=sys, 56Gbs IBoIP, v4.20 + my v4.21 patches
fio, 8KB random, 70% read, 30% write, 16 threads, iodepth=16

Without this patch:

read: IOPS=28.7k, BW=224MiB/s
(235MB/s)(11.2GiB/51092msec)
write: IOPS=12.3k, BW=96.3MiB/s
(101MB/s)(4918MiB/51092msec)

Quoted 8 lines

With this patch:

read: IOPS=28.6k, BW=224MiB/s
(235MB/s)(11.2GiB/51276msec)
write: IOPS=12.3k, BW=95.8MiB/s
(100MB/s)(4914MiB/51276msec)

Seems like that's in the noise.

Sigh. That's because it was the same kernel. Again, with feeling:

4.20.0-rc7-00048-g9274254:
read: IOPS=28.6k, BW=224MiB/s (235MB/s)(11.2GiB/51276msec)
write: IOPS=12.3k, BW=95.8MiB/s (100MB/s)(4914MiB/51276msec)

4.20.0-rc7-00049-ga4dea15:
read: IOPS=27.2k, BW=212MiB/s (223MB/s)(11.2GiB/53979msec)
write: IOPS=11.7k, BW=91.1MiB/s (95.5MB/s)(4917MiB/53979msec)

Quoted 7 lines
Quoted 1 line

So about a 5% reduction in performance?

On this workload, yes.

Could send the record marker in xs_send_kvec with the head[0] iovec.
I'm going to try that next.

Quoted 8 lines

That helps:

Linux 4.20.0-rc7-00049-g664f679 #651 SMP Thu Jan 3 17:35:26 EST 2019

read: IOPS=28.7k, BW=224MiB/s (235MB/s)(11.2GiB/51185msec)
write: IOPS=12.3k, BW=96.1MiB/s (101MB/s)(4919MiB/51185msec)

Quoted 7 lines

Interesting... Perhaps we might be able to eke out a few more percent
performance on file writes by also converting xs_send_pagedata() to use
a single sock_sendmsg() w/ iov_iter rather than looping through several
calls to sendpage()?

IMO...

For small requests (say, smaller than 17 pages), packing the head, pagevec,
and tail into an iov_iter and sending them all via a single sock_sendmsg
call would likely be efficient.

Quoted 7 lines

For larger requests, other overheads would dominate. And you'd have to keep around an iter array that held 257 entries... You could pass a
large pagevec to sock_sendmsg in smaller chunks.

Are you thinking of converting xs_sendpages (or even xdr_bufs) to use iov_iter directly?

For now, I was thinking of just converting xs_sendpages to call xdr_alloc_bvec(), and then do the equivalent of what xs_read_bvec() does for receives today.

The next step is to convert xdr_bufs to use bvecs natively instead of having to allocate them to shadow the array of pages. I believe someone was working on allowing a single bvec to take an array of pages (containing contiguous data), which would make that conversion almost trivial.

Quoted 4 lines

The final step would be to do as you say, to pack the kvecs into the same call to sock_sendmsg() as the bvecs. We might imagine adding a new type of iov_iter that can iterate over an array of struct iov_iter in order to deal with this case?

The same approach might help svc_send_common, and could be an easier first step.

--
Chuck Lever