Home | History | Annotate | Download | only in kern
History log of /src/sys/kern/subr_pserialize.c
RevisionDateAuthorComments
 1.24  04-Oct-2023  ad Eliminate l->l_ncsw and l->l_nivcsw. From memory think they were added
before we had per-LWP struct rusage; the same is now tracked there.
 1.23  16-Apr-2023  riastradh pserialize(9): Fix buggy assertion inside assertion.

If there has been a context switch, then we can't be in a pserialize
read section -- _and_ whatever we read out of curcpu() is stale, so
we can't assert anything based on it. So just delete the assertion.

Reported-by: syzbot+d7065ab16d7cd9cc09af@syzkaller.appspotmail.com
https://syzkaller.appspot.com/bug?id=0c63db890575d29c6a51fb24b003d3bab1f7f04b
 1.22  14-Apr-2023  riastradh pserialize(9): Fix bug in recent micro-optimization.

curcpu() is always a valid struct cpu_info pointer, but curlwp->l_cpu
is not necessarily -- early at boot on some architectures (like x86,
apparently) it may be null.

Not clear that l->l_cpu is always a cost win over curcpu(): on some
architectures curcpu() is basically a macro for curlwp->l_cpu, while
on others it is a fixed VA. So let's use the one that always works
instead of the one that's sometimes cheaper and sometimes crashier.
 1.21  09-Apr-2023  riastradh pserialize(9): Micro-optimize pserialize_read_exit.

Most of the time we're not cold, so let's convince gcc to make that a
statically predicted-not-taken branch.
 1.20  09-Apr-2023  riastradh pserialize(9): Micro-optimize pserialize_not_in_read_section_p.

Load l_ncsw to test whether we have been preempted, rather than
loading and storing l_nopreempt (via function call) to prevent it.
 1.19  15-Nov-2022  macallan don't KASSERT(kpreempt_disabled()) while cold
pserialize_read_*() can be called *very* early in kernel startup these days
 1.18  10-Oct-2021  riastradh pserialize(9): Lift rule that pserialize_perform be serialized.

There may have been a technical reason for this back when we were
following the expired passive serialization patent to the letter, but
no more -- and this is a real burden for some applications.
 1.17  05-Dec-2019  riastradh Switch psz_ev_excl to static evcnt.
 1.16  05-Dec-2019  riastradh Restore psz_lock just for the event count.

Cost of mutex_enter/exit is negligible compared to the xcall we just
did, so this is not going to meaningfully affect performance.
 1.15  03-Dec-2019  martin Stopgap hack to unbreak the build: #ifdef __HAVE_ATOMIC64_LOADSTORE
the event counter update. From rmind@
 1.14  03-Dec-2019  riastradh Rip out pserialize(9) logic now that the RCU patent has expired.

pserialize_perform() is now basically just xc_barrier(XC_HIGHPRI).
No more tentacles throughout the scheduler. Simplify the psz read
count for diagnostic assertions by putting it unconditionally into
cpu_info.

From rmind@, tidied up by me.
 1.13  06-Oct-2019  uwe xc_barrier - convenience function to xc_broadcast() a nop.

Make the intent more clear and also avoid a bunch of (xcfunc_t)nullop
casts that gcc 8 -Wcast-function-type is not happy about.
 1.12  14-Aug-2018  ozaki-r Change the place to check if a context switch doesn't happen within a pserialize read section

The previous place (pserialize_switchpoint) was not a good place because at that
point a suspect thread is already switched so that a backtrace gotten on
a KASSERT failure doesn't point out where a context switch happens.
 1.11  16-Apr-2018  hannken branches: 1.11.2;
Function pserialize_perform() usually succeeds after two cross calls
so defer kpause() to iterations three and above.

Speeds up VOP_REVOKE() on /proc/XXX/status by a factor of ~12.

Ok: core@
 1.10  28-Dec-2017  msaitoh branches: 1.10.2;
Prevent panic or hangup in softint_disestablish(), pserialize_perform() or
psref_target_destroy() while mp_online == false.

See http://mail-index.netbsd.org/tech-kern/2017/12/25/msg022829.html
 1.9  21-Nov-2017  ozaki-r Implement debugging feature for pserialize(9)

The debugging feature detects violations of pserialize constraints.
It causes a panic:
- if a context switch happens in a read section, or
- if a sleepable function is called in a read section.

The feature is enabled only if LOCKDEBUG is on.

Discussed on tech-kern@
 1.8  12-Jun-2015  dholland branches: 1.8.10;
Typo in comment.
 1.7  07-Feb-2013  rmind branches: 1.7.14;
- pserialize_switchpoint: check for passing twice, not more than needed.
- pserialize_perform: avoid a possible race with softint handler.
Reported by hannken@.
 1.6  07-Jan-2013  rmind - 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.
 1.5  29-Jan-2012  rmind branches: 1.5.2; 1.5.6; 1.5.8;
