Commit Graph

41 Commits

Author SHA1 Message Date
knakahara 26cfaca81e fix the following softint parallel operation problem.
(0) softint handler "handler A" is established
(1) CPU#X does softint_schedule() for "handler A"
    - the softhand_t is set SOFTINT_PENDING flag
    - the softhand_t is NOT set SOFTINT_ACTIVE flag yet
(2) CPU#X begins other H/W interrupt processing
(3) CPU#Y does softint_disestablish() for "handler A"
    - waits until softhand_t's SOFTINT_ACTIVE of all CPUs is clear
    - the softhand_t is set not SOFTINT_ACTIVE but SOFTINT_PENDING,
      so CPU#Y does not wait
    - unset the function of "handler A"
(4) CPU#X does softint_execute()
    - the function of "handler A" is already clear, so panic
2015-12-24 02:27:14 +00:00
rmind 0132815be0 softint: implement softint_schedule_cpu() to trigger software interrupts
on the remote CPUs and add SOFTINT_RCPU flag to indicate whether this is
going to be used; implemented using asynchronous IPIs.
2014-05-25 15:42:01 +00:00
matt 25fcead210 Change two KASSERTs to KASSERTMSG 2013-09-07 03:34:59 +00:00
rmind ef8a266f76 - softint_dispatch: perform pserialize(9) switchpoint when softintr processing
finishes (without blocking).  Problem reported by hannken@, thanks!
- pserialize_read_enter: use splsoftserial(), not splsoftclock().
- pserialize_perform: add xcall(9) barrier as interrupts may be coalesced.
2013-01-07 23:21:31 +00:00
jym 325494fe33 Modify *ASSERTMSG() so they are now used as variadic macros. The main goal
is to provide routines that do as KASSERT(9) says: append a message
to the panic format string when the assertion triggers, with optional
arguments.

Fix call sites to reflect the new definition.

Discussed on tech-kern@. See
http://mail-index.netbsd.org/tech-kern/2011/09/07/msg011427.html
2011-09-27 01:02:33 +00:00
uebayasi 7a93829794 Revert previous; s/kmem(9)/uvm_km(9)/ and comment why done so. Per request
from rmind@.
2011-07-31 13:41:30 +00:00
uebayasi 2eba9539a6 Use kmem(9) to allocate per-cpu softint context. No functional changes. 2011-07-30 05:24:16 +00:00
rmind bd5b92d68b - Replace few malloc(9) uses with kmem(9).
- Rename buf_malloc() to buf_alloc(), fix comments.
- Remove some unnecessary inclusions.
2011-04-24 18:46:22 +00:00
rmind 2ca6f25dde softint_execute: add assert which could catch locking bugs in softint handlers. 2011-04-11 19:13:54 +00:00
matt 6a66466f0c Move counting of faults, traps, intrs, soft[intr]s, syscalls, and nswtch
from uvmexp to per-cpu cpu_data and move them to 64bits.  Remove unneeded
includes of <uvm/uvm_extern.h> and/or <uvm/uvm.h>.
2010-12-20 00:25:23 +00:00
matt b7a7b9b8bc Make sure all for loops use { } 2010-12-11 22:32:13 +00:00
rmind a4c32a06f6 softint_overlay: disable kernel preemption before curlwp->l_cpu use. 2010-01-09 19:02:17 +00:00
rmind 8431ea0b5e softint_execute: release/re-acquire kernel-lock depending on SOFTINT_MPSAFE
flag.  Keeping it held for MP-safe cases break the lock order assumptions.
Per discussion with <martin>.
2010-01-08 12:10:46 +00:00
yamt 0436400c70 set LP_RUNNING when starting lwp0 and idle lwps.
add assertions.
2009-07-19 10:11:55 +00:00
bouyer 8ebd73cde8 Back out rev 1.27 now that MD implementations of spl*() have been fixed
to be a memory barrier.
2009-05-18 21:31:27 +00:00
bouyer f48b5c49cc Declare sh_flags volatile.
Without it, on ports where splhigh() is inline, the compiler will optimise
the second SOFTINT_PENDING test in softint_schedule(). A dissasembly
of softint_schedule() with and without the volatile sh_flags confirm this
on sparc.
Because of this there is a race that could lead to the softhand_t
being enqueued twice on si_q, leading to a corrupted queue and
some handler being SOFTINT_PENDING but never called.

