From owner-p4-projects@FreeBSD.ORG Tue Mar 18 08:23:28 2008 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id DE208106566C; Tue, 18 Mar 2008 08:23:27 +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 9C580106564A for ; Tue, 18 Mar 2008 08:23:27 +0000 (UTC) (envelope-from peter-gmail@wemm.org) Received: from repoman.freebsd.org (repoman.freebsd.org [IPv6:2001:4f8:fff6::29]) by mx1.freebsd.org (Postfix) with ESMTP id 808878FC1A for ; Tue, 18 Mar 2008 08:23:27 +0000 (UTC) (envelope-from peter-gmail@wemm.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.14.1/8.14.1) with ESMTP id m2I8NReO063547 for ; Tue, 18 Mar 2008 08:23:27 GMT (envelope-from peter-gmail@wemm.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.14.1/8.14.1/Submit) id m2I8NRPu063545 for perforce@freebsd.org; Tue, 18 Mar 2008 08:23:27 GMT (envelope-from peter-gmail@wemm.org) Date: Tue, 18 Mar 2008 08:23:27 GMT Message-Id: <200803180823.m2I8NRPu063545@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to peter-gmail@wemm.org using -f From: Peter Wemm To: Perforce Change Reviews Cc: Subject: PERFORCE change 137986 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: Tue, 18 Mar 2008 08:23:28 -0000 http://perforce.freebsd.org/chv.cgi?CH=137986 Change 137986 by peter@peter_overcee on 2008/03/18 08:23:13 IFC @137982 Affected files ... .. //depot/projects/bike_sched/sys/amd64/acpica/madt.c#4 integrate .. //depot/projects/bike_sched/sys/amd64/amd64/intr_machdep.c#4 integrate .. //depot/projects/bike_sched/sys/amd64/amd64/local_apic.c#4 integrate .. //depot/projects/bike_sched/sys/amd64/amd64/machdep.c#8 integrate .. //depot/projects/bike_sched/sys/amd64/amd64/mptable.c#3 integrate .. //depot/projects/bike_sched/sys/amd64/include/atomic.h#3 integrate .. //depot/projects/bike_sched/sys/amd64/include/intr_machdep.h#3 integrate .. //depot/projects/bike_sched/sys/amd64/isa/atpic.c#3 integrate .. //depot/projects/bike_sched/sys/amd64/linux32/linux32_proto.h#5 integrate .. //depot/projects/bike_sched/sys/amd64/linux32/linux32_syscall.h#5 integrate .. //depot/projects/bike_sched/sys/amd64/linux32/linux32_sysent.c#5 integrate .. //depot/projects/bike_sched/sys/amd64/linux32/syscalls.master#5 integrate .. //depot/projects/bike_sched/sys/arm/arm/intr.c#3 integrate .. //depot/projects/bike_sched/sys/arm/arm/machdep.c#3 integrate .. //depot/projects/bike_sched/sys/arm/arm/vm_machdep.c#6 integrate .. //depot/projects/bike_sched/sys/cam/scsi/scsi_ses.c#4 integrate .. //depot/projects/bike_sched/sys/compat/linux/linux_misc.c#5 integrate .. //depot/projects/bike_sched/sys/compat/svr4/svr4_fcntl.c#4 integrate .. //depot/projects/bike_sched/sys/conf/files#8 integrate .. //depot/projects/bike_sched/sys/contrib/opensolaris/uts/common/fs/zfs/zfs_vnops.c#3 integrate .. //depot/projects/bike_sched/sys/contrib/opensolaris/uts/common/os/callb.c#2 integrate .. //depot/projects/bike_sched/sys/contrib/opensolaris/uts/common/os/taskq.c#2 integrate .. //depot/projects/bike_sched/sys/dev/aac/aac.c#4 integrate .. //depot/projects/bike_sched/sys/dev/ata/ata-all.c#3 integrate .. //depot/projects/bike_sched/sys/dev/ata/ata-all.h#5 integrate .. //depot/projects/bike_sched/sys/dev/ata/ata-disk.c#4 integrate .. //depot/projects/bike_sched/sys/dev/ata/ata-disk.h#3 integrate .. //depot/projects/bike_sched/sys/dev/cxgb/common/cxgb_ael1002.c#3 integrate .. //depot/projects/bike_sched/sys/dev/cxgb/common/cxgb_common.h#3 integrate .. //depot/projects/bike_sched/sys/dev/cxgb/common/cxgb_version.h#3 integrate .. //depot/projects/bike_sched/sys/dev/cxgb/cxgb_ioctl.h#3 integrate .. //depot/projects/bike_sched/sys/dev/cxgb/cxgb_main.c#3 integrate .. //depot/projects/bike_sched/sys/dev/cxgb/ulp/tom/cxgb_cpl_io.c#2 integrate .. //depot/projects/bike_sched/sys/dev/cxgb/ulp/tom/cxgb_cpl_socket.c#2 integrate .. //depot/projects/bike_sched/sys/dev/cxgb/ulp/tom/cxgb_ddp.c#2 integrate .. //depot/projects/bike_sched/sys/dev/cxgb/ulp/tom/cxgb_defs.h#2 integrate .. //depot/projects/bike_sched/sys/dev/hwpmc/pmc_events.h#2 integrate .. //depot/projects/bike_sched/sys/dev/ofw/ofw_console.c#4 integrate .. //depot/projects/bike_sched/sys/dev/syscons/sysmouse.c#3 integrate .. //depot/projects/bike_sched/sys/dev/usb/if_zyd.c#3 integrate .. //depot/projects/bike_sched/sys/dev/usb/usb_quirks.c#3 integrate .. //depot/projects/bike_sched/sys/dev/usb/usbdevs#5 integrate .. //depot/projects/bike_sched/sys/gdb/gdb_cons.c#2 integrate .. //depot/projects/bike_sched/sys/i386/acpica/acpi_wakeup.c#4 integrate .. //depot/projects/bike_sched/sys/i386/acpica/madt.c#4 integrate .. //depot/projects/bike_sched/sys/i386/cpufreq/est.c#3 integrate .. //depot/projects/bike_sched/sys/i386/cpufreq/p4tcc.c#2 integrate .. //depot/projects/bike_sched/sys/i386/i386/intr_machdep.c#7 integrate .. //depot/projects/bike_sched/sys/i386/i386/local_apic.c#7 integrate .. //depot/projects/bike_sched/sys/i386/i386/machdep.c#8 integrate .. //depot/projects/bike_sched/sys/i386/i386/mp_machdep.c#4 integrate .. //depot/projects/bike_sched/sys/i386/i386/mptable.c#3 integrate .. //depot/projects/bike_sched/sys/i386/i386/vm_machdep.c#7 integrate .. //depot/projects/bike_sched/sys/i386/include/atomic.h#3 integrate .. //depot/projects/bike_sched/sys/i386/include/intr_machdep.h#4 integrate .. //depot/projects/bike_sched/sys/i386/isa/atpic.c#4 integrate .. //depot/projects/bike_sched/sys/i386/linux/linux_proto.h#5 integrate .. //depot/projects/bike_sched/sys/i386/linux/linux_syscall.h#5 integrate .. //depot/projects/bike_sched/sys/i386/linux/linux_sysent.c#5 integrate .. //depot/projects/bike_sched/sys/i386/linux/syscalls.master#5 integrate .. //depot/projects/bike_sched/sys/i386/xbox/xbox.c#3 integrate .. //depot/projects/bike_sched/sys/ia64/ia64/interrupt.c#3 integrate .. //depot/projects/bike_sched/sys/ia64/ia64/machdep.c#8 integrate .. //depot/projects/bike_sched/sys/ia64/ia64/sscdisk.c#2 integrate .. //depot/projects/bike_sched/sys/ia64/include/atomic.h#3 integrate .. //depot/projects/bike_sched/sys/ia64/isa/isa_dma.c#3 integrate .. //depot/projects/bike_sched/sys/kern/init_main.c#6 integrate .. //depot/projects/bike_sched/sys/kern/kern_alq.c#4 integrate .. //depot/projects/bike_sched/sys/kern/kern_clock.c#6 integrate .. //depot/projects/bike_sched/sys/kern/kern_conf.c#4 integrate .. //depot/projects/bike_sched/sys/kern/kern_descrip.c#6 integrate .. //depot/projects/bike_sched/sys/kern/kern_event.c#5 integrate .. //depot/projects/bike_sched/sys/kern/kern_idle.c#4 integrate .. //depot/projects/bike_sched/sys/kern/kern_intr.c#8 integrate .. //depot/projects/bike_sched/sys/kern/kern_linker.c#6 integrate .. //depot/projects/bike_sched/sys/kern/kern_malloc.c#3 integrate .. //depot/projects/bike_sched/sys/kern/kern_mbuf.c#5 integrate .. //depot/projects/bike_sched/sys/kern/kern_module.c#5 integrate .. //depot/projects/bike_sched/sys/kern/kern_ntptime.c#3 integrate .. //depot/projects/bike_sched/sys/kern/kern_poll.c#4 integrate .. //depot/projects/bike_sched/sys/kern/kern_resource.c#6 integrate .. //depot/projects/bike_sched/sys/kern/kern_shutdown.c#4 integrate .. //depot/projects/bike_sched/sys/kern/kern_switch.c#13 integrate .. //depot/projects/bike_sched/sys/kern/kern_synch.c#10 integrate .. //depot/projects/bike_sched/sys/kern/kern_tc.c#5 integrate .. //depot/projects/bike_sched/sys/kern/link_elf.c#5 integrate .. //depot/projects/bike_sched/sys/kern/link_elf_obj.c#5 integrate .. //depot/projects/bike_sched/sys/kern/sched_4bsd.c#22 integrate .. //depot/projects/bike_sched/sys/kern/sched_ule.c#22 integrate .. //depot/projects/bike_sched/sys/kern/subr_autoconf.c#4 integrate .. //depot/projects/bike_sched/sys/kern/subr_eventhandler.c#2 integrate .. //depot/projects/bike_sched/sys/kern/subr_log.c#2 integrate .. //depot/projects/bike_sched/sys/kern/subr_prof.c#3 integrate .. //depot/projects/bike_sched/sys/kern/subr_smp.c#4 integrate .. //depot/projects/bike_sched/sys/kern/subr_witness.c#5 integrate .. //depot/projects/bike_sched/sys/kern/tty_cons.c#4 integrate .. //depot/projects/bike_sched/sys/kern/tty_pts.c#3 integrate .. //depot/projects/bike_sched/sys/kern/tty_pty.c#4 integrate .. //depot/projects/bike_sched/sys/kern/tty_subr.c#2 integrate .. //depot/projects/bike_sched/sys/kern/tty_tty.c#3 integrate .. //depot/projects/bike_sched/sys/kern/uipc_domain.c#4 integrate .. //depot/projects/bike_sched/sys/kern/uipc_socket.c#6 integrate .. //depot/projects/bike_sched/sys/kern/vfs_acl.c#3 integrate .. //depot/projects/bike_sched/sys/kern/vfs_bio.c#4 integrate .. //depot/projects/bike_sched/sys/kern/vfs_cache.c#5 integrate .. //depot/projects/bike_sched/sys/kern/vfs_hash.c#3 integrate .. //depot/projects/bike_sched/sys/kern/vfs_lookup.c#4 integrate .. //depot/projects/bike_sched/sys/kern/vfs_subr.c#6 integrate .. //depot/projects/bike_sched/sys/net/bpf.c#6 integrate .. //depot/projects/bike_sched/sys/net/ieee8023ad_lacp.c#3 integrate .. //depot/projects/bike_sched/sys/net/ieee8023ad_lacp.h#3 integrate .. //depot/projects/bike_sched/sys/net/if.c#6 integrate .. //depot/projects/bike_sched/sys/net/if_lagg.c#3 integrate .. //depot/projects/bike_sched/sys/net/netisr.c#3 integrate .. //depot/projects/bike_sched/sys/net/rtsock.c#4 integrate .. //depot/projects/bike_sched/sys/netatm/ipatm/ipatm_load.c#2 integrate .. //depot/projects/bike_sched/sys/netatm/sigpvc/sigpvc_if.c#2 integrate .. //depot/projects/bike_sched/sys/netatm/spans/spans_if.c#2 integrate .. //depot/projects/bike_sched/sys/netatm/uni/uni_load.c#2 integrate .. //depot/projects/bike_sched/sys/netgraph/ng_base.c#5 integrate .. //depot/projects/bike_sched/sys/netgraph/ng_l2tp.c#4 integrate .. //depot/projects/bike_sched/sys/netinet/in_pcb.c#5 integrate .. //depot/projects/bike_sched/sys/netinet/ip_fw2.c#5 integrate .. //depot/projects/bike_sched/sys/netinet/ip_ipsec.c#4 integrate .. //depot/projects/bike_sched/sys/netinet/libalias/alias_irc.c#4 integrate .. //depot/projects/bike_sched/sys/netinet6/ip6_ipsec.c#3 integrate .. //depot/projects/bike_sched/sys/netinet6/ip6_ipsec.h#3 integrate .. //depot/projects/bike_sched/sys/netinet6/ip6_output.c#4 integrate .. //depot/projects/bike_sched/sys/netipsec/ipsec.c#4 integrate .. //depot/projects/bike_sched/sys/netipsec/ipsec_output.c#4 integrate .. //depot/projects/bike_sched/sys/netipsec/key.c#4 integrate .. //depot/projects/bike_sched/sys/nfsclient/nfs_diskless.c#5 integrate .. //depot/projects/bike_sched/sys/pc98/include/nexusvar.h#1 branch .. //depot/projects/bike_sched/sys/pc98/pc98/machdep.c#9 integrate .. //depot/projects/bike_sched/sys/powerpc/aim/machdep.c#2 integrate .. //depot/projects/bike_sched/sys/powerpc/booke/machdep.c#2 integrate .. //depot/projects/bike_sched/sys/powerpc/booke/vm_machdep.c#2 integrate .. //depot/projects/bike_sched/sys/powerpc/include/atomic.h#3 integrate .. //depot/projects/bike_sched/sys/powerpc/include/gdb_machdep.h#2 integrate .. //depot/projects/bike_sched/sys/powerpc/powerpc/gdb_machdep.c#3 integrate .. //depot/projects/bike_sched/sys/powerpc/powerpc/intr_machdep.c#4 integrate .. //depot/projects/bike_sched/sys/security/audit/audit.c#5 integrate .. //depot/projects/bike_sched/sys/sparc64/include/atomic.h#2 integrate .. //depot/projects/bike_sched/sys/sparc64/sparc64/intr_machdep.c#3 integrate .. //depot/projects/bike_sched/sys/sparc64/sparc64/vm_machdep.c#4 integrate .. //depot/projects/bike_sched/sys/sun4v/include/atomic.h#2 integrate .. //depot/projects/bike_sched/sys/sun4v/sun4v/intr_machdep.c#2 integrate .. //depot/projects/bike_sched/sys/sys/ata.h#4 integrate .. //depot/projects/bike_sched/sys/sys/bus_dma.h#3 integrate .. //depot/projects/bike_sched/sys/sys/conf.h#4 integrate .. //depot/projects/bike_sched/sys/sys/eventhandler.h#3 integrate .. //depot/projects/bike_sched/sys/sys/interrupt.h#3 integrate .. //depot/projects/bike_sched/sys/sys/kernel.h#4 integrate .. //depot/projects/bike_sched/sys/sys/module.h#3 integrate .. //depot/projects/bike_sched/sys/sys/resourcevar.h#3 integrate .. //depot/projects/bike_sched/sys/sys/rwlock.h#5 integrate .. //depot/projects/bike_sched/sys/sys/taskqueue.h#2 integrate .. //depot/projects/bike_sched/sys/ufs/ffs/ffs_softdep.c#4 integrate .. //depot/projects/bike_sched/sys/vm/vm_fault.c#5 integrate .. //depot/projects/bike_sched/sys/vm/vm_glue.c#6 integrate .. //depot/projects/bike_sched/sys/vm/vm_init.c#2 integrate .. //depot/projects/bike_sched/sys/vm/vm_mmap.c#5 integrate .. //depot/projects/bike_sched/sys/vm/vm_page.c#5 integrate .. //depot/projects/bike_sched/sys/vm/vm_page.h#3 integrate .. //depot/projects/bike_sched/sys/vm/vm_pageout.c#3 integrate .. //depot/projects/bike_sched/sys/vm/vm_pageq.c#4 delete .. //depot/projects/bike_sched/sys/vm/vm_zeroidle.c#4 integrate Differences ... ==== //depot/projects/bike_sched/sys/amd64/acpica/madt.c#4 (text+ko) ==== @@ -28,7 +28,7 @@ */ #include -__FBSDID("$FreeBSD: src/sys/amd64/acpica/madt.c,v 1.25 2008/01/31 16:51:42 jhb Exp $"); +__FBSDID("$FreeBSD: src/sys/amd64/acpica/madt.c,v 1.26 2008/03/16 10:58:02 rwatson Exp $"); #include #include @@ -409,7 +409,7 @@ apic_register_enumerator(&madt_enumerator); } SYSINIT(madt_register, SI_SUB_TUNABLES - 1, SI_ORDER_FIRST, - madt_register, NULL) + madt_register, NULL); /* * Call the handler routine for each entry in the MADT table. @@ -779,4 +779,4 @@ la->la_acpi_id); } } -SYSINIT(madt_set_ids, SI_SUB_CPU, SI_ORDER_ANY, madt_set_ids, NULL) +SYSINIT(madt_set_ids, SI_SUB_CPU, SI_ORDER_ANY, madt_set_ids, NULL); ==== //depot/projects/bike_sched/sys/amd64/amd64/intr_machdep.c#4 (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/amd64/amd64/intr_machdep.c,v 1.35 2007/11/21 04:03:50 scottl Exp $ + * $FreeBSD: src/sys/amd64/amd64/intr_machdep.c,v 1.39 2008/03/17 22:42:00 jhb Exp $ */ /* @@ -48,6 +48,7 @@ #include #include #include +#include #include #include #include @@ -76,18 +77,17 @@ static struct mtx intrcnt_lock; static STAILQ_HEAD(, pic) pics; -#ifdef INTR_FILTER -static void intr_eoi_src(void *arg); -static void intr_disab_eoi_src(void *arg); -static void intr_event_stray(void *cookie); -#endif - #ifdef SMP static int assign_cpu; static void intr_assign_next_cpu(struct intsrc *isrc); #endif +static int intr_assign_cpu(void *arg, u_char cpu); +static void intr_disable_src(void *arg); +#ifdef INTR_FILTER +static void intr_event_stray(void *cookie); +#endif static void intr_init(void *__dummy); static int intr_pic_registered(struct pic *pic); static void intrcnt_setname(const char *name, int index); @@ -142,14 +142,10 @@ vector = isrc->is_pic->pic_vector(isrc); if (interrupt_sources[vector] != NULL) return (EEXIST); -#ifdef INTR_FILTER error = intr_event_create(&isrc->is_event, isrc, 0, - (mask_fn)isrc->is_pic->pic_enable_source, - intr_eoi_src, intr_disab_eoi_src, "irq%d:", vector); -#else - error = intr_event_create(&isrc->is_event, isrc, 0, - (mask_fn)isrc->is_pic->pic_enable_source, "irq%d:", vector); -#endif + intr_disable_src, (mask_fn)isrc->is_pic->pic_enable_source, + (mask_fn)isrc->is_pic->pic_eoi_source, intr_assign_cpu, "irq%d:", + vector); if (error) return (error); sx_xlock(&intr_table_lock); @@ -233,6 +229,15 @@ return (isrc->is_pic->pic_config_intr(isrc, trig, pol)); } +static void +intr_disable_src(void *arg) +{ + struct intsrc *isrc; + + isrc = arg; + isrc->is_pic->pic_disable_source(isrc, PIC_EOI); +} + #ifdef INTR_FILTER void intr_execute_handlers(struct intsrc *isrc, struct trapframe *frame) @@ -285,24 +290,6 @@ "too many stray irq %d's: not logging anymore\n", isrc->is_pic->pic_vector(isrc)); } - -static void -intr_eoi_src(void *arg) -{ - struct intsrc *isrc; - - isrc = arg; - isrc->is_pic->pic_eoi_source(isrc); -} - -static void -intr_disab_eoi_src(void *arg) -{ - struct intsrc *isrc; - - isrc = arg; - isrc->is_pic->pic_disable_source(isrc, PIC_EOI); -} #else void intr_execute_handlers(struct intsrc *isrc, struct trapframe *frame) @@ -430,6 +417,28 @@ sx_xunlock(&intr_table_lock); } +static int +intr_assign_cpu(void *arg, u_char cpu) +{ +#ifdef SMP + struct intsrc *isrc; + + /* + * Don't do anything during early boot. We will pick up the + * assignment once the APs are started. + */ + if (assign_cpu && cpu != NOCPU) { + isrc = arg; + sx_xlock(&intr_table_lock); + isrc->is_pic->pic_assign_cpu(isrc, cpu_apic_ids[cpu]); + sx_xunlock(&intr_table_lock); + } + return (0); +#else + return (EOPNOTSUPP); +#endif +} + static void intrcnt_setname(const char *name, int index) { @@ -484,7 +493,7 @@ sx_init(&intr_table_lock, "intr sources"); mtx_init(&intrcnt_lock, "intrcnt", NULL, MTX_SPIN); } -SYSINIT(intr_init, SI_SUB_INTR, SI_ORDER_FIRST, intr_init, NULL) +SYSINIT(intr_init, SI_SUB_INTR, SI_ORDER_FIRST, intr_init, NULL); #ifndef DEV_ATPIC /* Initialize the two 8259A's to a known-good shutdown state. */ @@ -536,27 +545,35 @@ /* The BSP is always a valid target. */ static cpumask_t intr_cpus = (1 << 0); -static int current_cpu, num_cpus = 1; +static int current_cpu; static void intr_assign_next_cpu(struct intsrc *isrc) { - struct pic *pic; - u_int apic_id; /* * Assign this source to a local APIC in a round-robin fashion. */ - pic = isrc->is_pic; - apic_id = cpu_apic_ids[current_cpu]; - pic->pic_assign_cpu(isrc, apic_id); + isrc->is_pic->pic_assign_cpu(isrc, cpu_apic_ids[current_cpu]); do { current_cpu++; - if (current_cpu >= num_cpus) + if (current_cpu > mp_maxid) current_cpu = 0; } while (!(intr_cpus & (1 << current_cpu))); } +/* Attempt to bind the specified IRQ to the specified CPU. */ +int +intr_bind(u_int vector, u_char cpu) +{ + struct intsrc *isrc; + + isrc = intr_lookup_source(vector); + if (isrc == NULL) + return (EINVAL); + return (intr_event_bind(isrc->is_event, cpu)); +} + /* * Add a CPU to our mask of valid CPUs that can be destinations of * interrupts. @@ -572,7 +589,6 @@ cpu_apic_ids[cpu]); intr_cpus |= (1 << cpu); - num_cpus++; } /* @@ -586,7 +602,7 @@ int i; /* Don't bother on UP. */ - if (num_cpus <= 1) + if (mp_ncpus == 1) return; /* Round-robin assign a CPU to each enabled source. */ @@ -594,10 +610,21 @@ assign_cpu = 1; for (i = 0; i < NUM_IO_INTS; i++) { isrc = interrupt_sources[i]; - if (isrc != NULL && isrc->is_handlers > 0) - intr_assign_next_cpu(isrc); + if (isrc != NULL && isrc->is_handlers > 0) { + /* + * If this event is already bound to a CPU, + * then assign the source to that CPU instead + * of picking one via round-robin. + */ + if (isrc->is_event->ie_cpu != NOCPU) + isrc->is_pic->pic_assign_cpu(isrc, + cpu_apic_ids[isrc->is_event->ie_cpu]); + else + intr_assign_next_cpu(isrc); + } } sx_xunlock(&intr_table_lock); } -SYSINIT(intr_shuffle_irqs, SI_SUB_SMP, SI_ORDER_SECOND, intr_shuffle_irqs, NULL) +SYSINIT(intr_shuffle_irqs, SI_SUB_SMP, SI_ORDER_SECOND, intr_shuffle_irqs, + NULL); #endif ==== //depot/projects/bike_sched/sys/amd64/amd64/local_apic.c#4 (text+ko) ==== @@ -32,7 +32,7 @@ */ #include -__FBSDID("$FreeBSD: src/sys/amd64/amd64/local_apic.c,v 1.43 2007/10/27 13:34:53 jhb Exp $"); +__FBSDID("$FreeBSD: src/sys/amd64/amd64/local_apic.c,v 1.44 2008/03/16 10:58:02 rwatson Exp $"); #include "opt_hwpmc_hooks.h" @@ -1039,7 +1039,7 @@ printf("%s: Failed to probe CPUs: returned %d\n", best_enum->apic_name, retval); } -SYSINIT(apic_init, SI_SUB_TUNABLES - 1, SI_ORDER_SECOND, apic_init, NULL) +SYSINIT(apic_init, SI_SUB_TUNABLES - 1, SI_ORDER_SECOND, apic_init, NULL); /* * Setup the local APIC. We have to do this prior to starting up the APs @@ -1057,7 +1057,8 @@ printf("%s: Failed to setup the local APIC: returned %d\n", best_enum->apic_name, retval); } -SYSINIT(apic_setup_local, SI_SUB_CPU, SI_ORDER_SECOND, apic_setup_local, NULL) +SYSINIT(apic_setup_local, SI_SUB_CPU, SI_ORDER_SECOND, apic_setup_local, + NULL); /* * Setup the I/O APICs. @@ -1086,7 +1087,7 @@ /* Enable the MSI "pic". */ msi_init(); } -SYSINIT(apic_setup_io, SI_SUB_INTR, SI_ORDER_SECOND, apic_setup_io, NULL) +SYSINIT(apic_setup_io, SI_SUB_INTR, SI_ORDER_SECOND, apic_setup_io, NULL); #ifdef SMP /* ==== //depot/projects/bike_sched/sys/amd64/amd64/machdep.c#8 (text+ko) ==== @@ -39,7 +39,7 @@ */ #include -__FBSDID("$FreeBSD: src/sys/amd64/amd64/machdep.c,v 1.682 2008/03/13 10:54:36 kib Exp $"); +__FBSDID("$FreeBSD: src/sys/amd64/amd64/machdep.c,v 1.683 2008/03/16 10:58:02 rwatson Exp $"); #include "opt_atalk.h" #include "opt_atpic.h" @@ -149,7 +149,7 @@ static void cpu_startup(void *); static void get_fpcontext(struct thread *td, mcontext_t *mcp); static int set_fpcontext(struct thread *td, const mcontext_t *mcp); -SYSINIT(cpu, SI_SUB_CPU, SI_ORDER_FIRST, cpu_startup, NULL) +SYSINIT(cpu, SI_SUB_CPU, SI_ORDER_FIRST, cpu_startup, NULL); #ifdef DDB extern vm_offset_t ksym_start, ksym_end; ==== //depot/projects/bike_sched/sys/amd64/amd64/mptable.c#3 (text+ko) ==== @@ -25,7 +25,7 @@ */ #include -__FBSDID("$FreeBSD: src/sys/amd64/amd64/mptable.c,v 1.240 2007/05/08 22:01:02 jhb Exp $"); +__FBSDID("$FreeBSD: src/sys/amd64/amd64/mptable.c,v 1.241 2008/03/16 10:58:02 rwatson Exp $"); #include #include @@ -381,7 +381,7 @@ apic_register_enumerator(&mptable_enumerator); } SYSINIT(mptable_register, SI_SUB_TUNABLES - 1, SI_ORDER_FIRST, - mptable_register, NULL) + mptable_register, NULL); /* * Call the handler routine for each entry in the MP config table. ==== //depot/projects/bike_sched/sys/amd64/include/atomic.h#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/amd64/include/atomic.h,v 1.44 2006/12/29 15:29:49 bde Exp $ + * $FreeBSD: src/sys/amd64/include/atomic.h,v 1.45 2008/03/16 21:20:48 pjd Exp $ */ #ifndef _MACHINE_ATOMIC_H_ #define _MACHINE_ATOMIC_H_ @@ -74,6 +74,7 @@ int atomic_cmpset_int(volatile u_int *dst, u_int exp, u_int src); int atomic_cmpset_long(volatile u_long *dst, u_long exp, u_long src); u_int atomic_fetchadd_int(volatile u_int *p, u_int v); +u_long atomic_fetchadd_long(volatile u_long *p, u_long v); #define ATOMIC_STORE_LOAD(TYPE, LOP, SOP) \ u_##TYPE atomic_load_acq_##TYPE(volatile u_##TYPE *p); \ @@ -174,6 +175,25 @@ return (v); } +/* + * Atomically add the value of v to the long integer pointed to by p and return + * the previous value of *p. + */ +static __inline u_long +atomic_fetchadd_long(volatile u_long *p, u_long v) +{ + + __asm __volatile( + " " MPLOCKED " " + " xaddq %0, %1 ; " + "# atomic_fetchadd_long" + : "+r" (v), /* 0 (result) */ + "=m" (*p) /* 1 */ + : "m" (*p)); /* 2 */ + + return (v); +} + #if defined(_KERNEL) && !defined(SMP) /* ==== //depot/projects/bike_sched/sys/amd64/include/intr_machdep.h#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/amd64/include/intr_machdep.h,v 1.18 2007/05/08 21:29:13 jhb Exp $ + * $FreeBSD: src/sys/amd64/include/intr_machdep.h,v 1.19 2008/03/14 19:41:46 jhb Exp $ */ #ifndef __MACHINE_INTR_MACHDEP_H__ @@ -137,6 +137,9 @@ int intr_add_handler(const char *name, int vector, driver_filter_t filter, driver_intr_t handler, void *arg, enum intr_type flags, void **cookiep); +#ifdef SMP +int intr_bind(u_int vector, u_char cpu); +#endif int intr_config_intr(int vector, enum intr_trigger trig, enum intr_polarity pol); void intr_execute_handlers(struct intsrc *isrc, struct trapframe *frame); ==== //depot/projects/bike_sched/sys/amd64/isa/atpic.c#3 (text+ko) ==== @@ -32,7 +32,7 @@ */ #include -__FBSDID("$FreeBSD: src/sys/amd64/isa/atpic.c,v 1.22 2007/05/08 21:29:13 jhb Exp $"); +__FBSDID("$FreeBSD: src/sys/amd64/isa/atpic.c,v 1.23 2008/03/16 10:58:02 rwatson Exp $"); #include "opt_auto_eoi.h" #include "opt_isa.h" @@ -499,7 +499,7 @@ intr_register_source(&ai->at_intsrc); } } -SYSINIT(atpic_init, SI_SUB_INTR, SI_ORDER_SECOND + 1, atpic_init, NULL) +SYSINIT(atpic_init, SI_SUB_INTR, SI_ORDER_SECOND + 1, atpic_init, NULL); void atpic_handle_intr(u_int vector, struct trapframe *frame) ==== //depot/projects/bike_sched/sys/amd64/linux32/linux32_proto.h#5 (text+ko) ==== @@ -2,8 +2,8 @@ * System call prototypes. * * DO NOT EDIT-- this file is automatically generated. - * $FreeBSD: src/sys/amd64/linux32/linux32_proto.h,v 1.33 2007/09/18 19:50:32 dwmalone Exp $ - * created from FreeBSD: src/sys/amd64/linux32/syscalls.master,v 1.29 2007/08/28 12:26:34 kib Exp + * $FreeBSD: src/sys/amd64/linux32/linux32_proto.h,v 1.34 2008/03/16 16:29:37 rdivacky Exp $ + * created from FreeBSD: src/sys/amd64/linux32/syscalls.master,v 1.31 2008/03/16 16:24:20 rdivacky Exp */ #ifndef _LINUX_SYSPROTO_H_ @@ -734,6 +734,11 @@ char uaddr2_l_[PADL_(void *)]; void * uaddr2; char uaddr2_r_[PADR_(void *)]; char val3_l_[PADL_(int)]; int val3; char val3_r_[PADR_(int)]; }; +struct linux_sched_setaffinity_args { + char pid_l_[PADL_(l_pid_t)]; l_pid_t pid; char pid_r_[PADR_(l_pid_t)]; + char len_l_[PADL_(l_uint)]; l_uint len; char len_r_[PADR_(l_uint)]; + char user_mask_ptr_l_[PADL_(l_ulong *)]; l_ulong * user_mask_ptr; char user_mask_ptr_r_[PADR_(l_ulong *)]; +}; struct linux_sched_getaffinity_args { char pid_l_[PADL_(l_pid_t)]; l_pid_t pid; char pid_r_[PADR_(l_pid_t)]; char len_l_[PADL_(l_uint)]; l_uint len; char len_r_[PADR_(l_uint)]; @@ -1105,6 +1110,7 @@ int linux_fremovexattr(struct thread *, struct linux_fremovexattr_args *); int linux_tkill(struct thread *, struct linux_tkill_args *); int linux_sys_futex(struct thread *, struct linux_sys_futex_args *); +int linux_sched_setaffinity(struct thread *, struct linux_sched_setaffinity_args *); int linux_sched_getaffinity(struct thread *, struct linux_sched_getaffinity_args *); int linux_set_thread_area(struct thread *, struct linux_set_thread_area_args *); int linux_fadvise64(struct thread *, struct linux_fadvise64_args *); @@ -1360,6 +1366,7 @@ #define LINUX_SYS_AUE_linux_fremovexattr AUE_NULL #define LINUX_SYS_AUE_linux_tkill AUE_NULL #define LINUX_SYS_AUE_linux_sys_futex AUE_NULL +#define LINUX_SYS_AUE_linux_sched_setaffinity AUE_NULL #define LINUX_SYS_AUE_linux_sched_getaffinity AUE_NULL #define LINUX_SYS_AUE_linux_set_thread_area AUE_NULL #define LINUX_SYS_AUE_linux_fadvise64 AUE_NULL ==== //depot/projects/bike_sched/sys/amd64/linux32/linux32_syscall.h#5 (text+ko) ==== @@ -2,8 +2,8 @@ * System call numbers. * * DO NOT EDIT-- this file is automatically generated. - * $FreeBSD: src/sys/amd64/linux32/linux32_syscall.h,v 1.33 2007/09/18 19:50:32 dwmalone Exp $ - * created from FreeBSD: src/sys/amd64/linux32/syscalls.master,v 1.29 2007/08/28 12:26:34 kib Exp + * $FreeBSD: src/sys/amd64/linux32/linux32_syscall.h,v 1.34 2008/03/16 16:29:37 rdivacky Exp $ + * created from FreeBSD: src/sys/amd64/linux32/syscalls.master,v 1.31 2008/03/16 16:24:20 rdivacky Exp */ #define LINUX_SYS_exit 1 @@ -222,6 +222,7 @@ #define LINUX_SYS_linux_fremovexattr 237 #define LINUX_SYS_linux_tkill 238 #define LINUX_SYS_linux_sys_futex 240 +#define LINUX_SYS_linux_sched_setaffinity 241 #define LINUX_SYS_linux_sched_getaffinity 242 #define LINUX_SYS_linux_set_thread_area 243 #define LINUX_SYS_linux_fadvise64 250 ==== //depot/projects/bike_sched/sys/amd64/linux32/linux32_sysent.c#5 (text+ko) ==== @@ -2,8 +2,8 @@ * System call switch table. * * DO NOT EDIT-- this file is automatically generated. - * $FreeBSD: src/sys/amd64/linux32/linux32_sysent.c,v 1.33 2007/09/18 19:50:32 dwmalone Exp $ - * created from FreeBSD: src/sys/amd64/linux32/syscalls.master,v 1.29 2007/08/28 12:26:34 kib Exp + * $FreeBSD: src/sys/amd64/linux32/linux32_sysent.c,v 1.34 2008/03/16 16:29:37 rdivacky Exp $ + * created from FreeBSD: src/sys/amd64/linux32/syscalls.master,v 1.31 2008/03/16 16:24:20 rdivacky Exp */ #include @@ -261,7 +261,7 @@ { AS(linux_tkill_args), (sy_call_t *)linux_tkill, AUE_NULL, NULL, 0, 0 }, /* 238 = linux_tkill */ { 0, (sy_call_t *)nosys, AUE_NULL, NULL, 0, 0 }, /* 239 = linux_sendfile64 */ { AS(linux_sys_futex_args), (sy_call_t *)linux_sys_futex, AUE_NULL, NULL, 0, 0 }, /* 240 = linux_sys_futex */ - { 0, (sy_call_t *)nosys, AUE_NULL, NULL, 0, 0 }, /* 241 = linux_sched_setaffinity */ + { AS(linux_sched_setaffinity_args), (sy_call_t *)linux_sched_setaffinity, AUE_NULL, NULL, 0, 0 }, /* 241 = linux_sched_setaffinity */ { AS(linux_sched_getaffinity_args), (sy_call_t *)linux_sched_getaffinity, AUE_NULL, NULL, 0, 0 }, /* 242 = linux_sched_getaffinity */ { AS(linux_set_thread_area_args), (sy_call_t *)linux_set_thread_area, AUE_NULL, NULL, 0, 0 }, /* 243 = linux_set_thread_area */ { 0, (sy_call_t *)nosys, AUE_NULL, NULL, 0, 0 }, /* 244 = linux_get_thread_area */ ==== //depot/projects/bike_sched/sys/amd64/linux32/syscalls.master#5 (text+ko) ==== @@ -1,4 +1,4 @@ - $FreeBSD: src/sys/amd64/linux32/syscalls.master,v 1.30 2007/09/18 19:50:32 dwmalone Exp $ + $FreeBSD: src/sys/amd64/linux32/syscalls.master,v 1.31 2008/03/16 16:24:20 rdivacky Exp $ ; @(#)syscalls.master 8.1 (Berkeley) 7/19/93 ; System call name/number master file (or rather, slave, from LINUX). @@ -407,7 +407,8 @@ 239 AUE_SENDFILE UNIMPL linux_sendfile64 240 AUE_NULL STD { int linux_sys_futex(void *uaddr, int op, int val, \ struct l_timespec *timeout, void *uaddr2, int val3); } -241 AUE_NULL UNIMPL linux_sched_setaffinity +241 AUE_NULL STD { int linux_sched_setaffinity(l_pid_t pid, l_uint len, \ + l_ulong *user_mask_ptr); } 242 AUE_NULL STD { int linux_sched_getaffinity(l_pid_t pid, l_uint len, \ l_ulong *user_mask_ptr); } 243 AUE_NULL STD { int linux_set_thread_area(struct l_user_desc *desc); } ==== //depot/projects/bike_sched/sys/arm/arm/intr.c#3 (text+ko) ==== @@ -37,7 +37,7 @@ */ #include -__FBSDID("$FreeBSD: src/sys/arm/arm/intr.c,v 1.17 2007/07/27 14:26:42 cognet Exp $"); +__FBSDID("$FreeBSD: src/sys/arm/arm/intr.c,v 1.19 2008/03/17 22:42:00 jhb Exp $"); #include #include #include @@ -50,6 +50,8 @@ #include #include +typedef void (*mask_fn)(void *); + static struct intr_event *intr_events[NIRQ]; static int intrcnt_tab[NIRQ]; static int intrcnt_index = 0; @@ -57,27 +59,6 @@ void arm_handler_execute(struct trapframe *, int); -#ifdef INTR_FILTER -static void -intr_disab_eoi_src(void *arg) -{ - uintptr_t nb; - - nb = (uintptr_t)arg; - arm_mask_irq(nb); -} - -static void -intr_eoi_src(void *arg) -{ - uintptr_t nb; - - nb = (uintptr_t)arg; - arm_unmask_irq(nb); -} - -#endif - void arm_setup_irqhandler(const char *name, driver_filter_t *filt, void (*hand)(void*), void *arg, int irq, int flags, void **cookiep) @@ -89,14 +70,9 @@ return; event = intr_events[irq]; if (event == NULL) { -#ifdef INTR_FILTER error = intr_event_create(&event, (void *)irq, 0, - (void (*)(void *))arm_unmask_irq, intr_eoi_src, - intr_disab_eoi_src, "intr%d:", irq); -#else - error = intr_event_create(&event, (void *)irq, 0, - (void (*)(void *))arm_unmask_irq, "intr%d:", irq); -#endif + (mask_fn)arm_mask_irq, (mask_fn)arm_unmask_irq, + (mask_fn)arm_unmask_irq, NULL, "intr%d:", irq); if (error) return; intr_events[irq] = event; ==== //depot/projects/bike_sched/sys/arm/arm/machdep.c#3 (text+ko) ==== @@ -44,7 +44,7 @@ #include "opt_compat.h" #include -__FBSDID("$FreeBSD: src/sys/arm/arm/machdep.c,v 1.28 2007/05/31 22:52:10 attilio Exp $"); +__FBSDID("$FreeBSD: src/sys/arm/arm/machdep.c,v 1.29 2008/03/16 10:58:02 rwatson Exp $"); #include #include @@ -308,7 +308,7 @@ #endif } -SYSINIT(cpu, SI_SUB_CPU, SI_ORDER_FIRST, cpu_startup, NULL) +SYSINIT(cpu, SI_SUB_CPU, SI_ORDER_FIRST, cpu_startup, NULL); /* Get current clock frequency for the given cpu id. */ int ==== //depot/projects/bike_sched/sys/arm/arm/vm_machdep.c#6 (text+ko) ==== @@ -41,7 +41,7 @@ */ #include -__FBSDID("$FreeBSD: src/sys/arm/arm/vm_machdep.c,v 1.35 2007/11/14 20:21:53 marcel Exp $"); +__FBSDID("$FreeBSD: src/sys/arm/arm/vm_machdep.c,v 1.36 2008/03/16 10:58:02 rwatson Exp $"); #include #include @@ -77,7 +77,7 @@ #ifndef ARM_USE_SMALL_ALLOC static void sf_buf_init(void *arg); -SYSINIT(sock_sf, SI_SUB_MBUF, SI_ORDER_ANY, sf_buf_init, NULL) +SYSINIT(sock_sf, SI_SUB_MBUF, SI_ORDER_ANY, sf_buf_init, NULL); LIST_HEAD(sf_head, sf_buf); ==== //depot/projects/bike_sched/sys/cam/scsi/scsi_ses.c#4 (text+ko) ==== @@ -25,7 +25,7 @@ */ #include -__FBSDID("$FreeBSD: src/sys/cam/scsi/scsi_ses.c,v 1.36 2008/02/20 19:49:46 scottl Exp $"); +__FBSDID("$FreeBSD: src/sys/cam/scsi/scsi_ses.c,v 1.37 2008/03/17 17:18:16 scottl Exp $"); #include #include @@ -144,9 +144,9 @@ encvec ses_vec; /* vector to handlers */ void * ses_private; /* per-type private data */ encobj * ses_objmap; /* objects */ - u_int32_t ses_nobjects; /* number of objects */ + uint32_t ses_nobjects; /* number of objects */ ses_encstat ses_encstat; /* overall status */ - u_int8_t ses_flags; + uint8_t ses_flags; union ccb ses_saved_ccb; struct cdev *ses_dev; struct cam_periph *periph; @@ -166,9 +166,9 @@ static periph_dtor_t sescleanup; static periph_start_t sesstart; -static void sesasync(void *, u_int32_t, struct cam_path *, void *); +static void sesasync(void *, uint32_t, struct cam_path *, void *); static void sesdone(struct cam_periph *, union ccb *); -static int seserror(union ccb *, u_int32_t, u_int32_t); +static int seserror(union ccb *, uint32_t, uint32_t); static struct periph_driver sesdriver = { sesinit, "ses", @@ -234,7 +234,7 @@ } static void -sesasync(void *callback_arg, u_int32_t code, struct cam_path *path, void *arg) +sesasync(void *callback_arg, uint32_t code, struct cam_path *path, void *arg) { struct cam_periph *periph; @@ -303,7 +303,7 @@ return (CAM_REQ_CMP_ERR); } - softc = malloc(sizeof (struct ses_softc), M_SCSISES, M_NOWAIT); + softc = SES_MALLOC(sizeof (struct ses_softc)); if (softc == NULL) { printf("sesregister: Unable to probe new device. " "Unable to allocate softc\n"); @@ -472,7 +472,7 @@ } static int -seserror(union ccb *ccb, u_int32_t cflags, u_int32_t sflags) +seserror(union ccb *ccb, uint32_t cflags, uint32_t sflags) { struct ses_softc *softc; struct cam_periph *periph; @@ -489,7 +489,7 @@ struct cam_periph *periph; ses_encstat tmp; ses_objstat objs; - ses_object obj, *uobj; + ses_object *uobj; struct ses_softc *ssc; void *addr; int error, i; @@ -511,6 +511,9 @@ /* * Now check to see whether we're initialized or not. + * This actually should never fail as we're not supposed + * to get past ses_open w/o successfully initializing + * things. */ if ((ssc->ses_flags & SES_FLAG_INITIALIZED) == 0) { cam_periph_unlock(periph); @@ -526,6 +529,14 @@ /* * If this command can change the device's state, * we must have the device open for writing. + * + * For commands that get information about the + * device- we don't need to lock the peripheral + * if we aren't running a command. The number + * of objects and the contents will stay stable + * after the first open that does initialization. + * The periph also can't go away while a user + * process has it open. */ switch (cmd) { case SESIOC_GETNOBJ: @@ -546,23 +557,16 @@ break; case SESIOC_GETOBJMAP: - /* - * XXX Dropping the lock while copying multiple segments is - * bogus. - */ - cam_periph_lock(periph); - for (uobj = addr, i = 0; i != ssc->ses_nobjects; i++, uobj++) { - obj.obj_id = i; - obj.subencid = ssc->ses_objmap[i].subenclosure; - obj.object_type = ssc->ses_objmap[i].enctype; - cam_periph_unlock(periph); - error = copyout(&obj, uobj, sizeof (ses_object)); - cam_periph_lock(periph); + for (uobj = addr, i = 0; i != ssc->ses_nobjects; i++) { + ses_object kobj; + kobj.obj_id = i; + kobj.subencid = ssc->ses_objmap[i].subenclosure; + kobj.object_type = ssc->ses_objmap[i].enctype; + error = copyout(&kobj, &uobj[i], sizeof (ses_object)); if (error) { break; } } - cam_periph_unlock(periph); break; case SESIOC_GETENCSTAT: ==== //depot/projects/bike_sched/sys/compat/linux/linux_misc.c#5 (text+ko) ==== @@ -28,7 +28,7 @@ */ #include -__FBSDID("$FreeBSD: src/sys/compat/linux/linux_misc.c,v 1.217 2008/02/22 11:47:56 kib Exp $"); +__FBSDID("$FreeBSD: src/sys/compat/linux/linux_misc.c,v 1.218 2008/03/16 16:24:20 rdivacky Exp $"); #include "opt_compat.h" #include "opt_mac.h" @@ -63,6 +63,7 @@ #include #include #include +#include #include @@ -1730,22 +1731,52 @@ } /* - * XXX: fake one.. waiting for real implementation of affinity mask. + * Get affinity of a process. */ int linux_sched_getaffinity(struct thread *td, struct linux_sched_getaffinity_args *args) { int error; - cpumask_t i = ~0; + struct cpuset_getaffinity_args cga; + +#ifdef DEBUG + if (ldebug(sched_getaffinity)) + printf(ARGS(sched_getaffinity, "%d, %d, *"), args->pid, + args->len); +#endif + + cga.level = CPU_LEVEL_WHICH; + cga.which = CPU_WHICH_PID; + cga.id = args->pid; + cga.cpusetsize = sizeof(cpumask_t); + cga.mask = (long *) args->user_mask_ptr; + + if ((error = cpuset_getaffinity(td, &cga)) == 0) + td->td_retval[0] = sizeof(cpumask_t); + + return (error); +} - if (args->len < sizeof(cpumask_t)) - return (EINVAL); +/* + * Set affinity of a process. + */ +int +linux_sched_setaffinity(struct thread *td, >>> TRUNCATED FOR MAIL (1000 lines) <<<