Date: Tue, 7 Jan 2003 17:56:21 -0800 (PST) From: John Baldwin <jhb@FreeBSD.org> To: Perforce Change Reviews <perforce@freebsd.org> Subject: PERFORCE change 23386 for review Message-ID: <200301080156.h081uLwi035981@repoman.freebsd.org>
next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=23386 Change 23386 by jhb@jhb_laptop on 2003/01/07 17:55:36 IFC @23384. Affected files ... .. //depot/projects/smpng/sys/dev/em/LICENSE#1 branch .. //depot/projects/smpng/sys/i386/i386/identcpu.c#13 integrate .. //depot/projects/smpng/sys/i386/i386/initcpu.c#13 integrate .. //depot/projects/smpng/sys/i386/i386/locore.s#12 integrate .. //depot/projects/smpng/sys/i386/i386/mp_machdep.c#36 integrate .. //depot/projects/smpng/sys/i386/include/md_var.h#15 integrate .. //depot/projects/smpng/sys/i386/include/specialreg.h#3 integrate .. //depot/projects/smpng/sys/kern/kern_module.c#10 integrate .. //depot/projects/smpng/sys/kern/subr_prf.c#24 integrate .. //depot/projects/smpng/sys/kern/subr_prof.c#17 integrate .. //depot/projects/smpng/sys/kern/vfs_bio.c#34 integrate .. //depot/projects/smpng/sys/kern/vfs_vnops.c#34 integrate .. //depot/projects/smpng/sys/posix4/p1003_1b.c#7 integrate .. //depot/projects/smpng/sys/ufs/ffs/ffs_softdep.c#22 integrate .. //depot/projects/smpng/sys/ufs/ufs/ufsmount.h#8 integrate Differences ... ==== //depot/projects/smpng/sys/i386/i386/identcpu.c#13 (text+ko) ==== @@ -38,7 +38,7 @@ * SUCH DAMAGE. * * from: Id: machdep.c,v 1.193 1996/06/18 01:22:04 bde Exp - * $FreeBSD: src/sys/i386/i386/identcpu.c,v 1.109 2003/01/03 18:54:59 jhb Exp $ + * $FreeBSD: src/sys/i386/i386/identcpu.c,v 1.110 2003/01/08 01:23:16 jhb Exp $ */ #include "opt_cpu.h" @@ -604,6 +604,15 @@ "\037IA64" /* CPU can execute IA64 instructions */ "\040PBE" /* Pending Break Enable */ ); + + /* + * If this CPU supports hyperthreading then mention + * the number of logical CPU's it contains. + */ + if (cpu_feature & CPUID_HTT && + (cpuid_cpuinfo & CPUID_HTT_CORES) > 0x100) + printf("\n Hyperthreading: %d logical CPUs", + (cpuid_cpuinfo & CPUID_HTT_CORES) >> 16); } if (strcmp(cpu_vendor, "AuthenticAMD") == 0 && nreg >= 0x80000001) ==== //depot/projects/smpng/sys/i386/i386/initcpu.c#13 (text+ko) ==== @@ -26,7 +26,7 @@ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * - * $FreeBSD: src/sys/i386/i386/initcpu.c,v 1.38 2002/10/16 08:57:14 phk Exp $ + * $FreeBSD: src/sys/i386/i386/initcpu.c,v 1.39 2003/01/08 01:20:05 jhb Exp $ */ #include "opt_cpu.h" @@ -82,6 +82,7 @@ u_int cpu_id = 0; /* Stepping ID */ u_int cpu_feature = 0; /* Feature flags */ u_int cpu_high = 0; /* Highest arg to CPUID */ +u_int cpuid_cpuinfo = 0; /* HyperThreading Info / Brand Index / CLFUSH */ #ifdef CPU_ENABLE_SSE u_int cpu_fxsr = 0; /* SSE enabled */ #endif ==== //depot/projects/smpng/sys/i386/i386/locore.s#12 (text+ko) ==== @@ -34,7 +34,7 @@ * SUCH DAMAGE. * * from: @(#)locore.s 7.3 (Berkeley) 5/13/91 - * $FreeBSD: src/sys/i386/i386/locore.s,v 1.161 2002/12/02 19:58:55 deischen Exp $ + * $FreeBSD: src/sys/i386/i386/locore.s,v 1.162 2003/01/08 01:20:05 jhb Exp $ * * originally from: locore.s, by William F. Jolitz * @@ -720,6 +720,7 @@ movl $1,%eax cpuid # cpuid 1 movl %eax,R(cpu_id) # store cpu_id + movl %ebx,R(cpuid_cpuinfo) # store cpuid_cpuinfo movl %edx,R(cpu_feature) # store cpu_feature rorl $8,%eax # extract family type andl $15,%eax ==== //depot/projects/smpng/sys/i386/i386/mp_machdep.c#36 (text+ko) ==== @@ -22,7 +22,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $FreeBSD: src/sys/i386/i386/mp_machdep.c,v 1.192 2002/10/16 08:57:14 phk Exp $ + * $FreeBSD: src/sys/i386/i386/mp_machdep.c,v 1.193 2003/01/08 01:33:18 jhb Exp $ */ #include "opt_cpu.h" @@ -237,6 +237,9 @@ #define MP_ANNOUNCE_POST 0x19 +static int need_hyperthreading_fixup; +static u_int logical_cpus; + /* used to hold the AP's until we are ready to release them */ static struct mtx ap_boot_mtx; @@ -312,6 +315,7 @@ static int search_for_sig(u_int32_t target, int count); static void mp_enable(u_int boot_addr); +static void mptable_hyperthread_fixup(u_int id_mask); static void mptable_pass1(void); static int mptable_pass2(void); static void default_mp_table(int type); @@ -782,6 +786,7 @@ void* position; int count; int type; + u_int id_mask; POSTCODE(MPTABLE_PASS1_POST); @@ -795,6 +800,7 @@ mp_nbusses = 0; mp_napics = 0; nintrs = 0; + id_mask = 0; /* check for use of 'default' configuration */ if (MPFPS_MPFB1 != 0) { @@ -829,6 +835,8 @@ & PROCENTRY_FLAG_EN) { ++mp_naps; mp_maxid++; + id_mask |= 1 << + ((proc_entry_ptr)position)->apic_id; } break; case 1: /* bus_entry */ @@ -863,6 +871,9 @@ mp_naps = MAXCPU; } + /* See if we need to fixup HT logical CPUs. */ + mptable_hyperthread_fixup(id_mask); + /* * Count the BSP. * This is also used as a counter while starting the APs. @@ -887,6 +898,7 @@ static int mptable_pass2(void) { + struct PROCENTRY proc; int x; mpcth_t cth; int totalSize; @@ -899,6 +911,11 @@ POSTCODE(MPTABLE_PASS2_POST); + /* Initialize fake proc entry for use with HT fixup. */ + bzero(&proc, sizeof(proc)); + proc.type = 0; + proc.cpu_flags = PROCENTRY_FLAG_EN; + pgeflag = 0; /* XXX - Not used under SMP yet. */ MALLOC(io_apic_versions, u_int32_t *, sizeof(u_int32_t) * mp_napics, @@ -976,6 +993,20 @@ case 0: if (processor_entry(position, cpu)) ++cpu; + + if (need_hyperthreading_fixup) { + /* + * Create fake mptable processor entries + * and feed them to processor_entry() to + * enumerate the logical CPUs. + */ + proc.apic_id = ((proc_entry_ptr)position)->apic_id; + for (i = 1; i < logical_cpus; i++) { + proc.apic_id++; + (void)processor_entry(&proc, cpu); + cpu++; + } + } break; case 1: if (bus_entry(position, bus)) @@ -1008,6 +1039,55 @@ return 0; } +/* + * Check if we should perform a hyperthreading "fix-up" to + * enumerate any logical CPU's that aren't already listed + * in the table. + * + * XXX: We assume that all of the physical CPUs in the + * system have the same number of logical CPUs. + * + * XXX: We assume that APIC ID's are allocated such that + * the APIC ID's for a physical processor are aligned + * with the number of logical CPU's in the processor. + */ +static void +mptable_hyperthread_fixup(u_int id_mask) +{ + u_int i, id; + + /* Nothing to do if there is no HTT support. */ + if ((cpu_feature & CPUID_HTT) == 0) + return; + logical_cpus = (cpuid_cpuinfo & CPUID_HTT_CORES) >> 16; + if (logical_cpus <= 1) + return; + + /* + * For each APIC ID of a CPU that is set in the mask, + * scan the other candidate APIC ID's for this + * physical processor. If any of those ID's are + * already in the table, then kill the fixup. + */ + for (id = 0; id <= MAXCPU; id++) { + if ((id_mask & 1 << id) == 0) + continue; + /* First, make sure we are on a logical_cpus boundary. */ + if (id % logical_cpus != 0) + return; + for (i = id + 1; i < id + logical_cpus; i++) + if ((id_mask & 1 << i) != 0) + return; + } + + /* + * Ok, the ID's checked out, so enable the fixup. We have to fixup + * mp_naps and mp_maxid right now. + */ + need_hyperthreading_fixup = 1; + mp_maxid *= logical_cpus; + mp_naps *= logical_cpus; +} void assign_apic_irq(int apic, int intpin, int irq) ==== //depot/projects/smpng/sys/i386/include/md_var.h#15 (text+ko) ==== @@ -26,7 +26,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $FreeBSD: src/sys/i386/include/md_var.h,v 1.54 2002/10/25 19:10:56 peter Exp $ + * $FreeBSD: src/sys/i386/include/md_var.h,v 1.55 2003/01/08 01:20:05 jhb Exp $ */ #ifndef _MACHINE_MD_VAR_H_ @@ -44,6 +44,7 @@ extern int (*copyout_vector)(const void *kaddr, void *udaddr, size_t len); extern u_int cpu_feature; extern u_int cpu_high; +extern u_int cpuid_cpuinfo; extern u_int cpu_id; extern u_int cpu_fxsr; extern char cpu_vendor[]; ==== //depot/projects/smpng/sys/i386/include/specialreg.h#3 (text+ko) ==== @@ -31,7 +31,7 @@ * SUCH DAMAGE. * * from: @(#)specialreg.h 7.1 (Berkeley) 5/9/91 - * $FreeBSD: src/sys/i386/include/specialreg.h,v 1.21 2002/06/22 23:00:33 mp Exp $ + * $FreeBSD: src/sys/i386/include/specialreg.h,v 1.22 2003/01/08 01:15:26 jhb Exp $ */ #ifndef _MACHINE_SPECIALREG_H_ @@ -106,12 +106,20 @@ #define CPUID_XMM 0x02000000 #define CPUID_SSE2 0x04000000 #define CPUID_SS 0x08000000 -#define CPUID_HHT 0x10000000 +#define CPUID_HTT 0x10000000 #define CPUID_TM 0x20000000 #define CPUID_B30 0x40000000 #define CPUID_PBE 0x80000000 /* + *CPUID instruction 1 ebx info + */ +#define CPUID_BRAND_INDEX 0x000000ff +#define CPUID_CLFUSH_SIZE 0x0000ff00 +#define CPUID_HTT_CORES 0x00ff0000 +#define CPUID_LOCAL_APIC_ID 0xff000000 + +/* * Model-specific registers for the i386 family */ #define MSR_P5_MC_ADDR 0x000 ==== //depot/projects/smpng/sys/kern/kern_module.c#10 (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/kern/kern_module.c,v 1.38 2002/12/14 01:56:25 alfred Exp $ + * $FreeBSD: src/sys/kern/kern_module.c,v 1.39 2003/01/07 22:24:13 peter Exp $ */ #include <sys/param.h> @@ -74,7 +74,7 @@ sx_init(&modules_sx, "module subsystem sx lock"); TAILQ_INIT(&modules); - EVENTHANDLER_REGISTER(shutdown_post_sync, module_shutdown, NULL, + EVENTHANDLER_REGISTER(shutdown_final, module_shutdown, NULL, SHUTDOWN_PRI_DEFAULT); } ==== //depot/projects/smpng/sys/kern/subr_prf.c#24 (text+ko) ==== @@ -36,7 +36,7 @@ * SUCH DAMAGE. * * @(#)subr_prf.c 8.3 (Berkeley) 1/21/94 - * $FreeBSD: src/sys/kern/subr_prf.c,v 1.93 2003/01/04 20:15:32 phk Exp $ + * $FreeBSD: src/sys/kern/subr_prf.c,v 1.94 2003/01/07 18:17:18 jhb Exp $ */ #include "opt_ddb.h" @@ -560,7 +560,7 @@ width = n; goto reswitch; case 'b': - num = va_arg(ap, int); + num = (u_int)va_arg(ap, int); p = va_arg(ap, char *); for (q = ksprintn(nbuf, num, *p++, NULL); *q;) PCHAR(*q--); ==== //depot/projects/smpng/sys/kern/subr_prof.c#17 (text+ko) ==== @@ -31,7 +31,7 @@ * SUCH DAMAGE. * * @(#)subr_prof.c 8.3 (Berkeley) 9/23/93 - * $FreeBSD: src/sys/kern/subr_prof.c,v 1.56 2003/01/06 07:40:49 phk Exp $ + * $FreeBSD: src/sys/kern/subr_prof.c,v 1.57 2003/01/07 19:09:10 phk Exp $ */ #include <sys/param.h> @@ -157,7 +157,6 @@ uintfptr_t tmp_addr; #endif - tcov_init(); /* * Round lowpc and highpc to multiples of the density we're using * so the rest of the scaling (here and in gprof) stays in ints. @@ -563,7 +562,7 @@ } } -SYSINIT(kmem, SI_SUB_KPROF, SI_ORDER_SECOND, tcov_init, NULL) +SYSINIT(tcov_init, SI_SUB_KPROF, SI_ORDER_SECOND, tcov_init, NULL) /* * GCC contains magic to recognize calls to for instance execve() and ==== //depot/projects/smpng/sys/kern/vfs_bio.c#34 (text+ko) ==== @@ -11,7 +11,7 @@ * 2. Absolutely no warranty of function or purpose is made by the author * John S. Dyson. * - * $FreeBSD: src/sys/kern/vfs_bio.c,v 1.351 2003/01/05 22:01:08 phk Exp $ + * $FreeBSD: src/sys/kern/vfs_bio.c,v 1.352 2003/01/07 19:55:08 alc Exp $ */ /* @@ -167,12 +167,6 @@ vm_page_t bogus_page; /* - * Offset for bogus_page. - * XXX bogus_offset should be local to bufinit - */ -static vm_offset_t bogus_offset; - -/* * Synchronization (sleep/wakeup) variable for active buffer space requests. * Set when wait starts, cleared prior to wakeup(). * Used in runningbufwakeup() and waitrunningbufspace(). @@ -486,6 +480,7 @@ bufinit(void) { struct buf *bp; + vm_offset_t bogus_offset; int i; GIANT_REQUIRED; ==== //depot/projects/smpng/sys/kern/vfs_vnops.c#34 (text+ko) ==== @@ -36,7 +36,7 @@ * SUCH DAMAGE. * * @(#)vfs_vnops.c 8.2 (Berkeley) 1/21/94 - * $FreeBSD: src/sys/kern/vfs_vnops.c,v 1.178 2002/12/28 20:28:10 dillon Exp $ + * $FreeBSD: src/sys/kern/vfs_vnops.c,v 1.179 2003/01/07 20:59:55 green Exp $ */ #include "opt_mac.h" @@ -271,6 +271,7 @@ NDFREE(ndp, NDF_ONLY_PNBUF); vput(vp); *flagp = fmode; + ndp->ni_vp = NULL; return (error); } ==== //depot/projects/smpng/sys/posix4/p1003_1b.c#7 (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/posix4/p1003_1b.c,v 1.20 2002/11/15 22:55:06 alfred Exp $ + * $FreeBSD: src/sys/posix4/p1003_1b.c,v 1.21 2003/01/07 20:10:04 alfred Exp $ */ /* p1003_1b: Real Time common code. @@ -306,6 +306,7 @@ { int e; struct thread *targettd; + struct timespec timespec; struct proc *targetp; mtx_lock(&Giant); @@ -326,7 +327,10 @@ PROC_UNLOCK(targetp); if (e == 0) { e = ksched_rr_get_interval(&td->td_retval[0], ksched, targettd, - uap->interval); + ×pec); + if (e == 0) + e = copyout(×pec, uap->interval, + sizeof(timespec)); } done2: mtx_unlock(&Giant); ==== //depot/projects/smpng/sys/ufs/ffs/ffs_softdep.c#22 (text+ko) ==== @@ -39,7 +39,7 @@ */ #include <sys/cdefs.h> -__FBSDID("$FreeBSD: src/sys/ufs/ffs/ffs_softdep.c,v 1.131 2003/01/01 18:48:59 schweikh Exp $"); +__FBSDID("$FreeBSD: src/sys/ufs/ffs/ffs_softdep.c,v 1.132 2003/01/07 18:23:50 mckusick Exp $"); /* * For now we want the safety net that the DIAGNOSTIC and DEBUG flags provide. @@ -499,6 +499,7 @@ static int softdep_worklist_busy; /* 1 => trying to do unmount */ static int softdep_worklist_req; /* serialized waiters */ static int max_softdeps; /* maximum number of structs before slowdown */ +static int maxindirdeps = 50; /* max number of indirdeps before slowdown */ static int tickdelay = 2; /* number of ticks to pause during slowdown */ static int proc_waiting; /* tracks whether we have a timeout posted */ static int *stat_countp; /* statistic to count in proc_waiting timeout */ @@ -527,6 +528,7 @@ #include <sys/sysctl.h> SYSCTL_INT(_debug, OID_AUTO, max_softdeps, CTLFLAG_RW, &max_softdeps, 0, ""); SYSCTL_INT(_debug, OID_AUTO, tickdelay, CTLFLAG_RW, &tickdelay, 0, ""); +SYSCTL_INT(_debug, OID_AUTO, maxindirdeps, CTLFLAG_RW, &maxindirdeps, 0, ""); SYSCTL_INT(_debug, OID_AUTO, worklist_push, CTLFLAG_RW, &stat_worklist_push, 0,""); SYSCTL_INT(_debug, OID_AUTO, blk_limit_push, CTLFLAG_RW, &stat_blk_limit_push, 0,""); SYSCTL_INT(_debug, OID_AUTO, ino_limit_push, CTLFLAG_RW, &stat_ino_limit_push, 0,""); @@ -1862,8 +1864,7 @@ handle_workitem_freefrag(freefrag); } if (newindirdep) { - if (indirdep->ir_savebp != NULL) - brelse(newindirdep->ir_savebp); + brelse(newindirdep->ir_savebp); WORKITEM_FREE((caddr_t)newindirdep, D_INDIRDEP); } if (indirdep) @@ -2125,6 +2126,7 @@ panic("deallocate_dependencies: already gone"); } indirdep->ir_state |= GOINGAWAY; + VFSTOUFS(bp->b_vp->v_mount)->um_numindirdeps += 1; while ((aip = LIST_FIRST(&indirdep->ir_deplisthd)) != 0) free_allocindir(aip, inodedep); if (bp->b_lblkno >= 0 || @@ -2564,6 +2566,7 @@ FREE_LOCK(&lk); panic("indir_trunc: dangling dep"); } + VFSTOUFS(freeblks->fb_mnt)->um_numindirdeps -= 1; FREE_LOCK(&lk); } else { FREE_LOCK(&lk); @@ -3454,7 +3457,8 @@ * dependency can be freed. */ if (LIST_FIRST(&indirdep->ir_deplisthd) == NULL) { - indirdep->ir_savebp->b_flags |= B_INVAL | B_NOCACHE; + indirdep->ir_savebp->b_flags |= + B_INVAL | B_NOCACHE; brelse(indirdep->ir_savebp); /* inline expand WORKLIST_REMOVE(wk); */ wk->wk_state &= ~ONWORKLIST; @@ -5410,8 +5414,11 @@ max_softdeps_hard = max_softdeps * 11 / 10; if (num_dirrem < max_softdeps_hard / 2 && - num_inodedep < max_softdeps_hard) - return (0); + num_inodedep < max_softdeps_hard && + VFSTOUFS(vp->v_mount)->um_numindirdeps < maxindirdeps) + return (0); + if (VFSTOUFS(vp->v_mount)->um_numindirdeps >= maxindirdeps) + speedup_syncer(); stat_sync_limit_hit += 1; return (1); } ==== //depot/projects/smpng/sys/ufs/ufs/ufsmount.h#8 (text+ko) ==== @@ -31,7 +31,7 @@ * SUCH DAMAGE. * * @(#)ufsmount.h 8.6 (Berkeley) 3/30/95 - * $FreeBSD: src/sys/ufs/ufs/ufsmount.h,v 1.27 2002/12/27 10:06:37 phk Exp $ + * $FreeBSD: src/sys/ufs/ufs/ufsmount.h,v 1.28 2003/01/07 18:23:50 mckusick Exp $ */ #ifndef _UFS_UFS_UFSMOUNT_H_ @@ -73,6 +73,7 @@ u_long um_nindir; /* indirect ptrs per block */ u_long um_bptrtodb; /* indir ptr to disk block */ u_long um_seqinc; /* inc between seq blocks */ + long um_numindirdeps; /* indirdeps for this filesys */ time_t um_btime[MAXQUOTAS]; /* block quota time limit */ time_t um_itime[MAXQUOTAS]; /* inode quota time limit */ char um_qflags[MAXQUOTAS]; /* quota specific flags */ To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe p4-projects" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200301080156.h081uLwi035981>