Skip to contentSkip to conversation

SUNRPC: Use MSG_SENDPAGE_NOTLAST when calling sendpage()

PATCH In review Trond Myklebust 2 participants 7 messages Oct 7, 2015 – Oct 8, 2015

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

PATCH 1/1 SUNRPC: Use MSG_SENDPAGE_NOTLAST when calling sendpage()

If we're sending more pages via kernel_sendpage(), then set MSG_SENDPAGE_NOTLAST.

---
 net/sunrpc/svcsock.c  | 2 +-
 net/sunrpc/xprtsock.c | 4 +++-
 2 files changed, 4 insertions(+), 2 deletions(-)
net/sunrpc/svcsock.c +1 -1
index 0c8120229a03..48923730722d 100644
@@ -181,7 +181,7 @@ int svc_send_common(struct socket *sock, struct xdr_buf *xdr,
 	struct page	**ppage = xdr->pages;
 	size_t		base = xdr->page_base;
 	unsigned int	pglen = xdr->page_len;
-	unsigned int	flags = MSG_MORE;
+	unsigned int	flags = MSG_MORE | MSG_SENDPAGE_NOTLAST;
 	int		slen;
 	int		len = 0;
 
net/sunrpc/xprtsock.c +3 -1
index 1471ecceabf9..e71aff251ac1 100644
@@ -360,8 +360,10 @@ static int xs_send_pagedata(struct socket *sock, struct xdr_buf *xdr, unsigned i
 		int flags = XS_SENDMSG_FLAGS;
 
 		remainder -= len;
-		if (remainder != 0 || more)
+		if (more)
 			flags |= MSG_MORE;
+		if (remainder != 0)
+			flags |= MSG_SENDPAGE_NOTLAST | MSG_MORE;
 		err = do_sendpage(sock, *ppage, base, len, flags);
 		if (remainder == 0 || err != len)
 			break;
Signature · 1 line
2.4.3
#1 lore raw
Quoted 2 lines · Trond Myklebust

If we're sending more pages via kernel_sendpage(), then set MSG_SENDPAGE_NOTLAST.

Given that we've survived without this a while, I assume this is a hint that may provide better performance in some cases (have you seen that?) and that it doesn't have to be 100% correct?

In which case, looks fine, will queue up for 4.4....

--b.

Quoted 38 lines
---
 net/sunrpc/svcsock.c  | 2 +-
 net/sunrpc/xprtsock.c | 4 +++-
 2 files changed, 4 insertions(+), 2 deletions(-)
net/sunrpc/svcsock.c +1 -1
index 0c8120229a03..48923730722d 100644
@@ -181,7 +181,7 @@ int svc_send_common(struct socket *sock, struct xdr_buf *xdr,
 	struct page	**ppage = xdr->pages;
 	size_t		base = xdr->page_base;
 	unsigned int	pglen = xdr->page_len;
-	unsigned int	flags = MSG_MORE;
+	unsigned int	flags = MSG_MORE | MSG_SENDPAGE_NOTLAST;
 	int		slen;
 	int		len = 0;
 
net/sunrpc/xprtsock.c +3 -1
index 1471ecceabf9..e71aff251ac1 100644
@@ -360,8 +360,10 @@ static int xs_send_pagedata(struct socket *sock, struct xdr_buf *xdr, unsigned i
 		int flags = XS_SENDMSG_FLAGS;
 
 		remainder -= len;
-		if (remainder != 0 || more)
+		if (more)
 			flags |= MSG_MORE;
+		if (remainder != 0)
+			flags |= MSG_SENDPAGE_NOTLAST | MSG_MORE;
 		err = do_sendpage(sock, *ppage, base, len, flags);
 		if (remainder == 0 || err != len)
 			break;
Signature · 1 line
2.4.3
#2 lore raw
Quoted 7 lines · Bruce Fields
Quoted 2 lines · Trond Myklebust

If we're sending more pages via kernel_sendpage(), then set MSG_SENDPAGE_NOTLAST.

Given that we've survived without this a while, I assume this is a hint that may provide better performance in some cases (have you seen that?) and that it doesn't have to be 100% correct?

See the original motivation in:

commit 2f5338442425 ("tcp: allow splice() to build full TSO packets")

and the later bugfix (which actually introduces MSG_SENDPAGE_NOTLAST):

commit 35f9c09fe9c7 ("tcp: tcp_sendpages() should call tcp_push() once")

Quoted 1 line

In which case, looks fine, will queue up for 4.4....

Sure. It's a minor performance enhancement, so there is no immediate rush.

#3 lore raw
Quoted 13 lines · Trond Myklebust
Quoted 7 lines · Bruce Fields
Quoted 2 lines · Trond Myklebust

If we're sending more pages via kernel_sendpage(), then set MSG_SENDPAGE_NOTLAST.

Given that we've survived without this a while, I assume this is a hint that may provide better performance in some cases (have you seen that?) and that it doesn't have to be 100% correct?

See the original motivation in:

commit 2f5338442425 ("tcp: allow splice() to build full TSO packets")

Quoted 7 lines

and the later bugfix (which actually introduces MSG_SENDPAGE_NOTLAST):

commit 35f9c09fe9c7 ("tcp: tcp_sendpages() should call tcp_push() once")

Quoted 1 line

In which case, looks fine, will queue up for 4.4....

Sure. It's a minor performance enhancement, so there is no immediate rush.

Actually, please let me split this into 2 subpatches; one for the sunrpc server code and one for the client. It would make it easier for me if I could keep the client performance stuff in one branch.

#4 lore raw
Quoted 19 lines · Trond Myklebust
Quoted 17 lines · Trond Myklebust
Quoted 7 lines · Bruce Fields
Quoted 2 lines · Trond Myklebust

If we're sending more pages via kernel_sendpage(), then set MSG_SENDPAGE_NOTLAST.

Given that we've survived without this a while, I assume this is a hint that may provide better performance in some cases (have you seen that?) and that it doesn't have to be 100% correct?

See the original motivation in:

commit 2f5338442425 ("tcp: allow splice() to build full TSO packets")

and the later bugfix (which actually introduces MSG_SENDPAGE_NOTLAST):

commit 35f9c09fe9c7 ("tcp: tcp_sendpages() should call tcp_push() once")

Quoted 7 lines
Quoted 3 lines
Quoted 1 line

In which case, looks fine, will queue up for 4.4....

Sure. It's a minor performance enhancement, so there is no immediate rush.

Actually, please let me split this into 2 subpatches; one for the sunrpc server code and one for the client. It would make it easier for me if I could keep the client performance stuff in one branch.

Sure, makes sense.--b.

#5 lore raw

PATCH v2 1/2 SUNRPC: Use MSG_SENDPAGE_NOTLAST in xs_send_pagedata()

If we're sending more than one page via kernel_sendpage(), then set MSG_SENDPAGE_NOTLAST between the pages so that we don't send suboptimal frames (see commit 2f5338442425 and commit 35f9c09fe9c7).

---
 net/sunrpc/xprtsock.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
net/sunrpc/xprtsock.c +3 -1
index 1471ecceabf9..e71aff251ac1 100644
@@ -360,8 +360,10 @@ static int xs_send_pagedata(struct socket *sock, struct xdr_buf *xdr, unsigned i
 		int flags = XS_SENDMSG_FLAGS;
 
 		remainder -= len;
-		if (remainder != 0 || more)
+		if (more)
 			flags |= MSG_MORE;
+		if (remainder != 0)
+			flags |= MSG_SENDPAGE_NOTLAST | MSG_MORE;
 		err = do_sendpage(sock, *ppage, base, len, flags);
 		if (remainder == 0 || err != len)
 			break;
Signature · 1 line
2.4.3
#6 lore raw

PATCH v2 2/2 SUNRPC: Use MSG_SENDPAGE_NOTLAST in svc_send_common()

Allow the NFS server to send large amounts of data in page form without forcing early transmit by do_tcp_sendpages(). See commit 2f5338442425 and commit 35f9c09fe9c7.

---
 net/sunrpc/svcsock.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
net/sunrpc/svcsock.c +1 -1
index 0c8120229a03..48923730722d 100644
@@ -181,7 +181,7 @@ int svc_send_common(struct socket *sock, struct xdr_buf *xdr,
 	struct page	**ppage = xdr->pages;
 	size_t		base = xdr->page_base;
 	unsigned int	pglen = xdr->page_len;
-	unsigned int	flags = MSG_MORE;
+	unsigned int	flags = MSG_MORE | MSG_SENDPAGE_NOTLAST;
 	int		slen;
 	int		len = 0;
 
Signature · 1 line
2.4.3