History log of /netbsd-current/sys/kern/subr_pserialize.c
Revision (<<< Hide revision tags) (Show revision tags >>>) Date Author Comments
# 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.


Revision tags: netbsd-10-base
# 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


Revision tags: bouyer-sunxi-drm-base
# 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.


Revision tags: thorpej-i2c-spi-conf2-base thorpej-futex2-base thorpej-cfargs2-base cjep_sun2x-base1 cjep_sun2x-base cjep_staticlib_x-base1 cjep_staticlib_x-base thorpej-i2c-spi-conf-base thorpej-cfargs-base thorpej-futex-base bouyer-xenpvh-base2 phil-wifi-20200421 bouyer-xenpvh-base1 phil-wifi-20200411 bouyer-xenpvh-base is-mlppp-base phil-wifi-20200406 ad-namecache-base3 ad-namecache-base2 ad-namecache-base1 ad-namecache-base
# 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.


Revision tags: phil-wifi-20191119
# 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.


Revision tags: netbsd-9-3-RELEASE netbsd-9-2-RELEASE netbsd-9-1-RELEASE netbsd-9-0-RELEASE netbsd-9-0-RC2 netbsd-9-0-RC1 netbsd-9-base phil-wifi-20190609 isaki-audio2-base pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126 pgoyette-compat-1020 pgoyette-compat-0930 pgoyette-compat-0906
# 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.


Revision tags: pgoyette-compat-0728 phil-wifi-base pgoyette-compat-0625 pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422
# 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@


Revision tags: pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base
# 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


Revision tags: tls-maxphys-base-20171202
# 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@


Revision tags: matt-nb8-mediatek-base nick-nhusb-base-20170825 perseant-stdc-iso10646-base netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 jdolecek-ncq-base pgoyette-localcount-20170320 nick-nhusb-base-20170204 bouyer-socketcan-base pgoyette-localcount-20170107 nick-nhusb-base-20161204 pgoyette-localcount-20161104 nick-nhusb-base-20161004 localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base nick-nhusb-base-20160907 nick-nhusb-base-20160529 nick-nhusb-base-20160422 nick-nhusb-base-20160319 nick-nhusb-base-20151226 nick-nhusb-base-20150921
# 1.8 12-Jun-2015 dholland

branches: 1.8.10;
Typo in comment.


Revision tags: netbsd-7-2-RELEASE netbsd-7-1-2-RELEASE netbsd-7-1-1-RELEASE netbsd-7-1-RELEASE netbsd-7-1-RC2 netbsd-7-nhusb-base-20170116 netbsd-7-1-RC1 netbsd-7-0-2-RELEASE netbsd-7-nhusb-base netbsd-7-0-1-RELEASE netbsd-7-0-RELEASE netbsd-7-0-RC3 netbsd-7-0-RC2 netbsd-7-0-RC1 nick-nhusb-base-20150606 nick-nhusb-base-20150406 nick-nhusb-base netbsd-7-base yamt-pagecache-base9 tls-earlyentropy-base riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3 rmind-smpnet-nbase riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base rmind-smpnet-base agc-symver-base tls-maxphys-base
# 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@.


Revision tags: yamt-pagecache-base8
# 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.


Revision tags: netbsd-6-0-1-RELEASE yamt-pagecache-base7 matt-nb6-plus-nbase yamt-pagecache-base6 netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 jmcneill-usbmp-base10 yamt-pagecache-base5 jmcneill-usbmp-base9 yamt-pagecache-base4 jmcneill-usbmp-base8 jmcneill-usbmp-base7 jmcneill-usbmp-base6 jmcneill-usbmp-base5 jmcneill-usbmp-base4 jmcneill-usbmp-base3 jmcneill-usbmp-base2 netbsd-6-base
# 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().


Revision tags: jmcneill-usbmp-pre-base2 jmcneill-usbmp-base jmcneill-audiomp3-base yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base
# 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.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.


