Home | History | Annotate | Download | only in rumpkern
History log of /src/sys/rump/librump/rumpkern/intr.c
RevisionDateAuthorComments
 1.57  06-Apr-2025  riastradh rump: Set up the softint CPU bouncer only once, not once per CPU.

This is used for softint_schedule_cpu to schedule softints on other
CPUs. There is one global lock, and one global condition variable,
and really there only needs to be one thread to handle the requests.
Without this change, we reinitialize the lock and condition variable,
leaking them (and possibly leave some threads confused if they are
currently taking the lock or waiting on the condition variable as
they get reinitialized).

Leak found by lsan while investigating:

PR misc/59252: tests/rump/rumpkern/t_sp:sigsafe: out of memory
 1.56  01-Nov-2020  christos branches: 1.56.24;
PR/55664: Ruslan Nikolaev: Fix:

1. A race condition (bug) in sys/rump/librump/rumpkern/intr.c since
rumpuser_cv_signal() is called without holding a mutex
2. sleepq is implemented using a single (global) conditional
variable; that should be done per each sleepq separately
 1.55  16-Dec-2019  ad branches: 1.55.8;
- Extend the per-CPU counters matt@ did to include all of the hot counters
in UVM, excluding uvmexp.free, which needs special treatment and will be
done with a separate commit. Cuts system time for a build by 20-25% on
a 48 CPU machine w/DIAGNOSTIC.

- Avoid 64-bit integer divide on every fault (for rnd_add_uint32).
 1.54  26-Jan-2016  pooka branches: 1.54.18;
Put the kernelside rump kernel headers into <rump-sys> instead of
sprinkling them around the faction directories. Avoids having
to add a CPPFLAGS (or several) to pretty much every component
Makefile.

Leave compat headers around in the old locations.

The commit changes some autogenerated files, but I'll fix the
generators shortly and regen.
 1.53  16-Aug-2015  pooka Don't use KASSERT() to test for external return values, use panic()

from Robert Millan <rmh@freebsd.org>
 1.52  22-Apr-2015  pooka Apparently not all ports define struct clockframe in cpu.h, so we cannot
provide our definition that way. Instead, generate the struct clockframe
passed to hardclock() in MD code.
 1.51  22-Apr-2015  pooka Include kern_clock.c in rump kernels.
 1.50  21-Apr-2015  pooka Use hardclock_ticks instead of a homegrown variable.

... not that I understand how various kernel algorithms can work
after enough uptime with hardclock_ticks being a signed int.
 1.49  16-Apr-2015  pooka "extern int hz" was written in a very aesthetically pleasing way in this
file, but let's just be happy with the sys/kernel.h style of writing it.
 1.48  14-Jan-2015  pooka Execute softints in the order in which they are scheduled (per level).
 1.47  14-Jan-2015  pooka Implement softint_schedule_cpu() for rump kernels.

While distributing processing all over the place is not relevant for
high-performance rump kernel I/O stacks (and downright counterproductive),
the mechanism is used e.g. to reach a quiescent state when detaching
an interface, and therefore a semantically correct implementation is
required.

Fixes at least an uncommon race in the ifconfig destroy case.
reported & patch tested by Justin Cormack.
 1.46  22-Jun-2014  pooka branches: 1.46.4;
Initialize cpu_softcpu before creating softint threads. Fixes things
with rump kernel hypervisors which wrap the thread creation hypercall.

pointed out by Justin Cormack
 1.45  09-Jun-2014  rmind Restore the assert in RUMP's softint_schedule_cpu() and just ensure
curcpu() in the caller.
 1.44  08-Jun-2014  rmind RUMP's softint_schedule_cpu: comment out an assert for now.
 1.43  05-Jun-2014  rmind librump: add kpreempt_disabled(9) and softint_schedule_cpu(9).
 1.42  11-Nov-2013  pooka branches: 1.42.2;
Avoid calling curcpu() when we know the result is constant.
 1.41  11-Nov-2013  pooka Defer softint thread creation to first softint_establish() for that level.
