OpenBSD CVS

CVS log for src/sys/sys/srp.h


[BACK] Up to [local] / src / sys / sys

Request diff between arbitrary revisions


Default branch: MAIN


Revision 1.15 / (download) - annotate - [select for diffs], Sat May 9 10:18:27 2020 UTC (4 years, 1 month ago) by jca
Branch: MAIN
CVS Tags: OPENBSD_7_5_BASE, OPENBSD_7_5, OPENBSD_7_4_BASE, OPENBSD_7_4, OPENBSD_7_3_BASE, OPENBSD_7_3, OPENBSD_7_2_BASE, OPENBSD_7_2, OPENBSD_7_1_BASE, OPENBSD_7_1, OPENBSD_7_0_BASE, OPENBSD_7_0, OPENBSD_6_9_BASE, OPENBSD_6_9, OPENBSD_6_8_BASE, OPENBSD_6_8, HEAD
Changes since 1.14: +10 -3 lines
Diff to previous 1.14 (colored)

Initialize the srp_ref in the non-MP version of srp_enter

Silences an uninitialized warning in net/art.c

"reasonable" jmatthew@, ok mpi@

Revision 1.14 / (download) - annotate - [select for diffs], Sun Mar 31 14:03:40 2019 UTC (5 years, 2 months ago) by mpi
Branch: MAIN
CVS Tags: OPENBSD_6_7_BASE, OPENBSD_6_7, OPENBSD_6_6_BASE, OPENBSD_6_6, OPENBSD_6_5_BASE, OPENBSD_6_5
Changes since 1.13: +8 -8 lines
Diff to previous 1.13 (colored)

Make ART data structure definitions visible to userland, in order to fix
netstat(1) inspection of routing tables.

From Naoki Fukaumi, ok yasuoka@

Revision 1.13 / (download) - annotate - [select for diffs], Sun Nov 20 11:40:58 2016 UTC (7 years, 6 months ago) by mpi
Branch: MAIN
CVS Tags: OPENBSD_6_4_BASE, OPENBSD_6_4, OPENBSD_6_3_BASE, OPENBSD_6_3, OPENBSD_6_2_BASE, OPENBSD_6_2, OPENBSD_6_1_BASE, OPENBSD_6_1
Changes since 1.12: +6 -7 lines
Diff to previous 1.12 (colored)

Rename SRPL_ENTER() to SRPL_FIRST() and SRPL_NEXT() to SRPL_FOLLOW().

This allows us to introduce SRPL_NEXT() that can be used to start
iterating on an arbitrary member of an srp list, hence without calling
SRPL_ENTER().

ok dlg@, jmatthew@

Revision 1.12 / (download) - annotate - [select for diffs], Fri Oct 21 06:27:50 2016 UTC (7 years, 7 months ago) by dlg
Branch: MAIN
Changes since 1.11: +3 -1 lines
Diff to previous 1.11 (colored)

add generalised access to per cpu data structures and counters.

both the cpumem and counters api simply allocates memory for each cpu in
the system that can be used for arbitrary per cpu data (via cpumem), or
a versioned set of counters per cpu (counters).

there is an alternate backend for uniprocessor systems that basically
turns the percpu data access into an immediate access to a single
allocation.

there is also support for percpu data structures that are available at
boot time by providing an allocation for the boot cpu. after autoconf,
these allocations have to be resized to provide for all cpus that were
enumerated by boot.

ok mpi@

Revision 1.11 / (download) - annotate - [select for diffs], Tue Jun 7 07:53:33 2016 UTC (8 years ago) by mpi
Branch: MAIN
CVS Tags: OPENBSD_6_0_BASE, OPENBSD_6_0
Changes since 1.10: +22 -24 lines
Diff to previous 1.10 (colored)

Move initialization macro outside of #define _KERNEL to use them in
ART regression tests.

ok dlg@, jmatthew@

Revision 1.10 / (download) - annotate - [select for diffs], Wed Jun 1 03:34:32 2016 UTC (8 years ago) by dlg
Branch: MAIN
Changes since 1.9: +6 -1 lines
Diff to previous 1.9 (colored)

add support for using SRPs without the garbage collection machinery.

the gc machinery may sleep during srp_update, which makes it hard
to use from an interrupt context. srp_swap simply swaps the references
in an srp and relies ont he caller to schedule work in a process
context where it may sleep with srp_finalise until the reference
is no longer in use.

our network stack currently modifies routing tables in an interrupt
context, so this is built to be used to support rtable updates in
our current stack while supporting concurrent lookups.

ok jmatthew@ mpi@

Revision 1.9 / (download) - annotate - [select for diffs], Wed May 18 03:58:13 2016 UTC (8 years ago) by dlg
Branch: MAIN
Changes since 1.8: +2 -2 lines
Diff to previous 1.8 (colored)

rename srp_finalize to srp_gc_finalize

Revision 1.8 / (download) - annotate - [select for diffs], Wed May 18 03:46:03 2016 UTC (8 years ago) by dlg
Branch: MAIN
Changes since 1.7: +26 -38 lines
Diff to previous 1.7 (colored)

rework the srp api so it takes an srp_ref struct that the caller provides.

the srp_ref struct is used to track the location of the callers
hazard pointer so later calls to srp_follow and srp_enter already
know what to clear. this in turn means most of the caveats around
using srps go away. specifically, you can now:

- switch cpus while holding an srp ref
  - ie, you can sleep while holding an srp ref
- you can take and release srp refs in any order

the original intent was to simplify use of the api when dealing
with complicated data structures. the caller now no longer has to
track the location of the srp a value was fetched from, the srp_ref
effectively does that for you.

