Date: Fri, 18 Jun 2004 03:25:14 GMT From: Robert Watson <rwatson@FreeBSD.org> To: Perforce Change Reviews <perforce@freebsd.org> Subject: PERFORCE change 55215 for review Message-ID: <200406180325.i5I3PEBK092459@repoman.freebsd.org>
next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=55215 Change 55215 by rwatson@rwatson_tislabs on 2004/06/18 03:25:03 Integrate netperf_socket to loop back kqueue-related locking in socket and fifo kqueue filters. Affected files ... .. //depot/projects/netperf_socket/sys/dev/ed/if_ed_pci.c#2 integrate .. //depot/projects/netperf_socket/sys/fs/fifofs/fifo_vnops.c#9 integrate .. //depot/projects/netperf_socket/sys/i386/isa/npx.c#7 integrate .. //depot/projects/netperf_socket/sys/kern/uipc_socket.c#19 integrate .. //depot/projects/netperf_socket/sys/netinet/in_gif.c#3 integrate .. //depot/projects/netperf_socket/sys/netinet/tcp_output.c#5 integrate Differences ... ==== //depot/projects/netperf_socket/sys/dev/ed/if_ed_pci.c#2 (text+ko) ==== @@ -18,7 +18,7 @@ */ #include <sys/cdefs.h> -__FBSDID("$FreeBSD: src/sys/dev/ed/if_ed_pci.c,v 1.34 2003/10/31 18:31:58 brooks Exp $"); +__FBSDID("$FreeBSD: src/sys/dev/ed/if_ed_pci.c,v 1.36 2004/06/18 01:28:54 imp Exp $"); #include <sys/param.h> #include <sys/systm.h> @@ -58,11 +58,11 @@ { 0x00000000, NULL } }; -static int ed_pci_probe (device_t); -static int ed_pci_attach (device_t); +static int ed_pci_probe(device_t); +static int ed_pci_attach(device_t); static int -ed_pci_probe (device_t dev) +ed_pci_probe(device_t dev) { u_int32_t type = pci_get_devid(dev); struct _pcsid *ep =pci_ids; @@ -71,10 +71,9 @@ ++ep; if (ep->desc) { device_set_desc(dev, ep->desc); - return 0; - } else { - return ENXIO; + return (0); } + return (ENXIO); } static int ==== //depot/projects/netperf_socket/sys/fs/fifofs/fifo_vnops.c#9 (text+ko) ==== @@ -27,7 +27,7 @@ * SUCH DAMAGE. * * @(#)fifo_vnops.c 8.10 (Berkeley) 5/27/95 - * $FreeBSD: src/sys/fs/fifofs/fifo_vnops.c,v 1.98 2004/06/17 22:48:09 rwatson Exp $ + * $FreeBSD: src/sys/fs/fifofs/fifo_vnops.c,v 1.99 2004/06/18 02:57:54 rwatson Exp $ */ #include <sys/param.h> @@ -444,23 +444,33 @@ { struct socket *so = (struct socket *)kn->kn_hook; + SOCKBUF_LOCK(&so->so_rcv); SLIST_REMOVE(&so->so_rcv.sb_sel.si_note, kn, knote, kn_selnext); if (SLIST_EMPTY(&so->so_rcv.sb_sel.si_note)) so->so_rcv.sb_flags &= ~SB_KNOTE; + SOCKBUF_UNLOCK(&so->so_rcv); } static int filt_fiforead(struct knote *kn, long hint) { struct socket *so = (struct socket *)kn->kn_hook; + int need_lock, result; + need_lock = !SOCKBUF_OWNED(&so->so_rcv); + if (need_lock) + SOCKBUF_LOCK(&so->so_rcv); kn->kn_data = so->so_rcv.sb_cc; if (so->so_rcv.sb_state & SBS_CANTRCVMORE) { kn->kn_flags |= EV_EOF; - return (1); + result = 1; + } else { + kn->kn_flags &= ~EV_EOF; + result = (kn->kn_data > 0); } - kn->kn_flags &= ~EV_EOF; - return (kn->kn_data > 0); + if (need_lock) + SOCKBUF_UNLOCK(&so->so_rcv); + return (result); } static void @@ -468,23 +478,34 @@ { struct socket *so = (struct socket *)kn->kn_hook; + SOCKBUF_LOCK(&so->so_snd); SLIST_REMOVE(&so->so_snd.sb_sel.si_note, kn, knote, kn_selnext); if (SLIST_EMPTY(&so->so_snd.sb_sel.si_note)) so->so_snd.sb_flags &= ~SB_KNOTE; + SOCKBUF_UNLOCK(&so->so_snd); } static int filt_fifowrite(struct knote *kn, long hint) { struct socket *so = (struct socket *)kn->kn_hook; + int need_lock, result; + need_lock = !SOCKBUF_OWNED(&so->so_snd); + if (need_lock) + SOCKBUF_LOCK(&so->so_snd); kn->kn_data = sbspace(&so->so_snd); + /* Unlocked read. */ if (so->so_snd.sb_state & SBS_CANTSENDMORE) { kn->kn_flags |= EV_EOF; - return (1); + result = 1; + } else { + kn->kn_flags &= ~EV_EOF; + result = (kn->kn_data >= so->so_snd.sb_lowat); } - kn->kn_flags &= ~EV_EOF; - return (kn->kn_data >= so->so_snd.sb_lowat); + if (need_lock) + SOCKBUF_UNLOCK(&so->so_snd); + return (result); } /* ARGSUSED */ ==== //depot/projects/netperf_socket/sys/i386/isa/npx.c#7 (text+ko) ==== @@ -31,7 +31,7 @@ */ #include <sys/cdefs.h> -__FBSDID("$FreeBSD: src/sys/i386/isa/npx.c,v 1.149 2004/06/06 15:17:44 bde Exp $"); +__FBSDID("$FreeBSD: src/sys/i386/isa/npx.c,v 1.151 2004/06/18 02:10:55 bde Exp $"); #include "opt_cpu.h" #include "opt_debug_npx.h" @@ -872,6 +872,15 @@ { struct thread *td; + /* + * Discard pending exceptions in the !cpu_fxsr case so that unmasked + * ones don't cause a panic on the next frstor. + */ +#ifdef CPU_ENABLE_SSE + if (!cpu_fxsr) +#endif + fnclex(); + td = PCPU_GET(fpcurthread); PCPU_SET(fpcurthread, NULL); td->td_pcb->pcb_flags &= ~PCB_NPXINITDONE; ==== //depot/projects/netperf_socket/sys/kern/uipc_socket.c#19 (text+ko) ==== @@ -30,7 +30,7 @@ */ #include <sys/cdefs.h> -__FBSDID("$FreeBSD: src/sys/kern/uipc_socket.c,v 1.179 2004/06/17 22:48:09 rwatson Exp $"); +__FBSDID("$FreeBSD: src/sys/kern/uipc_socket.c,v 1.180 2004/06/18 02:57:55 rwatson Exp $"); #include "opt_inet.h" #include "opt_mac.h" @@ -509,9 +509,9 @@ int error; if ((so->so_state & SS_ISCONNECTED) == 0) - return ENOTCONN; + return (ENOTCONN); if (so->so_state & SS_ISDISCONNECTING) - return EALREADY; + return (EALREADY); error = (*so->so_proto->pr_usrreqs->pru_disconnect)(so); return (error); } @@ -1932,9 +1932,16 @@ filt_soread(struct knote *kn, long hint) { struct socket *so = kn->kn_fp->f_data; - int result; + int need_lock, result; - SOCKBUF_LOCK(&so->so_rcv); /* XXX too conservative? */ + /* + * XXXRW: Conditional locking because filt_soread() can be called + * either from KNOTE() in the socket context where the socket buffer + * lock is already held, or from kqueue() itself. + */ + need_lock = !SOCKBUF_OWNED(&so->so_rcv); + if (need_lock) + SOCKBUF_LOCK(&so->so_rcv); kn->kn_data = so->so_rcv.sb_cc - so->so_rcv.sb_ctl; if (so->so_rcv.sb_state & SBS_CANTRCVMORE) { kn->kn_flags |= EV_EOF; @@ -1946,7 +1953,8 @@ result = (kn->kn_data >= kn->kn_sdata); else result = (so->so_rcv.sb_cc >= so->so_rcv.sb_lowat); - SOCKBUF_UNLOCK(&so->so_rcv); + if (need_lock) + SOCKBUF_UNLOCK(&so->so_rcv); return (result); } @@ -1967,9 +1975,16 @@ filt_sowrite(struct knote *kn, long hint) { struct socket *so = kn->kn_fp->f_data; - int result; + int need_lock, result; - SOCKBUF_LOCK(&so->so_snd); /* XXX too conservative? */ + /* + * XXXRW: Conditional locking because filt_soread() can be called + * either from KNOTE() in the socket context where the socket buffer + * lock is already held, or from kqueue() itself. + */ + need_lock = !SOCKBUF_OWNED(&so->so_snd); + if (need_lock) + SOCKBUF_LOCK(&so->so_snd); kn->kn_data = sbspace(&so->so_snd); if (so->so_snd.sb_state & SBS_CANTSENDMORE) { kn->kn_flags |= EV_EOF; @@ -1984,7 +1999,8 @@ result = (kn->kn_data >= kn->kn_sdata); else result = (kn->kn_data >= so->so_snd.sb_lowat); - SOCKBUF_UNLOCK(&so->so_snd); + if (need_lock) + SOCKBUF_UNLOCK(&so->so_snd); return (result); } ==== //depot/projects/netperf_socket/sys/netinet/in_gif.c#3 (text+ko) ==== @@ -1,4 +1,4 @@ -/* $FreeBSD: src/sys/netinet/in_gif.c,v 1.25 2004/04/14 01:13:14 luigi Exp $ */ +/* $FreeBSD: src/sys/netinet/in_gif.c,v 1.26 2004/06/18 02:04:07 bms Exp $ */ /* $KAME: in_gif.c,v 1.54 2001/05/14 14:02:16 itojun Exp $ */ /* @@ -177,6 +177,7 @@ if (dst->sin_family != sin_dst->sin_family || dst->sin_addr.s_addr != sin_dst->sin_addr.s_addr) { /* cache route doesn't match */ + bzero(dst, sizeof(*dst)); dst->sin_family = sin_dst->sin_family; dst->sin_len = sizeof(struct sockaddr_in); dst->sin_addr = sin_dst->sin_addr; ==== //depot/projects/netperf_socket/sys/netinet/tcp_output.c#5 (text+ko) ==== @@ -27,7 +27,7 @@ * SUCH DAMAGE. * * @(#)tcp_output.c 8.4 (Berkeley) 5/24/95 - * $FreeBSD: src/sys/netinet/tcp_output.c,v 1.91 2004/05/04 02:11:47 rwatson Exp $ + * $FreeBSD: src/sys/netinet/tcp_output.c,v 1.92 2004/06/18 02:47:59 bms Exp $ */ #include "opt_inet.h" @@ -292,7 +292,7 @@ len = tp->t_maxseg; sendalot = 1; } - if (SEQ_LT(tp->snd_nxt + len, tp->snd_una + so->so_snd.sb_cc)) + if (off + len < so->so_snd.sb_cc) flags &= ~TH_FIN; recwin = sbspace(&so->so_rcv);
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200406180325.i5I3PEBK092459>
