Date: Mon, 21 Jun 2004 16:42:13 GMT From: Julian Elischer <julian@FreeBSD.org> To: Perforce Change Reviews <perforce@freebsd.org> Subject: PERFORCE change 55458 for review Message-ID: <200406211642.i5LGgD1r057330@repoman.freebsd.org>
next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=55458 Change 55458 by julian@julian_jules1 on 2004/06/21 16:41:20 IFC Affected files ... .. //depot/projects/nsched/sys/amd64/amd64/pmap.c#10 integrate .. //depot/projects/nsched/sys/conf/ldscript.ia64#2 integrate .. //depot/projects/nsched/sys/dev/esp/esp_sbus.c#4 integrate .. //depot/projects/nsched/sys/dev/rp/rp.c#5 integrate .. //depot/projects/nsched/sys/dev/rp/rp_pci.c#3 integrate .. //depot/projects/nsched/sys/dev/rp/rpreg.h#3 integrate .. //depot/projects/nsched/sys/geom/gate/g_gate.c#3 integrate .. //depot/projects/nsched/sys/i386/i386/pmap.c#7 integrate .. //depot/projects/nsched/sys/kern/kern_exit.c#13 integrate .. //depot/projects/nsched/sys/kern/kern_proc.c#9 integrate .. //depot/projects/nsched/sys/kern/tty_compat.c#5 integrate .. //depot/projects/nsched/sys/kern/uipc_socket.c#6 integrate .. //depot/projects/nsched/sys/kern/uipc_socket2.c#7 integrate .. //depot/projects/nsched/sys/kern/uipc_usrreq.c#6 integrate .. //depot/projects/nsched/sys/netgraph/ng_fec.c#5 integrate .. //depot/projects/nsched/sys/netinet/ip_mroute.c#3 integrate .. //depot/projects/nsched/sys/netinet/tcp_input.c#5 integrate .. //depot/projects/nsched/sys/netinet/tcp_subr.c#5 integrate .. //depot/projects/nsched/sys/netipx/spx_usrreq.c#3 integrate .. //depot/projects/nsched/sys/netkey/keysock.c#2 integrate .. //depot/projects/nsched/sys/sys/mutex.h#2 integrate .. //depot/projects/nsched/sys/sys/socketvar.h#5 integrate .. //depot/projects/nsched/sys/sys/user.h#5 integrate Differences ... ==== //depot/projects/nsched/sys/amd64/amd64/pmap.c#10 (text+ko) ==== @@ -75,7 +75,7 @@ */ #include <sys/cdefs.h> -__FBSDID("$FreeBSD: src/sys/amd64/amd64/pmap.c,v 1.477 2004/06/20 06:10:59 alc Exp $"); +__FBSDID("$FreeBSD: src/sys/amd64/amd64/pmap.c,v 1.478 2004/06/20 20:57:05 alc Exp $"); /* * Manages physical address maps. @@ -2461,7 +2461,7 @@ #ifdef PMAP_REMOVE_PAGES_CURPROC_ONLY pte = vtopte(pv->pv_va); #else - pte = pmap_pte(pv->pv_pmap, pv->pv_va); + pte = pmap_pte(pmap, pv->pv_va); #endif tpte = *pte; @@ -2487,7 +2487,7 @@ KASSERT(m < &vm_page_array[vm_page_array_size], ("pmap_remove_pages: bad tpte %#jx", (uintmax_t)tpte)); - pv->pv_pmap->pm_stats.resident_count--; + pmap->pm_stats.resident_count--; pte_clear(pte); @@ -2499,15 +2499,14 @@ } npv = TAILQ_NEXT(pv, pv_plist); - TAILQ_REMOVE(&pv->pv_pmap->pm_pvlist, pv, pv_plist); + TAILQ_REMOVE(&pmap->pm_pvlist, pv, pv_plist); m->md.pv_list_count--; TAILQ_REMOVE(&m->md.pv_list, pv, pv_list); - if (TAILQ_FIRST(&m->md.pv_list) == NULL) { + if (TAILQ_EMPTY(&m->md.pv_list)) vm_page_flag_clear(m, PG_WRITEABLE); - } - pmap_unuse_pt(pv->pv_pmap, pv->pv_va, pv->pv_ptem); + pmap_unuse_pt(pmap, pv->pv_va, pv->pv_ptem); free_pv_entry(pv); } pmap_invalidate_all(pmap); @@ -2525,9 +2524,11 @@ { pv_entry_t pv; pt_entry_t *pte; + boolean_t rv; + rv = FALSE; if (!pmap_initialized || (m->flags & PG_FICTITIOUS)) - return FALSE; + return (rv); mtx_assert(&vm_page_queue_mtx, MA_OWNED); TAILQ_FOREACH(pv, &m->md.pv_list, pv_list) { @@ -2546,13 +2547,12 @@ #endif PMAP_LOCK(pv->pv_pmap); pte = pmap_pte(pv->pv_pmap, pv->pv_va); - if (*pte & PG_M) { - PMAP_UNLOCK(pv->pv_pmap); - return TRUE; - } + rv = (*pte & PG_M) != 0; PMAP_UNLOCK(pv->pv_pmap); + if (rv) + break; } - return (FALSE); + return (rv); } /* ==== //depot/projects/nsched/sys/conf/ldscript.ia64#2 (text+ko) ==== @@ -1,4 +1,4 @@ -/* $FreeBSD: src/sys/conf/ldscript.ia64,v 1.10 2003/09/06 05:15:36 marcel Exp $ */ +/* $FreeBSD: src/sys/conf/ldscript.ia64,v 1.11 2004/06/20 22:32:19 marcel Exp $ */ OUTPUT_FORMAT("elf64-ia64-little", "elf64-ia64-little", "elf64-ia64-little") OUTPUT_ARCH(ia64) ENTRY(__start) @@ -74,6 +74,8 @@ *(.dtors) *(SORT(.dtors.*)) } + . = ALIGN(16); + __gp = . + 0x200000; .got : { *(.got.plt) *(.got) } .IA_64.pltoff : { *(.IA_64.pltoff) } /* We want the small data sections together, so single-instruction offsets ==== //depot/projects/nsched/sys/dev/esp/esp_sbus.c#4 (text+ko) ==== @@ -65,12 +65,13 @@ */ #include <sys/cdefs.h> -__FBSDID("$FreeBSD: src/sys/dev/esp/esp_sbus.c,v 1.3 2004/06/12 03:23:37 scottl Exp $"); +__FBSDID("$FreeBSD: src/sys/dev/esp/esp_sbus.c,v 1.4 2004/06/21 07:27:34 scottl Exp $"); #include <sys/param.h> #include <sys/systm.h> #include <sys/bus.h> #include <sys/kernel.h> +#include <sys/module.h> #include <sys/resource.h> #include <sys/lock.h> #include <sys/mutex.h> ==== //depot/projects/nsched/sys/dev/rp/rp.c#5 (text+ko) ==== @@ -32,7 +32,7 @@ */ #include <sys/cdefs.h> -__FBSDID("$FreeBSD: src/sys/dev/rp/rp.c,v 1.60 2004/06/16 09:46:54 phk Exp $"); +__FBSDID("$FreeBSD: src/sys/dev/rp/rp.c,v 1.61 2004/06/21 13:02:25 gallatin Exp $"); /* * rp.c - for RocketPort FreeBSD @@ -565,6 +565,7 @@ **********************************************************************/ static timeout_t rpdtrwakeup; +struct callout_handle rp_callout_handle; static d_open_t rpopen; static d_close_t rpclose; @@ -789,7 +790,8 @@ } } if(rp_num_ports_open) - timeout(rp_do_poll, (void *)NULL, POLL_INTERVAL); + rp_callout_handle = timeout(rp_do_poll, + (void *)NULL, POLL_INTERVAL); } int @@ -801,7 +803,6 @@ int ChanStatus, line, i, count; int retval; struct rp_port *rp; - struct tty *tty; struct cdev **dev_nodes; unit = device_get_unit(ctlp->dev); @@ -809,9 +810,10 @@ printf("RocketPort%d (Version %s) %d ports.\n", unit, RocketPortVersion, num_ports); rp_num_ports[unit] = num_ports; + callout_handle_init(&rp_callout_handle); ctlp->rp = rp = (struct rp_port *) - malloc(sizeof(struct rp_port) * num_ports, M_TTYS, M_NOWAIT); + malloc(sizeof(struct rp_port) * num_ports, M_TTYS, M_NOWAIT | M_ZERO); if (rp == NULL) { device_printf(ctlp->dev, "rp_attachcommon: Could not malloc rp_ports structures.\n"); retval = ENOMEM; @@ -823,15 +825,6 @@ minor_to_unit[i] = unit; bzero(rp, sizeof(struct rp_port) * num_ports); - ctlp->tty = tty = (struct tty *) - malloc(sizeof(struct tty) * num_ports, M_TTYS, - M_NOWAIT | M_ZERO); - if(tty == NULL) { - device_printf(ctlp->dev, "rp_attachcommon: Could not malloc tty structures.\n"); - retval = ENOMEM; - goto nogo; - } - oldspl = spltty(); rp_addr(unit) = rp; splx(oldspl); @@ -867,15 +860,15 @@ port = 0; for(aiop=0; aiop < num_aiops; aiop++) { num_chan = sGetAiopNumChan(ctlp, aiop); - for(chan=0; chan < num_chan; chan++, port++, rp++, tty++) { - rp->rp_tty = tty; + for(chan=0; chan < num_chan; chan++, port++, rp++) { + rp->rp_tty = ttymalloc(NULL); rp->rp_port = port; rp->rp_ctlp = ctlp; rp->rp_unit = unit; rp->rp_chan = chan; rp->rp_aiop = aiop; - tty->t_line = 0; + rp->rp_tty->t_line = 0; /* tty->t_termios = deftermios; */ rp->dtr_wait = 3 * hz; @@ -920,8 +913,19 @@ rp_releaseresource(CONTROLLER_t *ctlp) { int i, s, unit; + struct rp_port *rp; + unit = device_get_unit(ctlp->dev); + if (rp_addr(unit) != NULL) { + for (i = 0; i < rp_num_ports[unit]; i++) { + rp = rp_addr(unit) + i; + s = ttyrel(rp->rp_tty); + if (s) { + printf("Detaching with active tty (%d refs)!\n", s); + } + } + } if (ctlp->rp != NULL) { s = spltty(); @@ -935,10 +939,6 @@ free(ctlp->rp, M_DEVBUF); ctlp->rp = NULL; } - if (ctlp->tty != NULL) { - free(ctlp->tty, M_DEVBUF); - ctlp->tty = NULL; - } if (ctlp->dev != NULL) { for (i = 0 ; i < rp_num_ports[unit] * 6 ; i++) destroy_dev(ctlp->dev_nodes[i]); @@ -947,6 +947,11 @@ } } +void +rp_untimeout(void) +{ + untimeout(rp_do_poll, (void *)NULL, rp_callout_handle); +} static int rpopen(dev, flag, mode, td) struct cdev *dev; @@ -1072,8 +1077,8 @@ } if(rp_num_ports_open == 1) - timeout(rp_do_poll, (void *)NULL, POLL_INTERVAL); - + rp_callout_handle = timeout(rp_do_poll, + (void *)NULL, POLL_INTERVAL); } if(!(flag&O_NONBLOCK) && !(tp->t_cflag&CLOCAL) && ==== //depot/projects/nsched/sys/dev/rp/rp_pci.c#3 (text+ko) ==== @@ -34,7 +34,7 @@ */ #include <sys/cdefs.h> -__FBSDID("$FreeBSD: src/sys/dev/rp/rp_pci.c,v 1.8 2004/05/30 20:08:39 phk Exp $"); +__FBSDID("$FreeBSD: src/sys/dev/rp/rp_pci.c,v 1.9 2004/06/21 13:02:25 gallatin Exp $"); #include <sys/param.h> #include <sys/systm.h> @@ -208,7 +208,6 @@ return (retval); } -#if notdef static int rp_pcidetach(device_t dev) { @@ -238,20 +237,22 @@ return (0); } -#endif /* notdef */ static void rp_pcireleaseresource(CONTROLLER_t *ctlp) { - rp_releaseresource(ctlp); - + rp_untimeout(); if (ctlp->io != NULL) { if (ctlp->io[0] != NULL) bus_release_resource(ctlp->dev, SYS_RES_IOPORT, ctlp->io_rid[0], ctlp->io[0]); free(ctlp->io, M_DEVBUF); + ctlp->io = NULL; } - if (ctlp->io_rid != NULL) + if (ctlp->io_rid != NULL) { free(ctlp->io_rid, M_DEVBUF); + ctlp->io = NULL; + } + rp_releaseresource(ctlp); } static int @@ -351,10 +352,8 @@ /* Device interface */ DEVMETHOD(device_probe, rp_pciprobe), DEVMETHOD(device_attach, rp_pciattach), -#if notdef DEVMETHOD(device_detach, rp_pcidetach), DEVMETHOD(device_shutdown, rp_pcishutdown), -#endif /* notdef */ { 0, 0 } }; ==== //depot/projects/nsched/sys/dev/rp/rpreg.h#3 (text+ko) ==== @@ -29,7 +29,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $FreeBSD: src/sys/dev/rp/rpreg.h,v 1.5 2004/06/16 09:46:54 phk Exp $ + * $FreeBSD: src/sys/dev/rp/rpreg.h,v 1.6 2004/06/21 13:02:25 gallatin Exp $ */ /* @@ -368,7 +368,6 @@ struct resource **io; /* IO resources */ struct rp_port *rp; /* port */ - struct tty *tty; /* tty */ /* Device nodes */ struct cdev **dev_nodes; @@ -1005,6 +1004,7 @@ void sDisInterrupts(CHANNEL_T *ChP,Word_t Flags); int rp_attachcommon(CONTROLLER_T *ctlp, int num_aiops, int num_ports); void rp_releaseresource(CONTROLLER_t *ctlp); +void rp_untimeout(void); #ifndef ROCKET_C extern Byte_t R[RDATASIZE]; ==== //depot/projects/nsched/sys/geom/gate/g_gate.c#3 (text+ko) ==== @@ -23,7 +23,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $FreeBSD: src/sys/geom/gate/g_gate.c,v 1.6 2004/06/16 09:47:05 phk Exp $ + * $FreeBSD: src/sys/geom/gate/g_gate.c,v 1.7 2004/06/21 09:12:08 pjd Exp $ */ #include <sys/param.h> @@ -355,7 +355,9 @@ sbuf_printf(sb, "%s<queue_size>%u</queue_size>\n", indent, sc->sc_queue_size); sbuf_printf(sb, "%s<ref>%u</ref>\n", indent, sc->sc_ref); + g_topology_unlock(); g_gate_release(sc); + g_topology_lock(); } static int ==== //depot/projects/nsched/sys/i386/i386/pmap.c#7 (text+ko) ==== @@ -73,7 +73,7 @@ */ #include <sys/cdefs.h> -__FBSDID("$FreeBSD: src/sys/i386/i386/pmap.c,v 1.475 2004/06/20 06:11:00 alc Exp $"); +__FBSDID("$FreeBSD: src/sys/i386/i386/pmap.c,v 1.476 2004/06/20 20:57:06 alc Exp $"); /* * Manages physical address maps. @@ -2533,7 +2533,7 @@ #ifdef PMAP_REMOVE_PAGES_CURPROC_ONLY pte = vtopte(pv->pv_va); #else - pte = pmap_pte_quick(pv->pv_pmap, pv->pv_va); + pte = pmap_pte_quick(pmap, pv->pv_va); #endif tpte = *pte; @@ -2559,7 +2559,7 @@ KASSERT(m < &vm_page_array[vm_page_array_size], ("pmap_remove_pages: bad tpte %#jx", (uintmax_t)tpte)); - pv->pv_pmap->pm_stats.resident_count--; + pmap->pm_stats.resident_count--; pte_clear(pte); @@ -2571,15 +2571,14 @@ } npv = TAILQ_NEXT(pv, pv_plist); - TAILQ_REMOVE(&pv->pv_pmap->pm_pvlist, pv, pv_plist); + TAILQ_REMOVE(&pmap->pm_pvlist, pv, pv_plist); m->md.pv_list_count--; TAILQ_REMOVE(&m->md.pv_list, pv, pv_list); - if (TAILQ_FIRST(&m->md.pv_list) == NULL) { + if (TAILQ_EMPTY(&m->md.pv_list)) vm_page_flag_clear(m, PG_WRITEABLE); - } - pmap_unuse_pt(pv->pv_pmap, pv->pv_va, pv->pv_ptem); + pmap_unuse_pt(pmap, pv->pv_va, pv->pv_ptem); free_pv_entry(pv); } sched_unpin(); @@ -2598,9 +2597,11 @@ { pv_entry_t pv; pt_entry_t *pte; + boolean_t rv; + rv = FALSE; if (!pmap_initialized || (m->flags & PG_FICTITIOUS)) - return FALSE; + return (rv); sched_pin(); mtx_assert(&vm_page_queue_mtx, MA_OWNED); @@ -2620,15 +2621,13 @@ #endif PMAP_LOCK(pv->pv_pmap); pte = pmap_pte_quick(pv->pv_pmap, pv->pv_va); - if (*pte & PG_M) { - sched_unpin(); - PMAP_UNLOCK(pv->pv_pmap); - return TRUE; - } + rv = (*pte & PG_M) != 0; PMAP_UNLOCK(pv->pv_pmap); + if (rv) + break; } sched_unpin(); - return (FALSE); + return (rv); } /* ==== //depot/projects/nsched/sys/kern/kern_exit.c#13 (text+ko) ==== @@ -35,7 +35,7 @@ */ #include <sys/cdefs.h> -__FBSDID("$FreeBSD: src/sys/kern/kern_exit.c,v 1.236 2004/06/18 11:13:49 davidxu Exp $"); +__FBSDID("$FreeBSD: src/sys/kern/kern_exit.c,v 1.238 2004/06/21 14:49:50 bde Exp $"); #include "opt_compat.h" #include "opt_ktrace.h" @@ -103,6 +103,7 @@ void exit1(struct thread *td, int rv) { + struct bintime new_switchtime; struct proc *p, *nq, *q; struct tty *tp; struct vnode *ttyvp; @@ -512,14 +513,15 @@ mtx_lock_spin(&sched_lock); critical_exit(); - cnt.v_swtch++; - binuptime(PCPU_PTR(switchtime)); + + /* Do the same timestamp bookkeeping that mi_switch() would do. */ + binuptime(&new_switchtime); + bintime_add(&p->p_runtime, &new_switchtime); + bintime_sub(&p->p_runtime, PCPU_PTR(switchtime)); + PCPU_SET(switchtime, new_switchtime); PCPU_SET(switchticks, ticks); - /* - * Allow the scheduler to adjust the priority of the - * parent when a process is exiting. - */ + cnt.v_swtch++; sched_exit(p->p_pptr, td); /* ==== //depot/projects/nsched/sys/kern/kern_proc.c#9 (text+ko) ==== @@ -27,11 +27,11 @@ * SUCH DAMAGE. * * @(#)kern_proc.c 8.7 (Berkeley) 2/14/95 - * $FreeBSD: src/sys/kern/kern_proc.c,v 1.210 2004/06/20 02:03:33 gad Exp $ + * $FreeBSD: src/sys/kern/kern_proc.c,v 1.211 2004/06/20 22:17:22 gad Exp $ */ #include <sys/cdefs.h> -__FBSDID("$FreeBSD: src/sys/kern/kern_proc.c,v 1.210 2004/06/20 02:03:33 gad Exp $"); +__FBSDID("$FreeBSD: src/sys/kern/kern_proc.c,v 1.211 2004/06/20 22:17:22 gad Exp $"); #include "opt_ktrace.h" #include "opt_kstack_pages.h" @@ -751,6 +751,8 @@ kp->ki_lastcpu = td->td_lastcpu; kp->ki_oncpu = td->td_oncpu; kp->ki_tdflags = td->td_flags; + kp->ki_tid = td->td_tid; + kp->ki_numthreads = p->p_numthreads; kp->ki_pcb = td->td_pcb; kp->ki_kstack = (void *)td->td_kstack; kp->ki_pctcpu = sched_pctcpu(td); ==== //depot/projects/nsched/sys/kern/tty_compat.c#5 (text+ko) ==== @@ -30,7 +30,7 @@ */ #include <sys/cdefs.h> -__FBSDID("$FreeBSD: src/sys/kern/tty_compat.c,v 1.35 2004/06/11 11:16:24 phk Exp $"); +__FBSDID("$FreeBSD: src/sys/kern/tty_compat.c,v 1.36 2004/06/21 12:28:56 phk Exp $"); #include "opt_compat.h" @@ -82,9 +82,7 @@ }; static int -ttcompatspeedtab(speed, table) - int speed; - register struct speedtab *table; +ttcompatspeedtab(int speed, struct speedtab *table) { if (speed == 0) return (0); /* hangup */ @@ -95,16 +93,12 @@ } int -ttsetcompat(tp, com, data, term) - register struct tty *tp; - u_long *com; - caddr_t data; - struct termios *term; +ttsetcompat(struct tty *tp, u_long *com, caddr_t data, struct termios *term) { switch (*com) { case TIOCSETP: case TIOCSETN: { - register struct sgttyb *sg = (struct sgttyb *)data; + struct sgttyb *sg = (struct sgttyb *)data; int speed; if ((speed = sg->sg_ispeed) > MAX_SPEED || speed < 0) @@ -128,7 +122,7 @@ } case TIOCSETC: { struct tchars *tc = (struct tchars *)data; - register cc_t *cc; + cc_t *cc; cc = term->c_cc; cc[VINTR] = tc->t_intrc; @@ -144,7 +138,7 @@ } case TIOCSLTC: { struct ltchars *ltc = (struct ltchars *)data; - register cc_t *cc; + cc_t *cc; cc = term->c_cc; cc[VSUSP] = ltc->t_suspc; @@ -178,11 +172,7 @@ /*ARGSUSED*/ int -ttcompat(tp, com, data, flag) - register struct tty *tp; - u_long com; - caddr_t data; - int flag; +ttcompat(struct tty *tp, u_long com, caddr_t data, int flag) { switch (com) { case TIOCSETP: @@ -201,8 +191,8 @@ return ttioctl(tp, com, &term, flag); } case TIOCGETP: { - register struct sgttyb *sg = (struct sgttyb *)data; - register cc_t *cc = tp->t_cc; + struct sgttyb *sg = (struct sgttyb *)data; + cc_t *cc = tp->t_cc; sg->sg_ospeed = ttcompatspeedtab(tp->t_ospeed, compatspeeds); if (tp->t_ispeed == 0) @@ -216,7 +206,7 @@ } case TIOCGETC: { struct tchars *tc = (struct tchars *)data; - register cc_t *cc = tp->t_cc; + cc_t *cc = tp->t_cc; tc->t_intrc = cc[VINTR]; tc->t_quitc = cc[VQUIT]; @@ -228,7 +218,7 @@ } case TIOCGLTC: { struct ltchars *ltc = (struct ltchars *)data; - register cc_t *cc = tp->t_cc; + cc_t *cc = tp->t_cc; ltc->t_suspc = cc[VSUSP]; ltc->t_dsuspc = cc[VDSUSP]; @@ -269,14 +259,13 @@ } static int -ttcompatgetflags(tp) - register struct tty *tp; +ttcompatgetflags(struct tty *tp) { - register tcflag_t iflag = tp->t_iflag; - register tcflag_t lflag = tp->t_lflag; - register tcflag_t oflag = tp->t_oflag; - register tcflag_t cflag = tp->t_cflag; - register int flags = 0; + tcflag_t iflag = tp->t_iflag; + tcflag_t lflag = tp->t_lflag; + tcflag_t oflag = tp->t_oflag; + tcflag_t cflag = tp->t_cflag; + int flags = 0; if (iflag&IXOFF) flags |= TANDEM; @@ -330,15 +319,13 @@ } static void -ttcompatsetflags(tp, t) - register struct tty *tp; - register struct termios *t; +ttcompatsetflags(struct tty *tp, struct termios *t) { - register int flags = tp->t_flags; - register tcflag_t iflag = t->c_iflag; - register tcflag_t oflag = t->c_oflag; - register tcflag_t lflag = t->c_lflag; - register tcflag_t cflag = t->c_cflag; + int flags = tp->t_flags; + tcflag_t iflag = t->c_iflag; + tcflag_t oflag = t->c_oflag; + tcflag_t lflag = t->c_lflag; + tcflag_t cflag = t->c_cflag; if (flags & RAW) { iflag = IGNBRK; @@ -409,15 +396,13 @@ } static void -ttcompatsetlflags(tp, t) - register struct tty *tp; - register struct termios *t; +ttcompatsetlflags(struct tty *tp, struct termios *t) { - register int flags = tp->t_flags; - register tcflag_t iflag = t->c_iflag; - register tcflag_t oflag = t->c_oflag; - register tcflag_t lflag = t->c_lflag; - register tcflag_t cflag = t->c_cflag; + int flags = tp->t_flags; + tcflag_t iflag = t->c_iflag; + tcflag_t oflag = t->c_oflag; + tcflag_t lflag = t->c_lflag; + tcflag_t cflag = t->c_cflag; iflag &= ~(PARMRK|IGNPAR|IGNCR|INLCR); if (flags&CRTERA) ==== //depot/projects/nsched/sys/kern/uipc_socket.c#6 (text+ko) ==== @@ -30,7 +30,7 @@ */ #include <sys/cdefs.h> -__FBSDID("$FreeBSD: src/sys/kern/uipc_socket.c,v 1.185 2004/06/20 17:50:42 rwatson Exp $"); +__FBSDID("$FreeBSD: src/sys/kern/uipc_socket.c,v 1.186 2004/06/21 00:20:42 rwatson Exp $"); #include "opt_inet.h" #include "opt_mac.h" @@ -348,9 +348,15 @@ SOCKBUF_LOCK(&so->so_snd); so->so_snd.sb_flags |= SB_NOINTR; (void)sblock(&so->so_snd, M_WAITOK); - socantsendmore(so); + /* + * socantsendmore_locked() drops the socket buffer mutex so that it + * can safely perform wakeups. Re-acquire the mutex before + * continuing. + */ + socantsendmore_locked(so); + SOCKBUF_LOCK(&so->so_snd); sbunlock(&so->so_snd); - sbrelease(&so->so_snd, so); + sbrelease_locked(&so->so_snd, so); SOCKBUF_UNLOCK(&so->so_snd); sorflush(so); sodealloc(so); @@ -1202,7 +1208,7 @@ flags |= MSG_TRUNC; if ((flags & MSG_PEEK) == 0) { SOCKBUF_LOCK_ASSERT(&so->so_rcv); - (void) sbdroprecord(&so->so_rcv); + (void) sbdroprecord_locked(&so->so_rcv); } } if ((flags & MSG_PEEK) == 0) { @@ -1271,23 +1277,41 @@ struct protosw *pr = so->so_proto; struct sockbuf asb; + /* + * XXXRW: This is quite ugly. The existing code made a copy of the + * socket buffer, then zero'd the original to clear the buffer + * fields. However, with mutexes in the socket buffer, this causes + * problems. We only clear the zeroable bits of the original; + * however, we have to initialize and destroy the mutex in the copy + * so that dom_dispose() and sbrelease() can lock t as needed. + */ SOCKBUF_LOCK(sb); sb->sb_flags |= SB_NOINTR; (void) sblock(sb, M_WAITOK); - socantrcvmore(so); + /* + * socantrcvmore_locked() drops the socket buffer mutex so that it + * can safely perform wakeups. Re-acquire the mutex before + * continuing. + */ + socantrcvmore_locked(so); + SOCKBUF_LOCK(sb); sbunlock(sb); - asb = *sb; /* - * Invalidate/clear most of the sockbuf structure, but keep - * its selinfo structure valid. + * Invalidate/clear most of the sockbuf structure, but leave + * selinfo and mutex data unchanged. */ + bzero(&asb, offsetof(struct sockbuf, sb_startzero)); + bcopy(&sb->sb_startzero, &asb.sb_startzero, + sizeof(*sb) - offsetof(struct sockbuf, sb_startzero)); bzero(&sb->sb_startzero, sizeof(*sb) - offsetof(struct sockbuf, sb_startzero)); SOCKBUF_UNLOCK(sb); + SOCKBUF_LOCK_INIT(&asb, "so_rcv"); if (pr->pr_flags & PR_RIGHTS && pr->pr_domain->dom_dispose != NULL) (*pr->pr_domain->dom_dispose)(asb.sb_mb); sbrelease(&asb, so); + SOCKBUF_LOCK_DESTROY(&asb); } #ifdef INET ==== //depot/projects/nsched/sys/kern/uipc_socket2.c#7 (text+ko) ==== @@ -30,7 +30,7 @@ */ #include <sys/cdefs.h> -__FBSDID("$FreeBSD: src/sys/kern/uipc_socket2.c,v 1.133 2004/06/19 03:23:14 rwatson Exp $"); +__FBSDID("$FreeBSD: src/sys/kern/uipc_socket2.c,v 1.134 2004/06/21 00:20:42 rwatson Exp $"); #include "opt_mac.h" #include "opt_param.h" @@ -197,9 +197,9 @@ SOCKBUF_UNLOCK(&so->so_rcv); SOCKBUF_LOCK(&so->so_snd); so->so_snd.sb_state |= SBS_CANTSENDMORE; + sbdrop_locked(&so->so_snd, so->so_snd.sb_cc); SOCKBUF_UNLOCK(&so->so_snd); wakeup(&so->so_timeo); - sbdrop(&so->so_snd, so->so_snd.sb_cc); sowwakeup(so); sorwakeup(so); } @@ -296,14 +296,38 @@ * protocol when it detects that the peer will send no more data. * Data queued for reading in the socket may yet be read. */ +void +socantsendmore_locked(so) + struct socket *so; +{ + SOCKBUF_LOCK_ASSERT(&so->so_snd); + + so->so_snd.sb_state |= SBS_CANTSENDMORE; + sowwakeup_locked(so); + mtx_assert(SOCKBUF_MTX(&so->so_snd), MA_NOTOWNED); +} + void socantsendmore(so) struct socket *so; { - so->so_snd.sb_state |= SBS_CANTSENDMORE; - sowwakeup(so); + SOCKBUF_LOCK(&so->so_snd); + socantsendmore_locked(so); + mtx_assert(SOCKBUF_MTX(&so->so_snd), MA_NOTOWNED); +} + +void +socantrcvmore_locked(so) + struct socket *so; +{ + + SOCKBUF_LOCK_ASSERT(&so->so_rcv); + + so->so_rcv.sb_state |= SBS_CANTRCVMORE; + sorwakeup_locked(so); + mtx_assert(SOCKBUF_MTX(&so->so_rcv), MA_NOTOWNED); } void @@ -311,8 +335,9 @@ struct socket *so; { - so->so_rcv.sb_state |= SBS_CANTRCVMORE; - sorwakeup(so); + SOCKBUF_LOCK(&so->so_rcv); + socantrcvmore_locked(so); + mtx_assert(SOCKBUF_MTX(&so->so_rcv), MA_NOTOWNED); } /* @@ -356,9 +381,16 @@ } /* - * Wakeup processes waiting on a socket buffer. - * Do asynchronous notification via SIGIO - * if the socket has the SS_ASYNC flag set. + * Wakeup processes waiting on a socket buffer. Do asynchronous + * notification via SIGIO if the socket has the SS_ASYNC flag set. + * + * Called with the socket buffer lock held; will release the lock by the end + * of the function. This allows the caller to acquire the socket buffer lock + * while testing for the need for various sorts of wakeup and hold it through + * to the point where it's no longer required. We currently hold the lock + * through calls out to other subsystems (with the exception of kqueue), and + * then release it to avoid lock order issues. It's not clear that's + * correct. */ void sowakeup(so, sb) @@ -366,19 +398,23 @@ register struct sockbuf *sb; { + SOCKBUF_LOCK_ASSERT(sb); + selwakeuppri(&sb->sb_sel, PSOCK); sb->sb_flags &= ~SB_SEL; if (sb->sb_flags & SB_WAIT) { sb->sb_flags &= ~SB_WAIT; wakeup(&sb->sb_cc); } + KNOTE(&sb->sb_sel.si_note, 0); + SOCKBUF_UNLOCK(sb); if ((so->so_state & SS_ASYNC) && so->so_sigio != NULL) pgsigio(&so->so_sigio, SIGIO, 0); if (sb->sb_flags & SB_UPCALL) (*so->so_upcall)(so, so->so_upcallarg, M_DONTWAIT); if (sb->sb_flags & SB_AIO) aio_swake(so, sb); - KNOTE(&sb->sb_sel.si_note, 0); + mtx_assert(SOCKBUF_MTX(sb), MA_NOTOWNED); } /* @@ -500,17 +536,29 @@ * Free mbufs held by a socket, and reserved mbuf space. */ void -sbrelease(sb, so) +sbrelease_locked(sb, so) struct sockbuf *sb; struct socket *so; { - sbflush(sb); + SOCKBUF_LOCK_ASSERT(sb); + + sbflush_locked(sb); (void)chgsbsize(so->so_cred->cr_uidinfo, &sb->sb_hiwat, 0, RLIM_INFINITY); sb->sb_mbmax = 0; } +void +sbrelease(sb, so) + struct sockbuf *sb; + struct socket *so; +{ + + SOCKBUF_LOCK(sb); + sbrelease_locked(sb, so); + SOCKBUF_UNLOCK(sb); +} /* * Routines to add and remove * data from an mbuf queue. @@ -542,6 +590,8 @@ { struct mbuf *m = sb->sb_mb; + SOCKBUF_LOCK_ASSERT(sb); + while (m && m->m_nextpkt) m = m->m_nextpkt; @@ -561,6 +611,8 @@ struct mbuf *m = sb->sb_mb; struct mbuf *n; + SOCKBUF_LOCK_ASSERT(sb); + while (m && m->m_nextpkt) m = m->m_nextpkt; @@ -583,6 +635,7 @@ #endif /* SOCKBUF_DEBUG */ #define SBLINKRECORD(sb, m0) do { \ + SOCKBUF_LOCK_ASSERT(sb); \ if ((sb)->sb_lastrecord != NULL) \ (sb)->sb_lastrecord->m_nextpkt = (m0); \ else \ @@ -597,14 +650,17 @@ * discarded and mbufs are compacted where possible. */ void -sbappend(sb, m) +sbappend_locked(sb, m) struct sockbuf *sb; struct mbuf *m; { register struct mbuf *n; + SOCKBUF_LOCK_ASSERT(sb); + if (m == 0) return; + SBLASTRECORDCHK(sb); n = sb->sb_mb; if (n) { @@ -612,7 +668,7 @@ n = n->m_nextpkt; do { if (n->m_flags & M_EOR) { - sbappendrecord(sb, m); /* XXXXXX!!!! */ + sbappendrecord_locked(sb, m); /* XXXXXX!!!! */ >>> TRUNCATED FOR MAIL (1000 lines) <<<
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200406211642.i5LGgD1r057330>