the bitrig haesbaert_ithread branch has been created by haesbaert. it is 1 commit behind master, and 35 commits ahead.
commit bc0c17eb6e220308c42177f4b1044977ccb97331 diff: https://github.com/bitrig/bitrig/commit/bc0c17e author: Christiano Haesbaert <[email protected]> date: Thu Jan 15 14:13:48 2015 +0100 Add missing cld calls in vector.S to conform with the latest sync changes. M sys/arch/amd64/amd64/vector.S commit 9f60dd21570dc4fafcfc1075dc5d8d27e8f4e1e5 diff: https://github.com/bitrig/bitrig/commit/9f60dd2 author: Christiano Haesbaert <[email protected]> date: Tue Jan 13 23:08:30 2015 +0100 Kill ih_pin in amd64, we have that in intrsource.is_pin. M sys/arch/amd64/amd64/intr.c M sys/arch/amd64/include/intr.h M sys/kern/kern_softintr.c commit 8487882a2b892968b2cc208b2ddfc32c54210b56 diff: https://github.com/bitrig/bitrig/commit/8487882 author: Christiano Haesbaert <[email protected]> date: Tue Jan 13 18:52:39 2015 +0100 ARM atomic.h should include stdatomic if it inlines C11 atomic stuff M sys/arch/arm/include/atomic.h commit 3b6dc719f8c78871c28b16ccbb9c2ef64c3a678b diff: https://github.com/bitrig/bitrig/commit/3b6dc71 author: Christiano Haesbaert <[email protected]> date: Tue Jan 13 20:10:52 2015 +0100 Missing softintr.h include in kern_sig.c M sys/kern/kern_sig.c commit fd8f3757693cdac5d713009a652c78d39404800c diff: https://github.com/bitrig/bitrig/commit/fd8f375 author: Christiano Haesbaert <[email protected]> date: Tue Jan 13 20:46:16 2015 +0100 More missing includes found while porting smpns to ARM. M sys/dev/ic/ahcivar.h M sys/dev/sdmmc/sdmmc_io.c M sys/kern/kern_malloc.c M sys/kern/subr_disk.c M sys/kern/subr_evcount.c commit 182c4bf156a91071266e53b5fd6fbe46736241a9 diff: https://github.com/bitrig/bitrig/commit/182c4bf author: Christiano Haesbaert <[email protected]> date: Tue Jan 13 20:08:16 2015 +0100 Missing proc.h for crit_enter(). M sys/kern/kern_sensors.c commit 5173f17fd6d9b1db60355a8b43b822b569a2bb03 diff: https://github.com/bitrig/bitrig/commit/5173f17 author: Christiano Haesbaert <[email protected]> date: Tue Jan 13 17:46:33 2015 +0100 Some define alignment and whitespace cleanup. M sys/arch/arm/cortex/ampintc.c commit e4ecca59632b3ee9c9bc9d7d9b31fb3ee0c04d1c diff: https://github.com/bitrig/bitrig/commit/e4ecca5 author: Christiano Haesbaert <[email protected]> date: Tue Jan 13 17:39:42 2015 +0100 Rename intrsource members from iq_* to is_* and kill two unused ones. M sys/arch/arm/cortex/ampintc.c M sys/arch/armv7/include/intr.h M sys/arch/armv7/omap/intc.c M sys/arch/armv7/sunxi/a1xintc.c commit 1cfe230e6c4a5e36d1d887581d95437967b55758 diff: https://github.com/bitrig/bitrig/commit/1cfe230 author: Christiano Haesbaert <[email protected]> date: Tue Jan 13 17:32:10 2015 +0100 Rename intrq to intrsource and move to a common arm header. M sys/arch/arm/cortex/ampintc.c M sys/arch/armv7/include/intr.h M sys/arch/armv7/omap/intc.c M sys/arch/armv7/sunxi/a1xintc.c commit 0074f9c88e8098a09b888c67b2db4b4b90f57c84 diff: https://github.com/bitrig/bitrig/commit/0074f9c author: Christiano Haesbaert <[email protected]> date: Tue Jan 13 18:43:21 2015 +0100 If you're using crit_enter you need proc.h M sys/dev/ic/com.c M sys/dev/usb/ehci.c commit 47f2e303c74e55358ee5d001f4630483d0303a43 diff: https://github.com/bitrig/bitrig/commit/47f2e30 author: Christiano Haesbaert <[email protected]> date: Tue Jan 13 16:49:03 2015 +0100 Convert hand rolled intr handler list to TAILQ in amd64. Moves it closer to arm in making intrsource MI. M sys/arch/amd64/amd64/intr.c M sys/arch/amd64/include/intr.h M sys/arch/amd64/isa/isa_machdep.c M sys/kern/kern_ithread.c M sys/kern/kern_softintr.c commit ca39227bcf3003d46838616a4d10b69af60b1d30 diff: https://github.com/bitrig/bitrig/commit/ca39227 author: Christiano Haesbaert <[email protected]> date: Tue Jan 13 16:44:02 2015 +0100 Fix use after free in intr_disestablish(). M sys/arch/amd64/amd64/intr.c commit e488e4868160cdac9307bda9722e6fec3848b02c diff: https://github.com/bitrig/bitrig/commit/e488e48 author: Christiano Haesbaert <[email protected]> date: Tue Jan 13 15:06:32 2015 +0100 Cleanup genassym.cf from amd64 M sys/arch/amd64/amd64/genassym.cf commit 9a1078959940d643f665331a6cccf6f66c55ed2e diff: https://github.com/bitrig/bitrig/commit/9a10789 author: Christiano Haesbaert <[email protected]> date: Mon Jan 12 16:37:35 2015 +0100 Make sure ipi and clocks are always in a critical section. Don't assert ipi CRIT_DEPTH because of ddb and so on. M sys/arch/amd64/amd64/ipi.c M sys/arch/amd64/amd64/lapic.c M sys/arch/amd64/amd64/spl.S M sys/kern/kern_clock.c commit a6316abef83bc27a601bb503f1d67e6adfa5aeb9 diff: https://github.com/bitrig/bitrig/commit/a6316ab author: Christiano Haesbaert <[email protected]> date: Mon Jan 12 15:54:27 2015 +0100 Add P_ITHREAD to the string formatting bits. M sys/sys/proc.h commit 0bda22ab2b1b6192b46e700339ca20a5d63d4d02 diff: https://github.com/bitrig/bitrig/commit/0bda22a author: Christiano Haesbaert <[email protected]> date: Wed Dec 10 02:14:52 2014 +0100 Give device names to ithreads p_comm and evcounters to softintr. Concatenate all device names in the ithread's process name, this is useful for debugging and/or profiling. Also put event counters on software interrupts, I can't recall how many times I wanted to know this. A ps auxkl might show the following now: root 6034 0.0 0.0 0 0 ?? DK 2:01AM 0:04.97 (softclock) 0 0 0 -18 0 intr root 24717 0.0 0.0 0 0 ?? DK 2:01AM 0:01.06 (softnet) 0 0 0 -18 0 intr root 25481 0.0 0.0 0 0 ?? DK 2:01AM 0:01.08 (ehci0,mpi0) 0 0 0 -18 0 intr root 23688 0.0 0.0 0 0 ?? DK 2:01AM 0:01.02 (em0) 0 0 0 -18 0 intr .... M sys/dev/ic/com.c M sys/dev/usb/usb.c M sys/kern/kern_clock.c M sys/kern/kern_ithread.c M sys/kern/kern_softintr.c M sys/net/netisr.c M sys/net/pipex.c M sys/sys/softintr.h commit a81e77124f8595e5b43bd5a72efacc5403ea5018 diff: https://github.com/bitrig/bitrig/commit/a81e771 author: Christiano Haesbaert <[email protected]> date: Mon Dec 8 23:36:55 2014 +0100 Cleanup softintr, remove establish_mpsafe now that IPL_FLAGS is here. Also kill unused softintr.c from amd64. ok pwildt@ D sys/arch/amd64/amd64/softintr.c M sys/kern/kern_softintr.c M sys/sys/softintr.h commit 8f274f0699d6a765e60b28ae62f0dd37c6f2cfe4 diff: https://github.com/bitrig/bitrig/commit/8f274f0 author: Patrick Wildt <[email protected]> date: Sat Aug 23 22:52:57 2014 +0200 Revert to nearly the old softintr_ API, but keep ithreads for it. ok haesbaert@ M sys/arch/amd64/include/intr.h M sys/conf/files M sys/dev/ic/com.c M sys/dev/usb/usb.c M sys/kern/kern_clock.c M sys/kern/kern_ithread.c M sys/kern/kern_sig.c A sys/kern/kern_softintr.c M sys/net/netisr.c M sys/net/netisr.h M sys/net/pipex.c M sys/sys/ithread.h A sys/sys/softintr.h commit 5fea9e627003b6f51730a88c0150406ed9189c19 diff: https://github.com/bitrig/bitrig/commit/5fea9e6 author: Christiano Haesbaert <[email protected]> date: Tue Dec 2 19:21:36 2014 +0100 Simplify ithread_sleep() and ithread_run(). setrunnable() is less efficient since it does unecessary computations for a kthread. Even so, lets use it as it diminishes the amount of replicated code. Conflicts: sys/kern/kern_ithread.c sys/kern/sched_bsd.c M sys/kern/kern_ithread.c M sys/sys/proc.h commit e1e2ac5d539c257d02026f1a77ccbe96355191da diff: https://github.com/bitrig/bitrig/commit/e1e2ac5 author: Christiano Haesbaert <[email protected]> date: Thu Oct 30 21:04:14 2014 +0100 crit_rundeferred() -> crit_unpend(), call MD intr_unpend(). Make crit_unpend() the function to be called everytime we leave a critical section, make it call intr_unpend() which is MD. Trying to keep the code in intr_unpend() MI now is unrealistic. Conflicts: sys/kern/kern_crit.c M sys/arch/amd64/amd64/intr.c M sys/arch/amd64/amd64/spl.S M sys/arch/amd64/include/intr.h M sys/kern/kern_crit.c M sys/sys/proc.h commit 4a777778cef9e5c5ce2a1bbfcf80ca79a99c32f3 diff: https://github.com/bitrig/bitrig/commit/4a77777 author: Christiano Haesbaert <[email protected]> date: Mon Sep 29 22:46:05 2014 +0200 Slightly more efficient crit_rundeferred(). Instead of disabling/enabling interrupts for every ipending intrsource, do it once and clear it. Another option is using atomic_exchange_explicit() but the bus locking is unecessary since this is a cpu local word. M sys/kern/kern_crit.c commit 056e887968abe0135ea823bccb927e57db10e594 diff: https://github.com/bitrig/bitrig/commit/056e887 author: Christiano Haesbaert <[email protected]> date: Sun Sep 28 12:23:23 2014 +0200 Be a bit more strict with KERNEL_LOCK ordering DIAGNOSTIC. Also make the loss of atomicity in pool_get() drop and reaquire the critical sections. This makes the kernel lock crit depth messages go away on boot. M sys/kern/kern_malloc.c M sys/kern/subr_pool.c M sys/sys/systm.h commit 7198a9f2e4f117c1d3a552a7371019764a1695c3 diff: https://github.com/bitrig/bitrig/commit/7198a9f author: Christiano Haesbaert <[email protected]> date: Sat Sep 27 13:01:27 2014 +0200 Kill CRITCOUNTERS left overs M sys/kern/kern_crit.c commit 8253b00902e18b27d736b91cb7dc836726a24602 diff: https://github.com/bitrig/bitrig/commit/8253b00 author: Christiano Haesbaert <[email protected]> date: Sat Sep 27 12:52:48 2014 +0200 Use the intr_ as prefix for interrupt API, intr_[disable|enable|...] Discussed with Patrick, we both agree this makes more sense than using a suffix. Also use intr_get_state() and intr_set_state() instead of state() and restore(). M sys/arch/amd64/amd64/amd64_mem.c M sys/arch/amd64/amd64/hibernate_machdep.c M sys/arch/amd64/amd64/i8259.c M sys/arch/amd64/amd64/ioapic.c M sys/arch/amd64/amd64/ipifuncs.c M sys/arch/amd64/amd64/lapic.c M sys/arch/amd64/amd64/lock_machdep.c M sys/arch/amd64/amd64/machdep.c M sys/arch/amd64/include/cpufunc.h M sys/arch/amd64/isa/clock.c M sys/dev/acpi/acpi.c M sys/dev/isa/gus.c M sys/kern/kern_crit.c M sys/kern/kern_sched.c commit b9c70c490af05028ddf7982a7335a7941b88595e diff: https://github.com/bitrig/bitrig/commit/b9c70c4 author: Christiano Haesbaert <[email protected]> date: Tue Sep 16 20:21:46 2014 +0200 Add ithread.h to distrib sets. M distrib/sets/lists/base/md.amd64 M distrib/sets/lists/comp/mi commit 08e43d47f98a874c8bc4d33fca188ca2d6e1b48e diff: https://github.com/bitrig/bitrig/commit/08e43d4 author: Christiano Haesbaert <[email protected]> date: Fri Aug 29 13:38:18 2014 +0200 Use more sensical labels on vector.S M sys/arch/amd64/amd64/vector.S commit 636d349d846a2e283dc5de4eaaba1a0f72fa259c diff: https://github.com/bitrig/bitrig/commit/636d349 author: Christiano Haesbaert <[email protected]> date: Wed Aug 27 18:21:02 2014 +0200 Decouple the idea of masking/unmasking an intrsource from pic{}. When we take an interrupt, we mask the source and schedule the thread, when the thread eventually runs and finishes processing, it unmasks the source. So there must be a way of unmasking the source in a MI fashion, each architecture should have a intrsource_unmask() function. In amd64, we just map it to the corresponding pic{} callback. M sys/arch/amd64/include/intr.h M sys/kern/kern_ithread.c commit ccad555977b5ff6c08636f77459eb6bc69045e86 diff: https://github.com/bitrig/bitrig/commit/ccad555 author: Christiano Haesbaert <[email protected]> date: Wed Aug 27 18:06:11 2014 +0200 Fix interrupt account with intr_shared_edge != 0. M sys/kern/kern_ithread.c commit f69adc5c437d2b938d53ebaf8afa44dafd2ecec6 diff: https://github.com/bitrig/bitrig/commit/f69adc5 author: Christiano Haesbaert <[email protected]> date: Wed Aug 27 15:49:12 2014 +0200 Whitespace & wording M sys/kern/kern_ithread.c commit 8c4d45046690c0db68dc12bef2944034806621bf diff: https://github.com/bitrig/bitrig/commit/8c4d450 author: Christiano Haesbaert <[email protected]> date: Wed Aug 27 14:50:15 2014 +0200 Introduce intr_state_t and MI "API" for blocking interrupts. The fact that disabling/enabling real interrupts is totally MD makes writing portable code harder, here I propose the following API: enable_intr(void) Enables "all" hw interrupts. disable_intr(void) Disables "all" hw interrupts. intr_state_t state_intr(void) Reads hw interrupts state. restore_intr(intr_state_t) Restore hw interrupts state. I think this should map easily to arm or any other future platform, intr_state_t should be defined to whatever is convenient to the arch. Switch crit_rundeferred() to use it, when we port stuff to arm, we just need to mimick the API. M sys/arch/amd64/include/cpufunc.h M sys/kern/kern_crit.c commit 819cf693c6780a8bd30ea20e0fce7bbe3c061591 diff: https://github.com/bitrig/bitrig/commit/819cf69 author: Christiano Haesbaert <[email protected]> date: Tue Aug 26 16:13:16 2014 +0200 Kill is_minlevel & is_maxlevel from intrsource{}. This is a step into turning intrsource{} MI and getting rid of the IPL leftovers. M sys/arch/amd64/amd64/acpi_machdep.c M sys/arch/amd64/amd64/genassym.cf M sys/arch/amd64/amd64/intr.c M sys/arch/amd64/amd64/machdep.c M sys/arch/amd64/include/intr.h M sys/arch/amd64/include/segments.h M sys/kern/kern_ithread.c commit 7c4ae46560d9ac1a1798824693f1fdfdfa250112 diff: https://github.com/bitrig/bitrig/commit/7c4ae46 author: Christiano Haesbaert <[email protected]> date: Fri Jun 6 11:42:01 2014 +0200 Stop using the sleepqueue for interrupt threads. There is no need for it, it cuts some hacks and it's less instructions. Since we always wakeup from ithread_run(), we always know the proc to awake, the solely point of the sleepqueue is to be a storage to be found via ident hashing. Conflicts: sys/kern/kern_ithread.c M sys/kern/kern_ithread.c commit 1d6a82945f2967334e5f18333b4d8908f5f089ad diff: https://github.com/bitrig/bitrig/commit/1d6a829 author: Christiano Haesbaert <[email protected]> date: Sun May 11 17:22:11 2014 +0200 No need for running interrupt handlers in critical sections anymore. Preemption correctly relies on the priority to do preemption, having a ithread->ithread preemption due to ithread sleeping at a lower priority should be ok. M sys/kern/kern_ithread.c commit 8fbf660ea94b1def918f0ea733f59d7d558dd9f0 diff: https://github.com/bitrig/bitrig/commit/8fbf660 author: Christiano Haesbaert <[email protected]> date: Wed Feb 26 23:24:37 2014 +0100 Newly formed processes should start in a critical section. They have the schedlock, and release on proc_trampoline_mp(), if the newly formed process is not in a critical section, a clock interrupt might attempt to grab the SCHED LOCK, or worse, we might preempt to early in the future. This paves the way for preemption and allows SCHED LOCK to be a mutex, we only need guenther's fix for the recursive tsleep. M sys/kern/kern_fork.c M sys/sys/proc.h commit 931c77e11079c404380bcb8f6ab3fd4594ef96b7 diff: https://github.com/bitrig/bitrig/commit/931c77e author: Christiano F. Haesbaert <[email protected]> date: Sat May 25 13:19:17 2013 +0200 New interrupt model, move away from IPLs. This diff changes the interrupt model to something very similar to what other modern unixes like Solaris, FreeBSD, DragonflyBSD and linux. It also introduces critical sections. Interrupts except clock and ipi are handled by interrupt threads, when an interrupt fires, the only job for the small interrupt stub is to schedule the corresponding interrupt thread, when the ithread gets scheduled, it services the interrupt. The kernel must be made preemptive, so that interrupt threads may preempt the current running code. In this model, you normally never block interrupts, you rely solely on locks to protect the code, if the ithread preempts the running code, and it tries to acquire a contested lock, it blocks (sleeps) and gets resumed only when that lock is released. This allows us to have lower interrupt latency, as instead of blocking interrupts for a long section, you can fine grain that section in a specific lock. Instead of raising to IPL_BIO and preventing softclock from running for example, we can make softclock preempt the old IPL_BIO and only block if there is an actual lock contention. This was first implemented in Solaris 2 (Kleiman & Eykholt circa 93), they demonstrated that this model, after properly locked, changed the worst case latency from 1s to <1ms on a single-core 40mhz machine. It also allows for us to properly fight livelocks in the future, as the scheduler will make sure "everything runs at some point". The the kernel can now be synchronous with regard to locking, as you can use the same lock to interlock against interrupts or other normal kthreads. You can only block on locks if you have a process context, so you still need a way to block interrupts from normal (read: not ithread interrupts), like clock and ipi. For that we introduce critical sections, which block everything, in practice they're only used to protect scheduler data and on mutexes, so they are very short. In the future critical sections will also be the only thing that prevents kernel preemption. In order to prevent deadlocks, you must never be preempted while holding a spinlock, so a critical section is implied there, this is also akin to what every system does. In this present state, kernel preemption has not been implemented, all threads <IPL_CLOCK were moved to ithreads, there is no observable loss of performance, it's been stable since the last half a year. All spl calls <IPL_CLOCK were made no-ops, while >= IPL_CLOCK were replaced by critical sections. Most of the old assembly code has been rewritten in C, just because I refuse to maintain unecessary asm blocks. The next steps are: o Turn kernel lock into a rrwlock. o Enable kernel preemption, at this point all the interrupt interlocking will be done through kernel lock. o Decide on which subsystem to release first, having a wide subsytem lock. Make sure we have a process context early and kill crit_escaped. This was lost in a merge. M sys/arch/amd64/amd64/cpu.c M sys/arch/amd64/amd64/db_interface.c M sys/arch/amd64/amd64/fpu.c M sys/arch/amd64/amd64/genassym.cf M sys/arch/amd64/amd64/intr.c M sys/arch/amd64/amd64/ipi.c M sys/arch/amd64/amd64/lapic.c M sys/arch/amd64/amd64/locore.S M sys/arch/amd64/amd64/machdep.c M sys/arch/amd64/amd64/spl.S M sys/arch/amd64/amd64/trap.c M sys/arch/amd64/amd64/vector.S M sys/arch/amd64/amd64/via.c M sys/arch/amd64/conf/files.amd64 M sys/arch/amd64/include/atomic.h M sys/arch/amd64/include/cpu.h M sys/arch/amd64/include/frame.h M sys/arch/amd64/include/frameasm.h M sys/arch/amd64/include/intr.h M sys/arch/amd64/include/intrdefs.h M sys/arch/amd64/isa/clock.c M sys/arch/arm/arm/db_interface.c M sys/arch/arm/arm/pmap.c M sys/conf/files M sys/dev/acpi/acpi.c M sys/dev/cardbus/cardbus.c M sys/dev/ic/com.c M sys/dev/ic/comvar.h M sys/dev/ic/elink3.c M sys/dev/ic/i82365.c M sys/dev/ic/vga.c M sys/dev/ic/vga_subr.c M sys/dev/isa/if_ef_isapnp.c M sys/dev/isa/pcppi.c M sys/dev/onewire/onewire_bitbang.c M sys/dev/pci/drm/drm_atomic.h M sys/dev/pci/drm/radeon/radeon_kms.c M sys/dev/pci/mbg.c M sys/dev/pci/pccbb.c M sys/dev/pci/pci.c M sys/dev/pci/pci_map.c M sys/dev/pci/pciide.c M sys/dev/pcmcia/if_xe.c M sys/dev/rasops/rasops.c M sys/dev/sdmmc/sdmmc_io.c M sys/dev/usb/ehci.c M sys/dev/usb/ohci.c M sys/dev/usb/uhci.c M sys/dev/usb/umidi.c M sys/dev/usb/usb.c M sys/dev/usb/usbdivar.h M sys/dev/usb/usbf_subr.c M sys/dev/usb/usbfvar.h M sys/dev/usb/xhci.c M sys/dev/wsfont/wsfont.c M sys/kern/init_main.c M sys/kern/kern_clock.c A sys/kern/kern_crit.c M sys/kern/kern_event.c M sys/kern/kern_exec.c M sys/kern/kern_fork.c A sys/kern/kern_ithread.c M sys/kern/kern_lock.c M sys/kern/kern_mutex.c M sys/kern/kern_proc.c M sys/kern/kern_resource.c M sys/kern/kern_sched.c M sys/kern/kern_sensors.c M sys/kern/kern_sig.c M sys/kern/kern_synch.c M sys/kern/kern_time.c M sys/kern/kern_timeout.c M sys/kern/sched_bsd.c M sys/kern/subr_disk.c M sys/kern/subr_evcount.c M sys/kern/subr_hibernate.c M sys/kern/subr_log.c M sys/kern/subr_pool.c M sys/kern/subr_prf.c M sys/kern/subr_prof.c M sys/kern/subr_xxx.c M sys/kern/sys_generic.c M sys/kern/sys_process.c M sys/kern/vfs_subr.c M sys/kern/vfs_sync.c M sys/lib/libkern/libkern.h M sys/net/if_tun.c M sys/net/netisr.c M sys/net/netisr.h M sys/net/pipex.c A sys/sys/ithread.h M sys/sys/proc.h M sys/sys/sched.h M sys/sys/systm.h M sys/sys/timeout.h M sys/uvm/uvm_map.c
