Skip to content

Commit a838c2e

Browse files
Wu FengguangIngo Molnar
authored andcommitted
markers: comment marker_synchronize_unregister() on data dependency
Add document and comments on marker_synchronize_unregister(): it should be called before freeing resources that the probes depend on. Based on comments from Lai Jiangshan and Mathieu Desnoyers. Signed-off-by: Wu Fengguang <[email protected]> Reviewed-by: Mathieu Desnoyers <[email protected]> Reviewed-by: Lai Jiangshan <[email protected]> Signed-off-by: Ingo Molnar <[email protected]>
1 parent c7cc773 commit a838c2e

File tree

2 files changed

+14
-7
lines changed

2 files changed

+14
-7
lines changed

Documentation/markers.txt

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -51,11 +51,16 @@ to call) for the specific marker through marker_probe_register() and can be
5151
activated by calling marker_arm(). Marker deactivation can be done by calling
5252
marker_disarm() as many times as marker_arm() has been called. Removing a probe
5353
is done through marker_probe_unregister(); it will disarm the probe.
54-
marker_synchronize_unregister() must be called before the end of the module exit
55-
function to make sure there is no caller left using the probe. This, and the
56-
fact that preemption is disabled around the probe call, make sure that probe
57-
removal and module unload are safe. See the "Probe example" section below for a
58-
sample probe module.
54+
55+
marker_synchronize_unregister() must be called between probe unregistration and
56+
the first occurrence of
57+
- the end of module exit function,
58+
to make sure there is no caller left using the probe;
59+
- the free of any resource used by the probes,
60+
to make sure the probes wont be accessing invalid data.
61+
This, and the fact that preemption is disabled around the probe call, make sure
62+
that probe removal and module unload are safe. See the "Probe example" section
63+
below for a sample probe module.
5964

6065
The marker mechanism supports inserting multiple instances of the same marker.
6166
Markers can be put in inline functions, inlined static functions, and

include/linux/marker.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -211,8 +211,10 @@ extern void *marker_get_private_data(const char *name, marker_probe_func *probe,
211211

212212
/*
213213
* marker_synchronize_unregister must be called between the last marker probe
214-
* unregistration and the end of module exit to make sure there is no caller
215-
* executing a probe when it is freed.
214+
* unregistration and the first one of
215+
* - the end of module exit function
216+
* - the free of any resource used by the probes
217+
* to ensure the code and data are valid for any possibly running probes.
216218
*/
217219
#define marker_synchronize_unregister() synchronize_sched()
218220

0 commit comments

Comments
 (0)