Revision tags: netbsd-10-base
# 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


Revision tags: bouyer-sunxi-drm-base
# 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.


Revision tags: thorpej-i2c-spi-conf2-base thorpej-futex2-base thorpej-cfargs2-base cjep_sun2x-base1 cjep_sun2x-base cjep_staticlib_x-base1 cjep_staticlib_x-base thorpej-i2c-spi-conf-base thorpej-cfargs-base thorpej-futex-base bouyer-xenpvh-base2 phil-wifi-20200421 bouyer-xenpvh-base1 phil-wifi-20200411 bouyer-xenpvh-base is-mlppp-base phil-wifi-20200406 ad-namecache-base3 ad-namecache-base2 ad-namecache-base1 ad-namecache-base
# 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.


Revision tags: phil-wifi-20191119
# 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.


Revision tags: netbsd-9-3-RELEASE netbsd-9-2-RELEASE netbsd-9-1-RELEASE netbsd-9-0-RELEASE netbsd-9-0-RC2 netbsd-9-0-RC1 netbsd-9-base phil-wifi-20190609 isaki-audio2-base pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126 pgoyette-compat-1020 pgoyette-compat-0930 pgoyette-compat-0906
# 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.


Revision tags: pgoyette-compat-0728 phil-wifi-base pgoyette-compat-0625 pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422
# 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@


Revision tags: pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base
# 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


Revision tags: tls-maxphys-base-20171202
# 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@


Revision tags: matt-nb8-mediatek-base nick-nhusb-base-20170825 perseant-stdc-iso10646-base netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 jdolecek-ncq-base pgoyette-localcount-20170320 nick-nhusb-base-20170204 bouyer-socketcan-base pgoyette-localcount-20170107 nick-nhusb-base-20161204 pgoyette-localcount-20161104 nick-nhusb-base-20161004 localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base nick-nhusb-base-20160907 nick-nhusb-base-20160529 nick-nhusb-base-20160422 nick-nhusb-base-20160319 nick-nhusb-base-20151226 nick-nhusb-base-20150921
# 1.8 12-Jun-2015 dholland

branches: 1.8.10;
Typo in comment.


Revision tags: netbsd-7-2-RELEASE netbsd-7-1-2-RELEASE netbsd-7-1-1-RELEASE netbsd-7-1-RELEASE netbsd-7-1-RC2 netbsd-7-nhusb-base-20170116 netbsd-7-1-RC1 netbsd-7-0-2-RELEASE netbsd-7-nhusb-base netbsd-7-0-1-RELEASE netbsd-7-0-RELEASE netbsd-7-0-RC3 netbsd-7-0-RC2 netbsd-7-0-RC1 nick-nhusb-base-20150606 nick-nhusb-base-20150406 nick-nhusb-base netbsd-7-base yamt-pagecache-base9 tls-earlyentropy-base riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3 rmind-smpnet-nbase riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base rmind-smpnet-base agc-symver-base tls-maxphys-base
# 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@.


Revision tags: yamt-pagecache-base8
# 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.


Revision tags: netbsd-6-0-1-RELEASE yamt-pagecache-base7 matt-nb6-plus-nbase yamt-pagecache-base6 netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 jmcneill-usbmp-base10 yamt-pagecache-base5 jmcneill-usbmp-base9 yamt-pagecache-base4 jmcneill-usbmp-base8 jmcneill-usbmp-base7 jmcneill-usbmp-base6 jmcneill-usbmp-base5 jmcneill-usbmp-base4 jmcneill-usbmp-base3 jmcneill-usbmp-base2 netbsd-6-base
# 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().


Revision tags: jmcneill-usbmp-pre-base2 jmcneill-usbmp-base jmcneill-audiomp3-base yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base
# 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.19 15-Nov-2022 macallan

don't KASSERT(kpreempt_disabled()) while cold
pserialize_read_*() can be called *very* early in kernel startup these days


Revision tags: bouyer-sunxi-drm-base
# 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.


