History log of /freebsd-current/sys/sys/epoch.h
Revision Date Author Comments
# 95ee2897 16-Aug-2023 Warner Losh <imp@FreeBSD.org>

sys: Remove $FreeBSD$: two-line .h pattern

Remove /^\s*\*\n \*\s+\$FreeBSD\$$\n/


# 4d846d26 10-May-2023 Warner Losh <imp@FreeBSD.org>

spdx: The BSD-2-Clause-FreeBSD identifier is obsolete, drop -FreeBSD

The SPDX folks have obsoleted the BSD-2-Clause-FreeBSD identifier. Catch
up to that fact and revert to their recommended match of BSD-2-Clause.

Discussed with: pfg
MFC After: 3 days
Sponsored by: Netflix


# 150486f6 29-Jul-2022 Zhenlei Huang <zlei.huang@gmail.com>

Introduce and use the NET_EPOCH_DRAIN_CALLBACKS() macro

Reviewed by: melifao, kp
Differential Revision: https://reviews.freebsd.org/D35968


# aa70361d 24-Dec-2021 Kristof Provost <kp@FreeBSD.org>

headers: make a few more headers self-contained

Sponsored by: Rubicon Communications, LLC ("Netgate")


# db0ac6de 02-Dec-2021 Cy Schubert <cy@FreeBSD.org>

Revert "wpa: Import wpa_supplicant/hostapd commit 14ab4a816"

This reverts commit 266f97b5e9a7958e365e78288616a459b40d924a, reversing
changes made to a10253cffea84c0c980a36ba6776b00ed96c3e3b.

A mismerge of a merge to catch up to main resulted in files being
committed which should not have been.


# d96fccc5 02-Dec-2021 Gleb Smirnoff <glebius@FreeBSD.org>

epoch: with EPOCH_TRACE add epoch_where_report()
which will report where the epoch was entered and also
mark the tracker, so that exit will also be reported.

Helps to understand epoch entrance/exit scenarios in
complex cases, like network stack. As everything else
under EPOCH_TRACE it is a developer only tool.


# ef0f7ae9 21-May-2021 Hans Petter Selasky <hselasky@FreeBSD.org>

The old thread priority must be stored as part of the EPOCH(9) tracker.

Else recursive use of EPOCH(9) may cause the wrong priority to be restored.

Bump the __FreeBSD_version due to changing the thread and epoch tracker
structure.

Differential Revision: https://reviews.freebsd.org/D30375
Reviewed by: markj@
MFC after: 1 week
Sponsored by: Mellanox Technologies // NVIDIA Networking


# 4426b2e6 11-Feb-2020 Gleb Smirnoff <glebius@FreeBSD.org>

Add flag to struct task to mark the task as requiring network epoch.

When processing a taskqueue and a task has associated epoch, then
enter for duration of the task. If consecutive tasks belong to the
same epoch, batch them. Now we are talking about the network epoch
only.

Shrink the ta_priority size to 8-bits. No current consumers use
a priority that won't fit into 8 bits. Also complexity of
taskqueue_enqueue() is a square of maximum value of priority, so
we unlikely ever want to go over UCHAR_MAX here.

Reviewed by: hselasky
Differential Revision: https://reviews.freebsd.org/D23518


# 66c6c556 16-Jan-2020 Gleb Smirnoff <glebius@FreeBSD.org>

Change argument order of epoch_call() to more natural, first function,
then its argument.

Reviewed by: imp, cem, jhb


# 2a4bd982 14-Jan-2020 Gleb Smirnoff <glebius@FreeBSD.org>

Introduce NET_EPOCH_CALL() macro and use it everywhere where we free
data based on the network epoch. The macro reverses the argument
order of epoch_call(9) - first function, then its argument. NFC


# 3264dcad 14-Jan-2020 Gleb Smirnoff <glebius@FreeBSD.org>

- Move global network epoch definition to epoch.h, as more different
subsystems tend to need to know about it, and including if_var.h is
huge header pollution for them. Polluting possible non-network
users with single symbol seems much lesser evil.
- Remove non-preemptible network epoch. Not used yet, and unlikely
to get used in close future.