Should fix PR kern/38637
2009-05-05 20:26:36 +00:00
dyoung ac5f968c78 Fix spelling. 2009-04-06 21:22:47 +00:00
ad a190625ad7 softint_disestablish: don't pass softint_lock to kpause, it's not held. 2009-01-01 12:26:46 +00:00
ad 70a01ab869 softint_disestablish: the soft interrupt could still be running on a CPU
somewhere in the system. If it is, wait for it to complete before tearing
it down. The caller commits to not trigger the interrupt again once
disestablish is set in motion.
2008-12-13 21:13:30 +00:00
pooka 2002727b2c Give maximum level of network softinterrupts a symbolic constant
(which happened to get bumbed from 32 to 33 (AF_MAX) now).
2008-10-14 17:15:20 +00:00
ad 2feabc3836 PR kern/38812 race between lwp_exit_switchaway and exit1/coredump
Move the LWP RUNNING and TIMEINTR flags into the thread-private flag word.
2008-05-31 21:26:01 +00:00
ad 208df81d99 Move lwp_exit_switchaway() into kern_synch.c. Instead of always switching
to the idle loop, pick a new LWP from the run queue.
2008-05-27 17:51:17 +00:00
ad ffc4969f6e Don't count many items as EVCNT_TYPE_INTR because they clutter up the
systat vmstat display.
2008-04-28 23:00:22 +00:00
ad b96eb5aec9 Make the preemption switch a __HAVE instead of an option. 2008-04-28 21:17:16 +00:00
martin ce099b4099 Remove clause 3 and 4 from TNF licenses 2008-04-28 20:22:51 +00:00
ad 4c7ba24481 Add MI code to support in-kernel preemption. Preemption is deferred by
one of the following:

- Holding kernel_lock (indicating that the code is not MT safe).
- Bracketing critical sections with kpreempt_disable/kpreempt_enable.
- Holding the interrupt priority level above IPL_NONE.

Statistics on kernel preemption are reported via event counters, and
where preemption is deferred for some reason, it's also reported via
lockstat. The LWP priority at which preemption is triggered is tuneable
via sysctl.
2008-04-28 15:36:01 +00:00
ad 15e29e981b Merge the socket locking patch:
- Socket layer becomes MP safe.
- Unix protocols become MP safe.
- Allows protocol processing interrupts to safely block on locks.
- Fixes a number of race conditions.

With much feedback from matt@ and plunky@.
2008-04-24 11:38:36 +00:00
ad d87d01d660 Fix typo. Spotted by kardel@. 2008-04-12 18:22:03 +00:00
ad da60beabf5 softint_overlay: bind the stolen LWP to the current CPU while processing,
to prevent it blocking and migrating to another CPU.
2008-04-12 17:17:28 +00:00
ad a0bce9fd99 softint_execute: add more assertions. 2008-03-20 19:12:23 +00:00
martin d8788e7fd7 Use cpu index instead of the machine dependend, not very expressive
cpuid when naming user-visible kernel entities.
2008-03-10 22:20:14 +00:00
yamt caca6daa1a softint_dispatch: fix softint_timing. 2008-02-06 15:34:36 +00:00
ad 1b6e5c8b2e Remove reference to lockmgr(). 2008-01-29 18:06:14 +00:00
yamt 949e16d902 use binuptime for l_stime/l_rtime. 2007-12-22 01:14:53 +00:00
ad 7b8aa25abc Change the ncpu test to work when a pool_cache or softint is initialized
between mi_cpu_attach() and attachment of the boot CPU. Suggested by mrg@.
2007-12-11 19:07:27 +00:00
ad eb83663daa softint_establish: hack around CPU_INFO_FOREACH() not working before
configure() on some architectures.
2007-12-10 20:43:43 +00:00
ad 9027344d32 For the slow path soft interrupts, arrange to have the priority of a
borrowed user LWP raised into the 'kernel RT' range if the LWP sleeps
(which is unlikely).
2007-12-03 17:14:59 +00:00
ad 4b293a84e1 Interrupt handling changes, in discussion since February:
- Reduce available SPL levels for hardware devices to none, vm, sched, high.
- Acquire kernel_lock only for interrupts at IPL_VM.
- Implement threaded soft interrupts.
2007-12-03 15:33:00 +00:00
ad d831186d55 Merge scheduler changes from the vmlocking branch. All discussed on
tech-kern:

- Invert priority space so that zero is the lowest priority. Rearrange
  number and type of priority levels into bands. Add new bands like
  'kernel real time'.
- Ignore the priority level passed to tsleep. Compute priority for
  sleep dynamically.
- For SCHED_4BSD, make priority adjustment per-LWP, not per-process.
2007-11-06 00:42:39 +00:00
ad 36a1712707 Merge run time accounting changes from the vmlocking branch. These make
the LWP "start time" per-thread instead of per-CPU.
2007-10-08 20:06:17 +00:00
ad 342d5fc94f Add stubs that provide new soft interrupt API from the vmlocking branch.
For now these just pass through to the current softintr code.

(The naming is different to allow softint/softintr to co-exist for a while.
I'm hoping that should make it easier to transition.)
2007-10-08 15:51:02 +00:00