Revision tags: thorpej-i2c-spi-conf2-base thorpej-futex2-base thorpej-cfargs2-base cjep_sun2x-base1 cjep_sun2x-base cjep_staticlib_x-base1 cjep_staticlib_x-base thorpej-i2c-spi-conf-base thorpej-cfargs-base thorpej-futex-base bouyer-xenpvh-base2 phil-wifi-20200421 bouyer-xenpvh-base1 phil-wifi-20200411 bouyer-xenpvh-base is-mlppp-base phil-wifi-20200406 ad-namecache-base3 ad-namecache-base2 ad-namecache-base1 ad-namecache-base
# 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.


Revision tags: phil-wifi-20191119
# 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.


Revision tags: netbsd-9-3-RELEASE netbsd-9-2-RELEASE netbsd-9-1-RELEASE netbsd-9-0-RELEASE netbsd-9-0-RC2 netbsd-9-0-RC1 netbsd-9-base phil-wifi-20190609 isaki-audio2-base pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126 pgoyette-compat-1020 pgoyette-compat-0930 pgoyette-compat-0906
# 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.


Revision tags: pgoyette-compat-0728 phil-wifi-base pgoyette-compat-0625 pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422
# 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@


Revision tags: pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base
# 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


Revision tags: tls-maxphys-base-20171202
# 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@


Revision tags: matt-nb8-mediatek-base nick-nhusb-base-20170825 perseant-stdc-iso10646-base netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 jdolecek-ncq-base pgoyette-localcount-20170320 nick-nhusb-base-20170204 bouyer-socketcan-base pgoyette-localcount-20170107 nick-nhusb-base-20161204 pgoyette-localcount-20161104 nick-nhusb-base-20161004 localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base nick-nhusb-base-20160907 nick-nhusb-base-20160529 nick-nhusb-base-20160422 nick-nhusb-base-20160319 nick-nhusb-base-20151226 nick-nhusb-base-20150921
# 1.8 12-Jun-2015 dholland

branches: 1.8.10;
Typo in comment.


Revision tags: netbsd-7-2-RELEASE netbsd-7-1-2-RELEASE netbsd-7-1-1-RELEASE netbsd-7-1-RELEASE netbsd-7-1-RC2 netbsd-7-nhusb-base-20170116 netbsd-7-1-RC1 netbsd-7-0-2-RELEASE netbsd-7-nhusb-base netbsd-7-0-1-RELEASE netbsd-7-0-RELEASE netbsd-7-0-RC3 netbsd-7-0-RC2 netbsd-7-0-RC1 nick-nhusb-base-20150606 nick-nhusb-base-20150406 nick-nhusb-base netbsd-7-base yamt-pagecache-base9 tls-earlyentropy-base riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3 rmind-smpnet-nbase riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base rmind-smpnet-base agc-symver-base tls-maxphys-base
# 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@.


Revision tags: yamt-pagecache-base8
# 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.


Revision tags: netbsd-6-0-1-RELEASE yamt-pagecache-base7 matt-nb6-plus-nbase yamt-pagecache-base6 netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 jmcneill-usbmp-base10 yamt-pagecache-base5 jmcneill-usbmp-base9 yamt-pagecache-base4 jmcneill-usbmp-base8 jmcneill-usbmp-base7 jmcneill-usbmp-base6 jmcneill-usbmp-base5 jmcneill-usbmp-base4 jmcneill-usbmp-base3 jmcneill-usbmp-base2 netbsd-6-base
# 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().


Revision tags: jmcneill-usbmp-pre-base2 jmcneill-usbmp-base jmcneill-audiomp3-base yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base
# 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.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.