Speeds up rump kernel bootstrap and saves memory -- very rarely are all
softint levels in a rump kernel used.
 1.40  02-May-2013  pooka branches: 1.40.4;
Ok, maybe using int64 for nanoseconds in the (sec,nsec) tuple was
a bit too future-proof. I think long is enough there (let's just
hope nobody redefines "nano"). Also, make seconds signed just in
case someone wants their clock to be in 1901.
 1.39  30-Apr-2013  pooka Flip parameter order in the clock hypercalls to make them consistent
with everything else wrt in/out parameters.
 1.38  28-Apr-2013  pooka Improve the time-related hypercalls so that's it's possible to
sleep until an absolute time on the host's monotonic clock (should
something like that be supported).
 1.37  27-Apr-2013  pooka roll mutex init hypercalls into one (one of them already took a flag anyway)
 1.36  21-Mar-2011  pooka branches: 1.36.4; 1.36.14;
Update copyright statements.

no functional change.
 1.35  01-Dec-2010  pooka branches: 1.35.2;
Track lwp as the rumpuser mutex owner instead of pthread_t (this
is done in rumpuser for simplicity, since on the kernel side things
we assume we have only one pointer of space). As a side-effect,
we can no longer know if the current thread is holding on to a
mutex locked without curlwp context (basically all mutexes inited
outside of mutex_init()). The only thing that called rumpuser_mutex_held()
for a non-kmutex was the giant lock. So, instead implement recursive
locking for the giant lock in the rump kernel and get rid of the
now-unused recursive pthread mutex in the hypercall interface.
 1.34  07-Sep-2010  pooka Allocate softint vectors for the final number of CPUs, not the
number currently attached. Deals with a SNAFU in my commit earlier
today which would cause softints established early to lack a
softint context on non-bootstrap CPUs.
 1.33  07-Sep-2010  pooka update comments. no code change.
 1.32  15-Aug-2010  pooka Implement softints properly: they need to have a schedulable entity
per cpu.
 1.31  10-Aug-2010  pooka Don't create the percpu clock interrupt threads as softint threads
because they aren't softint threads. This fixes callouts in
situations where there is nothing else happening in the rump kernel
(i.e. no threads executed which would trigger the softints when
they unschedule).
 1.30  10-Aug-2010  pooka Use correct indices for clock threads and more descriptive ones
for the softint threads.
 1.29  18-May-2010  martin Add missing include
 1.28  18-May-2010  pooka Make it possible to use the scheduler lock as the rumpuser condvar
interlock. This is applicable in cases where the actual interlock
is the CPU the currently running thread is scheduled on. Borrowing
the scheduler lock as the mutex mandated by pthread_cond_wait()
does away with need to have an additional mutex. This both optimizes
runtime execution and simplifies code, as the extra lock typically
lead to quite some trickeries to avoid the dungeon collapsing due
to zaps from the wand of deadlock.
 1.27  12-May-2010  pooka fix inversion: advance clock on cpu0, not the complement of cpu0
 1.26  28-Apr-2010  pooka Fix snafu which caused the clock to travel lightspeed.
 1.25  27-Apr-2010  pooka Fix multiple virtual cpu support.

... or at least on x86. CPU_INFO_FOREACH() still isn't MI, and I
don't want to support 2^n different versions.
 1.24  14-Apr-2010  pooka Include kern_tc and use a timecounter driver instead of homerolled
kern_tc implementation.
 1.23  05-Dec-2009  pooka branches: 1.23.2; 1.23.4;
Cast Oh Kath Ra once every second.
 1.22  01-Dec-2009  pooka Almost there for virtual CPU MP support:
* support bound kernel threads
* bind softint threads to specific virtual cpus
+ remove now-unnecessary locks from softint code

Now, if we only had MI CPU_INFO_FOREACH() .... (hi rmind ;)
 1.21  11-Nov-2009  pooka Make rumpuser_cv_timedwait take two int64's instead timespec to
