netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Ilpo Järvinen" <ilpo.jarvinen-pxSi+dnQzZMxHbG02/KK1g@public.gmane.org>
To: Chuck Lever <chuck.lever-QHcLZuEGTsvQT0dZR+AlfA@public.gmane.org>
Cc: "J. Bruce Fields"
	<bfields-uC3wQj2KruNg9hUCZPvPmw@public.gmane.org>,
	Trond Myklebust <trond-HgOvQuBEEgTQT0dZR+AlfA@public.gmane.org>,
	Linux NFS Mailing List
	<linux-nfs-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>,
	Netdev <netdev-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>
Subject: Re: [PATCH] net/sunrpc/xprtsock.c: some common code found
Date: Sat, 7 Feb 2009 00:58:44 +0200 (EET)	[thread overview]
Message-ID: <Pine.LNX.4.64.0902070040530.31875@wrl-59.cs.helsinki.fi> (raw)
In-Reply-To: <CAF18546-B024-40C9-8276-8FCD89C98E72-QHcLZuEGTsvQT0dZR+AlfA@public.gmane.org>

[-- Attachment #1: Type: TEXT/PLAIN, Size: 5479 bytes --]

On Fri, 6 Feb 2009, Chuck Lever wrote:

> On Feb 6, 2009, at Feb 6, 2009, 5:07 PM, David Miller wrote:
> >From: "J. Bruce Fields" <bfields-uC3wQj2KruNg9hUCZPvPmw@public.gmane.org>
> >Date: Fri, 6 Feb 2009 16:20:43 -0500
> >
> > >On Fri, Feb 06, 2009 at 10:53:32PM +0200, Ilpo Järvinen wrote:
> > > >Grr, forgot to cc sunrpc maintainer... Added. Just ask if somebody wants
> > > >a complete resend.
> > >
> > >You probably wanted Trond, actually.  (And did this patch have a
> > >changelog?)
> >
> >Open your eyes :-)  That first "diff" you see is part of the
> >commit message not the patch itself.
> 
> There needs to be an explanation (in English not in source code)

Hmm, so you didn't heed Dave's warning... :-D

I think your "English" is too strict requirement. There's patch title 
which tells what is found, in plain English. And _the explanation_ is 
there too, but using two tools (and their names are certainly 
self-explanary): diff-funcs and codiff. The output of the tools shows why 
this is useful (and every developer capable of reviewing patches in the 
first place should be able to understand the output format of the tools in 
question). If you don't care the output but dismiss that as "source code" 
there's nothing I can do to help you _to review_ the patch by writing 
paragraphs of text about the change. But just to make it even easier for 
you I've added one sentence more, in English before codiff ;-).

> of why this change is needed, even if you are simply refactoring code or 
> correcting a comment.

It's there. Read again :-).

> A short description that starts with "SUNRPC: " is also recommended, and
> please copy linux-nfs-u79uwXL29TY76Z2rM5mHXA@public.gmane.org when submitting RPC-related patches.

Well, I've changed the title now to please all. :-)

--
[PATCH] SUNRPC: some common code found in xprtsock.c; call to that

$ diff-funcs xs_udp_write_space net/sunrpc/xprtsock.c
net/sunrpc/xprtsock.c xs_tcp_write_space
 --- net/sunrpc/xprtsock.c:xs_udp_write_space()
 +++ net/sunrpc/xprtsock.c:xs_tcp_write_space()
@@ -1,4 +1,4 @@
- * xs_udp_write_space - callback invoked when socket buffer space
+ * xs_tcp_write_space - callback invoked when socket buffer space
  *                             becomes available
  * @sk: socket whose state has changed
  *
@@ -7,12 +7,12 @@
  * progress, otherwise we'll waste resources thrashing kernel_sendmsg
  * with a bunch of small requests.
  */
