Subject: Re: sosend_loan tweak
To: None <wrstuden@netbsd.org>
From: YAMAMOTO Takashi <yamt@mwd.biglobe.ne.jp>
List: tech-net
Date: 06/18/2006 20:17:27
--NextPart-20060618201425-1607900
Content-Type: Text/Plain; charset=us-ascii

> heh, right.  i'll fix.  thanks.

the fixed version is attached.

YAMAMOTO Takashi

--NextPart-20060618201425-1607900
Content-Type: Text/Plain; charset=us-ascii
Content-Disposition: attachment; filename="a.diff"

Index: sys/socketvar.h
===================================================================
--- sys/socketvar.h	(revision 1673)
+++ sys/socketvar.h	(revision 1675)
@@ -255,6 +255,7 @@ do {									\
 #ifdef _KERNEL
 extern u_long		sb_max;
 extern int		somaxkva;
+extern int		sock_loan_thresh;
 /* to catch callers missing new second argument to sonewconn: */
 #define	sonewconn(head, connstatus)	sonewconn1((head), (connstatus))
 
Index: kern/uipc_socket.c
===================================================================
--- kern/uipc_socket.c	(revision 1673)
+++ kern/uipc_socket.c	(revision 1675)
@@ -130,9 +130,9 @@ EVCNT_ATTACH_STATIC(sosend_kvalimit);
 static struct callback_entry sokva_reclaimerentry;
 
 #ifdef SOSEND_NO_LOAN
-int use_sosend_loan = 0;
+int sock_loan_thresh = -1;
 #else
-int use_sosend_loan = 1;
+int sock_loan_thresh = 4096;
 #endif
 
 static struct simplelock so_pendfree_slock = SIMPLELOCK_INITIALIZER;
@@ -145,7 +145,6 @@ int somaxkva = SOMAXKVA;
 static int socurkva;
 static int sokvawaiters;
 
-#define	SOCK_LOAN_THRESH	4096
 #define	SOCK_LOAN_CHUNK		65536
 
 static size_t sodopendfree(void);
@@ -844,9 +843,9 @@ sosend(struct socket *so, struct mbuf *a
 					mlen = MLEN;
 				}
 				MCLAIM(m, so->so_snd.sb_mowner);
-				if (use_sosend_loan &&
-				    uio->uio_iov->iov_len >= SOCK_LOAN_THRESH &&
-				    space >= SOCK_LOAN_THRESH &&
+				if (sock_loan_thresh >= 0 &&
+				    uio->uio_iov->iov_len >= sock_loan_thresh &&
+				    space >= sock_loan_thresh &&
 				    (len = sosend_loan(so, uio, m,
 						       space)) != 0) {
 					SOSEND_COUNTER_INCR(&sosend_loan_big);
Index: kern/uipc_socket2.c
===================================================================
--- kern/uipc_socket2.c	(revision 1673)
+++ kern/uipc_socket2.c	(working copy)
@@ -385,7 +385,7 @@ soreserve(struct socket *so, u_long sndc
 	if (so->so_rcv.sb_lowat == 0)
 		so->so_rcv.sb_lowat = 1;
 	if (so->so_snd.sb_lowat == 0)
-		so->so_snd.sb_lowat = MCLBYTES;
+		so->so_snd.sb_lowat = MAX((int)MCLBYTES, sock_loan_thresh);
 	if (so->so_snd.sb_lowat > so->so_snd.sb_hiwat)
 		so->so_snd.sb_lowat = so->so_snd.sb_hiwat;
 	return (0);

--NextPart-20060618201425-1607900--