Date: Tue, 27 Sep 2005 20:39:31 GMT From: John Baldwin <jhb@FreeBSD.org> To: Perforce Change Reviews <perforce@freebsd.org> Subject: PERFORCE change 84391 for review Message-ID: <200509272039.j8RKdVGS029102@repoman.freebsd.org>
next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=84391 Change 84391 by jhb@jhb_slimer on 2005/09/27 20:39:25 Robert's IPI interrupt counts. Affected files ... .. //depot/projects/smpng/sys/i386/i386/apic_vector.s#15 edit .. //depot/projects/smpng/sys/i386/i386/mp_machdep.c#86 edit .. //depot/projects/smpng/sys/i386/include/smptests.h#8 edit .. //depot/projects/smpng/sys/notes#58 edit Differences ... ==== //depot/projects/smpng/sys/i386/i386/apic_vector.s#15 (text+ko) ==== @@ -151,14 +151,20 @@ movl $KDSEL, %eax /* Kernel data selector */ movl %eax, %ds -#ifdef COUNT_XINVLTLB_HITS +#if defined(COUNT_XINVLTLB_HITS) || defined(COUNT_IPIS) pushl %fs movl $KPSEL, %eax /* Private space selector */ movl %eax, %fs movl PCPU(CPUID), %eax popl %fs +#ifdef COUNT_XINVLTLB_HITS incl xhits_gbl(,%eax,4) -#endif /* COUNT_XINVLTLB_HITS */ +#endif +#ifdef COUNT_IPIS + movl ipi_invltlb_counts(,%eax,4),%eax + incl (%eax) +#endif +#endif movl %cr3, %eax /* invalidate the TLB */ movl %eax, %cr3 @@ -184,14 +190,20 @@ movl $KDSEL, %eax /* Kernel data selector */ movl %eax, %ds -#ifdef COUNT_XINVLTLB_HITS +#if defined(COUNT_XINVLTLB_HITS) || defined(COUNT_IPIS) pushl %fs movl $KPSEL, %eax /* Private space selector */ movl %eax, %fs movl PCPU(CPUID), %eax popl %fs +#ifdef COUNT_XINVLTLB_HITS incl xhits_pg(,%eax,4) -#endif /* COUNT_XINVLTLB_HITS */ +#endif +#ifdef COUNT_IPIS + movl ipi_invlpg_counts(,%eax,4),%eax + incl (%eax) +#endif +#endif movl smp_tlb_addr1, %eax invlpg (%eax) /* invalidate single page */ @@ -218,14 +230,20 @@ movl $KDSEL, %eax /* Kernel data selector */ movl %eax, %ds -#ifdef COUNT_XINVLTLB_HITS +#if defined(COUNT_XINVLTLB_HITS) || defined(COUNT_IPIS) pushl %fs movl $KPSEL, %eax /* Private space selector */ movl %eax, %fs movl PCPU(CPUID), %eax popl %fs +#ifdef COUNT_XINVLTLB_HITS incl xhits_rng(,%eax,4) -#endif /* COUNT_XINVLTLB_HITS */ +#endif +#ifdef COUNT_IPIS + movl ipi_invlrng_counts(,%eax,4),%eax + incl (%eax) +#endif +#endif movl smp_tlb_addr1, %edx movl smp_tlb_addr2, %eax @@ -322,10 +340,11 @@ test %eax, %eax jnz 2f - movl CNAME(cpustop_restartfunc), %eax + xorl %eax, %eax + lock + xchgl CNAME(cpustop_restartfunc), %eax test %eax, %eax jz 2f - movl $0, CNAME(cpustop_restartfunc) /* One-shot */ call *%eax 2: @@ -354,6 +373,11 @@ movl $KPSEL, %eax movl %eax, %fs +#ifdef COUNT_IPIS + movl PCPU(CPUID), %eax + movl ipi_rendezvous_counts(,%eax,4), %eax + incl (%eax) +#endif call smp_rendezvous_action movl lapic, %eax @@ -374,6 +398,11 @@ movl $KPSEL, %eax movl %eax, %fs +#ifdef COUNT_IPIS + movl PCPU(CPUID), %eax + movl ipi_lazyfix_counts(,%eax,4), %eax + incl (%eax) +#endif call pmap_lazyfix_action movl lapic, %eax ==== //depot/projects/smpng/sys/i386/i386/mp_machdep.c#86 (text+ko) ==== @@ -181,6 +181,19 @@ volatile cpumask_t ipi_nmi_pending; #endif +#ifdef COUNT_IPIS +/* Interrupt counts. */ +#ifdef IPI_PREEMPTION +static u_long *ipi_preempt_counts[MAXCPU]; +#endif +static u_long *ipi_ast_counts[MAXCPU]; +u_long *ipi_invltlb_counts[MAXCPU]; +u_long *ipi_invlrng_counts[MAXCPU]; +u_long *ipi_invlpg_counts[MAXCPU]; +u_long *ipi_rendezvous_counts[MAXCPU]; +u_long *ipi_lazypmap_counts[MAXCPU]; +#endif + /* * Local data and functions. */ @@ -953,16 +966,16 @@ } #ifdef COUNT_XINVLTLB_HITS -u_int xhits_gbl[MAXCPU]; -u_int xhits_pg[MAXCPU]; -u_int xhits_rng[MAXCPU]; +u_long xhits_gbl[MAXCPU]; +u_long xhits_pg[MAXCPU]; +u_long xhits_rng[MAXCPU]; SYSCTL_NODE(_debug, OID_AUTO, xhits, CTLFLAG_RW, 0, ""); SYSCTL_OPAQUE(_debug_xhits, OID_AUTO, global, CTLFLAG_RW, &xhits_gbl, - sizeof(xhits_gbl), "IU", ""); + sizeof(xhits_gbl), "LU", ""); SYSCTL_OPAQUE(_debug_xhits, OID_AUTO, page, CTLFLAG_RW, &xhits_pg, - sizeof(xhits_pg), "IU", ""); + sizeof(xhits_pg), "LU", ""); SYSCTL_OPAQUE(_debug_xhits, OID_AUTO, range, CTLFLAG_RW, &xhits_rng, - sizeof(xhits_rng), "IU", ""); + sizeof(xhits_rng), "LU", ""); u_int ipi_global; u_int ipi_page; @@ -1123,7 +1136,6 @@ } } - void ipi_bitmap_handler(struct clockframe frame) { @@ -1134,6 +1146,9 @@ #ifdef IPI_PREEMPTION if (ipi_bitmap & IPI_PREEMPT) { +#ifdef COUNT_IPIS + *ipi_preempt_counts[cpu]++; +#endif mtx_lock_spin(&sched_lock); /* Don't preempt the idle thread */ if (curthread->td_priority < PRI_MIN_IDLE) { @@ -1147,7 +1162,12 @@ } #endif - /* Nothing to do for AST */ + if (ipi_bitmap & IPI_AST) { +#ifdef COUNT_IPIS + *ipi_ast_counts[cpu]++; +#endif + /* Nothing to do for AST */ + } } /* @@ -1449,3 +1469,37 @@ __asm __volatile("sti; hlt" : : : "memory"); return (retval); } + +#ifdef COUNT_IPIS +/* + * Setup interrupt counters for IPI handlers. + */ +static void +mp_ipi_intrcnt(void *dummy) +{ + char buf[64]; + int i; + + for (i = 0; i < mp_maxid; i++) { + if (CPU_ABSENT(i)) + continue; + snprintf(buf, sizeof(buf), "cpu%d: invltlb", i); + intrcnt_add(buf, &ipi_invltlb_counts[i]); + snprintf(buf, sizeof(buf), "cpu%d: invlrng", i); + intrcnt_add(buf, &ipi_invlrng_counts[i]); + snprintf(buf, sizeof(buf), "cpu%d: invlpg", i); + intrcnt_add(buf, &ipi_invlpg_counts[i]); +#ifdef IPI_PREEMPTION + snprintf(buf, sizeof(buf), "cpu%d: preempt", i); + intrcnt_add(buf, &ipi_preempt_counts[i]); +#endif + snprintf(buf, sizeof(buf), "cpu%d: ast", i); + intrcnt_add(buf, &ipi_ast_counts[i]); + snprintf(buf, sizeof(buf), "cpu%d: rendezvous", i); + intrcnt_add(buf, &ipi_rendezvous_counts[i]); + snprintf(buf, sizeof(buf), "cpu%d: lazypmap", i); + intrcnt_add(buf, &ipi_lazypmap_counts[i]); + } +} +SYSINIT(mp_ipi_intrcnt, SI_SUB_INTR, SI_ORDER_MIDDLE, mp_ipi_intrcnt, NULL) +#endif ==== //depot/projects/smpng/sys/i386/include/smptests.h#8 (text+ko) ==== @@ -40,12 +40,18 @@ #define CPUSTOP_ON_DDBBREAK /* - * Misc. counters. + * TLB counters. * #define COUNT_XINVLTLB_HITS */ /* + * Per-CPU IPI interrupt counters. + * + */ +#define COUNT_IPIS + +/* * Address of POST hardware port. * Defining this enables POSTCODE macros. * ==== //depot/projects/smpng/sys/notes#58 (text+ko) ==== @@ -76,6 +76,8 @@ - fork counts? - Add a cache-line padded mtx_aligned union and use it for the mutex pools. - Robert wants intrcnt's for IPIs + - off by default, but can be enabled with COUNT_IPIS in smptests.h + - untested - Fix free race in eventhandlers: > In the macro "_EVENTHANDLER_INVOKE" in the file > "/sys/sys/eventhandler.h", you unlock the list lock
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200509272039.j8RKdVGS029102>