-static void xs_udp_write_space(struct sock *sk)
+static void xs_tcp_write_space(struct sock *sk)
 {
 	read_lock(&sk->sk_callback_lock);

-	/* from net/core/sock.c:sock_def_write_space */
-	if (sock_writeable(sk)) {
+	/* from net/core/stream.c:sk_stream_write_space */
+	if (sk_stream_wspace(sk) >= sk_stream_min_wspace(sk)) {
 		struct socket *sock;
 		struct rpc_xprt *xprt;

Besides less copy-paste, some space savings (measured allmodconfig 
x86_64) after the change:

$ codiff net/sunrpc/xprtsock.o net/sunrpc/xprtsock.o.new
net/sunrpc/xprtsock.c:
  xs_tcp_write_space | -163
  xs_udp_write_space | -163
 2 functions changed, 326 bytes removed

net/sunrpc/xprtsock.c:
  xs_write_space | +179
 1 function changed, 179 bytes added

net/sunrpc/xprtsock.o.new:
 3 functions changed, 179 bytes added, 326 bytes removed, diff: -147

Signed-off-by: Ilpo Järvinen <ilpo.jarvinen-pxSi+dnQzZMxHbG02/KK1g@public.gmane.org>
---
 net/sunrpc/xprtsock.c |   53 +++++++++++++++++++-----------------------------
 1 files changed, 21 insertions(+), 32 deletions(-)

diff --git a/net/sunrpc/xprtsock.c b/net/sunrpc/xprtsock.c
index 5cbb404..b49e434 100644
--- a/net/sunrpc/xprtsock.c
+++ b/net/sunrpc/xprtsock.c
@@ -1215,6 +1215,23 @@ out:
 	read_unlock(&sk->sk_callback_lock);
 }
 
+static void xs_write_space(struct sock *sk)
+{
+	struct socket *sock;
+	struct rpc_xprt *xprt;
+
+	if (unlikely(!(sock = sk->sk_socket)))
+		return;
+	clear_bit(SOCK_NOSPACE, &sock->flags);
+
+	if (unlikely(!(xprt = xprt_from_sock(sk))))
+		return;
+	if (test_and_clear_bit(SOCK_ASYNC_NOSPACE, &sock->flags) == 0)
+		return;
+
+	xprt_write_space(xprt);
+}
+
 /**
  * xs_udp_write_space - callback invoked when socket buffer space
  *                             becomes available
@@ -1230,23 +1247,9 @@ static void xs_udp_write_space(struct sock *sk)
 	read_lock(&sk->sk_callback_lock);
 
 	/* from net/core/sock.c:sock_def_write_space */
-	if (sock_writeable(sk)) {
-		struct socket *sock;
-		struct rpc_xprt *xprt;
-
-		if (unlikely(!(sock = sk->sk_socket)))
-			goto out;
-		clear_bit(SOCK_NOSPACE, &sock->flags);
-
-		if (unlikely(!(xprt = xprt_from_sock(sk))))
-			goto out;
-		if (test_and_clear_bit(SOCK_ASYNC_NOSPACE, &sock->flags) == 0)
-			goto out;
-
-		xprt_write_space(xprt);
-	}
+	if (sock_writeable(sk))
+		xs_write_space(sk);
 
- out:
 	read_unlock(&sk->sk_callback_lock);
 }
 
@@ -1265,23 +1268,9 @@ static void xs_tcp_write_space(struct sock *sk)
 	read_lock(&sk->sk_callback_lock);
 
 	/* from net/core/stream.c:sk_stream_write_space */
-	if (sk_stream_wspace(sk) >= sk_stream_min_wspace(sk)) {
-		struct socket *sock;
-		struct rpc_xprt *xprt;
-
-		if (unlikely(!(sock = sk->sk_socket)))
-			goto out;
-		clear_bit(SOCK_NOSPACE, &sock->flags);
+	if (sk_stream_wspace(sk) >= sk_stream_min_wspace(sk))
+		xs_write_space(sk);
 
-		if (unlikely(!(xprt = xprt_from_sock(sk))))
-			goto out;
-		if (test_and_clear_bit(SOCK_ASYNC_NOSPACE, &sock->flags) == 0)
-			goto out;
-
-		xprt_write_space(xprt);
-	}
-
- out:
 	read_unlock(&sk->sk_callback_lock);
 }
 
-- 
1.5.6.5

  parent reply	other threads:[~2009-02-06 22:58 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-02-06 20:51 [PATCH] net/sunrpc/xprtsock.c: some common code found Ilpo Järvinen
2009-02-06 20:53 ` Ilpo Järvinen
2009-02-06 21:20   ` J. Bruce Fields
2009-02-06 22:07     ` David Miller
     [not found]       ` <CAF18546-B024-40C9-8276-8FCD89C98E72@oracle.com>
     [not found]         ` <CAF18546-B024-40C9-8276-8FCD89C98E72-QHcLZuEGTsvQT0dZR+AlfA@public.gmane.org>
2009-02-06 22:58           ` Ilpo Järvinen [this message]
     [not found]             ` <Pine.LNX.4.64.0902070040530.31875-x/A8LOkYjdVsRR2hCrRKtT03IgOmwywn@public.gmane.org>
2009-02-07  3:22               ` David Miller
     [not found]                 ` <20090206.192243.47948705.davem-fT/PcQaiUtIeIZ0/mPfg9Q@public.gmane.org>
2009-02-07 16:23                   ` Trond Myklebust
     [not found]                     ` <1234023804.17241.14.camel-rJ7iovZKK19ZJLDQqaL3InhyD016LWXt@public.gmane.org>
2009-02-07 16:56                       ` Ilpo Järvinen
2009-02-07 17:22                         ` Trond Myklebust
     [not found]                           ` <1234027321.17241.25.camel-rJ7iovZKK19ZJLDQqaL3InhyD016LWXt@public.gmane.org>
2009-02-08  3:00                             ` David Miller
     [not found]                         ` <Pine.LNX.4.64.0902071831210.2805-x/A8LOkYjdVsRR2hCrRKtT03IgOmwywn@public.gmane.org>
2009-02-08  5:25                           ` J. Bruce Fields
     [not found]                             ` <20090208052543.GA20689-uC3wQj2KruNg9hUCZPvPmw@public.gmane.org>
2009-02-09 17:29                               ` Chuck Lever
2009-02-10 13:12                                 ` Ilpo Järvinen
     [not found]                                   ` <Pine.LNX.4.64.0902101417550.31742-x/A8LOkYjdVsRR2hCrRKtT03IgOmwywn@public.gmane.org>
2009-02-10 17:12                                     ` Chuck Lever
2009-02-10 13:20                               ` Ilpo Järvinen
2009-02-10 22:28                                 ` J. Bruce Fields
2009-02-07  7:49 ` David Miller

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=Pine.LNX.4.64.0902070040530.31875@wrl-59.cs.helsinki.fi \
    --to=ilpo.jarvinen-pxsi+dnqzzmxhbg02/kk1g@public.gmane.org \
    --cc=bfields-uC3wQj2KruNg9hUCZPvPmw@public.gmane.org \
    --cc=chuck.lever-QHcLZuEGTsvQT0dZR+AlfA@public.gmane.org \
    --cc=linux-nfs-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=netdev-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=trond-HgOvQuBEEgTQT0dZR+AlfA@public.gmane.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).