Commit Graph

1252 Commits

Author SHA1 Message Date
Matt Jacob
140509ab5d fix it so it compiles again after twerpage elsewhere 2001-04-23 18:38:01 +00:00
Matt Jacob
ac60aa4908 Fix includes so it compiles again. 2001-04-23 18:08:54 +00:00
Andrew Gallatin
62dbd2f29e Block out all interrupts, even machine checks, for critical_enter()
This is will be required to prevent lowering the ipl when a critical_enter()
is present in the interrupt path when handling a machine check.

reviewed by: jhb
2001-04-21 21:44:39 +00:00
Andrew Gallatin
29b3d1c151 GC some debugging code that's been #if 0'ed since we got the file from
NetBSD
2001-04-20 00:55:21 +00:00
John Baldwin
08b0f4f908 Convert the protection of hte i8254 from critical_enter/exit like it is
on the x86.
2001-04-18 21:47:48 +00:00
John Baldwin
e18935281b Back out the previous revision as it causes random sig 11's to userland
processes until a better fix is found.

Submitted by:	gallatin
2001-04-18 17:17:55 +00:00
John Baldwin
5d52039847 Save are floating point state in cpu_switch() if needed instead of relying
completely on lazy floating point state saving.  This is needed for the
SMP case since processes can migrate to other CPUs.

Submitted by:	dfr
2001-04-17 18:27:55 +00:00
Andrew Gallatin
73f446d078 set gd_other_cpus later, when we have a better idea what the other cpus
are.

submitted by: jhb
2001-04-17 14:59:05 +00:00
Andrew Gallatin
386eac30d9 Improved support for alpha SMP. The following commit gets dual AS2100s
and AS4100s into single user mode. This work was done jointly by jhb and
myself, and builds on dfr's earlier work.

smp_init_secondary() / smp_start_secondary()
- use the uniq val to pass the globalp (me)
- fancy footwork to take any pending machine checks (me)
- doing things the FreeBSD way and getting the per-cpu idleproc created
  correctly, and synchronizing the startup of secondaries (jhb)

mp_start()
- better recognition of available cpus (jhb)

smp_rendezvous()
- if smp hasn't started, only run the rendezvous function on the current
cpu.  Sleuthing and (prior) incorrect fix by me, correct fix by jhb

smp_handle_ipi()
- more verbose handling of console messages (jhb)
- grab sched lock around setting PS_ASTPENDING (jhb)

forward_*clock()
- commented out.  Joint decision by dfr, jhb and myself

 General synchronization improvements (more mb()s, etc) (jhb)

 Printf cleanups (joint)

 Whitespace cleanups (jhb)
2001-04-17 14:55:09 +00:00
Andrew Gallatin
3706fa1be6 Changes to support SMP:
- don't do the stack overflow sanity check on MP systems -- p->p_addr
will be malloc'ed memory (not K0SEG) and the check will fail.

- don't ignore clock interrupts on secondaries.  Alphas apparently
roundrobin clock interrupts to all cpus, so we're going to take clock
interrupts on all CPUS and not forward them.
2001-04-17 14:20:33 +00:00
Andrew Gallatin
ed4835b64d changes to smp_init_secondary_glue():
- use the unique value to save the per-cpu globalp struct like the
  comment says

- don't lower the ipl to ALPHA_PSL_IPL_HIGH: we may have a pending machine
  check to take and we're not prepared for that yet, as we haven't setup
  our interrupt entry points. (this may only happen on sable/lynx)

