diff mbox series

[v3,5/8] trace2: improve thread-name documentation in the thread-context

Message ID 8cb206b76323e14d8e07f6cfb5aa482a47eb54c5.1666290489.git.gitgitgadget@gmail.com (mailing list archive)
State Superseded
Headers show
Series Trace2 timers and counters and some cleanup | expand

Commit Message

Jeff Hostetler Oct. 20, 2022, 6:28 p.m. UTC
From: Jeff Hostetler <jeffhost@microsoft.com>

Improve the documentation of the tr2tls_thread_ctx.thread_name field
and its relation to the tr2tls_thread_ctx.thread_id field.

Signed-off-by: Jeff Hostetler <jeffhost@microsoft.com>
---
 trace2/tr2_tls.h | 15 +++++++++------
 1 file changed, 9 insertions(+), 6 deletions(-)

Comments

Ævar Arnfjörð Bjarmason Oct. 20, 2022, 6:57 p.m. UTC | #1
On Thu, Oct 20 2022, Jeff Hostetler via GitGitGadget wrote:

> From: Jeff Hostetler <jeffhost@microsoft.com>
>
> Improve the documentation of the tr2tls_thread_ctx.thread_name field
> and its relation to the tr2tls_thread_ctx.thread_id field.

Good to see this split off, thanks!

> Signed-off-by: Jeff Hostetler <jeffhost@microsoft.com>
> ---
>  trace2/tr2_tls.h | 15 +++++++++------
>  1 file changed, 9 insertions(+), 6 deletions(-)
>
> diff --git a/trace2/tr2_tls.h b/trace2/tr2_tls.h
> index d4e725f430b..7d1f03a2ea6 100644
> --- a/trace2/tr2_tls.h
> +++ b/trace2/tr2_tls.h
> @@ -25,12 +25,15 @@ struct tr2tls_thread_ctx {
>  /*
>   * 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
> - * threads.
> - *
> - * Truncate the thread name if necessary to help with column alignment
> - * in printf-style messages.
> + * The first thread in the process will have:
> + *     { .thread_id=0, .thread_name="main" }
> + * Subsequent threads are given a non-zero thread_id and a thread_name
> + * constructed from the id and a thread base name (which is usually just
> + * the name of the thread-proc function).  For example:
> + *     { .thread_id=10, .thread_name="th10fsm-listen" }

I think the example is missing a ":" after the "th10", i.e. it should be
"th10:fsm-listen" per the code in 6/8:

	strbuf_addf(&buf, "th%02d:", ctx->thread_id);
        [...]
Jeff Hostetler Oct. 20, 2022, 8:15 p.m. UTC | #2
On 10/20/22 2:57 PM, Ævar Arnfjörð Bjarmason wrote:
> 
> On Thu, Oct 20 2022, Jeff Hostetler via GitGitGadget wrote:
> 
>> From: Jeff Hostetler <jeffhost@microsoft.com>
>>
>> Improve the documentation of the tr2tls_thread_ctx.thread_name field
>> and its relation to the tr2tls_thread_ctx.thread_id field.
> 
> Good to see this split off, thanks!
> 
[...]
>> + * the name of the thread-proc function).  For example:
>> + *     { .thread_id=10, .thread_name="th10fsm-listen" }
> 
> I think the example is missing a ":" after the "th10", i.e. it should be
> "th10:fsm-listen" per the code in 6/8:
> 
> 	strbuf_addf(&buf, "th%02d:", ctx->thread_id);
>          [...]
> 

oops.  :-)
good catch.

i'll fix up and resend, but will wait a bit for any other comments.

Jeff
diff mbox series

Patch

diff --git a/trace2/tr2_tls.h b/trace2/tr2_tls.h
index d4e725f430b..7d1f03a2ea6 100644
--- a/trace2/tr2_tls.h
+++ b/trace2/tr2_tls.h
@@ -25,12 +25,15 @@  struct tr2tls_thread_ctx {
 /*
  * 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
- * threads.
- *
- * Truncate the thread name if necessary to help with column alignment
- * in printf-style messages.
+ * The first thread in the process will have:
+ *     { .thread_id=0, .thread_name="main" }
+ * Subsequent threads are given a non-zero thread_id and a thread_name
+ * constructed from the id and a thread base name (which is usually just
+ * the name of the thread-proc function).  For example:
+ *     { .thread_id=10, .thread_name="th10fsm-listen" }
+ * This helps to identify and distinguish messages from concurrent threads.
+ * The ctx.thread_name field is truncated if necessary to help with column
+ * alignment in printf-style messages.
  *
  * In this and all following functions the term "self" refers to the
  * current thread.