Commit Graph

490 Commits

Author SHA1 Message Date
Thomas Moestl
d279178df7 Clean up the code exporting interrupt statistics via sysctl a bit:
- move the sysctl code to kern_intr.c
- do not use INTRCNT_COUNT, but rather eintrcnt - intrcnt to determine
  the length of the intrcnt array
- move the declarations of intrnames, eintrnames, intrcnt and eintrcnt
  from machine-dependent include files to sys/interrupt.h
- remove the hw.nintr sysctl, it is not needed.
- fix various style bugs

Requested by:	bde
Reviewed by:	bde (some time ago)
2001-06-01 13:23:28 +00:00
Alfred Perlstein
b99c886a7f lock vm while playing with pmap 2001-05-23 22:13:58 +00:00
Bruce Evans
1c1771cb5b Convert npx interrupts into traps instead of vice versa. This is much
simpler for npx exceptions that start as traps (no assembly required...)
and works better for npx exceptions that start as interrupts (there is
no longer a problem for nested interrupts).

Submitted by:	original (pre-SMPng) version by luoqi
2001-05-22 21:20:49 +00:00
Bruce Evans
17008f5343 Throw away the complications in npxsave() and their infrastructure.
npxsave() went to great lengths to excecute fnsave with interrupts
enabled in case executing it froze the CPU.  This case can't happen,
at least for Intel CPU/NPX's.  Spurious IRQ13's don't imply spurious
freezes.  Anyway, the complications were usually no-ops because IRQ13
is not used on i486's and newer CPUs, and because SMPng broke them in
rev.1.84.  Forcible enabling of interrupts was changed to
write_eflags(old_eflags), but since SMPng usually calls npxsave() from
cpu_switch() with interrupts disabled, write_eflags() usually just
kept interrupts disabled.
2001-05-20 20:04:40 +00:00
Bruce Evans
7010278935 Use a critical region to protect almost everything in npxinit().
npxinit() didn't have the usual race because it doesn't save to curpcb,
but it may have had a worse form of it since it uses the npx when it
doesn't "own" it.  I'm not sure if locking prevented this.  npxinit()
is normally caled with the proc lock but not sched_lock.

Use a critical region to protect pushing of curproc's npx state to
curpcb in npxexit().  Not doing so was harmless since it at worst
saved a wrong state to a dieing pcb.
2001-05-20 18:05:44 +00:00
John Baldwin
ddfbf9d259 - Axe the IMEN_BITS and APIC_IMEN_BITS constants.
- Add back in a definition of NHWI which is preferred over ICU_LEN.

Submitted by:	bde
2001-05-17 22:24:17 +00:00
John Baldwin
8bd57f8fc2 Remove unneeded includes of sys/ipl.h and machine/ipl.h. 2001-05-15 23:22:29 +00:00
John Baldwin
4966b0e91c Move the definition of HWI_MASK to the i386/isa/icu.h header right next to
the definition of ICU_LEN.
2001-05-15 23:11:48 +00:00
John Baldwin
d008c720b6 - Use ICU_LEN rather than NHWI for the size of the array of ithreads.
- Remove unneeded include of sys/ipl.h.
2001-05-15 22:31:08 +00:00
Bruce Evans
79d4e25bea Fixed panics in npx exception handling. When using IRQ13 exception
handling, SMPng always switches the npx context away from curproc
before calling the handler, so the handler always paniced.  When using
exception 16 exception handling, SMPng sometimes switches the npx
context away from curproc before calling the handler, so the handler
sometimes paniced.  Also, we didn't lock the context while using it,
so we sometimes didn't detect the switch and then paniced in a less
controlled way.

Just lock the context while using it, and return without doing anything
except clearing the busy latch if the context is not for curproc.  This
fixes the exception 16 case and makes the IRQ13 case harmless.  In both
cases, the instruction that caused the exception is restarted and the
exception repeats.  In the exception 16 case, we soon get an exception
that can be handled without doing anything special.  In the IRQ13 case,
we get an easy to kill hung process.
2001-05-02 13:06:58 +00:00
Mark Murray
fb919e4d5a Undo part of the tangle of having sys/lock.h and sys/mutex.h included in
other "system" header files.

Also help the deprecation of lockmgr.h by making it a sub-include of
sys/lock.h and removing sys/lockmgr.h form kernel .c files.