- indicate the fact that the working version of smp_init_secondary() doesn't
  return (this is tied up in other changes and hasn't yet been committed).
2001-04-17 14:15:12 +00:00
John Baldwin
abd9053ee4 Blow away the panic mutex in favor of using a single atomic_cmpset() on a
panic_cpu shared variable.  I used a simple atomic operation here instead
of a spin lock as it seemed to be excessive overhead.  Also, this can avoid
recursive panics if, for example, witness is broken.
2001-04-17 04:18:08 +00:00
John Baldwin
8c321ed95f - Add appropriate #ifndef/#define/#endif to protect against multiple
inclusions.
- Blow away all evidence of a static curpcb as curpcb is a per-CPU variable
  and this definition is now bogus.
2001-04-17 02:51:28 +00:00
John Baldwin
2bec909c3d - Fix memory barriers in atomic operations so that the barriers are always
"inside" of locked regions.  That is, an acquire atomic operation will
  always enforce a memory barrier after the atomic operation and a release
  operation will always enforce a memory barrier before the atomic
  operation.
- Explicitly use 'mb' instead of 'wmb' in release atomic operations.  The
  'wmb' memory barrier is not strong enough to guarantee coherence with
  other processors.  This is effectively a nop since alpha_wmb() actually
  performs a 'mb' and not a 'wmb', but I wanted the code to be more
  correct since at some point in the future alpha_wmb()'s implementation
  may switch to being a real 'wmb'.
2001-04-17 02:50:05 +00:00
John Baldwin
85eba1489b Add a cpu_throw() function that secondary CPU's can use for their first
context switch.
2001-04-17 02:46:13 +00:00
John Baldwin
0f98ef505a In exception_return(), test for usermode before testing the IPL to see if
we should call ast().  This allows us to branch to a separate Lkernelret
label so we can fixup the saved t7 register in the trapframe.  Otherwise
we can run into a problem on SMP systems where a process is interrupted by
a trap or interrupt on one CPU, migrates to another CPU, and then returns
with the t7 in the stack clobbering the CPU's t7.  As a result, two CPU's
would both point to the same per-CPU data and things would go downhill from
there.

Sleuthing help by:	gallatin
2001-04-17 02:44:35 +00:00
John Baldwin
1a72a97045 - Stop other CPU's in the SMP case when we enter ddb.
- Add a new ddb command: 'show pcpu' similar to the i386 command added
  recently.  By default it displays the current CPU's info, but an optional
  argument can specify the logical ID of a specific CPU to examine.
2001-04-17 02:41:41 +00:00
David E. O'Brien
c5e70d92ce Turn on kernel debugging support (DDB, INVARIANTS, INVARIANT_SUPPORT, WITNESS)
by default while SMPng is still being developed.

Submitted by:	jhb
2001-04-15 19:37:28 +00:00
John Baldwin
2fea957dc5 Rename the IPI API from smp_ipi_* to ipi_* since the smp_ prefix is just
"redundant noise" and to match the IPI constant namespace (IPI_*).

Requested by:	bde
2001-04-11 17:06:02 +00:00
John Baldwin
45fdf62519 Parse the various argument registers in the printtrap() function so that
one doesn't have to go grab a reference manual to decode them by hand every
time the alpha kernel falls over.

Reviewed by:	drew, -alpha
2001-04-11 16:20:11 +00:00
Andrew Gallatin
ceca66bb01 insert a magical second memory barrier prior to calling draina() in
badaddr_read().  This fixes 'machine check in pal mode' halts on
ev5 2100As.

MFC candidate -- after spending 6 hours tracking this down, I checked and
discovered that it has been in NetBSD for over a year, so it should be safe
for MFC into 4.3-RELEASE
2001-04-08 16:43:59 +00:00
Andrew Gallatin
9a44dfa794 Regen after adding linux_sched_get_priority_max() and
linux_sched_get_priority_min()
2001-04-03 18:01:41 +00:00
Andrew Gallatin
a7f70675e9 Add linux_sched_get_priority_max() and linux_sched_get_priority_min() to
alpha md code & unbreak kernel build
2001-04-03 17:58:44 +00:00
Andrew Gallatin
bb193d2a6b Recognize a few newer cpus (pca57, ev67 & ev68) and update systypes to
include "CUSCO" and "Eiger" while I'm at it.
2001-03-30 22:04:08 +00:00
David E. O'Brien
083c3fbb6f Removed the ``#if 0'' that turned bounds_check_with_label() into worse
than a NOP.  bounds_check_with_label() would return -1 yet NOT set any
of the bio flags to show an error.  This meant the caller would not
properly see that bounds_check_with_label() did not do any work.  This
prevented newfs(8) from being able to write a file system on any partition
other than `c' on a `ccd'.

The logs of this file do not tell _why_ bounds_check_with_label() was
emasculated.  Nor are there any `XXX' comments.  So we'll unemasculated
it, and see what breaks.

Submitted by:	gallatin
2001-03-29 20:18:45 +00:00
Andrew Gallatin
57d4ab2d3e resurrect the declaration of order to unbreak kernel build. Put
it inside the ifdef so as to avoid unused variable warnings
2001-03-28 19:02:08 +00:00
John Baldwin
1005a129e5 Convert the allproc and proctree locks from lockmgr locks to sx locks. 2001-03-28 11:52:56 +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
192846463a Rework the witness code to work with sx locks as well as mutexes.
- Introduce lock classes and lock objects.  Each lock class specifies a
  name and set of flags (or properties) shared by all locks of a given
  type.  Currently there are three lock classes: spin mutexes, sleep
  mutexes, and sx locks.  A lock object specifies properties of an
  additional lock along with a lock name and all of the extra stuff needed
  to make witness work with a given lock.  This abstract lock stuff is
  defined in sys/lock.h.  The lockmgr constants, types, and prototypes have
  been moved to sys/lockmgr.h.  For temporary backwards compatability,
  sys/lock.h includes sys/lockmgr.h.
- Replace proc->p_spinlocks with a per-CPU list, PCPU(spinlocks), of spin
  locks held.  By making this per-cpu, we do not have to jump through
  magic hoops to deal with sched_lock changing ownership during context
  switches.
- Replace proc->p_heldmtx, formerly a list of held sleep mutexes, with
  proc->p_sleeplocks, which is a list of held sleep locks including sleep
  mutexes and sx locks.
- Add helper macros for logging lock events via the KTR_LOCK KTR logging
  level so that the log messages are consistent.
- Add some new flags that can be passed to mtx_init():
  - MTX_NOWITNESS - specifies that this lock should be ignored by witness.
    This is used for the mutex that blocks a sx lock for example.
  - MTX_QUIET - this is not new, but you can pass this to mtx_init() now
    and no events will be logged for this lock, so that one doesn't have
    to change all the individual mtx_lock/unlock() operations.
- All lock objects maintain an initialized flag.  Use this flag to export
  a mtx_initialized() macro that can be safely called from drivers.  Also,
  we on longer walk the all_mtx list if MUTEX_DEBUG is defined as witness
  performs the corresponding checks using the initialized flag.
- The lock order reversal messages have been improved to output slightly
  more accurate file and line numbers.
2001-03-28 09:03:24 +00:00
John Baldwin
0006681fe6 Switch from save/disable/restore_intr() to critical_enter/exit(). 2001-03-28 03:06:10 +00:00
John Baldwin
6283b7d01b - Switch from using save/disable/restore_intr to using critical_enter/exit
and change the u_int mtx_saveintr member of struct mtx to a critical_t
  mtx_savecrit.
- On the alpha we no longer need a custom _get_spin_lock() macro to avoid
  an extra PAL call, so remove it.
- Partially fix using mutexes with WITNESS in modules.  Change all the
  _mtx_{un,}lock_{spin,}_flags() macros to accept explicit file and line
  parameters and rename them to use a prefix of two underscores.  Inside
  of kern_mutex.c, generate wrapper functions for
  _mtx_{un,}lock_{spin,}_flags() (only using a prefix of one underscore)
  that are called from modules.  The macros mtx_{un,}lock_{spin,}_flags()
  are mapped to the __mtx_* macros inside of the kernel to inline the
  usual case of mutex operations and map to the internal _mtx_* functions
  in the module case so that modules will use WITNESS and KTR logging if
  the kernel is compiled with support for it.
2001-03-28 02:40:47 +00:00
John Baldwin
034dc442ad - Add the new critical_t type used to save state inside of critical
sections.
- Add implementations of the critical_enter() and critical_exit() functions
  and remove restore_intr() and save_intr().
- Remove the somewhat bogus disable_intr() and enable_intr() functions on
  the alpha as the alpha actually uses a priority level and not simple bit
  flag on the CPU.
2001-03-28 02:31:54 +00:00
John Baldwin
090697c65b Revert previous commit which had a bogus message. It actually just
disabled the somewhat annoying KTR log trace for clock interrupts.
2001-03-28 02:03:29 +00:00
John Baldwin
82da2f64b3 - Include <machine/prom.h> to get the prototype for prom_halt().
- If there is no gdb device, just return without trying to return any
  value since gdb_handle_exception() returns void.
- When calling prom_halt(), pass in a value telling it to actually halt
  and not to randomly choose whether or not to halt or reboot depending on
  whatever value happened to be in a0 when the call was made.
2001-03-28 01:54:06 +00:00
Andrew Gallatin
919eea6db9 Check whether we need to do a full restore after handling ASTs. If
an AST results in a signal being delivered, we'll need to do a full register
restore so as to properly setup the signal handler.  This is somewhat of
a pessimization, because ast() will be called twice in this case.

This fixes several problems that have been reported where signal intensive
userland apps (most notably dump) have been SEGV'ing for no fault of their
own.

Thanks to Peter Jeremy <peter.jeremy@alcatel.com.au> for presenting the
AST scenario which led to me fiinally figuring this out.

Reviewed by: jhb
2001-03-28 01:19:41 +00:00
Poul-Henning Kamp
f83880518b Send the remains (such as I have located) of "block major numbers" to
the bit-bucket.
2001-03-26 12:41:29 +00:00
Hajimu UMEMOTO
8b625cb701 Unbreak build on alpha.
- Move in_port_t to sys/types.h.
  - Nuke in_addr_t from each endian.h.

Reported by:	jhb
2001-03-24 15:17:27 +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
Peter Wemm
6eb39ac8fc Use a generic implementation of the Fowler/Noll/Vo hash (FNV hash).
Make the name cache hash as well as the nfsnode hash use it.

As a special tweak, create an unsigned version of register_t.  This allows
us to use a special tweak for the 64 bit versions that significantly
speeds up the i386 version (ie: int64 XOR int64 is slower than int64
XOR int32).

The code layout is a little strange for the string function, but I was
able to get between 5 to 10% improvement over the original version I
started with. The layout affects gcc code generation choices and this way
was fastest on x86 and alpha.

Note that 'CPUTYPE=p3' etc makes a fair difference to this.  It is
around 45% faster with -march=pentiumpro on a p6 cpu.
2001-03-17 09:31:06 +00:00
Andrew Gallatin
283da0012f prevent gdb from panic'ing an alpha with "mutex Giant not owned"
reviewed by: jhb
2001-03-16 21:44:21 +00:00
Andrew Gallatin
64007795de remove bogus check -- for kernel threads we fork off of proc0, not curproc
This was causing panics when modules which create kthreads were loaded
after boot.

pointed out by: jake, jhb
2001-03-15 02:32:26 +00:00
John Baldwin
0fb8828fe2 - Call fork1() directly instead of calling rfork() so that it doesn't mask
out RFSTOPPED.
- Lock the child process when settings p_sigparent instead of locking the
  parent.

Pointy-hat to:	me
2001-03-11 23:41:55 +00:00
John Baldwin
5db078a9be Fix mtx_legal2block. The only time that it is bad to block on a mutex is
if we hold a spin mutex, since we can trivially get into deadlocks if we
start switching out of processes that hold spinlocks.  Checking to see if
interrupts were disabled was a sort of cheap way of doing this since most
of the time interrupts were only disabled when holding a spin lock.  At
least on the i386.  To fix this properly, use a per-process counter
p_spinlocks that counts the number of spin locks currently held, and
instead of checking to see if interrupts are disabled in the witness code,
check to see if we hold any spin locks.  Since child processes always
start up with the sched lock magically held in fork_exit(), we initialize
p_spinlocks to 1 for child processes.  Note that proc0 doesn't go through
fork_exit(), so it starts with no spin locks held.

Consulting from:	cp
2001-03-09 07:24:17 +00:00
John Baldwin
136d8f42b9 Unrevert the pmap_map() changes. They weren't broken on x86.
Sense beaten into me by:	peter
2001-03-07 05:29:21 +00:00
John Baldwin
f227364a17 - Release Giant a bit earlier on syscall exit.
- Don't try to grab Giant before postsig() in userret() as it is no longer
  needed.
- Don't grab Giant before psignal() in ast() but get the proc lock instead.
2001-03-07 03:53:39 +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
ff655691d8 Use the proc lock to protect p_pptr when waking up our parent in cpu_exit()
and remove the mpfixme() message that is now fixed.
2001-03-07 03:20:15 +00:00
John Baldwin
88411ba791 Just use proc lock to protect reading of p_pptr rather than a proctree
lock.
2001-03-07 03:18:36 +00:00
John Baldwin
4a01ebd482 Back out the pmap_map() change for now, it isn't completely stable on the
i386.
2001-03-07 01:04:17 +00:00
John Baldwin
968950e5d1 - Rework pmap_map() to take advantage of direct-mapped segments on
supported architectures such as the alpha.  This allows us to save
  on kernel virtual address space, TLB entries, and (on the ia64) VHPT
  entries.  pmap_map() now modifies the passed in virtual address on
  architectures that do not support direct-mapped segments to point to
  the next available virtual address.  It also returns the actual
  address that the request was mapped to.
- On the IA64 don't use a special zone of PV entries needed for early
  calls to pmap_kenter() during pmap_init().  This gets us in trouble
  because we end up trying to use the zone allocator before it is
  initialized.  Instead, with the pmap_map() change, the number of needed
  PV entries is small enough that we can get by with a static pool that is
  used until pmap_init() is complete.

Submitted by:		dfr
Debugging help:		peter
Tested by:		me
2001-03-06 06:06:42 +00:00