Skip to content

Commit a70839c

Browse files
jeffhostetlergitster
authored andcommitted
trace2: rename the thread_name argument to trace2_thread_start
Rename the `thread_name` argument in `tr2tls_create_self()` and `trace2_thread_start()` to be `thread_base_name` to make it clearer that the passed argument is a component used in the construction of the actual `struct tr2tls_thread_ctx.thread_name` variable. The base name will be used along with the thread id to create a unique thread name. This commit does not change how the `thread_name` field is allocated or stored within the `tr2tls_thread_ctx` structure. Signed-off-by: Jeff Hostetler <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 8e8c5ad commit a70839c

File tree

4 files changed

+12
-11
lines changed

4 files changed

+12
-11
lines changed

trace2.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -466,7 +466,7 @@ void trace2_exec_result_fl(const char *file, int line, int exec_id, int code)
466466
file, line, us_elapsed_absolute, exec_id, code);
467467
}
468468

469-
void trace2_thread_start_fl(const char *file, int line, const char *thread_name)
469+
void trace2_thread_start_fl(const char *file, int line, const char *thread_base_name)
470470
{
471471
struct tr2_tgt *tgt_j;
472472
int j;
@@ -488,14 +488,14 @@ void trace2_thread_start_fl(const char *file, int line, const char *thread_name)
488488
*/
489489
trace2_region_enter_printf_fl(file, line, NULL, NULL, NULL,
490490
"thread-proc on main: %s",
491-
thread_name);
491+
thread_base_name);
492492
return;
493493
}
494494

495495
us_now = getnanotime() / 1000;
496496
us_elapsed_absolute = tr2tls_absolute_elapsed(us_now);
497497

498-
tr2tls_create_self(thread_name, us_now);
498+
tr2tls_create_self(thread_base_name, us_now);
499499

500500
for_each_wanted_builtin (j, tgt_j)
501501
if (tgt_j->pfn_thread_start_fl)

trace2.h

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -304,14 +304,15 @@ void trace2_exec_result_fl(const char *file, int line, int exec_id, int code);
304304
* thread-proc to allow the thread to create its own thread-local
305305
* storage.
306306
*
307-
* Thread names should be descriptive, like "preload_index".
308-
* Thread names will be decorated with an instance number automatically.
307+
* The thread base name should be descriptive, like "preload_index" or
308+
* taken from the thread-proc function. A unique thread name will be
309+
* created from the given base name and the thread id automatically.
309310
*/
310311
void trace2_thread_start_fl(const char *file, int line,
311-
const char *thread_name);
312+
const char *thread_base_name);
312313

313-
#define trace2_thread_start(thread_name) \
314-
trace2_thread_start_fl(__FILE__, __LINE__, (thread_name))
314+
#define trace2_thread_start(thread_base_name) \
315+
trace2_thread_start_fl(__FILE__, __LINE__, (thread_base_name))
315316

316317
/*
317318
* Emit a 'thread_exit' event. This must be called from inside the

trace2/tr2_tls.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ void tr2tls_start_process_clock(void)
3131
tr2tls_us_start_process = getnanotime() / 1000;
3232
}
3333

34-
struct tr2tls_thread_ctx *tr2tls_create_self(const char *thread_name,
34+
struct tr2tls_thread_ctx *tr2tls_create_self(const char *thread_base_name,
3535
uint64_t us_thread_start)
3636
{
3737
struct tr2tls_thread_ctx *ctx = xcalloc(1, sizeof(*ctx));
@@ -50,7 +50,7 @@ struct tr2tls_thread_ctx *tr2tls_create_self(const char *thread_name,
5050
strbuf_init(&ctx->thread_name, 0);
5151
if (ctx->thread_id)
5252
strbuf_addf(&ctx->thread_name, "th%02d:", ctx->thread_id);
53-
strbuf_addstr(&ctx->thread_name, thread_name);
53+
strbuf_addstr(&ctx->thread_name, thread_base_name);
5454
if (ctx->thread_name.len > TR2_MAX_THREAD_NAME)
5555
strbuf_setlen(&ctx->thread_name, TR2_MAX_THREAD_NAME);
5656

trace2/tr2_tls.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ struct tr2tls_thread_ctx {
3535
* In this and all following functions the term "self" refers to the
3636
* current thread.
3737
*/
38-
struct tr2tls_thread_ctx *tr2tls_create_self(const char *thread_name,
38+
struct tr2tls_thread_ctx *tr2tls_create_self(const char *thread_base_name,
3939
uint64_t us_thread_start);
4040

4141
/*

0 commit comments

Comments
 (0)