Sort sys/*.h includes where possible in affected files.

OK'ed by:	bde (with reservations)
2001-05-01 08:13:21 +00:00
John Baldwin
4d4bc9acc6 Add in a missing call to forward_hardclock() in the SMP case.
Submitted by:	bde
2001-04-28 01:37:44 +00:00
John Baldwin
6caa8a1501 Overhaul of the SMP code. Several portions of the SMP kernel support have
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
2001-04-27 19:28:25 +00:00
John Baldwin
adccbaa77d People are still having problems with i586_* on UP machines and SMP
machines, so just hack it to disable them for now until it can be fixed.

Inspired by hair pulling of:	asmodai
2001-04-13 17:14:53 +00:00
John Baldwin
ca7ef17c08 Remove the BETTER_CLOCK #ifdef's. The code is on by default and is here
to stay for the foreseeable future.

OK'd by:	peter (the idea)
2001-04-10 21:34:13 +00:00
John Baldwin
f34fa851e0 Catch up to header include changes:
- <sys/mutex.h> now requires <sys/systm.h>
- <sys/mutex.h> and <sys/sx.h> now require <sys/lock.h>
2001-03-28 09:17:56 +00:00
John Baldwin
0006681fe6 Switch from save/disable/restore_intr() to critical_enter/exit(). 2001-03-28 03:06:10 +00:00
Thomas Moestl
368d2edce4 Export intrnames and intrcnt as sysctls (hw.nintr, hw.intrnames and
hw.intrcnt).

Approved by:	rwatson
2001-03-23 03:45:17 +00:00
Dag-Erling Smørgrav
a6221d8c82 Show the bzero() bandwidth in kBps instead of Bps; use u_int32_t instead
of long and int64_t; and print the result as an unsigned long. This should
make the output from the bzero() test more readable, and avoid printing a
negative bandwidth. Note that this doesn't change the decision process,
since that is based on time elapsed, not on computed bandwidth.
2001-03-19 00:28:04 +00:00
John Baldwin
19eb87d22a Grab the process lock while calling psignal and before calling psignal. 2001-03-07 03:37:06 +00:00
John Baldwin
ae383d0cc7 Don't enable interrupts before calling sched_ithd for threaded interrupts.
Tested by:	obrien
2001-03-05 04:37:54 +00:00
Jake Burkholder
02318dac2c Remove the leading underscore from all symbols defined in x86 asm
and used in C or vice versa.  The elf compiler uses the same names
for both.  Remove asnames.h with great prejudice; it has served its
purpose.

Note that this does not affect the ability to generate an aout kernel
due to gcc's -mno-underscores option.

moral support from:	peter, jhb
2001-02-25 06:29:04 +00:00
John Baldwin
3e5da75445 - Add a new ithread_schedule() function to do the bulk of the work of
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().
2001-02-20 10:25:29 +00:00
Bruce Evans
12a586bbda Fixed style bugs in clock.c rev.1.164 and cpu.h rev.1.52-1.53 -- declare
tsc_present in the right places (together with other variables of the
same linkage), and don't use messy ifdefs just to avoid exporting it in
some cases.
2001-02-19 03:00:34 +00:00
Mark Murray
2564fe499d Allow the superuser to prefent all interrupt harvesting on
her system.
2001-02-18 17:47:55 +00:00
Mark Murray
d888fc4e73 RIP <machine/lock.h>.
Some things needed bits of <i386/include/lock.h> - cy.c now has its
own (only) copy of the COM_(UN)LOCK() macros, and IMASK_(UN)LOCK()
has been moved to <i386/include/apic.h> (AKA <machine/apic.h>).
Reviewed by:	jhb
2001-02-11 10:44:09 +00:00
John Baldwin
e990501c21 Re-enable preemption on interrupts. My last commit accidentally reverted
it as I was playing with some other ways of doing kernel preemption.
2001-02-10 02:41:50 +00:00
John Baldwin
5781f5419e Catch up to changes to inthand_add(). 2001-02-09 17:48:33 +00:00
John Baldwin
2e0c76cd20 Use the MI ithread helper functions in the x86 interrupt code. 2001-02-09 17:47:44 +00:00
Bosko Milekic
9ed346bab0 Change and clean the mutex lock interface.
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)
2001-02-09 06:11:45 +00:00
Jake Burkholder
05f6ee66ea Implement preemptive scheduling of hardware interrupt threads.
- If possible, context switch to the thread directly in sched_ithd(),
  rather than triggering a delayed ast reschedule.

- Disable interrupts while restoring fpu state in the trap handler,
  in order to ensure that we are not preempted in the middle, which
  could cause migration to another cpu.

Reviewed by:	peter
Tested by:	peter (alpha)
2001-02-01 03:34:20 +00:00
Peter Wemm
f444a0efe9 Convert mca (microchannel bus support) from something that we count
(bogus) to something that we test for the presence of.
2001-01-29 11:57:27 +00:00
Peter Wemm
03927d3c33 Send "#if NISA > 0" to the bit-bucket and replace it with an option.
These were compile-time "is the isa code present?" tests and not
'how many isa busses' tests.
2001-01-29 09:38:39 +00:00
Jake Burkholder
07ce8269b1 Clear intr_nesting_level when an interrupt thread has no more
handlers and wants to exit, so it doesn't panic in exit1()
which malloc()s with M_WAITOK.

Reported by:	Bob Bishop <rb@gid.co.uk>
2001-01-28 17:20:11 +00:00
John Baldwin
bb4b2d8b2a Remove the Xforward_irq IPI. 2001-01-24 10:01:13 +00:00
Jake Burkholder
a448b62ac9 Make intr_nesting_level per-process, rather than per-cpu. Setup
interrupt threads to run with it always >= 1, so that malloc can
detect M_WAITOK from "interrupt" context.  This is also necessary
in order to context switch from sched_ithd() directly.

Reviewed By:	peter
2001-01-21 19:25:07 +00:00
Jason Evans
d1c1b8413e Remove MUTEX_DECLARE() and MTX_COLD. Instead, postpone full mutex
initialization until after malloc() is safe to call, then iterate through
all mutexes and complete their initialization.

This change is necessary in order to avoid some circular bootstrapping
dependencies.
2001-01-21 07:52:20 +00:00
Jake Burkholder
c1ef8aac9e - Make npx_intr INTR_MPSAFE and move acquiring Giant into the
function itself.
- Remove a hack to allow acquiring Giant from the npx asm trap
  vector.
2001-01-20 02:30:58 +00:00
Peter Wemm
1467a651ab Convert apm from a bogus 'count' into a plain option. Clean out some
other cruft from the files.alpha and files.ia64 that were related to this.
2001-01-19 14:09:54 +00:00
John Baldwin
8339bca6db Add in a space that got lost in the previous commit in some debugging code
so that '&' becomes a binary operator and not a unary operator.
2001-01-19 11:43:13 +00:00
Peter Wemm
95bca00f46 EEK! I missed a couple of places with the 24->32 interrupt change. 2001-01-19 10:55:13 +00:00
Peter Wemm
dfb1071f3c Fix a warning (the prototypes probably shouldn't be so over-zealously
#ifdef'ed though)
2001-01-19 09:07:16 +00:00
John Baldwin
10fd583277 Free the intrhand name when free'ing a intrhand.
Submitted by:	bde
2001-01-16 02:17:51 +00:00
Peter Wemm
194b08ffc3 Implement an optimization for INTREN/INTRDIS that bde pointed out last
time I tinkered around here.  Since INTREN is called from the interrupt
critical path now, it should not be too expensive.  In this case, we
look at the bits being changed to decide which 8 bit IO port to write to
rather than unconditionally writing to both.  I could probably have gone
further and only done the write if the bits actually changed, but that
seemed overkill for the usual case in interrupt threads.

[an outb is rather expensive when it has to cross the ISA bus]
2001-01-15 04:18:58 +00:00
Jake Burkholder
ef73ae4b0c Use PCPU_GET, PCPU_PTR and PCPU_SET to access all per-cpu variables
other then curproc.
2001-01-10 04:43:51 +00:00
Jake Burkholder
41ed17bfec Use %fs to access per-cpu variables in uni-processor kernels the same
as multi-processor kernels.  The old way made it difficult for kernel
modules to be portable between uni-processor and multi-processor
kernels.  It is no longer necessary to jump through hoops.

- always load %fs with the private segment on entry to the kernel
- change the type of the self referntial pointer from struct privatespace
  to struct globaldata
- make the globaldata symbol have value 0 in all cases, so the symbols
  in globals.s are always offsets, not aliases for fields in globaldata
- define the globaldata space used for uniprocessor kernels in C, rather
  than assembler
- change the assmebly language accessors to use %fs, add a macro
  PCPU_ADDR(member, reg), which loads the register reg with the address
  of the per-cpu variable member
2001-01-06 17:40:04 +00:00
Jake Burkholder
6d43764a10 Introduce a new potientially cleaner interface for accessing per-cpu
variables from i386 assembly language.  The syntax is PCPU(member)
where member is the capitalized name of the per-cpu variable, without
the gd_ prefix.  Example: movl %eax,PCPU(CURPROC).  The capitalization
is due to using the offsets generated by genassym rather than the symbols
provided by linking with globals.o.  asmacros.h is the wrong place for
this but it seemed as good a place as any for now.  The old implementation
in asnames.h has not been removed because it is still used to de-mangle
the symbols used by the C variables for the UP case.
2000-12-13 09:23:53 +00:00
David Malone
7cc0979fd6 Convert more malloc+bzero to malloc+M_ZERO.
Submitted by:	josh@zipperup.org
Submitted by:	Robert Drehmel <robd@gmx.net>
2000-12-08 21:51:06 +00:00
Peter Wemm
5ee171d264 Cleanup some leftover lint from the old interrupt system.
Also, while here, run up to 32 interrupt sources on APIC systems.
Normalize INTREN/INTRDIS so they are the same on both UP and SMP systems
rather than sometimes a macro, and sometimes a function.

Reviewed by:  jhb, jakeb
2000-12-04 21:15:14 +00:00
Mark Murray
4a3a2f0704 Namespace cleanup. Remove some #includes in favour of an explicit
declaration.

Asked for by:	bde
2000-12-02 17:59:41 +00:00