uncouple it from the timespec layout. Also, change return value
to zero for "timeout didn't expire" and non-zero for "timeout
expired". This decouples the interface from errno assignments.
 1.20  09-Nov-2009  pooka Hash out soft interrupts to be a little closer to real softints:
* split them into levels
* allow only one per level to be active at a time
* fire softints only when we are unscheduling from a CPU instead
of immediately in softint_schedule(). this will later morph
into return from interrupt, but that part isn't done yet.
 1.19  06-Nov-2009  pooka lie that we are never in a softintr (i.e. add stub)
 1.18  19-Sep-2009  pooka arrr, implement softint_disestablish(). this code be needin' an enema, matey.
 1.17  26-Apr-2009  pooka fix uninitialized
 1.16  26-Apr-2009  pooka Fix getnano/microuptime to report actual uptime.
 1.15  27-Feb-2009  pooka decouple rumpuser gettime from struct timeval
 1.14  07-Feb-2009  pooka branches: 1.14.2;
Make the clock interrupt tick based on absolute time instead of
relative time. This prevents drifting. Also, keep track of time
within userspace, so we do not have to make a syscall to get the
clock value. This is approximately 7 times cheaper, but on the
negative side is limited to the clock interrupt frequency.
 1.13  04-Feb-2009  pooka Create the clock interrupt and soft interrupt workers as MPSAFE
 1.12  13-Jan-2009  pooka misc cleanup, mainly header polish
 1.11  18-Dec-2008  pooka __KERNEL_RCSID
 1.10  18-Dec-2008  pooka Separate the timer thread and soft interrut workers. Use a dynamic
size pool of workers to make sure there are enough for processing
the scheduled soft interrupts.
 1.9  30-Oct-2008  christos fix compilation and lint warnings.
 1.8  10-Oct-2008  pooka branches: 1.8.2;
Provide time_uptime and push it forward every now and then if we happen
to have the timer thread. rump uptime - woohoo.
 1.7  10-Oct-2008  pooka fix brainfart: kthread_create() sets curlwp
 1.6  10-Oct-2008  pooka Support callouts and call callout_hardclock() from the timer
interrupt thread.

The sleepq implementation required for callouts is horrible, kludged
only for callouts, and generally unacceptable. It needs revisiting,
but I'm not sure yet should rump or kern_timeout be improved. It's
almost untested as of now, but committing this will give me some
maneuvering space while letting application compile.
 1.5  09-Oct-2008  pooka Rewrite interrupts to provide better softintr support, i.e. not
execute them simply in the context of the scheduling code, as this
does not work for all applications (e.g. networking soft interrupts).
Rather, schedule them and execute them from a separate context.

Also provide a timer which for now executes just hardclock_callout()
(well, at least after callouts are included in librump, which is
soon).
 1.4  29-Jul-2008  pooka Install rump libraries and utilities to the base system and remove the
private non-installed build infrastructure from sys/rump.

breakdown of commit:
* install relevant headers into /usr/include/rump
* build sys/rump/librump/rumpuser and sys/rump/librump/rumpkern
from src/lib and install as librumpuser and librump, respectively
+ this retains the ability to test a librump build with just the
kernel sources at hand
* move sys/rump/fs/lib/libukfs and sys/rump/fs/lib/libp2k to src/lib
for general consumption, they are not kernel-space dwellers anyway
* build and install sys/rump/fs/lib/lib$fs as librumpfs_$fs
* add chapter 3 manual pages for rump, rumpuser, ukfs and p2k
* build and install userspace kernel file system daemons if MKPUFFS=yes
is spexified
* retire fsconsole for now, it will make a comeback with an actually
implemented version shortly
 1.3  28-Apr-2008  martin branches: 1.3.2; 1.3.4; 1.3.6;
Remove clause 3 and 4 from TNF licenses
 1.2  02-Jan-2008  ad branches: 1.2.2; 1.2.4; 1.2.6; 1.2.8; 1.2.14; 1.2.16; 1.2.18;
