diff mbox series

[v4,1/8] trace2: use size_t alloc,nr_open_regions in tr2tls_thread_ctx

Message ID 6e7e4f3187e2fbbbb54bb1cf5793bf6e981a5a94.1666618868.git.gitgitgadget@gmail.com (mailing list archive)
State Accepted
Commit 545ddca0c32cb3ccdffed4aa9f063c84b432940c
Headers show
Series Trace2 timers and counters and some cleanup | expand

Commit Message

Jeff Hostetler Oct. 24, 2022, 1:41 p.m. UTC
From: Jeff Hostetler <jeffhost@microsoft.com>

Use "size_t" rather than "int" for the "alloc" and "nr_open_regions"
fields in the "tr2tls_thread_ctx".  These are used by ALLOC_GROW().

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

Comments

Junio C Hamano Oct. 24, 2022, 8:31 p.m. UTC | #1
As I do not see a cover letter for this series, here is the summary
of the change since the previous round that has been in 'seen'.

I didn't see anything questionable in these.

Thanks, will queue.

 trace2/tr2_tgt.h        | 2 +-
 trace2/tr2_tgt_event.c  | 6 +++---
 trace2/tr2_tgt_normal.c | 6 +++---
 trace2/tr2_tgt_perf.c   | 6 +++---
 trace2/tr2_tls.h        | 2 +-
 5 files changed, 11 insertions(+), 11 deletions(-)

diff --git c/trace2/tr2_tgt.h w/trace2/tr2_tgt.h
index 95f4c75472..bf8745c4f0 100644
--- c/trace2/tr2_tgt.h
+++ w/trace2/tr2_tgt.h
@@ -9,7 +9,7 @@ struct tr2_timer;
 struct tr2_counter_metadata;
 struct tr2_counter;
 
-#define NS_PER_SEC_D ((double)1000*1000*1000)
+#define NS_TO_SEC(ns) ((double)(ns) / 1.0e9)
 
 /*
  * Function prototypes for a TRACE2 "target" vtable.
diff --git c/trace2/tr2_tgt_event.c w/trace2/tr2_tgt_event.c
index 981863a660..16f6332755 100644
--- c/trace2/tr2_tgt_event.c
+++ w/trace2/tr2_tgt_event.c
@@ -624,9 +624,9 @@ static void fn_timer(const struct tr2_timer_metadata *meta,
 {
 	const char *event_name = is_final_data ? "timer" : "th_timer";
 	struct json_writer jw = JSON_WRITER_INIT;
-	double t_total = ((double)timer->total_ns) / NS_PER_SEC_D;
-	double t_min = ((double)timer->min_ns) / NS_PER_SEC_D;
-	double t_max = ((double)timer->max_ns) / NS_PER_SEC_D;
+	double t_total = NS_TO_SEC(timer->total_ns);
+	double t_min = NS_TO_SEC(timer->min_ns);
+	double t_max = NS_TO_SEC(timer->max_ns);
 
 	jw_object_begin(&jw, 0);
 	event_fmt_prepare(event_name, __FILE__, __LINE__, NULL, &jw);
diff --git c/trace2/tr2_tgt_normal.c w/trace2/tr2_tgt_normal.c
index def18674e8..fbbef68dfc 100644
--- c/trace2/tr2_tgt_normal.c
+++ w/trace2/tr2_tgt_normal.c
@@ -336,9 +336,9 @@ static void fn_timer(const struct tr2_timer_metadata *meta,
 {
 	const char *event_name = is_final_data ? "timer" : "th_timer";
 	struct strbuf buf_payload = STRBUF_INIT;
-	double t_total = ((double)timer->total_ns) / NS_PER_SEC_D;
-	double t_min = ((double)timer->min_ns) / NS_PER_SEC_D;
-	double t_max = ((double)timer->max_ns) / NS_PER_SEC_D;
+	double t_total = NS_TO_SEC(timer->total_ns);
+	double t_min = NS_TO_SEC(timer->min_ns);
+	double t_max = NS_TO_SEC(timer->max_ns);
 
 	strbuf_addf(&buf_payload, ("%s %s/%s"
 				   " intervals:%"PRIu64
diff --git c/trace2/tr2_tgt_perf.c w/trace2/tr2_tgt_perf.c
index db94b2ef47..adae803263 100644
--- c/trace2/tr2_tgt_perf.c
+++ w/trace2/tr2_tgt_perf.c
@@ -562,9 +562,9 @@ static void fn_timer(const struct tr2_timer_metadata *meta,
 {
 	const char *event_name = is_final_data ? "timer" : "th_timer";
 	struct strbuf buf_payload = STRBUF_INIT;
-	double t_total = ((double)timer->total_ns) / NS_PER_SEC_D;
-	double t_min = ((double)timer->min_ns) / NS_PER_SEC_D;
-	double t_max = ((double)timer->max_ns) / NS_PER_SEC_D;
+	double t_total = NS_TO_SEC(timer->total_ns);
+	double t_min = NS_TO_SEC(timer->min_ns);
+	double t_max = NS_TO_SEC(timer->max_ns);
 
 	strbuf_addf(&buf_payload, ("name:%s"
 				   " intervals:%"PRIu64
diff --git c/trace2/tr2_tls.h w/trace2/tr2_tls.h
index 289b62d072..f9049805d4 100644
--- c/trace2/tr2_tls.h
+++ w/trace2/tr2_tls.h
@@ -38,7 +38,7 @@ struct tr2tls_thread_ctx {
  * 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" }
+ *     { .thread_id=10, .thread_name="th10:fsm-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.
Derrick Stolee Oct. 25, 2022, 12:35 p.m. UTC | #2
On 10/24/2022 4:31 PM, Junio C Hamano wrote:
> As I do not see a cover letter for this series, here is the summary
> of the change since the previous round that has been in 'seen'.
> 
> I didn't see anything questionable in these.
> 
> Thanks, will queue.

The cover letter appears on my end, but I'm on the CC list.

Jeff: be sure to CC Junio by adding him to the CC list on your
PR description for anything you want to have considered for
queuing.

Thanks,
-Stolee
Junio C Hamano Oct. 25, 2022, 3:40 p.m. UTC | #3
Derrick Stolee <derrickstolee@github.com> writes:

> On 10/24/2022 4:31 PM, Junio C Hamano wrote:
>> As I do not see a cover letter for this series, here is the summary
>> of the change since the previous round that has been in 'seen'.
>> 
>> I didn't see anything questionable in these.
>> 
>> Thanks, will queue.
>
> The cover letter appears on my end, but I'm on the CC list.

Yeah, it seems vger was a bit constipated yesterday.  Everything
came through at the end, and I am happy with the series.

> Jeff: be sure to CC Junio by adding him to the CC list on your
> PR description for anything you want to have considered for
> queuing.

Everybody wants their non RFC patches to have considered for
queuing, but vger is not that lossy ;-)
diff mbox series

Patch

diff --git a/trace2/tr2_tls.h b/trace2/tr2_tls.h
index b1e327a928e..a90bd639d48 100644
--- a/trace2/tr2_tls.h
+++ b/trace2/tr2_tls.h
@@ -11,8 +11,8 @@ 
 struct tr2tls_thread_ctx {
 	struct strbuf thread_name;
 	uint64_t *array_us_start;
-	int alloc;
-	int nr_open_regions; /* plays role of "nr" in ALLOC_GROW */
+	size_t alloc;
+	size_t nr_open_regions; /* plays role of "nr" in ALLOC_GROW */
 	int thread_id;
 };