Skip to contentSkip to conversation

Improved RPC congestion handling for 2.4.0 (and 2.2.18)

CFT Trond Myklebust 2 participants 5 messages Dec 14, 2000 – Jan 24, 2001

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

Hi,

One of the things we've been lacking in the Linux implementation of
RPC is the 'ping' routine. The latter is used on most *NIX implementations in order to test whether or not the RPC server is alive. To do so, it simply calls procedure-0 (the NULL procedure), which is always set up to return the value 0 and therefore acts more or less like the icmp 'ping'.

The appended patch implements such a routine, and uses it to improve
our congestion control, by allowing the entire set of pending requests to inquire whether or not the server is alive, and then to sleep for 5 seconds before retrying. This is done if and only if we get a major RPC timeout and we see that the client Van Jacobson congestion control can no longer throttle back the number of pending requests.

This is more accurate than the current system of just retrying each
request, and waiting for 5 seconds if icmp fails, because the ping directly tests whether the server is up and responding to requests. Furthermore, unlike the retried requests, the packet length of a ping request is always short, so we don't fall prone to issues of udp fragmentation messing up the test. Finally, because all pending requests are made to wait on a single ping rather than bombarding the server with retries, it avoids further congestion to the network.

A version of this patch for linux-2.2.18 is available on

http://www.fys.uio.no/~trondmy/src/2.2.18/linux-2.2.18-sunrpc.dif

Cheers,
Trond

include/linux/sunrpc/clnt.h +7 -0
diff -u --recursive --new-file linux-2.4.0-test12/include/linux/sunrpc/clnt.h linux-2.4.0-ping/include/linux/sunrpc/clnt.h
@@ -111,6 +111,8 @@
 void		rpc_release_client(struct rpc_clnt *);
 void		rpc_getport(struct rpc_task *, struct rpc_clnt *);
 int		rpc_register(u32, u32, int, unsigned short, int *);
+u32 *		rpc_call_header(struct rpc_task *task);
+u32 *		rpc_call_verify(struct rpc_task *task);
 
 void		rpc_call_setup(struct rpc_task *, struct rpc_message *, int);
 
@@ -143,6 +145,11 @@
  * Helper function for NFSroot support
  */
 int		rpc_getport_external(struct sockaddr_in *, __u32, __u32, int);
+
+/*
+ * Ping function
+ */
+void		rpc_ping(struct rpc_task *task);
 
 #endif /* __KERNEL__ */
 #endif /* _LINUX_SUNRPC_CLNT_H */
include/linux/sunrpc/xprt.h +16 -1
diff -u --recursive --new-file linux-2.4.0-test12/include/linux/sunrpc/xprt.h linux-2.4.0-ping/include/linux/sunrpc/xprt.h
@@ -39,12 +39,14 @@
  * Come Linux 2.3, we'll handle fragments directly.
  */
 #define RPC_MAXCONG		16
-#define RPC_MAXREQS		(RPC_MAXCONG + 1)
+#define RPC_MAXREQS		(RPC_MAXCONG + 2)
 #define RPC_CWNDSCALE		256
 #define RPC_MAXCWND		(RPC_MAXCONG * RPC_CWNDSCALE)
 #define RPC_INITCWND		RPC_CWNDSCALE
 #define RPCXPRT_CONGESTED(xprt) \
 	((xprt)->cong >= (xprt)->cwnd)
+#define RPCXPRT_SUPERCONGESTED(xprt) \
+				((xprt)->cwnd < 2*RPC_CWNDSCALE)
 
 /* Default timeout values */
 #define RPC_MAX_UDP_TIMEOUT	(60*HZ)
@@ -136,6 +138,7 @@
 	struct rpc_wait_queue	pending;	/* requests in flight */
 	struct rpc_wait_queue	backlog;	/* waiting for slot */
 	struct rpc_wait_queue	reconn;		/* waiting for reconnect */
+	struct rpc_wait_queue	pingwait;	/* waiting on ping() */
 	struct rpc_rqst *	free;		/* free slots */
 	struct rpc_rqst		slot[RPC_MAXREQS];
 	unsigned int		sockstate;	/* Socket state */
@@ -179,10 +182,12 @@
 					unsigned long);
 
 int			xprt_reserve(struct rpc_task *);
