Skip to content

Commit 5bbb925

Browse files
jeffhostetlergitster
authored andcommitted
tr2tls: clarify TLS terminology
Reduce or eliminate use of the term "TLS" in the Trace2 code. The term "TLS" has two popular meanings: "thread-local storage" and "transport layer security". In the Trace2 source, the term is associated with the former. There was concern on the mailing list about it refering to the latter. Update the source and documentation to eliminate the use of the "TLS" term or replace it with the phrase "thread-local storage" to reduce ambiguity. Signed-off-by: Jeff Hostetler <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 545ddca commit 5bbb925

File tree

5 files changed

+24
-20
lines changed

5 files changed

+24
-20
lines changed

Documentation/technical/api-trace2.txt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -685,8 +685,8 @@ The "exec_id" field is a command-unique id and is only useful if the
685685

686686
`"thread_start"`::
687687
This event is generated when a thread is started. It is
688-
generated from *within* the new thread's thread-proc (for TLS
689-
reasons).
688+
generated from *within* the new thread's thread-proc (because
689+
it needs to access data in the thread's thread-local storage).
690690
+
691691
------------
692692
{
@@ -698,7 +698,7 @@ The "exec_id" field is a command-unique id and is only useful if the
698698

699699
`"thread_exit"`::
700700
This event is generated when a thread exits. It is generated
701-
from *within* the thread's thread-proc (for TLS reasons).
701+
from *within* the thread's thread-proc.
702702
+
703703
------------
704704
{
@@ -1206,7 +1206,7 @@ worked on 508 items at offset 2032. Thread "th04" worked on 508 items
12061206
at offset 508.
12071207
+
12081208
This example also shows that thread names are assigned in a racy manner
1209-
as each thread starts and allocates TLS storage.
1209+
as each thread starts.
12101210

12111211
Config (def param) Events::
12121212

trace2.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ static struct tr2_tgt *tr2_tgt_builtins[] =
5252
* Force (rather than lazily) initialize any of the requested
5353
* builtin TRACE2 targets at startup (and before we've seen an
5454
* actual TRACE2 event call) so we can see if we need to setup
55-
* the TR2 and TLS machinery.
55+
* private data structures and thread-local storage.
5656
*
5757
* Return the number of builtin targets enabled.
5858
*/

trace2.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -73,8 +73,7 @@ void trace2_initialize_clock(void);
7373
/*
7474
* Initialize TRACE2 tracing facility if any of the builtin TRACE2
7575
* targets are enabled in the system config or the environment.
76-
* This includes setting up the Trace2 thread local storage (TLS).
77-
* Emits a 'version' message containing the version of git
76+
* This emits a 'version' message containing the version of git
7877
* and the Trace2 protocol.
7978
*
8079
* This function should be called from `main()` as early as possible in
@@ -302,7 +301,8 @@ void trace2_exec_result_fl(const char *file, int line, int exec_id, int code);
302301

303302
/*
304303
* Emit a 'thread_start' event. This must be called from inside the
305-
* thread-proc to set up the trace2 TLS data for the thread.
304+
* thread-proc to allow the thread to create its own thread-local
305+
* storage.
306306
*
307307
* Thread names should be descriptive, like "preload_index".
308308
* Thread names will be decorated with an instance number automatically.
@@ -315,8 +315,8 @@ void trace2_thread_start_fl(const char *file, int line,
315315

316316
/*
317317
* Emit a 'thread_exit' event. This must be called from inside the
318-
* thread-proc to report thread-specific data and cleanup TLS data
319-
* for the thread.
318+
* thread-proc so that the thread can access and clean up its
319+
* thread-local storage.
320320
*/
321321
void trace2_thread_exit_fl(const char *file, int line);
322322

trace2/tr2_tls.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -69,9 +69,9 @@ struct tr2tls_thread_ctx *tr2tls_get_self(void)
6969
ctx = pthread_getspecific(tr2tls_key);
7070

7171
/*
72-
* If the thread-proc did not call trace2_thread_start(), we won't
73-
* have any TLS data associated with the current thread. Fix it
74-
* here and silently continue.
72+
* If the current thread's thread-proc did not call
73+
* trace2_thread_start(), then the thread will not have any
74+
* thread-local storage. Create it now and silently continue.
7575
*/
7676
if (!ctx)
7777
ctx = tr2tls_create_self("unknown", getnanotime() / 1000);

trace2/tr2_tls.h

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,12 @@
33

44
#include "strbuf.h"
55

6+
/*
7+
* Notice: the term "TLS" refers to "thread-local storage" in the
8+
* Trace2 source files. This usage is borrowed from GCC and Windows.
9+
* There is NO relation to "transport layer security".
10+
*/
11+
612
/*
713
* Arbitry limit for thread names for column alignment.
814
*/
@@ -17,9 +23,7 @@ struct tr2tls_thread_ctx {
1723
};
1824

1925
/*
20-
* Create TLS data for the current thread. This gives us a place to
21-
* put per-thread data, such as thread start time, function nesting
22-
* and a per-thread label for our messages.
26+
* Create thread-local storage for the current thread.
2327
*
2428
* We assume the first thread is "main". Other threads are given
2529
* non-zero thread-ids to help distinguish messages from concurrent
@@ -35,7 +39,7 @@ struct tr2tls_thread_ctx *tr2tls_create_self(const char *thread_name,
3539
uint64_t us_thread_start);
3640

3741
/*
38-
* Get our TLS data.
42+
* Get the thread-local storage pointer of the current thread.
3943
*/
4044
struct tr2tls_thread_ctx *tr2tls_get_self(void);
4145

@@ -45,7 +49,7 @@ struct tr2tls_thread_ctx *tr2tls_get_self(void);
4549
int tr2tls_is_main_thread(void);
4650

4751
/*
48-
* Free our TLS data.
52+
* Free the current thread's thread-local storage.
4953
*/
5054
void tr2tls_unset_self(void);
5155

@@ -81,12 +85,12 @@ uint64_t tr2tls_region_elasped_self(uint64_t us);
8185
uint64_t tr2tls_absolute_elapsed(uint64_t us);
8286

8387
/*
84-
* Initialize the tr2 TLS system.
88+
* Initialize thread-local storage for Trace2.
8589
*/
8690
void tr2tls_init(void);
8791

8892
/*
89-
* Free all tr2 TLS resources.
93+
* Free all Trace2 thread-local storage resources.
9094
*/
9195
void tr2tls_release(void);
9296

0 commit comments

Comments
 (0)