Hi, list,
I'm reading FreeBSD's network codes, and I have noticed that we call
tcp_output() from tcp_usr_send() with tcbinfo locked. According to the
comment in the tcp_usr_send(), we must call tcp_connect() or
tcp_usrclosed() with tcbinfo locked. But it seems that we does not need to
lock it to call tcp_output(). Is there any reason not to unlock it before
calling tcp_output()? I have tried the attached patch, so I get about
10-20% performance up when running my test server program.
-------------------
Kazuaki Oda
--- tcp_usrreq.c.orig Tue Mar 29 10:10:46 2005
+++ tcp_usrreq.c Wed Apr 20 17:32:16 2005
@@ -619,7 +619,7 @@
int error = 0;
struct inpcb *inp;
struct tcpcb *tp;
- const int inirw = INI_WRITE;
+ int unlocked = 0;
#ifdef INET6
int isipv6;
#endif
@@ -694,6 +694,8 @@
socantsendmore(so);
tp = tcp_usrclosed(tp);
}
+ INP_INFO_WUNLOCK(&tcbinfo);
+ unlocked = 1;
if (tp != NULL) {
if (flags & PRUS_MORETOCOME)
tp->t_flags |= TF_MORETOCOME;
@@ -742,8 +744,13 @@
error = tcp_output(tp);
tp->t_force = 0;
}
- COMMON_END((flags & PRUS_OOB) ? PRU_SENDOOB :
- ((flags & PRUS_EOF) ? PRU_SEND_EOF : PRU_SEND));
+out: TCPDEBUG2((flags & PRUS_OOB) ? PRU_SENDOOB :
+ ((flags & PRUS_EOF) ? PRU_SEND_EOF : PRU_SEND));
+ if (tp)
+ INP_UNLOCK(inp);
+ if (!unlocked)
+ INP_INFO_WUNLOCK(&tcbinfo);
+ return error;
}
/*
_______________________________________________
freebsd-net@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-net
To unsubscribe, send any mail to "[EMAIL PROTECTED]"