+int			xprt_ping_reserve(struct rpc_task *);
 void			xprt_transmit(struct rpc_task *);
 void			xprt_receive(struct rpc_task *);
 int			xprt_adjust_timeout(struct rpc_timeout *);
 void			xprt_release(struct rpc_task *);
+void			xprt_ping_release(struct rpc_task *);
 void			xprt_reconnect(struct rpc_task *);
 int			xprt_clear_backlog(struct rpc_xprt *);
 void			__rpciod_tcp_dispatcher(void);
@@ -191,6 +196,8 @@
 
 #define XPRT_WSPACE	0
 #define XPRT_CONNECT	1
+#define XPRT_PING	2
+#define XPRT_NORESPOND	3
 
 #define xprt_wspace(xp)			(test_bit(XPRT_WSPACE, &(xp)->sockstate))
 #define xprt_test_and_set_wspace(xp)	(test_and_set_bit(XPRT_WSPACE, &(xp)->sockstate))
@@ -200,6 +207,14 @@
 #define xprt_set_connected(xp)		(set_bit(XPRT_CONNECT, &(xp)->sockstate))
 #define xprt_test_and_set_connected(xp)	(test_and_set_bit(XPRT_CONNECT, &(xp)->sockstate))
 #define xprt_clear_connected(xp)	(clear_bit(XPRT_CONNECT, &(xp)->sockstate))
+
+#define xprt_pinging(xp)		(test_bit(XPRT_PING, &(xp)->sockstate))
+#define xprt_test_and_set_pinging(xp)	(test_and_set_bit(XPRT_PING, &(xp)->sockstate))
+#define xprt_clear_pinging(xp)		(clear_bit(XPRT_PING, &(xp)->sockstate))
+
+#define xprt_norespond(xp)		(test_bit(XPRT_NORESPOND, &(xp)->sockstate))
+#define xprt_test_and_set_norespond(xp)	(test_and_set_bit(XPRT_NORESPOND, &(xp)->sockstate))
+#define xprt_clear_norespond(xp)	(clear_bit(XPRT_NORESPOND, &(xp)->sockstate))
 
 static inline
 int xprt_tcp_pending(void)
net/sunrpc/Makefile +1 -1
diff -u --recursive --new-file linux-2.4.0-test12/net/sunrpc/Makefile linux-2.4.0-ping/net/sunrpc/Makefile
@@ -11,7 +11,7 @@
 O_OBJS   := clnt.o xprt.o sched.o \
 	    auth.o auth_null.o auth_unix.o \
 	    svc.o svcsock.o svcauth.o \
-	    pmap_clnt.o xdr.o
+	    pmap_clnt.o ping.o xdr.o
 OX_OBJS  := sunrpc_syms.o
 
 ifeq ($(CONFIG_PROC_FS),y)
net/sunrpc/clnt.c +69 -30

161 lines not on this page · raw message

net/sunrpc/ping.c +209 -0

209 lines not on this page · raw message

net/sunrpc/xprt.c +57 -8

83 lines not on this page · raw message

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [email protected]
Please read the FAQ at http://www.tux.org/lkml/

#1 lore raw
Quoted 17 lines · Trond Myklebust

Hi,

One of the things we've been lacking in the Linux implementation of
RPC is the 'ping' routine. The latter is used on most *NIX implementations in order to test whether or not the RPC server is alive. To do so, it simply calls procedure-0 (the NULL procedure), which is always set up to return the value 0 and therefore acts more or less like the icmp 'ping'.

The appended patch implements such a routine, and uses it to improve
our congestion control, by allowing the entire set of pending requests to inquire whether or not the server is alive, and then to sleep for 5 seconds before retrying. This is done if and only if we get a major RPC timeout and we see that the client Van Jacobson congestion control can no longer throttle back the number of pending requests.

Quoted 8 lines

This is more accurate than the current system of just retrying each
request, and waiting for 5 seconds if icmp fails, because the ping directly tests whether the server is up and responding to requests. Furthermore, unlike the retried requests, the packet length of a ping request is always short, so we don't fall prone to issues of udp fragmentation messing up the test. Finally, because all pending requests are made to wait on a single ping rather than bombarding the server with retries, it avoids further congestion to the network.