# 279b9aab 21-Oct-2019 Gleb Smirnoff <glebius@FreeBSD.org>

Remove epoch tracker from struct thread. It was an ugly crutch to emulate
locking semantics for if_addr_rlock() and if_maddr_rlock().


# bac06038 15-Oct-2019 Gleb Smirnoff <glebius@FreeBSD.org>

When assertion for a thread not being in an epoch fails also print all
entered epochs. Works with EPOCH_TRACE only.

Reviewed by: hselasky
Differential Revision: https://reviews.freebsd.org/D22017


# 05ee75ef 26-Sep-2019 Gleb Smirnoff <glebius@FreeBSD.org>

Move EPOCH_TRACE to opt_global.h, so that any external modules that
use epoch don't need Makefile tweaks.

The downside is that any developer who wants EPOCH_TRACE needs to
rebuild kernel in full, but that's fine.

Reviewed by: imp


# dd902d01 25-Sep-2019 Gleb Smirnoff <glebius@FreeBSD.org>

Add debugging facility EPOCH_TRACE that checks that epochs entered are
properly nested and warns about recursive entrances. Unlike with locks,
there is nothing fundamentally wrong with such use, the intent of tracer
is to help to review complex epoch-protected code paths, and we mean the
network stack here.

Reviewed by: hselasky
Sponsored by: Netflix
Pull Request: https://reviews.freebsd.org/D21610


# 131b2b76 28-Jun-2019 Hans Petter Selasky <hselasky@FreeBSD.org>

Implement API for draining EPOCH(9) callbacks.

The epoch_drain_callbacks() function is used to drain all pending
callbacks which have been invoked by prior epoch_call() function calls
on the same epoch. This function is useful when there are shared
memory structure(s) referred to by the epoch callback(s) which are not
refcounted and are rarely freed. The typical place for calling this
function is right before freeing or invalidating the shared
resource(s) used by the epoch callback(s). This function can sleep and
is not optimized for performance.

Differential Revision: https://reviews.freebsd.org/D20109
MFC after: 1 week
Sponsored by: Mellanox Technologies


# 9f360eec 13-Nov-2018 Gleb Smirnoff <glebius@FreeBSD.org>

The dualism between epoch_tracker and epoch_thread is fragile and
unnecessary. So, expose CK types to kernel and use a single normal
structure for epoch_tracker.

Reviewed by: jtl, gallatin


# b79aa45e 13-Nov-2018 Gleb Smirnoff <glebius@FreeBSD.org>

For compatibility KPI functions like if_addr_rlock() that used to have
mutexes but now are converted to epoch(9) use thread-private epoch_tracker.
Embedding tracker into ifnet(9) or ifnet derived structures creates a non
reentrable function, that will fail miserably if called simultaneously from
two different contexts.
A thread private tracker will provide a single tracker that would allow to
call these functions safely. It doesn't allow nested call, but this is not
expected from compatibility KPIs.

Reviewed by: markj


# a82296c2 13-Nov-2018 Gleb Smirnoff <glebius@FreeBSD.org>

Uninline epoch(9) entrance and exit. There is no proof that modern
processors would benefit from avoiding a function call, but bloating
code. In fact, clang created an uninlined real function for many
object files in the network stack.

- Move epoch_private.h into subr_epoch.c. Code copied exactly, avoiding
any changes, including style(9).
- Remove private copies of critical_enter/exit.

Reviewed by: kib, jtl
Differential Revision: https://reviews.freebsd.org/D17879


# 2aae9642 20-Aug-2018 Matt Macy <mmacy@FreeBSD.org>

Make epoch KBI consistent between INVARIANTS and non-INVARIANTS

move extra fields under EPOCH_TRACKER_DEBUG

Reported by: hps


# 6573d758 03-Jul-2018 Matt Macy <mmacy@FreeBSD.org>

epoch(9): allow preemptible epochs to compose

