Reorganize elements of the inpcb struct to take better advantage of

cache lines. Removed the struct ip proto since only a couple of chars
were actually being used in it. Changed the order of compares in the
PCB hash lookup to take advantage of partial cache line fills (on PPro).

Discussed-with: wollman
This commit is contained in:
David Greenman 1997-04-03 05:14:45 +00:00
parent 5d00c0a499
commit ca98b82c8d
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=24570
9 changed files with 38 additions and 31 deletions

View File

@ -31,7 +31,7 @@
* SUCH DAMAGE.
*
* @(#)in_pcb.c 8.4 (Berkeley) 5/24/95
* $Id: in_pcb.c,v 1.28 1997/03/03 09:23:33 davidg Exp $
* $Id: in_pcb.c,v 1.29 1997/03/24 11:24:50 bde Exp $
*/
#include <sys/param.h>
@ -688,8 +688,9 @@ in_pcblookuphash(pcbinfo, faddr, fport_arg, laddr, lport_arg, wildcard)
head = &pcbinfo->hashbase[INP_PCBHASH(faddr.s_addr, lport, fport, pcbinfo->hashmask)];
for (inp = head->lh_first; inp != NULL; inp = inp->inp_hash.le_next) {
if (inp->inp_faddr.s_addr == faddr.s_addr &&
inp->inp_fport == fport && inp->inp_lport == lport &&
inp->inp_laddr.s_addr == laddr.s_addr)
inp->inp_laddr.s_addr == laddr.s_addr &&
inp->inp_fport == fport &&
inp->inp_lport == lport)
goto found;
}
if (wildcard) {

View File

@ -31,7 +31,7 @@
* SUCH DAMAGE.
*
* @(#)in_pcb.h 8.1 (Berkeley) 6/10/93
* $Id: in_pcb.h,v 1.18 1997/02/22 09:41:29 peter Exp $
* $Id: in_pcb.h,v 1.19 1997/03/03 09:23:34 davidg Exp $
*/
#ifndef _NETINET_IN_PCB_H_
@ -51,18 +51,24 @@ LIST_HEAD(inpcbhead, inpcb);
struct inpcb {
LIST_ENTRY(inpcb) inp_list; /* list for all PCBs of this proto */
LIST_ENTRY(inpcb) inp_hash; /* hash list */
struct inpcbinfo *inp_pcbinfo;
struct inpcbinfo *inp_pcbinfo; /* PCB list info */
struct in_addr inp_faddr; /* foreign host table entry */
u_short inp_fport; /* foreign port */
struct in_addr inp_laddr; /* local host table entry */
u_short inp_fport; /* foreign port */
u_short inp_lport; /* local port */
struct socket *inp_socket; /* back pointer to socket */
caddr_t inp_ppcb; /* pointer to per-protocol pcb */
struct socket *inp_socket; /* back pointer to socket */
struct mbuf *inp_options; /* IP options */
struct route inp_route; /* placeholder for routing entry */
int inp_flags; /* generic IP/datagram flags */
struct ip inp_ip; /* header prototype; should have more */
struct mbuf *inp_options; /* IP options */
u_char inp_ip_tos; /* type of service proto */
u_char inp_ip_ttl; /* time to live proto */
u_char inp_ip_p; /* protocol proto */
u_char pad[1]; /* alignment */
struct ip_moptions *inp_moptions; /* IP multicast options */
#if 0 /* Someday, perhaps... */
struct ip inp_ip; /* header prototype; should have more */
#endif
};
struct inpcbinfo {

View File

@ -30,7 +30,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $Id: ip_divert.c,v 1.6 1997/02/22 09:41:31 peter Exp $
* $Id: ip_divert.c,v 1.7 1997/03/03 09:23:34 davidg Exp $
*/
#include <sys/param.h>
@ -280,7 +280,7 @@ div_usrreq(so, req, m, nam, control)
(error = in_pcballoc(so, &divcbinfo)))
break;
inp = (struct inpcb *)so->so_pcb;
inp->inp_ip.ip_p = (int)nam; /* XXX */
inp->inp_ip_p = (int)nam; /* XXX */
inp->inp_flags |= INP_HDRINCL;
/* The socket is always "connected" because
we always know "where" to send the packet */

View File

@ -31,7 +31,7 @@
* SUCH DAMAGE.
*
* @(#)ip_output.c 8.3 (Berkeley) 1/21/94
* $Id: ip_output.c,v 1.51 1997/02/22 09:41:36 peter Exp $
* $Id: ip_output.c,v 1.52 1997/02/28 19:40:48 fenner Exp $
*/
#define _IP_VHL
@ -658,11 +658,11 @@ ip_ctloutput(op, so, level, optname, mp)
switch (optname) {
case IP_TOS:
inp->inp_ip.ip_tos = optval;
inp->inp_ip_tos = optval;
break;
case IP_TTL:
inp->inp_ip.ip_ttl = optval;
inp->inp_ip_ttl = optval;
break;
#define OPTSET(bit) \
if (optval) \
@ -761,11 +761,11 @@ ip_ctloutput(op, so, level, optname, mp)
switch (optname) {
case IP_TOS:
optval = inp->inp_ip.ip_tos;
optval = inp->inp_ip_tos;
break;
case IP_TTL:
optval = inp->inp_ip.ip_ttl;
optval = inp->inp_ip_ttl;
break;
#define OPTBIT(bit) (inp->inp_flags & bit ? 1 : 0)

View File

@ -31,7 +31,7 @@
* SUCH DAMAGE.
*
* @(#)raw_ip.c 8.7 (Berkeley) 5/15/95
* $Id: raw_ip.c,v 1.42 1997/02/18 20:46:29 wollman Exp $
* $Id: raw_ip.c,v 1.43 1997/03/03 09:23:35 davidg Exp $
*/
#include <sys/param.h>
@ -114,7 +114,7 @@ rip_input(m, iphlen)
ripsrc.sin_addr = ip->ip_src;
for (inp = ripcb.lh_first; inp != NULL; inp = inp->inp_list.le_next) {
if (inp->inp_ip.ip_p && inp->inp_ip.ip_p != ip->ip_p)
if (inp->inp_ip_p && inp->inp_ip_p != ip->ip_p)
continue;
if (inp->inp_laddr.s_addr &&
inp->inp_laddr.s_addr != ip->ip_dst.s_addr)
@ -187,7 +187,7 @@ rip_output(m, so, dst)
ip = mtod(m, struct ip *);
ip->ip_tos = 0;
ip->ip_off = 0;
ip->ip_p = inp->inp_ip.ip_p;
ip->ip_p = inp->inp_ip_p;
ip->ip_len = m->m_pkthdr.len;
ip->ip_src = inp->inp_laddr;
ip->ip_dst.s_addr = dst;
@ -402,7 +402,7 @@ rip_attach(struct socket *so, int proto)
(error = in_pcballoc(so, &ripcbinfo)))
return error;
inp = (struct inpcb *)so->so_pcb;
inp->inp_ip.ip_p = proto;
inp->inp_ip_p = proto;
return 0;
}

View File

@ -31,7 +31,7 @@
* SUCH DAMAGE.
*
* @(#)tcp_output.c 8.4 (Berkeley) 5/24/95
* $Id$
* $Id: tcp_output.c,v 1.23 1997/02/22 09:41:40 peter Exp $
*/
#include <sys/param.h>
@ -673,8 +673,8 @@ send:
struct rtentry *rt;
#endif
((struct ip *)ti)->ip_len = m->m_pkthdr.len;
((struct ip *)ti)->ip_ttl = tp->t_inpcb->inp_ip.ip_ttl; /* XXX */
((struct ip *)ti)->ip_tos = tp->t_inpcb->inp_ip.ip_tos; /* XXX */
((struct ip *)ti)->ip_ttl = tp->t_inpcb->inp_ip_ttl; /* XXX */
((struct ip *)ti)->ip_tos = tp->t_inpcb->inp_ip_tos; /* XXX */
#if 1
/*
* See if we should do MTU discovery. We do it only if the following

View File

@ -31,7 +31,7 @@
* SUCH DAMAGE.
*
* @(#)tcp_subr.c 8.2 (Berkeley) 5/24/95
* $Id: tcp_subr.c,v 1.34 1997/02/22 09:41:41 peter Exp $
* $Id: tcp_subr.c,v 1.35 1997/03/03 09:23:36 davidg Exp $
*/
#include <sys/param.h>
@ -276,7 +276,7 @@ tcp_newtcpcb(inp)
tp->t_rxtcur = TCPTV_RTOBASE;
tp->snd_cwnd = TCP_MAXWIN << TCP_MAX_WINSHIFT;
tp->snd_ssthresh = TCP_MAXWIN << TCP_MAX_WINSHIFT;
inp->inp_ip.ip_ttl = ip_defttl;
inp->inp_ip_ttl = ip_defttl;
inp->inp_ppcb = (caddr_t)tp;
return (tp);
}

View File

@ -31,7 +31,7 @@
* SUCH DAMAGE.
*
* @(#)tcp_subr.c 8.2 (Berkeley) 5/24/95
* $Id: tcp_subr.c,v 1.34 1997/02/22 09:41:41 peter Exp $
* $Id: tcp_subr.c,v 1.35 1997/03/03 09:23:36 davidg Exp $
*/
#include <sys/param.h>
@ -276,7 +276,7 @@ tcp_newtcpcb(inp)
tp->t_rxtcur = TCPTV_RTOBASE;
tp->snd_cwnd = TCP_MAXWIN << TCP_MAX_WINSHIFT;
tp->snd_ssthresh = TCP_MAXWIN << TCP_MAX_WINSHIFT;
inp->inp_ip.ip_ttl = ip_defttl;
inp->inp_ip_ttl = ip_defttl;
inp->inp_ppcb = (caddr_t)tp;
return (tp);
}

View File

@ -31,7 +31,7 @@
* SUCH DAMAGE.
*
* @(#)udp_usrreq.c 8.6 (Berkeley) 5/23/95
* $Id: udp_usrreq.c,v 1.35 1997/02/24 20:31:25 wollman Exp $
* $Id: udp_usrreq.c,v 1.36 1997/03/03 09:23:37 davidg Exp $
*/
#include <sys/param.h>
@ -435,8 +435,8 @@ udp_output(inp, m, addr, control)
ui->ui_sum = 0xffff;
}
((struct ip *)ui)->ip_len = sizeof (struct udpiphdr) + len;
((struct ip *)ui)->ip_ttl = inp->inp_ip.ip_ttl; /* XXX */
((struct ip *)ui)->ip_tos = inp->inp_ip.ip_tos; /* XXX */
((struct ip *)ui)->ip_ttl = inp->inp_ip_ttl; /* XXX */
((struct ip *)ui)->ip_tos = inp->inp_ip_tos; /* XXX */
udpstat.udps_opackets++;
error = ip_output(m, inp->inp_options, &inp->inp_route,
inp->inp_socket->so_options & (SO_DONTROUTE | SO_BROADCAST),
@ -497,7 +497,7 @@ udp_attach(struct socket *so, int proto)
error = soreserve(so, udp_sendspace, udp_recvspace);
if (error)
return error;
((struct inpcb *) so->so_pcb)->inp_ip.ip_ttl = ip_defttl;
((struct inpcb *) so->so_pcb)->inp_ip_ttl = ip_defttl;
return 0;
}