Revision tags: thorpej-i2c-spi-conf2-base thorpej-futex2-base thorpej-cfargs2-base cjep_sun2x-base1 cjep_sun2x-base cjep_staticlib_x-base1 cjep_staticlib_x-base thorpej-i2c-spi-conf-base thorpej-cfargs-base thorpej-futex-base bouyer-xenpvh-base2 phil-wifi-20200421 bouyer-xenpvh-base1 phil-wifi-20200411 bouyer-xenpvh-base is-mlppp-base phil-wifi-20200406 ad-namecache-base3 ad-namecache-base2 ad-namecache-base1 ad-namecache-base
# 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.


Revision tags: phil-wifi-20191119
# 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.


Revision tags: netbsd-9-2-RELEASE netbsd-9-1-RELEASE netbsd-9-0-RELEASE netbsd-9-0-RC2 netbsd-9-0-RC1 netbsd-9-base phil-wifi-20190609 isaki-audio2-base pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126 pgoyette-compat-1020 pgoyette-compat-0930 pgoyette-compat-0906
# 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.


Revision tags: pgoyette-compat-0728 phil-wifi-base pgoyette-compat-0625 pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422
# 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@


Revision tags: pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base
# 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


Revision tags: tls-maxphys-base-20171202
# 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@


Revision tags: matt-nb8-mediatek-base nick-nhusb-base-20170825 perseant-stdc-iso10646-base netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 jdolecek-ncq-base pgoyette-localcount-20170320 nick-nhusb-base-20170204 bouyer-socketcan-base pgoyette-localcount-20170107 nick-nhusb-base-20161204 pgoyette-localcount-20161104 nick-nhusb-base-20161004 localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base nick-nhusb-base-20160907 nick-nhusb-base-20160529 nick-nhusb-base-20160422 nick-nhusb-base-20160319 nick-nhusb-base-20151226 nick-nhusb-base-20150921
# 1.8 12-Jun-2015 dholland

branches: 1.8.10;
Typo in comment.


Revision tags: netbsd-7-2-RELEASE netbsd-7-1-2-RELEASE netbsd-7-1-1-RELEASE netbsd-7-1-RELEASE netbsd-7-1-RC2 netbsd-7-nhusb-base-20170116 netbsd-7-1-RC1 netbsd-7-0-2-RELEASE netbsd-7-nhusb-base netbsd-7-0-1-RELEASE netbsd-7-0-RELEASE netbsd-7-0-RC3 netbsd-7-0-RC2 netbsd-7-0-RC1 nick-nhusb-base-20150606 nick-nhusb-base-20150406 nick-nhusb-base netbsd-7-base yamt-pagecache-base9 tls-earlyentropy-base riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3 rmind-smpnet-nbase riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base rmind-smpnet-base agc-symver-base tls-maxphys-base
# 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@.


Revision tags: yamt-pagecache-base8
# 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.


Revision tags: netbsd-6-0-1-RELEASE yamt-pagecache-base7 matt-nb6-plus-nbase yamt-pagecache-base6 netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 jmcneill-usbmp-base10 yamt-pagecache-base5 jmcneill-usbmp-base9 yamt-pagecache-base4 jmcneill-usbmp-base8 jmcneill-usbmp-base7 jmcneill-usbmp-base6 jmcneill-usbmp-base5 jmcneill-usbmp-base4 jmcneill-usbmp-base3 jmcneill-usbmp-base2 netbsd-6-base
# 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().


Revision tags: jmcneill-usbmp-pre-base2 jmcneill-usbmp-base jmcneill-audiomp3-base yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base
# 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.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.


Revision tags: phil-wifi-20191119
# 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.


Revision tags: netbsd-9-0-RC1 netbsd-9-base phil-wifi-20190609 isaki-audio2-base pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126 pgoyette-compat-1020 pgoyette-compat-0930 pgoyette-compat-0906
# 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.


Revision tags: pgoyette-compat-0728 phil-wifi-base pgoyette-compat-0625 pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422
# 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@


Revision tags: pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base
# 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


Revision tags: tls-maxphys-base-20171202
# 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@


