summaryrefslogtreecommitdiffstats
path: root/sys/kern/kern_intr.c
Commit message (Collapse)AuthorAgeFilesLines
* Overhaul of the SMP code. Several portions of the SMP kernel support havejhb2001-04-271-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | been made machine independent and various other adjustments have been made to support Alpha SMP. - It splits the per-process portions of hardclock() and statclock() off into hardclock_process() and statclock_process() respectively. hardclock() and statclock() call the *_process() functions for the current process so that UP systems will run as before. For SMP systems, it is simply necessary to ensure that all other processors execute the *_process() functions when the main clock functions are triggered on one CPU by an interrupt. For the alpha 4100, clock interrupts are delievered in a staggered broadcast fashion, so we simply call hardclock/statclock on the boot CPU and call the *_process() functions on the secondaries. For x86, we call statclock and hardclock as usual and then call forward_hardclock/statclock in the MD code to send an IPI to cause the AP's to execute forwared_hardclock/statclock which then call the *_process() functions. - forward_signal() and forward_roundrobin() have been reworked to be MI and to involve less hackery. Now the cpu doing the forward sets any flags, etc. and sends a very simple IPI_AST to the other cpu(s). AST IPIs now just basically return so that they can execute ast() and don't bother with setting the astpending or needresched flags themselves. This also removes the loop in forward_signal() as sched_lock closes the race condition that the loop worked around. - need_resched(), resched_wanted() and clear_resched() have been changed to take a process to act on rather than assuming curproc so that they can be used to implement forward_roundrobin() as described above. - Various other SMP variables have been moved to a MI subr_smp.c and a new header sys/smp.h declares MI SMP variables and API's. The IPI API's from machine/ipl.h have moved to machine/smp.h which is included by sys/smp.h. - The globaldata_register() and globaldata_find() functions as well as the SLIST of globaldata structures has become MI and moved into subr_smp.c. Also, the globaldata list is only available if SMP support is compiled in. Reviewed by: jake, peter Looked over by: eivind
* Catch up to header include changes:jhb2001-03-281-0/+1
| | | | | - <sys/mutex.h> now requires <sys/systm.h> - <sys/mutex.h> and <sys/sx.h> now require <sys/lock.h>
* Catch up to the mtx_saveintr -> mtx_savecrit change.jhb2001-03-281-3/+3
|
* Use (..., "%s", foo) instead of (..., foo) to avoid a warning about ajhb2001-03-241-1/+1
| | | | | non-constant format string when calling kthread_create() to create an ithread.
* Ok, the kernel will panic in kmem_malloc() if the kernel map is full, sojhb2001-03-021-4/+0
| | | | | | | malloc with M_WAITOK can't actually return NULL. I wish I could get two people to give me the same answer about this when I ask... Submitted by: jake
* - Check to see if malloc() returned NULL even with M_WAITOK.jhb2001-03-021-1/+6
| | | | | | | - Add a KASSERT() to ensure an ithread has a backing kernel thread when we schedule it. - Don't attempt to preemptively switch to an ithread if p_stat of curproc is not SRUN.
* Sigh. Try to get priorities sorted out. Don't bother trying tojake2001-02-281-0/+1
| | | | | | | | | | | update native priority, it is diffcult to get right and likely to end up horribly wrong. Use an honestly wrong fixed value that seems to work; PUSER for user threads, and the interrupt priority for ithreads. Set it once when the process is created and forget about it. Suggested by: bde Pointy hat: me
* Work around a race condition where an interrupt handler can be removed fromjhb2001-02-221-3/+34
| | | | | | | | | | | an interrupt thread while the interrupt thread is blocked on Giant waiting to execute the interrupt handler being removed. The result was that the intrhand structure would be free'd, and we would call 0xdeadc0de. The work around is to check to see if the interrupt thread is idle when removing a handler. If not, then we mark the interrupt handler as being dead using the new IH_DEAD flag and don't remove it from the interrupt threads' list of handlers. When the interrupt thread resumes, it will see a dead handler while traversing the list of handlers and will remove the handler then.
* Just use the ithread->it_proc directly in a KTR tracepoint instead ofjhb2001-02-221-2/+1
| | | | | | | assigning a local var to it and using it, as otherwise the local var wasn't used, and generated a warning in the !KTR case. Noticed by: bde
* Add KTR tracepoints for adding/removing interrupt handlers,jhb2001-02-221-0/+8
| | | | | creating/destroying interrupt threads, and updating the state of an interrupt thread.
* Fix a bug where the 'ithread' variable was being set in a KASSERT()jhb2001-02-221-2/+2
| | | | | | | condition and thus was not initialized properly in the !INVARIANTS case. Noticed by: bde Pointy hat to: me
* Remove attempt to add in PREEMPTION #ifdef test in MI code that didn'tjhb2001-02-211-2/+0
| | | | | | work because opt_preemption.h wasn't #include'd. Instead, make use of the do_switch parameter to ithread_schedule() and do the check in the alpha interrupt code.
* - Add a new ithread_schedule() function to do the bulk of the work ofjhb2001-02-201-47/+101
| | | | | | | | | | | | | | | | scheduling an interrupt thread to run when needed. This has the side effect of enabling support for entropy gathering from interrupts on all architectures. - Change the software interrupt and x86 and alpha hardware interrupt code to use ithread_schedule() for most of their processing when scheduling an interrupt to run. - Remove the pesky Warning message about interrupt threads having entropy enabled. I'm not sure why I put that in there in the first place. - Add more error checking for parameters and change some cases that returned EINVAL to panic on failure instead via KASSERT(). - Instead of doing a documented evil hack of setting the P_NOLOAD flag on every interrupt thread whose pri was SWI_CLOCK, set the flag explicity for clk_ithd's proc during start_softintr().
* Implement a unified run queue and adjust priority levels accordingly.jake2001-02-121-6/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | - All processes go into the same array of queues, with different scheduling classes using different portions of the array. This allows user processes to have their priorities propogated up into interrupt thread range if need be. - I chose 64 run queues as an arbitrary number that is greater than 32. We used to have 4 separate arrays of 32 queues each, so this may not be optimal. The new run queue code was written with this in mind; changing the number of run queues only requires changing constants in runq.h and adjusting the priority levels. - The new run queue code takes the run queue as a parameter. This is intended to be used to create per-cpu run queues. Implement wrappers for compatibility with the old interface which pass in the global run queue structure. - Group the priority level, user priority, native priority (before propogation) and the scheduling class into a struct priority. - Change any hard coded priority levels that I found to use symbolic constants (TTIPRI and TTOPRI). - Remove the curpriority global variable and use that of curproc. This was used to detect when a process' priority had lowered and it should yield. We now effectively yield on every interrupt. - Activate propogate_priority(). It should now have the desired effect without needing to also propogate the scheduling class. - Temporarily comment out the call to vm_page_zero_idle() in the idle loop. It interfered with propogate_priority() because the idle process needed to do a non-blocking acquire of Giant and then other processes would try to propogate their priority onto it. The idle process should not do anything except idle. vm_page_zero_idle() will return in the form of an idle priority kernel thread which is woken up at apprioriate times by the vm system. - Update struct kinfo_proc to the new priority interface. Deliberately change its size by adjusting the spare fields. It remained the same size, but the layout has changed, so userland processes that use it would parse the data incorrectly. The size constraint should really be changed to an arbitrary version number. Also add a debug.sizeof sysctl node for struct kinfo_proc.
* - Move struct ithd to sys/interrupt.h.jhb2001-02-091-85/+302
| | | | | | | | | | | | | | | - Add a set of MI helper functions for interrupt threads: - ithread_create() creates a new interrupt thread - ithread_destroy() destroys an interrupt thread - ithread_add_handler() attaches a new handler to an interrupt thread - ithread_remove_handler() detaches a handler from an interrupt thread - Rename sinthand_add() and sched_swi() to swi_add() and swi_sched() respectively so that they live in a consistent namespace. - struct intrhand is no longer a public type. It would be private to kern_intr.c but the current implementation of fast interrupts on the alpha requires the type to be exported. However, all handlers should be treated as void * cookies in the way that new-bus treats them. This includes references to software interrupt handlers.
* Change and clean the mutex lock interface.bmilekic2001-02-091-6/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | mtx_enter(lock, type) becomes: mtx_lock(lock) for sleep locks (MTX_DEF-initialized locks) mtx_lock_spin(lock) for spin locks (MTX_SPIN-initialized) similarily, for releasing a lock, we now have: mtx_unlock(lock) for MTX_DEF and mtx_unlock_spin(lock) for MTX_SPIN. We change the caller interface for the two different types of locks because the semantics are entirely different for each case, and this makes it explicitly clear and, at the same time, it rids us of the extra `type' argument. The enter->lock and exit->unlock change has been made with the idea that we're "locking data" and not "entering locked code" in mind. Further, remove all additional "flags" previously passed to the lock acquire/release routines with the exception of two: MTX_QUIET and MTX_NOSWITCH The functionality of these flags is preserved and they can be passed to the lock/unlock routines by calling the corresponding wrappers: mtx_{lock, unlock}_flags(lock, flag(s)) and mtx_{lock, unlock}_spin_flags(lock, flag(s)) for MTX_DEF and MTX_SPIN locks, respectively. Re-inline some lock acq/rel code; in the sleep lock case, we only inline the _obtain_lock()s in order to ensure that the inlined code fits into a cache line. In the spin lock case, we inline recursion and actually only perform a function call if we need to spin. This change has been made with the idea that we generally tend to avoid spin locks and that also the spin locks that we do have and are heavily used (i.e. sched_lock) do recurse, and therefore in an effort to reduce function call overhead for some architectures (such as alpha), we inline recursion for this case. Create a new malloc type for the witness code and retire from using the M_DEV type. The new type is called M_WITNESS and is only declared if WITNESS is enabled. Begin cleaning up some machdep/mutex.h code - specifically updated the "optimized" inlined code in alpha/mutex.h and wrote MTX_LOCK_SPIN and MTX_UNLOCK_SPIN asm macros for the i386/mutex.h as we presently need those. Finally, caught up to the interface changes in all sys code. Contributors: jake, jhb, jasone (in no particular order)
* Remove the static splXXX functions and replace them by static __inlinepeter2001-01-191-24/+0
| | | | | stubs. Remove the xxx_imask variables which have been all but gone for a while.
* Ignore a net interrupt if the corresponding handler is nottanimura2000-12-311-1/+4
| | | | | | | registered. This fixes panic on my laptop where a spurious arp packet is received when arp is not ready to run.
* Fix another sched_sihand -> sched_swi in a KTR trace message.jhb2000-12-181-1/+1
|
* Remove the last of the MD netisr code. It is now all MI. Removejake2000-12-051-0/+27
| | | | | | | | spending, which was unused now that all software interrupts have their own thread. Make the legacy schednetisr use an atomic op for setting bits in the netisr mask. Reviewed by: jhb
* Whitespace. Fix an overly long line.jake2000-12-041-2/+2
|
* - Protect the callout wheel with a separate spin mutex, callout_lock.jake2000-11-191-1/+1
| | | | | | | | | | | - Use the mutex in hardclock to ensure no races between it and softclock. - Make softclock be INTR_MPSAFE and provide a flag, CALLOUT_MPSAFE, which specifies that a callout handler does not need giant. There is still no way to set this flag when regstering a callout. Reviewed by: -smp@, jlemon
* - Replace some instances of sched_ithd with sched_swi in KTR tracepoints.jhb2000-11-151-2/+3
| | | | - Assert that Giant is not owned during the main loop of sithd_loop().
* Ignore the INTR_MPSAFE flag when calculating the priority of an interruptjhb2000-11-101-0/+1
| | | | thread.
* Minor nit: missed ithd_loop -> sithd_loop in the KTR tracepoints.jhb2000-11-071-1/+1
|
* - Overhaul the software interrupt code to use interrupt threads for eachjhb2000-10-251-225/+160
| | | | | | | | | | | | | | | | | | | type of software interrupt. Roughly, what used to be a bit in spending now maps to a swi thread. Each thread can have multiple handlers, just like a hardware interrupt thread. - Instead of using a bitmask of pending interrupts, we schedule the specific software interrupt thread to run, so spending, NSWI, and the shandlers array are no longer needed. We can now have an arbitrary number of software interrupt threads. When you register a software interrupt thread via sinthand_add(), you get back a struct intrhand that you pass to sched_swi() when you wish to schedule your swi thread to run. - Convert the name of 'struct intrec' to 'struct intrhand' as it is a bit more intuitive. Also, prefix all the members of struct intrhand with 'ih_'. - Make swi_net() a MI function since there is now no point in it being MD. Submitted by: cp
* Catch up to moving headers:jhb2000-10-201-1/+1
| | | | | - machine/ipl.h -> sys/ipl.h - machine/mutex.h -> sys/mutex.h
* - Heavyweight interrupt threads on the alpha for device I/O interrupts.jhb2000-10-051-17/+225
| | | | | | | | | | | - Make softinterrupts (SWI's) almost completely MI, and divorce them completely from the x86 hardware interrupt code. - The ihandlers array is now gone. Instead, there is a MI shandlers array that just contains SWI handlers. - Most of the former machine/ipl.h files have moved to a new sys/ipl.h. - Stub out all the spl*() functions on all architectures. Submitted by: dfr
* - Remove the inthand2_t type and use the equivalent driver_intr_t type fromjhb2000-09-131-0/+39
| | | | | | | | | | | | | newbus for referencing device interrupt handlers. - Move the 'struct intrec' type which describes interrupt sources into sys/interrupt.h instead of making it just be a x86 structure. - Don't create 'ithd' and 'intrec' typedefs, instead, just use 'struct ithd' and 'struct intrec' - Move the code to translate new-bus interrupt flags into an interrupt thread priority out of the x86 nexus code and into a MI ithread_priority() function in sys/kern/kern_intr.c. - Remove now-uneeded x86-specific headers from sys/dev/ata/ata-all.c and sys/pci/pci_compat.c.
* Trim unused options (or #ifdef for undoc options).peter1999-10-111-1/+0
| | | | Submitted by: phk
* $Id$ -> $FreeBSD$peter1999-08-281-1/+1
|
* Stage 1 of a cleanup of the i386 interrupt registration mechanism.peter1999-04-211-405/+1
| | | | | | | Interrupts under the new scheme are managed by the i386 nexus with the awareness of the resource manager. There is further room for optimizing the interfaces still. All the users of register_intr()/intr_create() should be gone, with the exception of pcic and i386/isa/clock.c.
* add #include <sys/kernel.h> where it's needed by MALLOC_DEFINE()peter1998-11-101-3/+3
|
* Start using the new SWI registration system instead of hardwiring everything.dfr1998-09-261-9/+13
|
* Implemented dynamic registration of software interrupt handlers. Notbde1998-08-111-6/+97
| | | | | | used yet. Use dummy SWI handlers to avoid some checks for null pointers.
* Cast pointers to uintptr_t/intptr_t instead of to u_long/long,bde1998-07-151-5/+5
| | | | | | | respectively. Most of the longs should probably have been u_longs, but this changes is just to prevent warnings about casts between pointers and integers of different sizes, not to fix poorly chosen types.
* Changed the type of an isa/general interrupt handler to take abde1998-06-181-3/+2
| | | | | | `void *' arg. Fixed or hid most of the resulting type mismatches. Handlers can now be updated locally (except for reworking their global declarations in isa_device.h).
* Only build this on i386 for now. I may use it for the alpha later butdfr1998-06-111-1/+10
| | | | currently it doesn't compile.
* This commit fixes various 64bit portability problems required fordfr1998-06-071-6/+6
| | | | | | | | | | FreeBSD/alpha. The most significant item is to change the command argument to ioctl functions from int to u_long. This change brings us inline with various other BSD versions. Driver writers may like to use (__FreeBSD_version == 300003) to detect this change. The prototype FreeBSD/alpha machdep will follow in a couple of days time.
* Really finish supporting compiling with `gcc -ansi'.bde1998-04-171-2/+2
|
* Move include of <machine/ipl.h> inside ifndef SMP where it is used, toeivind1998-02-101-3/+3
| | | | avoid getting 'unused include file' warnings in the SMP case.
* - Hide the 'device doesn't supported shared interrupts' code behindnate1997-10-061-4/+5
| | | | | | bootverbose, since the older register_intr() code didn't print out anything, and the laptop support will cause lots of these un-necessary messages.
* Added a half dozen casts to eliminate annoying warnings.fsmp1997-08-211-7/+7
|
* Moved splq() to isa/ipl_funcs.c for SMP only.fsmp1997-08-201-2/+4
| | | | This is in preperation for moving all cpl accesses behind a critical region lock.
* Removed unused #includes.bde1997-08-021-4/+1
|
* Back out changes for 'conflicts' with IRQ, remove intr_registered()ache1997-07-091-7/+1
|
* Add safety check in case "conflicts" keyword specified more times thanache1997-06-081-1/+7
| | | | needed
* The defines INTR_FAST and INTR_EXCL are part of the public interface. Thedfr1997-06-021-3/+1
| | | | previous commit made them private which broke things.
* Move interrupt handling code from isa.c to a new file. This should makedfr1997-06-021-3/+3
| | | | | | | isa.c (slightly) more portable and will make my life developing the really portable version much easier. Reviewed by: peter, fsmp
* Move "typedef struct intrec {} intrec" from sys/interrupt.h to kern_intr.cpeter1997-06-011-1/+14
| | | | | | since that's the only place that it's used. Submitted by: se (apparently on suggestion from dfr)
OpenPOWER on IntegriCloud