Merge vmlocking2 to head.
 1.1  28-Dec-2007  ad branches: 1.1.2;
file intr.c was initially added on branch vmlocking2.
 1.1.2.1  28-Dec-2007  ad Make rump build.
 1.2.18.5  09-Oct-2010  yamt sync with head
 1.2.18.4  11-Aug-2010  yamt sync with head.
 1.2.18.3  11-Mar-2010  yamt sync with head
 1.2.18.2  04-May-2009  yamt sync with head.
 1.2.18.1  16-May-2008  yamt sync with head.
 1.2.16.1  18-May-2008  yamt sync with head.
 1.2.14.3  17-Jan-2009  mjf Sync with HEAD.
 1.2.14.2  28-Sep-2008  mjf Sync with HEAD.
 1.2.14.1  02-Jun-2008  mjf Sync with HEAD.
 1.2.8.2  18-Feb-2008  mjf Sync with HEAD.
 1.2.8.1  02-Jan-2008  mjf file intr.c was added on branch mjf-devfs on 2008-02-18 21:07:22 +0000
 1.2.6.2  21-Jan-2008  yamt sync with head
 1.2.6.1  02-Jan-2008  yamt file intr.c was added on branch yamt-lazymbuf on 2008-01-21 09:47:42 +0000
 1.2.4.2  09-Jan-2008  matt sync with HEAD
 1.2.4.1  02-Jan-2008  matt file intr.c was added on branch matt-armv6 on 2008-01-09 01:58:00 +0000
 1.2.2.2  02-Jan-2008  bouyer Sync with HEAD
 1.2.2.1  02-Jan-2008  bouyer file intr.c was added on branch bouyer-xeni386 on 2008-01-02 21:57:53 +0000
 1.3.6.2  13-Dec-2008  haad Update haad-dm branch to haad-dm-base2.
 1.3.6.1  19-Oct-2008  haad Sync with HEAD.
 1.3.4.1  31-Jul-2008  simonb Sync with head.
 1.3.2.2  10-Oct-2008  skrll Sync with HEAD.
 1.3.2.1  18-Sep-2008  wrstuden Sync with wrstuden-revivesa-base-2.
 1.8.2.3  28-Apr-2009  skrll Sync with HEAD.
 1.8.2.2  03-Mar-2009  skrll Sync with HEAD.
 1.8.2.1  19-Jan-2009  skrll Sync with HEAD.
 1.14.2.1  13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.23.4.3  21-Apr-2011  rmind sync with head
 1.23.4.2  05-Mar-2011  rmind sync with head
 1.23.4.1  30-May-2010  rmind sync with head
 1.23.2.3  22-Oct-2010  uebayasi Sync with HEAD (-D20101022).
 1.23.2.2  17-Aug-2010  uebayasi Sync with HEAD.
 1.23.2.1  30-Apr-2010  uebayasi Sync with HEAD.
 1.35.2.1  06-Jun-2011  jruoho Sync with HEAD.
 1.36.14.3  03-Dec-2017  jdolecek update from HEAD
 1.36.14.2  20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.36.14.1  23-Jun-2013  tls resync from head
 1.36.4.1  22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.40.4.1  18-May-2014  rmind sync with head
 1.42.2.1  10-Aug-2014  tls Rebase.
 1.46.4.4  19-Mar-2016  skrll Sync with HEAD
 1.46.4.3  22-Sep-2015  skrll Sync with HEAD
 1.46.4.2  06-Jun-2015  skrll Sync with HEAD
 1.46.4.1  06-Apr-2015  skrll Sync with HEAD
 1.54.18.1  08-Apr-2020  martin Merge changes from current as of 20200406
 1.55.8.1  14-Dec-2020  thorpej Sync w/ HEAD.
 1.56.24.1  02-Aug-2025  perseant Sync with HEAD

RSS XML Feed