srp lists have been refactored to use srp_refs instead of srpl_iter
structs.

this is in preparation of using srps inside the ART code. ART is a
complicated data structure, and lookups require overlapping holds
of srp references.

ok mpi@ jmatthew@

Revision 1.7 / (download) - annotate - [select for diffs], Thu Dec 3 16:27:32 2015 UTC (8 years, 6 months ago) by mpi
Branch: MAIN
CVS Tags: OPENBSD_5_9_BASE, OPENBSD_5_9
Changes since 1.6: +8 -5 lines
Diff to previous 1.6 (colored)

Use SRPL_HEAD() and SRPL_ENTRY() to be consistent with and allow to
fallback to a SLIST.

ok dlg@, jasper@

Revision 1.6 / (download) - annotate - [select for diffs], Thu Nov 26 12:17:19 2015 UTC (8 years, 6 months ago) by mpi
Branch: MAIN
Changes since 1.5: +6 -1 lines
Diff to previous 1.5 (colored)

Add SRPL_FOREACH_SAFE_LOCKED(9), needed to turn the single list of
multipath route entries mpsafe.

ok dlg@

Revision 1.5 / (download) - annotate - [select for diffs], Fri Sep 18 08:30:23 2015 UTC (8 years, 8 months ago) by dlg
Branch: MAIN
Changes since 1.4: +18 -1 lines
Diff to previous 1.4 (colored)

implement SRPL_INSERT_AFTER_LOCKED.

i thought id committed this at l2k15. sorry for the delay.

Revision 1.4 / (download) - annotate - [select for diffs], Fri Sep 11 19:22:37 2015 UTC (8 years, 9 months ago) by dlg
Branch: MAIN
Changes since 1.3: +5 -3 lines
Diff to previous 1.3 (colored)

make srp use refcnts so it can use refcnt_finalize instead of
sleep_setup/sleep_finish.

Revision 1.3 / (download) - annotate - [select for diffs], Wed Sep 9 11:21:51 2015 UTC (8 years, 9 months ago) by dlg
Branch: MAIN
Changes since 1.2: +106 -1 lines
Diff to previous 1.2 (colored)

implement a singly linked list built with SRPs.

this allows us to build lists of things that can be followed by
multiple cpus.

ok mpi@ claudio@

Revision 1.2 / (download) - annotate - [select for diffs], Tue Sep 1 03:47:58 2015 UTC (8 years, 9 months ago) by dlg
Branch: MAIN
Changes since 1.1: +3 -1 lines
Diff to previous 1.1 (colored)

mattieu baptiste reported a problem with bpf+srps where the per cpu
hazard pointers were becoming corrupt and therefore panics.

the problem turned out to be that bridge_input calls if_input on
behalf of a hardware interface which then calls bpf_mtap at splsoftnet,
while the actual hardware nic calls if_input and bpf_mtap at splnet.
the hardware interrupts ran in the middle of the bpf calls bridge
runs at softnet. this means the same srps are being entered and
left on the same cpu at different ipls, which led to races because
of the order of operations on the per cpu hazard pointers.

after a lot of experimentation, jmatthew@ figured out how to deal
with this problem without introducing per cpu critical sections
(ie, splhigh) calls in srp_enter and srp_leave, and without introducing
atomic operations.

the solution is to iterate forward through the array of hazard
pointers in srp_enter, and backward in srp_leave to clear. if you
guarantee that you leave srps in the reverse order to entering them,
then you can use the same set of SRPs at different IPLs on the same
CPU.

the ordering requirement is a problem if we want to build linked
data structures out of srps because you need to hold a ref to the
current element containing the next srp to use it, before giving
up the current ref. we're adding srp_follow() to support taking the
next ref and giving up the current one while preserving the structure
of the hazard pointer list. srp_follow() does this by reusing the
hazard pointer for the current reference for the next ref.

both mattieu baptiste and jmatthew@ have been hitting this pretty
hard with a tweaked version of srp+bpf that uses srp_follow instead
of interleaved srp_enter/srp_leave sequences. neither can reproduce
the panics anymore.

thanks to mattieu for the report and tests
ok jmatthew@

Revision 1.1 / (download) - annotate - [select for diffs], Thu Jul 2 01:34:00 2015 UTC (8 years, 11 months ago) by dlg
Branch: MAIN
CVS Tags: OPENBSD_5_8_BASE, OPENBSD_5_8

introduce srp, which according to the manpage i wrote is short for
"shared reference pointers".

srp allows concurrent access to a data structure by multiple cpus
while avoiding interlocking cpu opcodes. it manages its own reference
counts and the garbage collection of those data structure to avoid
use after frees.

internally srp is a twisted version of hazard pointers, which are
a relative of RCU.

jmatthew wrote the bulk of a hazard pointer implementation and
changed bpf to use it to allow mpsafe access to bpfilters. however,
at s2k15 we were trying to apply it to other data structures but
the memory overhead of every hazard pointer would have blown out
significantly in several uses cases. a bulk of our time at s2k15
was spent reworking hazard pointers into srp.

this diff adds the srp api and adds the necessary metadata to struct
cpuinfo on our MP architectures. srp on uniprocessor platforms has
alternate code that is optimised because it knows there'll be no
concurrent access to data by multiple cpus.

srp is made available to the system via param.h, so it should be
available everywhere in the kernel.

the docs likely need improvement cos im too close to the implementation.

ok mpi@

This form allows you to request diff's between any two revisions of a file. You may select a symbolic revision name using the selection box or you may type in a numeric name using the type-in text box.