From owner-svn-src-head@FreeBSD.ORG Sat May 2 12:20:44 2009 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id EFCCE1065670; Sat, 2 May 2009 12:20:43 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id DE3708FC22; Sat, 2 May 2009 12:20:43 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n42CKhHT084720; Sat, 2 May 2009 12:20:43 GMT (envelope-from mav@svn.freebsd.org) Received: (from mav@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n42CKh4A084716; Sat, 2 May 2009 12:20:43 GMT (envelope-from mav@svn.freebsd.org) Message-Id: <200905021220.n42CKh4A084716@svn.freebsd.org> From: Alexander Motin Date: Sat, 2 May 2009 12:20:43 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r191744 - in head/sys/amd64: amd64 include isa X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 02 May 2009 12:20:44 -0000 Author: mav Date: Sat May 2 12:20:43 2009 New Revision: 191744 URL: http://svn.freebsd.org/changeset/base/191744 Log: Add support for using i8254 and rtc timers as event sources for amd64 SMP system. Redistribute hard-/stat-/profclock events to other CPUs using IPIs. Modified: head/sys/amd64/amd64/mp_machdep.c head/sys/amd64/include/apicvar.h head/sys/amd64/include/clock.h head/sys/amd64/isa/clock.c Modified: head/sys/amd64/amd64/mp_machdep.c ============================================================================== --- head/sys/amd64/amd64/mp_machdep.c Sat May 2 11:59:56 2009 (r191743) +++ head/sys/amd64/amd64/mp_machdep.c Sat May 2 12:20:43 2009 (r191744) @@ -57,6 +57,7 @@ __FBSDID("$FreeBSD$"); #include #include +#include #include #include #include @@ -1124,6 +1125,15 @@ ipi_bitmap_handler(struct trapframe fram sched_preempt(curthread); /* Nothing to do for AST */ + + if (ipi_bitmap & (1 << IPI_HARDCLOCK)) + hardclockintr(&frame); + + if (ipi_bitmap & (1 << IPI_STATCLOCK)) + statclockintr(&frame); + + if (ipi_bitmap & (1 << IPI_PROFCLOCK)) + profclockintr(&frame); } /* Modified: head/sys/amd64/include/apicvar.h ============================================================================== --- head/sys/amd64/include/apicvar.h Sat May 2 11:59:56 2009 (r191743) +++ head/sys/amd64/include/apicvar.h Sat May 2 12:20:43 2009 (r191744) @@ -126,7 +126,10 @@ /* IPIs handled by IPI_BITMAPED_VECTOR (XXX ups is there a better place?) */ #define IPI_AST 0 /* Generate software trap. */ #define IPI_PREEMPT 1 -#define IPI_BITMAP_LAST IPI_PREEMPT +#define IPI_HARDCLOCK 2 +#define IPI_STATCLOCK 3 +#define IPI_PROFCLOCK 4 +#define IPI_BITMAP_LAST IPI_PROFCLOCK #define IPI_IS_BITMAPED(x) ((x) <= IPI_BITMAP_LAST) #define IPI_STOP (APIC_IPI_INTS + 7) /* Stop CPU until restarted. */ Modified: head/sys/amd64/include/clock.h ============================================================================== --- head/sys/amd64/include/clock.h Sat May 2 11:59:56 2009 (r191743) +++ head/sys/amd64/include/clock.h Sat May 2 12:20:43 2009 (r191744) @@ -24,6 +24,12 @@ extern int tsc_is_invariant; void i8254_init(void); +struct trapframe; + +int hardclockintr(struct trapframe *frame); +int statclockintr(struct trapframe *frame); +int profclockintr(struct trapframe *frame); + /* * Driver to clock driver interface. */ Modified: head/sys/amd64/isa/clock.c ============================================================================== --- head/sys/amd64/isa/clock.c Sat May 2 11:59:56 2009 (r191743) +++ head/sys/amd64/isa/clock.c Sat May 2 12:20:43 2009 (r191744) @@ -53,6 +53,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include @@ -62,6 +63,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #ifdef DEV_ISA @@ -112,6 +114,35 @@ static struct timecounter i8254_timecoun 0 /* quality */ }; +int +hardclockintr(struct trapframe *frame) +{ + + if (PCPU_GET(cpuid) == 0) + hardclock(TRAPF_USERMODE(frame), TRAPF_PC(frame)); + else + hardclock_cpu(TRAPF_USERMODE(frame)); + return (FILTER_HANDLED); +} + +int +statclockintr(struct trapframe *frame) +{ + + if (profprocs != 0) + profclock(TRAPF_USERMODE(frame), TRAPF_PC(frame)); + statclock(TRAPF_USERMODE(frame)); + return (FILTER_HANDLED); +} + +int +profclockintr(struct trapframe *frame) +{ + + profclock(TRAPF_USERMODE(frame), TRAPF_PC(frame)); + return (FILTER_HANDLED); +} + static int clkintr(struct trapframe *frame) { @@ -128,7 +159,14 @@ clkintr(struct trapframe *frame) mtx_unlock_spin(&clock_lock); } KASSERT(!using_lapic_timer, ("clk interrupt enabled with lapic timer")); - hardclock(TRAPF_USERMODE(frame), TRAPF_PC(frame)); +#ifdef SMP + if (smp_started) + ipi_all_but_self(IPI_HARDCLOCK); +#endif + if (PCPU_GET(cpuid) == 0) + hardclock(TRAPF_USERMODE(frame), TRAPF_PC(frame)); + else + hardclock_cpu(TRAPF_USERMODE(frame)); return (FILTER_HANDLED); } @@ -209,10 +247,19 @@ rtcintr(struct trapframe *frame) if (profprocs != 0) { if (--pscnt == 0) pscnt = psdiv; +#ifdef SMP + if (pscnt != psdiv && smp_started) + ipi_all_but_self(IPI_PROFCLOCK); +#endif profclock(TRAPF_USERMODE(frame), TRAPF_PC(frame)); } - if (pscnt == psdiv) + if (pscnt == psdiv) { +#ifdef SMP + if (smp_started) + ipi_all_but_self(IPI_STATCLOCK); +#endif statclock(TRAPF_USERMODE(frame)); + } } return(flag ? FILTER_HANDLED : FILTER_STRAY); }