Revision tags: matt-nb8-mediatek-base nick-nhusb-base-20170825 perseant-stdc-iso10646-base netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 jdolecek-ncq-base pgoyette-localcount-20170320 nick-nhusb-base-20170204 bouyer-socketcan-base pgoyette-localcount-20170107 nick-nhusb-base-20161204 pgoyette-localcount-20161104 nick-nhusb-base-20161004 localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base nick-nhusb-base-20160907 nick-nhusb-base-20160529 nick-nhusb-base-20160422 nick-nhusb-base-20160319 nick-nhusb-base-20151226 nick-nhusb-base-20150921
# 1.8 12-Jun-2015 dholland

branches: 1.8.10;
Typo in comment.


Revision tags: netbsd-7-2-RELEASE netbsd-7-1-2-RELEASE netbsd-7-1-1-RELEASE netbsd-7-1-RELEASE netbsd-7-1-RC2 netbsd-7-nhusb-base-20170116 netbsd-7-1-RC1 netbsd-7-0-2-RELEASE netbsd-7-nhusb-base netbsd-7-0-1-RELEASE netbsd-7-0-RELEASE netbsd-7-0-RC3 netbsd-7-0-RC2 netbsd-7-0-RC1 nick-nhusb-base-20150606 nick-nhusb-base-20150406 nick-nhusb-base netbsd-7-base yamt-pagecache-base9 tls-earlyentropy-base riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3 rmind-smpnet-nbase riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base rmind-smpnet-base agc-symver-base tls-maxphys-base
# 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@.


Revision tags: yamt-pagecache-base8
# 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.


Revision tags: netbsd-6-0-1-RELEASE yamt-pagecache-base7 matt-nb6-plus-nbase yamt-pagecache-base6 netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 jmcneill-usbmp-base10 yamt-pagecache-base5 jmcneill-usbmp-base9 yamt-pagecache-base4 jmcneill-usbmp-base8 jmcneill-usbmp-base7 jmcneill-usbmp-base6 jmcneill-usbmp-base5 jmcneill-usbmp-base4 jmcneill-usbmp-base3 jmcneill-usbmp-base2 netbsd-6-base
# 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().


Revision tags: jmcneill-usbmp-pre-base2 jmcneill-usbmp-base jmcneill-audiomp3-base yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base
# 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.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.


Revision tags: phil-wifi-20191119
# 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.


Revision tags: netbsd-9-0-RC1 netbsd-9-base phil-wifi-20190609 isaki-audio2-base pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126 pgoyette-compat-1020 pgoyette-compat-0930 pgoyette-compat-0906
# 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.


Revision tags: pgoyette-compat-0728 phil-wifi-base pgoyette-compat-0625 pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422
# 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@


Revision tags: pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base
# 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


Revision tags: tls-maxphys-base-20171202
# 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@


Revision tags: matt-nb8-mediatek-base nick-nhusb-base-20170825 perseant-stdc-iso10646-base netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 jdolecek-ncq-base pgoyette-localcount-20170320 nick-nhusb-base-20170204 bouyer-socketcan-base pgoyette-localcount-20170107 nick-nhusb-base-20161204 pgoyette-localcount-20161104 nick-nhusb-base-20161004 localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base nick-nhusb-base-20160907 nick-nhusb-base-20160529 nick-nhusb-base-20160422 nick-nhusb-base-20160319 nick-nhusb-base-20151226 nick-nhusb-base-20150921
# 1.8 12-Jun-2015 dholland

branches: 1.8.10;
Typo in comment.


Revision tags: netbsd-7-2-RELEASE netbsd-7-1-2-RELEASE netbsd-7-1-1-RELEASE netbsd-7-1-RELEASE netbsd-7-1-RC2 netbsd-7-nhusb-base-20170116 netbsd-7-1-RC1 netbsd-7-0-2-RELEASE netbsd-7-nhusb-base netbsd-7-0-1-RELEASE netbsd-7-0-RELEASE netbsd-7-0-RC3 netbsd-7-0-RC2 netbsd-7-0-RC1 nick-nhusb-base-20150606 nick-nhusb-base-20150406 nick-nhusb-base netbsd-7-base yamt-pagecache-base9 tls-earlyentropy-base riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3 rmind-smpnet-nbase riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base rmind-smpnet-base agc-symver-base tls-maxphys-base
# 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@.


