git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: "Jeff Hostetler via GitGitGadget" <gitgitgadget@gmail.com>
To: git@vger.kernel.org
Cc: "Ævar Arnfjörð Bjarmason" <avarab@gmail.com>,
	"Jeff Hostetler" <git@jeffhostetler.com>,
	"Derrick Stolee" <derrickstolee@github.com>,
	"Jeff Hostetler" <jeffhost@microsoft.com>,
	"Jeff Hostetler" <jeffhost@microsoft.com>
Subject: [PATCH v3 2/8] tr2tls: clarify TLS terminology
Date: Thu, 20 Oct 2022 18:28:03 +0000	[thread overview]
Message-ID: <9dee7a75903936f086d97580441c776978d70b43.1666290489.git.gitgitgadget@gmail.com> (raw)
In-Reply-To: <pull.1373.v3.git.1666290489.gitgitgadget@gmail.com>

From: Jeff Hostetler <jeffhost@microsoft.com>

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 <jeffhost@microsoft.com>
---
 Documentation/technical/api-trace2.txt |  8 ++++----
 trace2.c                               |  2 +-
 trace2.h                               | 10 +++++-----
 trace2/tr2_tls.c                       |  6 +++---
 trace2/tr2_tls.h                       | 18 +++++++++++-------
 5 files changed, 24 insertions(+), 20 deletions(-)

diff --git a/Documentation/technical/api-trace2.txt b/Documentation/technical/api-trace2.txt
index 2afa28bb5aa..431d424f9d5 100644
--- a/Documentation/technical/api-trace2.txt
+++ b/Documentation/technical/api-trace2.txt
@@ -685,8 +685,8 @@ The "exec_id" field is a command-unique id and is only useful if the
 
 `"thread_start"`::
 	This event is generated when a thread is started.  It is