- Add tracker argument to preemptible epochs
- Inline epoch read path in kernel and tied modules
- Change in_epoch to take an epoch as argument
- Simplify tfb_tcp_do_segment to not take a ti_locked argument,
there's no longer any benefit to dropping the pcbinfo lock
and trying to do so just adds an error prone branchfest to
these functions
- Remove cases of same function recursion on the epoch as
recursing is no longer free.
- Remove the the TAILQ_ENTRY and epoch_section from struct
thread as the tracker field is now stack or heap allocated
as appropriate.

Tested by: pho and Limelight Networks
Reviewed by: kbowling at llnw dot com
Sponsored by: Limelight Networks
Differential Revision: https://reviews.freebsd.org/D16066


# 74333b3d 24-Jun-2018 Matt Macy <mmacy@FreeBSD.org>

fix assert and conditionally allow mutexes to be held across epoch_wait_preempt


# e445381f 29-May-2018 Matt Macy <mmacy@FreeBSD.org>

epoch(9): make epoch closer to style(9)


# fe524329 23-May-2018 Matt Macy <mmacy@FreeBSD.org>

convert allocations to INVARIANTS M_ZERO


# 246a6199 23-May-2018 Matt Macy <mmacy@FreeBSD.org>

epoch: allow for conditionally asserting that the epoch context fields
are unused by zeroing on INVARIANTS builds


# ce8054a0 19-May-2018 Matt Macy <mmacy@FreeBSD.org>

epoch.h: hide proc.h->priority.h from user


# 5d9bb5d9 19-May-2018 Matt Macy <mmacy@FreeBSD.org>

epoch.h: move kernel only bits under _KERNEL


# b25651a4 18-May-2018 Matt Macy <mmacy@FreeBSD.org>

epoch: avoid warning when INVARIANTS is not enabled


# 70398c2f 18-May-2018 Matt Macy <mmacy@FreeBSD.org>

epoch(9): Make epochs non-preemptible by default

There are risks associated with waiting on a preemptible epoch section.
Change the name to make them not be the default and document the issue
under CAVEATS.

Reported by: markj


# 5e68a3df 17-May-2018 Matt Macy <mmacy@FreeBSD.org>

epoch: add non-preemptible "critical" variant

adds:
- epoch_enter_critical() - can be called inside a different epoch,
starts a section that will acquire any MTX_DEF mutexes or do
anything that might sleep.
- epoch_exit_critical() - corresponding exit call
- epoch_wait_critical() - wait variant that is guaranteed that any
threads in a section are running.
- epoch_global_critical - an epoch_wait_critical safe epoch instance

Requested by: markj
Approved by: sbruno


# a5f10424 17-May-2018 Matt Macy <mmacy@FreeBSD.org>

epoch: skip poll function call in hardclock unless there are callbacks pending

Reported by: mjg
Approved by: sbruno


# c4d901e9 17-May-2018 Matt Macy <mmacy@FreeBSD.org>

epoch(9): schedule pcpu callback task in hardclock if there are callbacks pending

Approved by: sbruno


# fdf71aeb 16-May-2018 Matt Macy <mmacy@FreeBSD.org>

epoch(9): make recursion lighter weight

There isn't any real work to do except bump td_epochnest when recursing.
Skip the additional work in this case.

Approved by: sbruno


# 1f4beb63 13-May-2018 Matt Macy <mmacy@FreeBSD.org>

epoch(9): cleanups, additional debug checks, and add global_epoch

- GC the _nopreempt routines
- to really benefit we'd need a separate routine
- they're not currently in use
- they complicate the API for no benefit at this time

- check that we're actually in a epoch section at exit

- handle epoch_call() early in boot

- Fix copyright declaration language

Approved by: sbruno@


# 06bf2a6a 10-May-2018 Matt Macy <mmacy@FreeBSD.org>

Add simple preempt safe epoch API

Read locking is over used in the kernel to guarantee liveness. This API makes
it easy to provide livenes guarantees without atomics.

Includes epoch_test kernel module to stress test the API.

Documentation will follow initial use case.

Test case and improvements to preemption handling in response to discussion
with mjg@

Reviewed by: imp@, shurd@
Approved by: sbruno@