From owner-p4-projects@FreeBSD.ORG Fri Jul 27 22:19:09 2007 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id D852216A41F; Fri, 27 Jul 2007 22:19:08 +0000 (UTC) Delivered-To: perforce@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 895FE16A417 for ; Fri, 27 Jul 2007 22:19:08 +0000 (UTC) (envelope-from lulf@FreeBSD.org) Received: from repoman.freebsd.org (repoman.freebsd.org [IPv6:2001:4f8:fff6::29]) by mx1.freebsd.org (Postfix) with ESMTP id 6CEB513C48E for ; Fri, 27 Jul 2007 22:19:08 +0000 (UTC) (envelope-from lulf@FreeBSD.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.14.1/8.14.1) with ESMTP id l6RMJ8fs081082 for ; Fri, 27 Jul 2007 22:19:08 GMT (envelope-from lulf@FreeBSD.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.14.1/8.14.1/Submit) id l6RMJ7DC081079 for perforce@freebsd.org; Fri, 27 Jul 2007 22:19:07 GMT (envelope-from lulf@FreeBSD.org) Date: Fri, 27 Jul 2007 22:19:07 GMT Message-Id: <200707272219.l6RMJ7DC081079@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to lulf@FreeBSD.org using -f From: Ulf Lilleengen To: Perforce Change Reviews Cc: Subject: PERFORCE change 124223 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 27 Jul 2007 22:19:09 -0000 http://perforce.freebsd.org/chv.cgi?CH=124223 Change 124223 by lulf@lulf_carrot on 2007/07/27 22:18:45 IFC Affected files ... .. //depot/projects/soc2007/lulf/gvinum_fixup/sbin/Makefile#4 integrate .. //depot/projects/soc2007/lulf/gvinum_fixup/sys/conf/NOTES#12 integrate .. //depot/projects/soc2007/lulf/gvinum_fixup/sys/conf/files#13 integrate .. //depot/projects/soc2007/lulf/gvinum_fixup/sys/conf/options#10 integrate .. //depot/projects/soc2007/lulf/gvinum_fixup/sys/i386/i386/trap.c#5 integrate .. //depot/projects/soc2007/lulf/gvinum_fixup/sys/i386/isa/clock.c#4 integrate .. //depot/projects/soc2007/lulf/gvinum_fixup/sys/i386/linux/linux_machdep.c#5 integrate .. //depot/projects/soc2007/lulf/gvinum_fixup/sys/kern/kern_kse.c#4 integrate .. //depot/projects/soc2007/lulf/gvinum_fixup/sys/kern/kern_rwlock.c#6 integrate .. //depot/projects/soc2007/lulf/gvinum_fixup/sys/kern/kern_sig.c#5 integrate .. //depot/projects/soc2007/lulf/gvinum_fixup/sys/kern/kern_switch.c#4 integrate .. //depot/projects/soc2007/lulf/gvinum_fixup/sys/kern/kern_thread.c#5 integrate .. //depot/projects/soc2007/lulf/gvinum_fixup/sys/kern/sched_ule.c#7 integrate .. //depot/projects/soc2007/lulf/gvinum_fixup/sys/kern/subr_clock.c#2 integrate .. //depot/projects/soc2007/lulf/gvinum_fixup/sys/kern/tty.c#5 integrate .. //depot/projects/soc2007/lulf/gvinum_fixup/sys/kern/uipc_usrreq.c#5 integrate .. //depot/projects/soc2007/lulf/gvinum_fixup/sys/kern/vfs_mount.c#6 integrate .. //depot/projects/soc2007/lulf/gvinum_fixup/sys/kern/vfs_vnops.c#4 integrate .. //depot/projects/soc2007/lulf/gvinum_fixup/sys/modules/Makefile#8 integrate .. //depot/projects/soc2007/lulf/gvinum_fixup/sys/sys/proc.h#5 integrate .. //depot/projects/soc2007/lulf/gvinum_fixup/sys/sys/rwlock.h#4 integrate .. //depot/projects/soc2007/lulf/gvinum_fixup/sys/vm/vm_fault.c#6 integrate .. //depot/projects/soc2007/lulf/gvinum_fixup/sys/vm/vnode_pager.c#4 integrate Differences ... ==== //depot/projects/soc2007/lulf/gvinum_fixup/sbin/Makefile#4 (text+ko) ==== @@ -1,5 +1,5 @@ # @(#)Makefile 8.5 (Berkeley) 3/31/94 -# $FreeBSD: src/sbin/Makefile,v 1.167 2007/06/25 05:06:53 rafan Exp $ +# $FreeBSD: src/sbin/Makefile,v 1.168 2007/07/24 15:35:00 scottl Exp $ .include @@ -41,6 +41,7 @@ init \ ${_ipf} \ ipfw \ + iscontrol \ kldconfig \ kldload \ kldstat \ ==== //depot/projects/soc2007/lulf/gvinum_fixup/sys/conf/NOTES#12 (text+ko) ==== @@ -1,4 +1,4 @@ -# $FreeBSD: src/sys/conf/NOTES,v 1.1445 2007/07/18 02:51:21 jeff Exp $ +# $FreeBSD: src/sys/conf/NOTES,v 1.1447 2007/07/24 15:35:01 scottl Exp $ # # NOTES -- Lines that can be cut/pasted into kernel and hints configs. # @@ -1441,6 +1441,7 @@ device ahd device amd device esp +device iscsi_initiator device isp hint.isp.0.disable="1" hint.isp.0.role="3" @@ -1506,6 +1507,10 @@ # controllers that have it configured only if this option is set. options ADW_ALLOW_MEMIO +# Options used in dev/iscsi (Software iSCSI stack) +# +options ISCSI_INITIATOR_DEBUG=9 + # Options used in dev/isp/ (Qlogic SCSI/FC driver). # # ISP_TARGET_MODE - enable target mode operation @@ -1899,6 +1904,7 @@ # PCI Ethernet NICs. device de # DEC/Intel DC21x4x (``Tulip'') device le # AMD Am7900 LANCE and Am79C9xx PCnet +device mxge # Myricom Myri-10G 10GbE NIC device nxge # Neterion Xframe 10GbE Server/Storage Adapter device txp # 3Com 3cR990 (``Typhoon'') device vx # 3Com 3c590, 3c595 (``Vortex'') ==== //depot/projects/soc2007/lulf/gvinum_fixup/sys/conf/files#13 (text+ko) ==== @@ -1,4 +1,4 @@ -# $FreeBSD: src/sys/conf/files,v 1.1238 2007/07/14 21:49:23 rwatson Exp $ +# $FreeBSD: src/sys/conf/files,v 1.1241 2007/07/24 15:35:01 scottl Exp $ # # The long compile-with and dependency lines are required because of # limitations in config: backslash-newline doesn't work in strings, and @@ -721,6 +721,12 @@ dev/ips/ips_ioctl.c optional ips dev/ips/ips_pci.c optional ips pci dev/ipw/if_ipw.c optional ipw +dev/iscsi/initiator/iscsi.c optional iscsi_initiator scbus +dev/iscsi/initiator/iscsi_subr.c optional iscsi_initiator scbus +dev/iscsi/initiator/isc_cam.c optional iscsi_initiator scbus +dev/iscsi/initiator/isc_soc.c optional iscsi_initiator scbus +dev/iscsi/initiator/isc_sm.c optional iscsi_initiator scbus +dev/iscsi/initiator/isc_subr.c optional iscsi_initiator scbus dev/isp/isp.c optional isp dev/isp/isp_freebsd.c optional isp dev/isp/isp_library.c optional isp @@ -812,6 +818,10 @@ dev/mpt/mpt_pci.c optional mpt pci dev/mpt/mpt_raid.c optional mpt dev/msk/if_msk.c optional msk +dev/mxge/if_mxge.c optional mxge pci +dev/mxge/mxge_lro.c optional mxge pci +dev/mxge/mxge_eth_z8e.c optional mxge pci +dev/mxge/mxge_ethp_z8e.c optional mxge pci dev/my/if_my.c optional my dev/ncv/ncr53c500.c optional ncv dev/ncv/ncr53c500_pccard.c optional ncv pccard @@ -1630,7 +1640,7 @@ net/slcompress.c optional netgraph_vjc | ppp | sl | sppp | \ netgraph_sppp net/zlib.c optional crypto | geom_uzip | ipsec | \ - ppp_deflate | netgraph_deflate + mxge | ppp_deflate | netgraph_deflate net80211/ieee80211.c optional wlan net80211/ieee80211_acl.c optional wlan_acl net80211/ieee80211_amrr.c optional wlan_amrr @@ -1908,7 +1918,6 @@ netinet6/route6.c optional inet6 netinet6/scope6.c optional inet6 netinet6/sctp6_usrreq.c optional inet6 sctp -netinet6/udp6_output.c optional inet6 netinet6/udp6_usrreq.c optional inet6 netipsec/ipsec.c optional ipsec netipsec/ipsec_input.c optional ipsec ==== //depot/projects/soc2007/lulf/gvinum_fixup/sys/conf/options#10 (text+ko) ==== @@ -1,4 +1,4 @@ -# $FreeBSD: src/sys/conf/options,v 1.602 2007/07/14 21:49:23 rwatson Exp $ +# $FreeBSD: src/sys/conf/options,v 1.603 2007/07/24 15:35:01 scottl Exp $ # # On the handling of kernel options # @@ -323,6 +323,9 @@ ISP_FW_CRASH_DUMP opt_isp.h ISP_DEFAULT_ROLES opt_isp.h +# Options used only in dev/iscsi +ISCSI_INITIATOR_DEBUG opt_iscsi_initiator.h + # Options used in the 'ata' ATA/ATAPI driver ATA_STATIC_ID opt_ata.h ATA_NOPCI opt_ata.h ==== //depot/projects/soc2007/lulf/gvinum_fixup/sys/i386/i386/trap.c#5 (text+ko) ==== @@ -38,7 +38,7 @@ */ #include -__FBSDID("$FreeBSD: src/sys/i386/i386/trap.c,v 1.306 2007/06/13 22:37:48 jhb Exp $"); +__FBSDID("$FreeBSD: src/sys/i386/i386/trap.c,v 1.307 2007/07/26 15:32:55 jhb Exp $"); /* * 386 Trap and System call handling @@ -173,7 +173,8 @@ { struct thread *td = curthread; struct proc *p = td->td_proc; - int i = 0, ucode = 0, type, code; + int i = 0, ucode = 0, code; + u_int type; register_t addr = 0; vm_offset_t eva; ksiginfo_t ksi; @@ -793,7 +794,8 @@ struct trapframe *frame; vm_offset_t eva; { - int code, type, ss, esp; + int code, ss, esp; + u_int type; struct soft_segment_descriptor softseg; char *msg; ==== //depot/projects/soc2007/lulf/gvinum_fixup/sys/i386/isa/clock.c#4 (text+ko) ==== @@ -33,7 +33,7 @@ */ #include -__FBSDID("$FreeBSD: src/sys/i386/isa/clock.c,v 1.237 2007/06/15 22:58:13 peter Exp $"); +__FBSDID("$FreeBSD: src/sys/i386/isa/clock.c,v 1.238 2007/07/23 09:42:31 dwmalone Exp $"); /* * Routines to handle clock hardware. @@ -679,8 +679,7 @@ /* Look if we have a RTC present and the time is valid */ if (!(rtcin(RTC_STATUSD) & RTCSD_PWR)) { - printf("Invalid time in real time clock.\n"); - printf("Check and reset the date immediately!\n"); + printf("Invalid time in clock: check and reset the date!\n"); return; } @@ -704,7 +703,11 @@ #else ct.year += 2000; #endif - clock_ct_to_ts(&ct, &ts); + /* Should we set dow = -1 because some clocks don't set it correctly? */ + if (clock_ct_to_ts(&ct, &ts)) { + printf("Invalid time in clock: check and reset the date!\n"); + return; + } ts.tv_sec += utc_offset(); tc_setclock(&ts); } ==== //depot/projects/soc2007/lulf/gvinum_fixup/sys/i386/linux/linux_machdep.c#5 (text+ko) ==== @@ -27,7 +27,7 @@ */ #include -__FBSDID("$FreeBSD: src/sys/i386/linux/linux_machdep.c,v 1.77 2007/07/04 23:06:43 peter Exp $"); +__FBSDID("$FreeBSD: src/sys/i386/linux/linux_machdep.c,v 1.78 2007/07/20 08:35:18 attilio Exp $"); #include #include @@ -846,9 +846,7 @@ iia.start = args->start; iia.length = args->length; iia.enable = args->enable; - mtx_lock(&Giant); error = i386_set_ioperm(td, &iia); - mtx_unlock(&Giant); return (error); } @@ -884,10 +882,8 @@ ldt.start = 0; ldt.descs = uap->ptr; ldt.num = uap->bytecount / sizeof(union descriptor); - mtx_lock(&Giant); error = i386_get_ldt(td, &ldt); td->td_retval[0] *= sizeof(union descriptor); - mtx_unlock(&Giant); break; case 0x01: /* write_ldt */ case 0x11: /* write_ldt */ @@ -912,9 +908,7 @@ desc.sd.sd_xx = 0; desc.sd.sd_def32 = ld.seg_32bit; desc.sd.sd_gran = ld.limit_in_pages; - mtx_lock(&Giant); error = i386_set_ldt(td, &ldt, &desc); - mtx_unlock(&Giant); break; default: error = EINVAL; ==== //depot/projects/soc2007/lulf/gvinum_fixup/sys/kern/kern_kse.c#4 (text+ko) ==== @@ -27,7 +27,7 @@ */ #include -__FBSDID("$FreeBSD: src/sys/kern/kern_kse.c,v 1.231 2007/06/12 19:49:39 jeff Exp $"); +__FBSDID("$FreeBSD: src/sys/kern/kern_kse.c,v 1.233 2007/07/23 23:16:53 attilio Exp $"); #include #include @@ -67,10 +67,6 @@ static void thread_alloc_spare(struct thread *td); static struct thread *thread_schedule_upcall(struct thread *td, struct kse_upcall *ku); static struct kse_upcall *upcall_alloc(void); -static void upcall_free(struct kse_upcall *ku); -static void upcall_link(struct kse_upcall *ku, struct proc *p); -static void upcall_unlink(struct kse_upcall *ku); -static void upcall_stash(struct kse_upcall *ke); struct mtx kse_lock; @@ -86,37 +82,11 @@ } void -upcall_free(struct kse_upcall *ku) -{ - - uma_zfree(upcall_zone, ku); -} - -void -upcall_link(struct kse_upcall *ku, struct proc *p) -{ - - PROC_SLOCK_ASSERT(p, MA_OWNED); - TAILQ_INSERT_TAIL(&p->p_upcalls, ku, ku_link); - ku->ku_proc = p; -} - -void -upcall_unlink(struct kse_upcall *ku) -{ - struct proc *p = ku->ku_proc; - - PROC_SLOCK_ASSERT(p, MA_OWNED); - KASSERT(ku->ku_owner == NULL, ("%s: have owner", __func__)); - TAILQ_REMOVE(&p->p_upcalls, ku, ku_link); - upcall_stash(ku); -} - -void upcall_remove(struct thread *td) { PROC_SLOCK_ASSERT(td->td_proc, MA_OWNED); + THREAD_LOCK_ASSERT(td, MA_OWNED); if (td->td_upcall != NULL) { /* * If we are not a bound thread then decrement the count of @@ -124,8 +94,12 @@ */ if (td->td_pflags & TDP_SA) td->td_proc->p_numupcalls--; + mtx_lock_spin(&kse_lock); td->td_upcall->ku_owner = NULL; - upcall_unlink(td->td_upcall); + TAILQ_REMOVE(&td->td_upcall->ku_proc->p_upcalls, td->td_upcall, + ku_link); + TAILQ_INSERT_HEAD(&zombie_upcalls, td->td_upcall, ku_link); + mtx_unlock_spin(&kse_lock); td->td_upcall = NULL; } } @@ -157,8 +131,12 @@ struct kse_upcall *ku; int error; - if ((ku = td->td_upcall) == NULL || TD_CAN_UNBIND(td)) + thread_lock(td); + if ((ku = td->td_upcall) == NULL || TD_CAN_UNBIND(td)) { + thread_unlock(td); return (EINVAL); + } + thread_unlock(td); error = (uap->tmbx == NULL) ? EINVAL : 0; if (!error) error = copyin(uap->tmbx, &tmbx, sizeof(tmbx)); @@ -181,11 +159,11 @@ else ptrace_clear_single_step(td); if (tmbx.tm_dflags & TMDF_SUSPEND) { - PROC_SLOCK(td->td_proc); + thread_lock(td); /* fuword can block, check again */ if (td->td_upcall) ku->ku_flags |= KUF_DOUPCALL; - PROC_SUNLOCK(td->td_proc); + thread_unlock(td); } _PRELE(td->td_proc); } @@ -219,8 +197,12 @@ p = td->td_proc; - if (!(p->p_flag & P_SA)) + PROC_LOCK(p); + if (!(p->p_flag & P_SA)) { + PROC_UNLOCK(p); return (EINVAL); + } + PROC_UNLOCK(p); switch (uap->cmd) { case KSE_INTR_SENDSIG: @@ -274,16 +256,18 @@ /* this sub-function is only for bound thread */ if (td->td_pflags & TDP_SA) return (EINVAL); + thread_lock(td); ku = td->td_upcall; + thread_unlock(td); tmbx = (void *)fuword((void *)&ku->ku_mailbox->km_curthread); if (tmbx == NULL || tmbx == (void *)-1) return (EINVAL); flags = 0; + PROC_LOCK(p); while ((p->p_flag & P_TRACED) && !(p->p_flag & P_SINGLE_EXIT)) { flags = fuword32(&tmbx->tm_dflags); if (!(flags & TMDF_SUSPEND)) break; - PROC_LOCK(p); PROC_SLOCK(p); thread_stopped(p); PROC_UNLOCK(p); @@ -292,7 +276,9 @@ PROC_SUNLOCK(p); mi_switch(SW_VOL, NULL); thread_unlock(td); + PROC_LOCK(p); } + PROC_UNLOCK(p); return (0); case KSE_INTR_EXECVE: @@ -338,9 +324,12 @@ /* * Ensure that this is only called from the UTS */ - if ((ku = td->td_upcall) == NULL || TD_CAN_UNBIND(td)) + thread_lock(td); + if ((ku = td->td_upcall) == NULL || TD_CAN_UNBIND(td)) { + thread_unlock(td); return (EINVAL); - + } + thread_unlock(td); /* * Calculate the existing non-exiting upcalls in this process. @@ -384,7 +373,9 @@ psignal(p, SIGSEGV); sigqueue_flush(&td->td_sigqueue); PROC_SLOCK(p); + thread_lock(td); upcall_remove(td); + thread_unlock(td); if (p->p_numthreads != 1) { thread_stopped(p); thread_exit(); @@ -435,10 +426,13 @@ int error; p = td->td_proc; + thread_lock(td); if ((ku = td->td_upcall) == NULL || TD_CAN_UNBIND(td)) { + thread_unlock(td); printf("kse_release: called outside of threading. exiting"); exit1(td, 0); } + thread_unlock(td); if (uap->timeout != NULL) { if ((error = copyin(uap->timeout, &timeout, sizeof(timeout)))) return (error); @@ -508,9 +502,11 @@ td2 = NULL; ku = NULL; /* KSE-enabled processes only, please. */ - if (!(p->p_flag & P_SA)) + PROC_LOCK(p); + if (!(p->p_flag & P_SA)) { + PROC_UNLOCK(p); return (EINVAL); - PROC_LOCK(p); + } PROC_SLOCK(p); if (uap->mbx) { FOREACH_UPCALL_IN_PROC(p, ku) { @@ -531,10 +527,14 @@ PROC_UNLOCK(p); return (ESRCH); } + mtx_lock_spin(&kse_lock); if ((td2 = ku->ku_owner) == NULL) { + mtx_unlock_spin(&kse_lock); PROC_SUNLOCK(p); + PROC_UNLOCK(p); panic("%s: no owner", __func__); } else if (td2->td_kflags & (TDK_KSEREL | TDK_KSERELSIG)) { + mtx_unlock_spin(&kse_lock); if (!(td2->td_kflags & TDK_WAKEUP)) { td2->td_kflags |= TDK_WAKEUP; if (td2->td_kflags & TDK_KSEREL) @@ -544,6 +544,7 @@ } } else { ku->ku_flags |= KUF_DOUPCALL; + mtx_unlock_spin(&kse_lock); } PROC_SUNLOCK(p); PROC_UNLOCK(p); @@ -582,6 +583,7 @@ * suddenly start calling this one * XXX maybe... */ + PROC_LOCK(p); if ((p->p_flag & (P_SA|P_HADTHREADS)) == P_HADTHREADS) { PROC_UNLOCK(p); return (EINVAL); @@ -590,6 +592,7 @@ first = 1; p->p_flag |= P_SA|P_HADTHREADS; } + PROC_UNLOCK(p); if ((err = copyin(uap->mbx, &mbx, sizeof(mbx)))) return (err); @@ -662,7 +665,8 @@ * Make the new upcall available to the process. * It may or may not use it, but it's available. */ - upcall_link(newku, p); + TAILQ_INSERT_TAIL(&p->p_upcalls, newku, ku_link); + newku->ku_proc = p; PROC_UNLOCK(p); if (mbx.km_quantum) /* XXX should this be in the thread? */ @@ -786,44 +790,6 @@ } /* - * Stash an embarasingly extra upcall into the zombie upcall queue. - */ - -void -upcall_stash(struct kse_upcall *ku) -{ - mtx_lock_spin(&kse_lock); - TAILQ_INSERT_HEAD(&zombie_upcalls, ku, ku_link); - mtx_unlock_spin(&kse_lock); -} - -/* - * Reap zombie kse resource. - */ -void -kse_GC(void) -{ - struct kse_upcall *ku_first, *ku_next; - - /* - * Don't even bother to lock if none at this instant, - * we really don't care about the next instant.. - */ - if (!TAILQ_EMPTY(&zombie_upcalls)) { - mtx_lock_spin(&kse_lock); - ku_first = TAILQ_FIRST(&zombie_upcalls); - if (ku_first) - TAILQ_INIT(&zombie_upcalls); - mtx_unlock_spin(&kse_lock); - while (ku_first) { - ku_next = TAILQ_NEXT(ku_first, ku_link); - upcall_free(ku_first); - ku_first = ku_next; - } - } -} - -/* * Store the thread context in the UTS's mailbox. * then add the mailbox at the head of a list we are building in user space. * The list is anchored in the proc structure. @@ -885,6 +851,7 @@ } PROC_LOCK(p); if (mbx == (uintptr_t)p->p_completed) { + thread_lock(td); p->p_completed = td->td_mailbox; /* * The thread context may be taken away by @@ -893,6 +860,7 @@ * use it again in any other places. */ td->td_mailbox = NULL; + thread_unlock(td); PROC_UNLOCK(p); break; } @@ -968,8 +936,12 @@ caddr_t addr; u_int uticks; - if (td->td_mailbox == NULL) + thread_lock(td); + if (td->td_mailbox == NULL) { + thread_unlock(td); return (-1); + } + thread_unlock(td); if ((uticks = td->td_uuticks) != 0) { td->td_uuticks = 0; @@ -1173,7 +1145,9 @@ * note where our mailbox is. */ + thread_lock(td); ku = td->td_upcall; + thread_unlock(td); KASSERT(ku != NULL, ("no upcall owned")); KASSERT(ku->ku_owner == td, ("wrong owner")); @@ -1200,16 +1174,18 @@ } else { td->td_mailbox = tmbx; td->td_pflags |= TDP_CAN_UNBIND; + PROC_LOCK(p); if (__predict_false(p->p_flag & P_TRACED)) { flags = fuword32(&tmbx->tm_dflags); if (flags & TMDF_SUSPEND) { - PROC_SLOCK(td->td_proc); + thread_lock(td); /* fuword can block, check again */ if (td->td_upcall) ku->ku_flags |= KUF_DOUPCALL; - PROC_SUNLOCK(td->td_proc); + thread_unlock(td); } } + PROC_UNLOCK(p); } } } @@ -1249,6 +1225,7 @@ } p = td->td_proc; + thread_lock(td); ku = td->td_upcall; /* @@ -1258,6 +1235,7 @@ * then it can return direct to userland. */ if (TD_CAN_UNBIND(td)) { + thread_unlock(td); td->td_pflags &= ~TDP_CAN_UNBIND; if ((td->td_flags & TDF_NEEDSIGCHK) == 0 && (p->p_completed == NULL) && @@ -1281,6 +1259,7 @@ */ td->td_pflags |= TDP_UPCALLING; } else if (td->td_mailbox && (ku == NULL)) { + thread_unlock(td); thread_export_context(td, 1); PROC_LOCK(p); if (p->p_upsleeps) @@ -1292,15 +1271,16 @@ thread_stopped(p); thread_exit(); /* NOTREACHED */ - } + } else + thread_unlock(td); KASSERT(ku != NULL, ("upcall is NULL")); KASSERT(TD_CAN_UNBIND(td) == 0, ("can unbind")); + PROC_LOCK(p); + PROC_SLOCK(p); if (p->p_numthreads > max_threads_per_proc) { max_threads_hits++; - PROC_LOCK(p); - PROC_SLOCK(p); while (p->p_numthreads > max_threads_per_proc) { if (p->p_numupcalls >= max_threads_per_proc) break; @@ -1309,13 +1289,12 @@ "maxthreads", hz/10) != EWOULDBLOCK) { PROC_SLOCK(p); break; - } else { + } else PROC_SLOCK(p); - } } - PROC_SUNLOCK(p); - PROC_UNLOCK(p); } + PROC_SUNLOCK(p); + PROC_UNLOCK(p); if (td->td_pflags & TDP_UPCALLING) { uts_crit = 0; ==== //depot/projects/soc2007/lulf/gvinum_fixup/sys/kern/kern_rwlock.c#6 (text+ko) ==== @@ -32,7 +32,7 @@ */ #include -__FBSDID("$FreeBSD: src/sys/kern/kern_rwlock.c,v 1.27 2007/06/26 21:31:56 attilio Exp $"); +__FBSDID("$FreeBSD: src/sys/kern/kern_rwlock.c,v 1.28 2007/07/20 08:43:41 attilio Exp $"); #include "opt_ddb.h" #include "opt_no_adaptive_rwlocks.h" @@ -45,7 +45,7 @@ #include #include #include -#include + #include CTASSERT((RW_RECURSE & LO_CLASSFLAGS) == RW_RECURSE); @@ -221,8 +221,10 @@ #ifdef ADAPTIVE_RWLOCKS volatile struct thread *owner; #endif +#ifdef LOCK_PROFILING_SHARED uint64_t waittime = 0; int contested = 0; +#endif uintptr_t x; KASSERT(rw->rw_lock != RW_DESTROYED, @@ -265,22 +267,22 @@ MPASS((x & RW_LOCK_READ_WAITERS) == 0); if (atomic_cmpset_acq_ptr(&rw->rw_lock, x, x + RW_ONE_READER)) { +#ifdef LOCK_PROFILING_SHARED + if (RW_READERS(x) == 0) + lock_profile_obtain_lock_success( + &rw->lock_object, contested, + waittime, file, line); +#endif if (LOCK_LOG_TEST(&rw->lock_object, 0)) CTR4(KTR_LOCK, "%s: %p succeed %p -> %p", __func__, rw, (void *)x, (void *)(x + RW_ONE_READER)); - if (RW_READERS(x) == 0) - lock_profile_obtain_lock_success( - &rw->lock_object, contested, waittime, - file, line); break; } cpu_spinwait(); continue; } - lock_profile_obtain_lock_failed(&rw->lock_object, &contested, - &waittime); /* * Okay, now it's the hard case. Some other thread already @@ -331,6 +333,10 @@ if (LOCK_LOG_TEST(&rw->lock_object, 0)) CTR3(KTR_LOCK, "%s: spinning on %p held by %p", __func__, rw, owner); +#ifdef LOCK_PROFILING_SHARED + lock_profile_obtain_lock_failed(&rw->lock_object, + &contested, &waittime); +#endif while ((struct thread*)RW_OWNER(rw->rw_lock)== owner && TD_IS_RUNNING(owner)) cpu_spinwait(); @@ -345,6 +351,10 @@ if (LOCK_LOG_TEST(&rw->lock_object, 0)) CTR2(KTR_LOCK, "%s: %p blocking on turnstile", __func__, rw); +#ifdef LOCK_PROFILING_SHARED + lock_profile_obtain_lock_failed(&rw->lock_object, &contested, + &waittime); +#endif turnstile_wait(ts, rw_owner(rw), TS_SHARED_QUEUE); if (LOCK_LOG_TEST(&rw->lock_object, 0)) CTR2(KTR_LOCK, "%s: %p resuming from turnstile", @@ -403,6 +413,9 @@ */ KASSERT(!(x & RW_LOCK_READ_WAITERS), ("%s: waiting readers", __func__)); +#ifdef LOCK_PROFILING_SHARED + lock_profile_release_lock(&rw->lock_object); +#endif /* * If there aren't any waiters for a write lock, then try @@ -479,7 +492,6 @@ turnstile_chain_unlock(&rw->lock_object); break; } - lock_profile_release_lock(&rw->lock_object); } /* @@ -494,7 +506,9 @@ #ifdef ADAPTIVE_RWLOCKS volatile struct thread *owner; #endif + uint64_t waittime = 0; uintptr_t v; + int contested = 0; if (rw_wlocked(rw)) { KASSERT(rw->lock_object.lo_flags & RW_RECURSE, @@ -578,6 +592,8 @@ if (LOCK_LOG_TEST(&rw->lock_object, 0)) CTR3(KTR_LOCK, "%s: spinning on %p held by %p", __func__, rw, owner); + lock_profile_obtain_lock_failed(&rw->lock_object, + &contested, &waittime); while ((struct thread*)RW_OWNER(rw->rw_lock)== owner && TD_IS_RUNNING(owner)) cpu_spinwait(); @@ -592,11 +608,15 @@ if (LOCK_LOG_TEST(&rw->lock_object, 0)) CTR2(KTR_LOCK, "%s: %p blocking on turnstile", __func__, rw); + lock_profile_obtain_lock_failed(&rw->lock_object, &contested, + &waittime); turnstile_wait(ts, rw_owner(rw), TS_EXCLUSIVE_QUEUE); if (LOCK_LOG_TEST(&rw->lock_object, 0)) CTR2(KTR_LOCK, "%s: %p resuming from turnstile", __func__, rw); } + lock_profile_obtain_lock_success(&rw->lock_object, contested, waittime, + file, line); } /* ==== //depot/projects/soc2007/lulf/gvinum_fixup/sys/kern/kern_sig.c#5 (text+ko) ==== @@ -35,7 +35,7 @@ */ #include -__FBSDID("$FreeBSD: src/sys/kern/kern_sig.c,v 1.348 2007/06/11 23:27:03 jeff Exp $"); +__FBSDID("$FreeBSD: src/sys/kern/kern_sig.c,v 1.349 2007/07/19 08:49:16 jeff Exp $"); #include "opt_compat.h" #include "opt_ktrace.h" @@ -2365,12 +2365,8 @@ * Bring the priority of a thread up if we want it to get * killed in this lifetime. */ - if (action == SIG_DFL && (prop & SA_KILL)) { - if (p->p_nice > 0) - sched_nice(td->td_proc, 0); - if (td->td_priority > PUSER) - sched_prio(td, PUSER); - } + if (action == SIG_DFL && (prop & SA_KILL) && td->td_priority > PUSER) + sched_prio(td, PUSER); if (TD_ON_SLEEPQ(td)) { /* ==== //depot/projects/soc2007/lulf/gvinum_fixup/sys/kern/kern_switch.c#4 (text+ko) ==== @@ -26,7 +26,7 @@ #include -__FBSDID("$FreeBSD: src/sys/kern/kern_switch.c,v 1.131 2007/06/12 19:50:31 jeff Exp $"); +__FBSDID("$FreeBSD: src/sys/kern/kern_switch.c,v 1.132 2007/07/19 08:58:40 jeff Exp $"); #include "opt_sched.h" @@ -267,8 +267,7 @@ /* * Thread is runnable but not yet put on system run queue. */ - MPASS(ctd->td_lock == &sched_lock); - MPASS(td->td_lock == &sched_lock); + MPASS(ctd->td_lock == td->td_lock); MPASS(TD_ON_RUNQ(td)); TD_SET_RUNNING(td); CTR3(KTR_PROC, "preempting to thread %p (pid %d, %s)\n", td, ==== //depot/projects/soc2007/lulf/gvinum_fixup/sys/kern/kern_thread.c#5 (text+ko) ==== @@ -27,7 +27,7 @@ */ #include -__FBSDID("$FreeBSD: src/sys/kern/kern_thread.c,v 1.250 2007/06/12 19:49:39 jeff Exp $"); +__FBSDID("$FreeBSD: src/sys/kern/kern_thread.c,v 1.251 2007/07/23 14:52:21 attilio Exp $"); #include #include @@ -550,7 +550,9 @@ KASSERT((p->p_numthreads == 1), ("Unthreading with >1 threads")); #ifdef KSE + thread_lock(td); upcall_remove(td); + thread_unlock(td); p->p_flag &= ~(P_SA|P_HADTHREADS); td->td_mailbox = NULL; td->td_pflags &= ~(TDP_SA | TDP_CAN_UNBIND); ==== //depot/projects/soc2007/lulf/gvinum_fixup/sys/kern/sched_ule.c#7 (text+ko) ==== @@ -36,7 +36,7 @@ */ #include -__FBSDID("$FreeBSD: src/sys/kern/sched_ule.c,v 1.200 2007/07/17 22:53:23 jeff Exp $"); +__FBSDID("$FreeBSD: src/sys/kern/sched_ule.c,v 1.202 2007/07/19 20:03:15 jeff Exp $"); #include "opt_hwpmc_hooks.h" #include "opt_sched.h" @@ -177,8 +177,6 @@ static int sched_slice; static int preempt_thresh = PRI_MIN_KERN; -#define SCHED_BAL_SECS 2 /* How often we run the rebalance algorithm. */ - /* * tdq - per processor runqs and statistics. All fields are protected by the * tdq_lock. The load and lowpri may be accessed without to avoid excess @@ -229,14 +227,14 @@ /* * Run-time tunables. */ -static int rebalance = 0; -static int pick_pri = 0; -static int pick_zero = 0; +static int rebalance = 1; +static int balance_secs = 1; +static int pick_pri = 1; static int affinity; static int tryself = 1; -static int tryselfidle = 1; static int steal_htt = 0; -static int steal_idle = 0; +static int steal_idle = 1; +static int steal_thresh = 2; static int topology = 0; /* @@ -514,7 +512,7 @@ int cnt; int i; - callout_reset(&balco, max(hz / 2, random() % (hz * SCHED_BAL_SECS)), + callout_reset(&balco, max(hz / 2, random() % (hz * balance_secs)), sched_balance, NULL); if (smp_started == 0 || rebalance == 0) return; @@ -547,7 +545,7 @@ { int i; - callout_reset(&gbalco, max(hz / 2, random() % (hz * SCHED_BAL_SECS)), + callout_reset(&gbalco, max(hz / 2, random() % (hz * balance_secs)), sched_balance_groups, NULL); if (smp_started == 0 || rebalance == 0) return; @@ -683,6 +681,7 @@ ts->ts_cpu = cpu; td->td_lock = TDQ_LOCKPTR(to); tdq_add(to, td, SRQ_YIELDING); + tdq_notify(ts); } /* @@ -734,11 +733,11 @@ highload = load; highcpu = cpu; } - if (highload < 2) + if (highload < steal_thresh) break; steal = TDQ_CPU(highcpu); TDQ_LOCK(steal); - if (steal->tdq_transferable > 1 && + if (steal->tdq_transferable >= steal_thresh && (ts = tdq_steal(steal, 1)) != NULL) goto steal; TDQ_UNLOCK(steal); @@ -863,11 +862,9 @@ struct rqhead *rqh; struct rqbits *rqb; struct td_sched *ts; - int first; int word; int bit; - first = 0; rqb = &rq->rq_status; for (word = 0; word < RQB_LEN; word++) { if (rqb->rqb_bits[word] == 0) @@ -876,11 +873,9 @@ if ((rqb->rqb_bits[word] & (1ul << bit)) == 0) continue; rqh = &rq->rq_queues[bit + (word << RQB_L2BPW)]; - TAILQ_FOREACH(ts, rqh, ts_procq) { - if (first && THREAD_CAN_MIGRATE(ts->ts_thread)) + TAILQ_FOREACH(ts, rqh, ts_procq) + if (THREAD_CAN_MIGRATE(ts->ts_thread)) return (ts); - first = 1; - } } } return (NULL); @@ -1036,6 +1031,14 @@ cpu = self = PCPU_GET(cpuid); if (smp_started == 0) return (self); + /* >>> TRUNCATED FOR MAIL (1000 lines) <<<