I got a report which indicates it may not be a good idea, especially for UDP. Suppose you have a lousy LAN or NFS UDP server for whatever reason, some NFS/UDP packets may get lost very easily while a ping request may get through. In that case, the rpc ping may slow down the NFS client over UDP significantly.

H.J.
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [email protected]
Please read the FAQ at http://www.tux.org/lkml/

#2 lore raw
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

" " == H J Lu <[email protected]> writes:

> I got a report which indicates it may not be a good idea, > especially for UDP. Suppose you have a lousy LAN or NFS UDP > server for whatever reason, some NFS/UDP packets may get lost > very easily while a ping request may get through. In that case, > the rpc ping may slow down the NFS client over UDP
> significantly.

Hi HJ,

Could you clarify this? Don't forget that we only send the ping after a major timeout (usually after 3 or more resends).

IOW: If the ping gets through, then it'll have cost us 1 RPC request, which is hardly a major contribution when talking about timescales of the order of 5 seconds which is what that major timeout will have cost (Don't forget that RPC timeout values increase geometrically).

I'm not touting this as a cure for incorrect rsize/wsize settings. I use it rather to avoid false 'server is not responding' due to server congestion. On the current RPC code, the latter can occur sometimes even with a loopback NFS mount when, say, kflushd is busy hogging the disk...

Cheers,
Trond
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [email protected]
Please read the FAQ at http://www.tux.org/lkml/

#3 lore raw
In reply to Trond Myklebust
Quoted 11 lines · Trond Myklebust
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

" " == H J Lu <[email protected]> writes:

> I got a report which indicates it may not be a good idea, > especially for UDP. Suppose you have a lousy LAN or NFS UDP > server for whatever reason, some NFS/UDP packets may get lost > very easily while a ping request may get through. In that case, > the rpc ping may slow down the NFS client over UDP
> significantly.

Hi HJ,

Quoted 8 lines

Could you clarify this? Don't forget that we only send the ping after a major timeout (usually after 3 or more resends).

IOW: If the ping gets through, then it'll have cost us 1 RPC request, which is hardly a major contribution when talking about timescales of the order of 5 seconds which is what that major timeout will have cost (Don't forget that RPC timeout values increase geometrically).

Michael Kriss <[email protected]> is having this problem. I think this problem may be very specific to his network setup. I couldn't duplicate his problem. My guess is for his case, every ping sent is a loss of a potential working retry packet. He is using Solaris NFS sever with Linux client. I had an impression that packets from Solaris NFS server was dropped quite often. I don't know what happened.

Signature · 5 lines
H.J. Lu ([email protected])
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [email protected]
Please read the FAQ at http://www.tux.org/lkml/
#4 lore raw
In reply to Trond Myklebust
Quoted 21 lines · H . J . Lu
Quoted 11 lines · Trond Myklebust
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

" " == H J Lu <[email protected]> writes:

> I got a report which indicates it may not be a good idea, > especially for UDP. Suppose you have a lousy LAN or NFS UDP > server for whatever reason, some NFS/UDP packets may get lost > very easily while a ping request may get through. In that case, > the rpc ping may slow down the NFS client over UDP
> significantly.

Hi HJ,

Quoted 8 lines

Could you clarify this? Don't forget that we only send the ping after a major timeout (usually after 3 or more resends).

IOW: If the ping gets through, then it'll have cost us 1 RPC request, which is hardly a major contribution when talking about timescales of the order of 5 seconds which is what that major timeout will have cost (Don't forget that RPC timeout values increase geometrically).

Quoted 7 lines

Michael Kriss <[email protected]> is having this problem. I think this problem may be very specific to his network setup. I couldn't duplicate his problem. My guess is for his case, every ping sent is a loss of a potential working retry packet. He is using Solaris NFS sever with Linux client. I had an impression that packets from Solaris NFS server was dropped quite often. I don't know what happened.

I believe it is a false alarm. It turned out that the interface was not in the full duplex mode. After turning on autonego on switch, everything seems fine now. Sorry for that.

Signature · 5 lines
H.J. Lu ([email protected])
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [email protected]
Please read the FAQ at http://www.tux.org/lkml/