- Add mi_cpu_init() and initialise cpu_lock and kcpuset_attached/running there.
- Add kcpuset_running which gets set in idle_loop().
- Use kcpuset_running in pserialize_perform().
 1.4  07-Aug-2011  rmind branches: 1.4.2; 1.4.6;
- Add an argument to kcpuset_create() for zeroing.
- Add kcpuset_atomic_set(), kcpuset_atomic_clear() and kcpuset_merge().
 1.3  07-Aug-2011  rmind Add kcpuset(9) - a reworked dynamic CPU set implementation for kernel.
Suitable for use during the early boot. MD and other implementations
should be replaced with this interface.

Discussed on: tech-kern@
 1.2  01-Aug-2011  he Need to include <sys/evcnt.h> explicitly to build this on at least amiga.
 1.1  30-Jul-2011  christos Add an implementation of passive serialization as described in expired
US patent 4809168. This is a reader / writer synchronization mechanism,
designed for lock-less read operations.
 1.4.6.1  18-Feb-2012  mrg merge to -current.
 1.4.2.3  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.4.2.2  23-Jan-2013  yamt sync with head
 1.4.2.1  17-Apr-2012  yamt sync with head
 1.5.8.2  11-Feb-2013  riz Pull up following revision(s) (requested by rmind in ticket #811):
sys/kern/subr_pserialize.c: revision 1.7
- pserialize_switchpoint: check for passing twice, not more than needed.
- pserialize_perform: avoid a possible race with softint handler.
Reported by hannken@.
 1.5.8.1  08-Feb-2013  riz Pull up following revision(s) (requested by rmind in ticket #782):
sys/rump/include/machine/intr.h: revision 1.19
sys/kern/subr_pserialize.c: revision 1.6
sys/kern/kern_softint.c: revision 1.39
- 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.
Provide splsoftserial.
GRRR RUMP
 1.5.6.2  03-Dec-2017  jdolecek update from HEAD
 1.5.6.1  25-Feb-2013  tls resync with head
 1.5.2.2  11-Feb-2013  riz Pull up following revision(s) (requested by rmind in ticket #811):
sys/kern/subr_pserialize.c: revision 1.7
- pserialize_switchpoint: check for passing twice, not more than needed.
- pserialize_perform: avoid a possible race with softint handler.
Reported by hannken@.
 1.5.2.1  08-Feb-2013  riz Pull up following revision(s) (requested by rmind in ticket #782):
sys/rump/include/machine/intr.h: revision 1.19
sys/kern/subr_pserialize.c: revision 1.6
sys/kern/kern_softint.c: revision 1.39
- 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.
Provide splsoftserial.
GRRR RUMP
 1.7.14.1  22-Sep-2015  skrll Sync with HEAD
 1.8.10.3  17-Apr-2018  martin Pull up following revision(s) (requested by hannken in ticket #771):

sys/kern/subr_pserialize.c: revision 1.11

Function pserialize_perform() usually succeeds after two cross calls
so defer kpause() to iterations three and above.

Speeds up VOP_REVOKE() on /proc/XXX/status by a factor of ~12.

Ok: core@
 1.8.10.2  22-Jan-2018  martin Pull up following revision(s) (requested by jdolecek in ticket #506):
sys/kern/kern_softint.c: revision 1.45
sys/rump/librump/rumpkern/rump.c: revision 1.331
sys/kern/subr_pserialize.c: revision 1.10
sys/kern/subr_psref.c: revision 1.10
Prevent panic or hangup in softint_disestablish(), pserialize_perform() or
psref_target_destroy() while mp_online == false.
See http://mail-index.netbsd.org/tech-kern/2017/12/25/msg022829.html
Set mp_online = true. This change might fix PR#52886.
 1.8.10.1  30-Nov-2017  martin Pull up following revision(s) (requested by ozaki-r in ticket #405):
sys/sys/pserialize.h: revision 1.2
sys/kern/kern_lock.c: revision 1.160
sys/kern/subr_pserialize.c: revision 1.9
sys/rump/librump/rumpkern/emul.c: revision 1.184
sys/rump/librump/rumpkern/emul.c: revision 1.185
sys/rump/librump/rumpkern/rump.c: revision 1.330
Implement debugging feature for pserialize(9)
The debugging feature detects violations of pserialize constraints.
It causes a panic:
- if a context switch happens in a read section, or
- if a sleepable function is called in a read section.
The feature is enabled only if LOCKDEBUG is on.
Discussed on tech-kern@
Add missing inclusion of pserialize.h (fix build)
 1.10.2.2  06-Sep-2018  pgoyette Sync with HEAD

Resolve a couple of conflicts (result of the uimin/uimax changes)
 1.10.2.1  22-Apr-2018  pgoyette Sync with HEAD
 1.11.2.2  13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.11.2.1  10-Jun-2019  christos Sync with HEAD

RSS XML Feed