Revision tags: yamt-pagecache-base8
# 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.


Revision tags: netbsd-6-0-1-RELEASE yamt-pagecache-base7 matt-nb6-plus-nbase yamt-pagecache-base6 netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 jmcneill-usbmp-base10 yamt-pagecache-base5 jmcneill-usbmp-base9 yamt-pagecache-base4 jmcneill-usbmp-base8 jmcneill-usbmp-base7 jmcneill-usbmp-base6 jmcneill-usbmp-base5 jmcneill-usbmp-base4 jmcneill-usbmp-base3 jmcneill-usbmp-base2 netbsd-6-base
# 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().


Revision tags: jmcneill-usbmp-pre-base2 jmcneill-usbmp-base jmcneill-audiomp3-base yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base
# 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.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.


Revision tags: phil-wifi-20191119
# 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.


Revision tags: netbsd-9-0-RC1 netbsd-9-base phil-wifi-20190609 isaki-audio2-base pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126 pgoyette-compat-1020 pgoyette-compat-0930 pgoyette-compat-0906
# 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.


Revision tags: pgoyette-compat-0728 phil-wifi-base pgoyette-compat-0625 pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422
# 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@


Revision tags: pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base
# 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


Revision tags: tls-maxphys-base-20171202
# 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@


Revision tags: matt-nb8-mediatek-base nick-nhusb-base-20170825 perseant-stdc-iso10646-base netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 jdolecek-ncq-base pgoyette-localcount-20170320 nick-nhusb-base-20170204 bouyer-socketcan-base pgoyette-localcount-20170107 nick-nhusb-base-20161204 pgoyette-localcount-20161104 nick-nhusb-base-20161004 localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base nick-nhusb-base-20160907 nick-nhusb-base-20160529 nick-nhusb-base-20160422 nick-nhusb-base-20160319 nick-nhusb-base-20151226 nick-nhusb-base-20150921
# 1.8 12-Jun-2015 dholland

branches: 1.8.10;
Typo in comment.


Revision tags: netbsd-7-2-RELEASE netbsd-7-1-2-RELEASE netbsd-7-1-1-RELEASE netbsd-7-1-RELEASE netbsd-7-1-RC2 netbsd-7-nhusb-base-20170116 netbsd-7-1-RC1 netbsd-7-0-2-RELEASE netbsd-7-nhusb-base netbsd-7-0-1-RELEASE netbsd-7-0-RELEASE netbsd-7-0-RC3 netbsd-7-0-RC2 netbsd-7-0-RC1 nick-nhusb-base-20150606 nick-nhusb-base-20150406 nick-nhusb-base netbsd-7-base yamt-pagecache-base9 tls-earlyentropy-base riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3 rmind-smpnet-nbase riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base rmind-smpnet-base agc-symver-base tls-maxphys-base
# 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@.


Revision tags: yamt-pagecache-base8
# 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.


Revision tags: netbsd-6-0-1-RELEASE yamt-pagecache-base7 matt-nb6-plus-nbase yamt-pagecache-base6 netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 jmcneill-usbmp-base10 yamt-pagecache-base5 jmcneill-usbmp-base9 yamt-pagecache-base4 jmcneill-usbmp-base8 jmcneill-usbmp-base7 jmcneill-usbmp-base6 jmcneill-usbmp-base5 jmcneill-usbmp-base4 jmcneill-usbmp-base3 jmcneill-usbmp-base2 netbsd-6-base
# 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().


Revision tags: jmcneill-usbmp-pre-base2 jmcneill-usbmp-base jmcneill-audiomp3-base yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base
# 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.