-	generated from *within* the new thread's thread-proc (for TLS
-	reasons).
+	generated from *within* the new thread's thread-proc (because
+	it needs to access data in the thread's thread-local storage).
 +
 ------------
 {
@@ -698,7 +698,7 @@ The "exec_id" field is a command-unique id and is only useful if the
 
 `"thread_exit"`::
 	This event is generated when a thread exits.  It is generated
-	from *within* the thread's thread-proc (for TLS reasons).
+	from *within* the thread's thread-proc.
 +
 ------------
 {
@@ -1206,7 +1206,7 @@ worked on 508 items at offset 2032.  Thread "th04" worked on 508 items
 at offset 508.
 +
 This example also shows that thread names are assigned in a racy manner
-as each thread starts and allocates TLS storage.
+as each thread starts.
 
 Config (def param) Events::
 
diff --git a/trace2.c b/trace2.c
index 0c0a11e07d5..c1244e45ace 100644
--- a/trace2.c
+++ b/trace2.c
@@ -52,7 +52,7 @@ static struct tr2_tgt *tr2_tgt_builtins[] =
  * Force (rather than lazily) initialize any of the requested
  * builtin TRACE2 targets at startup (and before we've seen an
  * actual TRACE2 event call) so we can see if we need to setup
- * the TR2 and TLS machinery.
+ * private data structures and thread-local storage.
  *
  * Return the number of builtin targets enabled.
  */
diff --git a/trace2.h b/trace2.h
index 88d906ea830..af3c11694cc 100644
--- a/trace2.h
+++ b/trace2.h
@@ -73,8 +73,7 @@ void trace2_initialize_clock(void);
 /*
  * Initialize TRACE2 tracing facility if any of the builtin TRACE2
  * targets are enabled in the system config or the environment.
- * This includes setting up the Trace2 thread local storage (TLS).
- * Emits a 'version' message containing the version of git
+ * This emits a 'version' message containing the version of git
  * and the Trace2 protocol.
  *
  * 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);
 
 /*
  * Emit a 'thread_start' event.  This must be called from inside the
- * thread-proc to set up the trace2 TLS data for the thread.
+ * thread-proc to allow the thread to create its own thread-local
+ * storage.
  *
  * Thread names should be descriptive, like "preload_index".
  * Thread names will be decorated with an instance number automatically.
@@ -315,8 +315,8 @@ void trace2_thread_start_fl(const char *file, int line,
 
 /*
  * Emit a 'thread_exit' event.  This must be called from inside the
- * thread-proc to report thread-specific data and cleanup TLS data
- * for the thread.
+ * thread-proc so that the thread can access and clean up its
+ * thread-local storage.
  */
 void trace2_thread_exit_fl(const char *file, int line);
 
diff --git a/trace2/tr2_tls.c b/trace2/tr2_tls.c
index 7da94aba522..8d2182fbdbb 100644
--- a/trace2/tr2_tls.c
+++ b/trace2/tr2_tls.c
@@ -69,9 +69,9 @@ struct tr2tls_thread_ctx *tr2tls_get_self(void)
 	ctx = pthread_getspecific(tr2tls_key);
 
 	/*
-	 * If the thread-proc did not call trace2_thread_start(), we won't
-	 * have any TLS data associated with the current thread.  Fix it
-	 * here and silently continue.
+	 * If the current thread's thread-proc did not call
+	 * trace2_thread_start(), then the thread will not have any
+	 * thread-local storage.  Create it now and silently continue.
 	 */
 	if (!ctx)
 		ctx = tr2tls_create_self("unknown", getnanotime() / 1000);
diff --git a/trace2/tr2_tls.h b/trace2/tr2_tls.h
index a90bd639d48..1297509fd23 100644
--- a/trace2/tr2_tls.h
+++ b/trace2/tr2_tls.h
@@ -3,6 +3,12 @@
 
 #include "strbuf.h"
 
+/*
+ * Notice: the term "TLS" refers to "thread-local storage" in the
+ * Trace2 source files.  This usage is borrowed from GCC and Windows.
+ * There is NO relation to "transport layer security".
+ */
+
 /*
  * Arbitry limit for thread names for column alignment.
  */
@@ -17,9 +23,7 @@ struct tr2tls_thread_ctx {
 };
 
 /*
- * Create TLS data for the current thread.  This gives us a place to
- * put per-thread data, such as thread start time, function nesting
- * and a per-thread label for our messages.
+ * Create thread-local storage for the current thread.
  *
  * We assume the first thread is "main".  Other threads are given
  * 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,
 					     uint64_t us_thread_start);
 
 /*
- * Get our TLS data.
+ * Get the thread-local storage pointer of the current thread.
  */
 struct tr2tls_thread_ctx *tr2tls_get_self(void);
 
@@ -45,7 +49,7 @@ struct tr2tls_thread_ctx *tr2tls_get_self(void);
 int tr2tls_is_main_thread(void);
 
 /*
- * Free our TLS data.
+ * Free the current thread's thread-local storage.
  */
 void tr2tls_unset_self(void);
 
@@ -81,12 +85,12 @@ uint64_t tr2tls_region_elasped_self(uint64_t us);
 uint64_t tr2tls_absolute_elapsed(uint64_t us);
 
 /*
- * Initialize the tr2 TLS system.
+ * Initialize thread-local storage for Trace2.
  */
 void tr2tls_init(void);
 
 /*
- * Free all tr2 TLS resources.
+ * Free all Trace2 thread-local storage resources.
  */
 void tr2tls_release(void);
 
-- 
gitgitgadget


  parent reply	other threads:[~2022-10-20 18:28 UTC|newest]

Thread overview: 73+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-10-04 16:19 [PATCH 0/9] Trace2 timers and counters and some cleanup Jeff Hostetler via GitGitGadget
2022-10-04 16:19 ` [PATCH 1/9] builtin/merge-file: fix compiler warning on MacOS with clang 11.0.0 Jeff Hostetler via GitGitGadget
2022-10-04 16:20 ` [PATCH 2/9] builtin/unpack-objects.c: " Jeff Hostetler via GitGitGadget
2022-10-04 16:20 ` [PATCH 3/9] trace2: use size_t alloc,nr_open_regions in tr2tls_thread_ctx Jeff Hostetler via GitGitGadget
2022-10-04 16:20 ` [PATCH 4/9] tr2tls: clarify TLS terminology Jeff Hostetler via GitGitGadget
2022-10-04 16:20 ` [PATCH 5/9] trace2: rename trace2 thread_name argument as name_hint Jeff Hostetler via GitGitGadget
2022-10-04 16:20 ` [PATCH 6/9] trace2: convert ctx.thread_name to flex array Jeff Hostetler via GitGitGadget
2022-10-05 11:14   ` Ævar Arnfjörð Bjarmason
2022-10-06 16:28     ` Jeff Hostetler
2022-10-10 18:31     ` Jeff Hostetler
2022-10-05 18:03   ` Junio C Hamano
2022-10-06 21:05     ` Ævar Arnfjörð Bjarmason
2022-10-06 21:50       ` Junio C Hamano
2022-10-07  1:10         ` [RFC PATCH] trace2 API: don't save a copy of constant "thread_name" Ævar Arnfjörð Bjarmason
2022-10-07  1:16           ` Junio C Hamano
2022-10-07 10:03             ` Ævar Arnfjörð Bjarmason
2022-10-10 19:16               ` Jeff Hostetler
2022-10-11 13:31                 ` Ævar Arnfjörð Bjarmason
2022-10-12 13:31                   ` Jeff Hostetler
2022-10-10 19:05           ` Jeff Hostetler
2022-10-11 12:52             ` Ævar Arnfjörð Bjarmason
2022-10-11 14:40               ` Junio C Hamano
2022-10-10 18:39       ` [PATCH 6/9] trace2: convert ctx.thread_name to flex array Jeff Hostetler
2022-10-04 16:20 ` [PATCH 7/9] api-trace2.txt: elminate section describing the public trace2 API Jeff Hostetler via GitGitGadget
2022-10-04 16:20 ` [PATCH 8/9] trace2: add stopwatch timers Jeff Hostetler via GitGitGadget
2022-10-04 16:20 ` [PATCH 9/9] trace2: add global counter mechanism Jeff Hostetler via GitGitGadget
2022-10-05 13:04 ` [PATCH 0/9] Trace2 timers and counters and some cleanup Ævar Arnfjörð Bjarmason
2022-10-06 15:45   ` Jeff Hostetler
2022-10-06 18:12 ` Derrick Stolee
2022-10-12 18:52 ` [PATCH v2 0/7] " Jeff Hostetler via GitGitGadget
2022-10-12 18:52   ` [PATCH v2 1/7] trace2: use size_t alloc,nr_open_regions in tr2tls_thread_ctx Jeff Hostetler via GitGitGadget
2022-10-12 18:52   ` [PATCH v2 2/7] tr2tls: clarify TLS terminology Jeff Hostetler via GitGitGadget
2022-10-13 21:12     ` Junio C Hamano
2022-10-12 18:52   ` [PATCH v2 3/7] api-trace2.txt: elminate section describing the public trace2 API Jeff Hostetler via GitGitGadget
2022-10-12 18:52   ` [PATCH v2 4/7] trace2: rename the thread_name argument to trace2_thread_start Jeff Hostetler via GitGitGadget
2022-10-12 21:06     ` Ævar Arnfjörð Bjarmason
2022-10-20 14:40       ` Jeff Hostetler
2022-10-13 21:12     ` Junio C Hamano
2022-10-12 18:52   ` [PATCH v2 5/7] trace2: convert ctx.thread_name from strbuf to pointer Jeff Hostetler via GitGitGadget
2022-10-13 21:12     ` Junio C Hamano
2022-10-12 18:52   ` [PATCH v2 6/7] trace2: add stopwatch timers Jeff Hostetler via GitGitGadget
2022-10-13 21:12     ` Junio C Hamano
2022-10-20 14:42       ` Jeff Hostetler
2022-10-12 18:52   ` [PATCH v2 7/7] trace2: add global counter mechanism Jeff Hostetler via GitGitGadget
2022-10-20 18:28   ` [PATCH v3 0/8] Trace2 timers and counters and some cleanup Jeff Hostetler via GitGitGadget
2022-10-20 18:28     ` [PATCH v3 1/8] trace2: use size_t alloc,nr_open_regions in tr2tls_thread_ctx Jeff Hostetler via GitGitGadget
2022-10-20 18:28     ` Jeff Hostetler via GitGitGadget [this message]
2022-10-20 18:28     ` [PATCH v3 3/8] api-trace2.txt: elminate section describing the public trace2 API Jeff Hostetler via GitGitGadget
2022-10-20 18:28     ` [PATCH v3 4/8] trace2: rename the thread_name argument to trace2_thread_start Jeff Hostetler via GitGitGadget
2022-10-20 18:28     ` [PATCH v3 5/8] trace2: improve thread-name documentation in the thread-context Jeff Hostetler via GitGitGadget
2022-10-20 18:57       ` Ævar Arnfjörð Bjarmason
2022-10-20 20:15         ` Jeff Hostetler
2022-10-20 18:28     ` [PATCH v3 6/8] trace2: convert ctx.thread_name from strbuf to pointer Jeff Hostetler via GitGitGadget
2022-10-20 18:28     ` [PATCH v3 7/8] trace2: add stopwatch timers Jeff Hostetler via GitGitGadget
2022-10-20 20:25       ` Junio C Hamano
2022-10-20 20:52         ` Jeff Hostetler
2022-10-20 20:55           ` Junio C Hamano
2022-10-21 21:51             ` Jeff Hostetler
2022-10-20 18:28     ` [PATCH v3 8/8] trace2: add global counter mechanism Jeff Hostetler via GitGitGadget
2022-10-24 13:40     ` [PATCH v4 0/8] Trace2 timers and counters and some cleanup Jeff Hostetler via GitGitGadget
2022-10-24 13:41       ` [PATCH v4 1/8] trace2: use size_t alloc,nr_open_regions in tr2tls_thread_ctx Jeff Hostetler via GitGitGadget
2022-10-24 20:31         ` Junio C Hamano
2022-10-25 12:35           ` Derrick Stolee
2022-10-25 15:40             ` Junio C Hamano
2022-10-24 13:41       ` [PATCH v4 2/8] tr2tls: clarify TLS terminology Jeff Hostetler via GitGitGadget
2022-10-24 13:41       ` [PATCH v4 3/8] api-trace2.txt: elminate section describing the public trace2 API Jeff Hostetler via GitGitGadget
2022-10-24 13:41       ` [PATCH v4 4/8] trace2: rename the thread_name argument to trace2_thread_start Jeff Hostetler via GitGitGadget
2022-10-24 13:41       ` [PATCH v4 5/8] trace2: improve thread-name documentation in the thread-context Jeff Hostetler via GitGitGadget
2022-10-24 13:41       ` [PATCH v4 6/8] trace2: convert ctx.thread_name from strbuf to pointer Jeff Hostetler via GitGitGadget
2022-10-24 13:41       ` [PATCH v4 7/8] trace2: add stopwatch timers Jeff Hostetler via GitGitGadget
2022-10-24 13:41       ` [PATCH v4 8/8] trace2: add global counter mechanism Jeff Hostetler via GitGitGadget
2022-10-25 12:27       ` [PATCH v4 0/8] Trace2 timers and counters and some cleanup Derrick Stolee
2022-10-25 15:36         ` Junio C Hamano

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: http://vger.kernel.org/majordomo-info.html

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=9dee7a75903936f086d97580441c776978d70b43.1666290489.git.gitgitgadget@gmail.com \
    --to=gitgitgadget@gmail.com \
    --cc=avarab@gmail.com \
    --cc=derrickstolee@github.com \
    --cc=git@jeffhostetler.com \
    --cc=git@vger.kernel.org \
    --cc=jeffhost@microsoft.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).