Trace subsystem fixes
cover Trace subsystem fixes
Hello,
This series addresses a number of issues and limitations I have identified over time in the trace subsystem.
The main issue was with dynamically enabling trace points which was not working if no trace point had been enabled at rte_eal_init() time.
This is 22.11 material from my pov.
We may start thinking about marking this API stable, but this is another topic.
Signature · 23 lines
David Marchand David Marchand (8): trace: fix mode for new trace point trace: fix mode change trace: fix leak with regexp trace: fix dynamically enabling trace points trace: fix race in debug dump trace: fix metadata dump trace: remove limitation on trace point name trace: remove limitation on directory app/test/test_trace.c | 67 +++++++++--------- app/test/test_trace.h | 2 + doc/guides/prog_guide/trace_lib.rst | 14 ++-- lib/eal/common/eal_common_trace.c | 92 +++++++++++-------------- lib/eal/common/eal_common_trace_ctf.c | 3 - lib/eal/common/eal_common_trace_utils.c | 87 +++++++++++------------ lib/eal/common/eal_trace.h | 11 +-- 7 files changed, 130 insertions(+), 146 deletions(-) -- 2.37.3
PATCH 1/8 trace: fix mode for new trace point
If an application registers trace points later than rte_eal_init(), changes in the trace point mode were not applied.
--- lib/eal/common/eal_common_trace.c | 1 + 1 file changed, 1 insertion(+)
lib/eal/common/eal_common_trace.c +1 -0
@@ -511,6 +511,7 @@ __rte_trace_point_register(rte_trace_point_t *handle, const char *name,/* Form the trace handle */ *handle = sz; *handle |= trace.nb_trace_points << __RTE_TRACE_FIELD_ID_SHIFT; +trace_mode_set (handle, trace.mode); trace.nb_trace_points++; tp->handle = handle;
Signature · 1 line
2.37.3
PATCH 2/8 trace: fix mode change
In reply to David MarchandThe API does not state that changing mode should be refused if no trace point is enabled. Remove this limitation.
--- app/test/test_trace.c | 3 --- lib/eal/common/eal_common_trace.c | 3 --- 2 files changed, 6 deletions(-)
app/test/test_trace.c +0 -3
@@ -126,9 +126,6 @@ test_trace_mode(void) current =rte_trace_mode_get (); -if (!rte_trace_is_enabled ()) -return TEST_SKIPPED ; -rte_trace_mode_set (RTE_TRACE_MODE_DISCARD );if (rte_trace_mode_get () !=RTE_TRACE_MODE_DISCARD ) goto failed;
lib/eal/common/eal_common_trace.c +0 -3
@@ -126,9 +126,6 @@ rte_trace_mode_set(enum rte_trace_mode mode) {struct trace_point *tp; -if (!rte_trace_is_enabled ()) -return ; - STAILQ_FOREACH(tp, &tp_list, next)trace_mode_set (tp->handle, mode);
Signature · 1 line
2.37.3
PATCH 3/8 trace: fix leak with regexp
In reply to David MarchandThe precompiled buffer initialised in regcomp must be freed before leaving rte_trace_regexp.
--- lib/eal/common/eal_common_trace.c | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-)
lib/eal/common/eal_common_trace.c +11 -8
@@ -210,15 +210,18 @@ rte_trace_regexp(const char *regex, bool enable)return -EINVAL ; STAILQ_FOREACH(tp, &tp_list, next) { -if (regexec (&r, tp->name,0 ,NULL ,0 ) ==0 ) { -if (enable) - rc =rte_trace_point_enable (tp->handle); -else - rc =rte_trace_point_disable (tp->handle); - found =1 ; +if (regexec (&r, tp->name,0 ,NULL ,0 ) !=0 ) +continue ; + +if (enable) + rc =rte_trace_point_enable (tp->handle); +else + rc =rte_trace_point_disable (tp->handle); +if (rc <0 ) { + found =0 ; +break ; } -if (rc <0 ) -return rc; + found =1 ; }regfree (&r);
Signature · 1 line
2.37.3
RE: [EXT] [PATCH 3/8] trace: fix leak with regexp
Quoted 45 lines
-----Original Message-----
From: David Marchand <[email protected]>
Sent: Wednesday, September 21, 2022 5:34 PM
To: [email protected]
Cc: [email protected]; Jerin Jacob Kollanukkaran <[email protected]>; Sunil Kumar Kori <[email protected]>
Subject: [EXT] [PATCH 3/8] trace: fix leak with regexpExternal Email
----------------------------------------------------------------------
The precompiled buffer initialised in regcomp must be freed before leavingrte_trace_regexp.Fixes 84c4fae4628f ("trace: implement operation APIs")Signed-off-by David Marchand <[email protected]>--- lib/eal/common/eal_common_trace.c | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-)lib/eal/common/eal_common_trace.c +8
-6@@ -210,15 +210,18 @@ rte_trace_regexp(const char *regex, bool enable)return -EINVAL ; STAILQ_FOREACH(tp, &tp_list, next) { -if (regexec (&r, tp->name,0 ,NULL ,0 ) ==0 ) { -if (enable) - rc =rte_trace_point_enable (tp->handle); -else - rc =rte_trace_point_disable (tp->handle); - found =1 ; +if (regexec (&r, tp->name,0 ,NULL ,0 ) !=0 ) +continue ; + +if (enable) + rc =rte_trace_point_enable (tp->handle); +else + rc =rte_trace_point_disable (tp->handle); +if (rc <0 ) {
lib/eal/common/eal_common_trace.c rte_trace_regexp(const char *regex, bool enable)
Quoted 10 lines
lib/eal/common/eal_common_trace.c +3
-3+ found =0 ; +break ; } -if (rc <0 ) -return rc; + found =1 ; }regfree (&r); --
I understand the problem addressed by this fix but may be following changes will be sufficient to fix it. Please highlight, If I am missing. Just trying to reduce the line of changes.
@@ -220,8 +220,10 @@ rte_trace_regexp(const char *regex, bool enable)
rc = rte_trace_point_disable(tp->handle);
found = 1;
}- if (rc < 0)
- return rc;
+ if (rc < 0) {
+ found = 0;
+ break;
+ }
}
Quoted 1 line
2.37.3
Re: [EXT] [PATCH 3/8] trace: fix leak with regexp
Quoted 33 lines · Sunil Kumar Kori
Quoted 18 lines
lib/eal/common/eal_common_trace.c +8
-6@@ -210,15 +210,18 @@ rte_trace_regexp(const char *regex, bool enable)return -EINVAL ; STAILQ_FOREACH(tp, &tp_list, next) { -if (regexec (&r, tp->name,0 ,NULL ,0 ) ==0 ) { -if (enable) - rc =rte_trace_point_enable (tp->handle); -else - rc =rte_trace_point_disable (tp->handle); - found =1 ; +if (regexec (&r, tp->name,0 ,NULL ,0 ) !=0 ) +continue ; + +if (enable) + rc =rte_trace_point_enable (tp->handle); +else + rc =rte_trace_point_disable (tp->handle); +if (rc <0 ) {lib/eal/common/eal_common_trace.c rte_trace_regexp(const char *regex, bool enable)
Quoted 10 lines
lib/eal/common/eal_common_trace.c +3
-3+ found =0 ; +break ; } -if (rc <0 ) -return rc; + found =1 ; }regfree (&r); --I understand the problem addressed by this fix but may be following changes will be sufficient to fix it. Please highlight, If I am missing. Just trying to reduce the line of changes.
Review rte_trace_regexp(const char *regex, bool enable) · line 227
Quoted 10 lines
(quoted diff) +4
-2@@ -220,8 +220,10 @@ rte_trace_regexp(const char *regex, bool enable) rc = rte_trace_point_disable(tp->handle); found = 1; } - if (rc < 0) - return rc; + if (rc < 0) { + found = 0; + break; + } }
rc is compared against 0 for all non-matching tracepoints. This is unnecessary and fragile.
I can split this change in two: one for the fix, and one other where the loop is updated with a continue and an inverted matching condition like above.
If going like this, I would update rte_trace_pattern() too, in the second patch.
WDYT?
Signature · 1 line
David Marchand
RE: [EXT] [PATCH 3/8] trace: fix leak with regexp
Quoted 60 lines
-----Original Message-----
From: David Marchand <[email protected]>
Sent: Friday, September 23, 2022 12:05 PM
To: Sunil Kumar Kori <[email protected]>
Cc: [email protected]; [email protected]; Jerin Jacob Kollanukkaran <[email protected]>
Subject: Re: [EXT] [PATCH 3/8] trace: fix leak with regexpQuoted 1 line · Sunil Kumar Kori
Review rte_trace_regexp(const char *regex, bool
Quoted 1 line
(quoted diff) +0
-0@@ -210,15 +210,18 @@ rte_trace_regexp(const char *regex, boolenable)
Quoted 26 lines
Quoted 26 lines
lib/eal/common/eal_common_trace.c +11
-8return -EINVAL ; STAILQ_FOREACH(tp, &tp_list, next) { -if (regexec (&r, tp->name,0 ,NULL ,0 ) ==0 ) { -if (enable) - rc =rte_trace_point_enable (tp->handle); -else - rc =rte_trace_point_disable (tp->handle); - found =1 ; +if (regexec (&r, tp->name,0 ,NULL ,0 ) !=0 ) +continue ; + +if (enable) + rc =rte_trace_point_enable (tp->handle); +else + rc =rte_trace_point_disable (tp->handle); +if (rc <0 ) { + found =0 ; +break ; } -if (rc <0 ) -return rc; + found =1 ; }regfree (&r);Quoted 3 lines
Quoted 1 line
--
I understand the problem addressed by this fix but may be following
changes will be sufficient to fix it.
Review rte_trace_regexp(const char *regex, bool enable) · line 227
Quoted 13 lines
Please highlight, If I am missing. Just trying to reduce the line of changes.
(quoted diff) +4
-2@@ -220,8 +220,10 @@ rte_trace_regexp(const char *regex, bool enable) rc = rte_trace_point_disable(tp->handle); found = 1; } - if (rc < 0) - return rc; + if (rc < 0) { + found = 0; + break; + } }rc is compared against 0 for all non-matching tracepoints. This is unnecessary and fragile.
Quoted 5 lines
I can split this change in two: one for the fix, and one other where the loop is updated with a continue and an inverted matching condition like above. If going like this, I would update
rte_trace_pattern()too, in the second patch.WDYT?
Sounds okay. You can proceed in either way. No hard opinion on it.
Quoted 4 lines
--
David Marchand
PATCH 4/8 trace: fix dynamically enabling trace points
In reply to David MarchandEnabling trace points at runtime was not working if no trace point had been enabled first at rte_eal_init() time. The reason was that trace.args reflected the arguments passed to --trace= EAL option.
To fix this:
- the trace subsystem initialisation is updated: trace directory creation is deferred to when traces are dumped (to avoid creating directories that may not be used),
- per lcore memory allocation still relies on rte_trace_is_enabled() but this helper now tracks if any trace point is enabled. The documentation is updated accordingly,
- cleanup helpers must always be called in rte_eal_cleanup() since some trace points might have been enabled and disabled in the lifetime of the DPDK application,
With this fix, we can update the unit test and check that a trace point callback is invoked when expected.
Note:
- the 'trace' global variable might be shadowed with the argument passed to the functions dealing with trace point handles. 'tp' has been used for referring to trace_point object. Prefer 't' for referring to handles,
--- app/test/test_trace.c | 20 ++++++++++ app/test/test_trace.h | 2 + doc/guides/prog_guide/trace_lib.rst | 14 +++++-- lib/eal/common/eal_common_trace.c | 53 ++++++++++--------------- lib/eal/common/eal_common_trace_utils.c | 17 +++++++- lib/eal/common/eal_trace.h | 3 +- 6 files changed, 70 insertions(+), 39 deletions(-)
app/test/test_trace.c +20 -0
@@ -9,6 +9,8 @@#include "test.h" #include "test_trace.h" +int app_dpdk_test_tp_count; +#ifdef RTE_EXEC_ENV_WINDOWS static int
@@ -95,8 +97,15 @@ test_trace_point_regex(void)static int32_t test_trace_point_disable_enable (void ) { +int expected;int rc; +/* At tp registration, the associated counter increases once. */ + expected =1 ; +TEST_ASSERT_EQUAL (app_dpdk_test_tp_count, expected, +"Expecting %d, but got %d for app_dpdk_test_tp_count" , + expected, app_dpdk_test_tp_count); + rc =rte_trace_point_disable (&__app_dpdk_test_tp);if (rc <0 ) goto failed;
@@ -104,6 +113,12 @@ test_trace_point_disable_enable(void)if (rte_trace_point_is_enabled (&__app_dpdk_test_tp)) goto failed; +/* No emission expected */ +app_dpdk_test_tp ("app.dpdk.test.tp" ); +TEST_ASSERT_EQUAL (app_dpdk_test_tp_count, expected, +"Expecting %d, but got %d for app_dpdk_test_tp_count" , + expected, app_dpdk_test_tp_count); + rc =rte_trace_point_enable (&__app_dpdk_test_tp);if (rc <0 ) goto failed;
@@ -113,6 +128,11 @@ test_trace_point_disable_enable(void)/* Emit the trace */ app_dpdk_test_tp ("app.dpdk.test.tp" ); + expected++; +TEST_ASSERT_EQUAL (app_dpdk_test_tp_count, expected, +"Expecting %d, but got %d for app_dpdk_test_tp_count" , + expected, app_dpdk_test_tp_count); +return TEST_SUCCESS ; failed:
app/test/test_trace.h +2 -0
@@ -3,10 +3,12 @@*/ #include <rte_trace_point.h> +extern int app_dpdk_test_tp_count;RTE_TRACE_POINT ( app_dpdk_test_tp, RTE_TRACE_POINT_ARGS(const char *str), rte_trace_point_emit_string(str); + app_dpdk_test_tp_count++; ) RTE_TRACE_POINT_FP(
doc/guides/prog_guide/trace_lib.rst +10 -4
@@ -271,10 +271,16 @@ Trace memory The trace memory will be allocated through an internal function ``__rte_trace_mem_per_thread_alloc()``. The trace memory will be allocated per thread to enable lock less trace-emit function. -The memory for the trace memory for DPDK lcores will be allocated on -``rte_eal_init()`` if the trace is enabled through a EAL option. -For non DPDK threads, on the first trace emission, the memory will be -allocated. + +For non lcore threads, the trace memory is allocated on the first trace +emission. + +For lcore threads, if trace points are enabled through a EAL option, the trace +memory is allocated when the threads are known of DPDK +(``rte_eal_init`` for EAL lcores, ``rte_thread_register`` for non-EAL lcores). +Otherwise, when trace points are enabled later in the life of the application, +the behavior is the same as non lcore threads and the trace memory is allocated +on the first trace emission. Trace memory layout ~~~~~~~~~~~~~~~~~~~
lib/eal/common/eal_common_trace.c +22 -31
117 lines not on this page · raw message
lib/eal/common/eal_common_trace_utils.c +15 -2
@@ -314,14 +314,18 @@ trace_dir_default_path_get(char *dir_path)return 0 ; } -int +static int trace_mkdir (void ) {struct trace *trace =trace_obj_get ();char session[TRACE_DIR_STR_LEN ]; +static bool already_done;char *dir_path;int rc; +if (already_done) +return 0 ; +if (!trace->dir_offset) { dir_path =calloc (1 ,sizeof (trace->dir));if (dir_path ==NULL ) {
@@ -364,7 +368,8 @@ trace_mkdir(void)return -rte_errno; } -RTE_LOG (INFO ,EAL ,"Trace dir: %s\n" , trace->dir); +RTE_LOG (DEBUG ,EAL ,"Trace dir: %s\n" , trace->dir); + already_done = true;return 0 ; }
@@ -375,6 +380,10 @@ trace_meta_save(struct trace *trace)FILE *f;int rc; + rc =trace_mkdir (); +if (rc <0 ) +return rc; + rc =snprintf (file_name,PATH_MAX ,"%s/metadata" , trace->dir);if (rc <0 )return rc;
@@ -406,6 +415,10 @@ trace_mem_save(struct trace *trace, struct __rte_trace_header *hdr,FILE *f;int rc; + rc =trace_mkdir (); +if (rc <0 ) +return rc; + rc =snprintf (file_name,PATH_MAX ,"%s/channel0_%d" , trace->dir, cnt);if (rc <0 )return rc;
lib/eal/common/eal_trace.h +1 -2
@@ -54,7 +54,7 @@ struct trace {char dir[PATH_MAX ];int dir_offset;int register_errno; -bool status; +uint32_t status;enum rte_trace_mode mode;rte_uuid_t uuid;uint32_t buff_len;
@@ -104,7 +104,6 @@ void trace_uuid_generate(void);int trace_metadata_create (void );void trace_metadata_destroy (void );char *trace_metadata_fixup_field (const char *field); -int trace_mkdir (void );int trace_epoch_time_save (void );void trace_mem_free (void );void trace_mem_per_thread_free (void );
Signature · 1 line
2.37.3
RE: [EXT] [PATCH 4/8] trace: fix dynamically enabling trace points
Quoted 49 lines
-----Original Message-----
From: David Marchand <[email protected]>
Sent: Wednesday, September 21, 2022 5:34 PM
To: [email protected]
Cc: [email protected]; Jerin Jacob Kollanukkaran <[email protected]>; Sunil Kumar Kori <[email protected]>
Subject: [EXT] [PATCH 4/8] trace: fix dynamically enabling trace pointsExternal Email
----------------------------------------------------------------------
Enabling trace points at runtime was not working if no trace point had been enabled first atrte_eal_init()time. The reason was that trace.args reflected the arguments passed to --trace= EAL option.To fix this:
- the trace subsystem initialisation is updated: trace directory creation is deferred to when traces are dumped (to avoid creating directories that may not be used),
- per lcore memory allocation still relies onrte_trace_is_enabled()but this helper now tracks if any trace point is enabled. The documentation is updated accordingly,
- cleanup helpers must always be called inrte_eal_cleanup()since some trace points might have been enabled and disabled in the lifetime of the DPDK application,With this fix, we can update the unit test and check that a trace point callback is invoked when expected.
Note:
- the 'trace' global variable might be shadowed with the argument passed to the functions dealing with trace point handles. 'tp' has been used for referring totrace_pointobject. Prefer 't' for referring to handles,Fixes 84c4fae4628f ("trace: implement operation APIs")Signed-off-by David Marchand <[email protected]>--- app/test/test_trace.c | 20 ++++++++++ app/test/test_trace.h | 2 + doc/guides/prog_guide/trace_lib.rst | 14 +++++-- lib/eal/common/eal_common_trace.c | 53 ++++++++++--------------- lib/eal/common/eal_common_trace_utils.c | 17 +++++++- lib/eal/common/eal_trace.h | 3 +- 6 files changed, 70 insertions(+), 39 deletions(-)
[snipped]
Quoted 15 lines
int
lib/eal/common/eal_common_trace.c +5
-4-rte_trace_point_disable(rte_trace_point_t *trace) +rte_trace_point_disable(rte_trace_point_t *t) { -if (trace_point_is_invalid (trace)) +uint64_t prev; + +if (trace_point_is_invalid (t))return -ERANGE ; -__atomic_and_fetch (trace, ~__RTE_TRACE_FIELD_ENABLE_MASK, - __ATOMIC_RELEASE); + prev = __atomic_fetch_and(t, ~__RTE_TRACE_FIELD_ENABLE_MASK,
__ATOMIC_RELEASE);
lib/eal/common/eal_common_trace.c trace_point_is_invalid(rte_trace_point_t *t) · line 173
Quoted 4 lines
lib/eal/common/eal_common_trace.c +2
-0+if ((prev & __RTE_TRACE_FIELD_ENABLE_MASK) !=0 ) +__atomic_sub_fetch (&trace.status,1 , __ATOMIC_RELEASE);return 0 ; }
IMO, above change should go as a separate commit as it just replaces the variable name.
Quoted 37 lines
lib/eal/common/eal_common_trace.c +0
-3@@ -413,9 +407,6 @@ trace_mem_free(void)struct trace *trace =trace_obj_get ();uint32_t count; -if (!rte_trace_is_enabled ()) -return ; -rte_spinlock_lock (&trace->lock);for (count =0 ; count < trace->nb_trace_mem_list; count++) { trace_mem_per_thread_free_unlocked(&trace-Quoted 1 line
lcore_meta[count]);
lib/eal/common/eal_common_trace_utils.c +5
-1@@ -314,14 +314,18 @@ trace_dir_default_path_get(char *dir_path)return 0 ; } -int +static int trace_mkdir (void ) {struct trace *trace =trace_obj_get ();char session[TRACE_DIR_STR_LEN ]; +static bool already_done;char *dir_path;int rc; +if (already_done) +return 0 ; +if (!trace->dir_offset) { dir_path =calloc (1 ,sizeof (trace->dir));if (dir_path ==NULL ) {
lib/eal/common/eal_common_trace_utils.c trace_mkdir(void) · line 372
Quoted 6 lines
lib/eal/common/eal_common_trace_utils.c +2
-1@@ -364,7 +368,8 @@ trace_mkdir(void)return -rte_errno; } -RTE_LOG (INFO ,EAL ,"Trace dir: %s\n" , trace->dir); +RTE_LOG (DEBUG ,EAL ,"Trace dir: %s\n" , trace->dir); + already_done = true;
I request you to keep it as INFO only. If a user enables traces, then it will give information directly about the directory without running in debug mode.
lib/eal/common/eal_common_trace_utils.c trace_meta_save(struct trace *trace) · line 386
Quoted 11 lines
lib/eal/common/eal_common_trace_utils.c +4
-0return 0 ; }@@ -375,6 +380,10 @@ trace_meta_save(struct trace *trace)FILE *f;int rc; + rc =trace_mkdir (); +if (rc <0 ) +return rc; +
Trace directory is being created here and in trace_mem_save() function along with the logic to handle whether it is already done or not. Instead can't it be called in rte_trace_save() directly. That will suffice the intention, I believe.
Quoted 17 lines
lib/eal/common/eal_common_trace_utils.c +4
-0rc =snprintf (file_name,PATH_MAX ,"%s/metadata" , trace->dir);if (rc <0 )return rc;@@ -406,6 +415,10 @@ trace_mem_save(struct trace *trace, struct __rte_trace_header *hdr,FILE *f;int rc; + rc =trace_mkdir (); +if (rc <0 ) +return rc; + rc =snprintf (file_name,PATH_MAX ,"%s/channel0_%d" , trace->dir, cnt);lib/eal/common/eal_common_trace_utils.c +0
-1if (rc <0 )return rc; --
[snipped]
Quoted 1 line
2.37.3
Re: [EXT] [PATCH 4/8] trace: fix dynamically enabling trace points
Quoted 10 lines · Sunil Kumar Kori
Quoted 10 lines
int
lib/eal/common/eal_common_trace.c +4
-2-rte_trace_point_disable(rte_trace_point_t *trace) +rte_trace_point_disable(rte_trace_point_t *t) { -if (trace_point_is_invalid (trace)) +uint64_t prev; + +if (trace_point_is_invalid (t))return -ERANGE ;
Quoted 10 lines
lib/eal/common/eal_common_trace.c trace_point_is_invalid(rte_trace_point_t *t) · line 173
Quoted 9 lines
lib/eal/common/eal_common_trace.c +1
-2-__atomic_and_fetch (trace, ~__RTE_TRACE_FIELD_ENABLE_MASK, - __ATOMIC_RELEASE); + prev = __atomic_fetch_and(t, ~__RTE_TRACE_FIELD_ENABLE_MASK,
__ATOMIC_RELEASE);lib/eal/common/eal_common_trace.c +2
-0+if ((prev & __RTE_TRACE_FIELD_ENABLE_MASK) !=0 ) +__atomic_sub_fetch (&trace.status,1 , __ATOMIC_RELEASE);return 0 ; }IMO, above change should go as a separate commit as it just replaces the variable name.
The count of enabled tracepoints (stored in the 'trace' global variable) must be updated as part of the change.
So the renaming is necessary.
[snip]
Quoted 11 lines
lib/eal/common/eal_common_trace_utils.c trace_meta_save(struct trace *trace) · line 386
Quoted 8 lines
lib/eal/common/eal_common_trace_utils.c +4
-0@@ -375,6 +380,10 @@ trace_meta_save(struct trace *trace)FILE *f;int rc; + rc =trace_mkdir (); +if (rc <0 ) +return rc; +Trace directory is being created here and in
trace_mem_save()function along with the logic to handle whether it is already done or not. Instead can't it be called inrte_trace_save()directly. That will suffice the intention, I believe.
Oh indeed, I had the false impression that there were other path than rte_trace_save(), leading to trace_mkdir().
Will fix.
Signature · 1 line
David Marchand
PATCH 5/8 trace: fix race in debug dump
In reply to David Marchandtrace->nb_trace_mem_list access must be under trace->lock to avoid races with threads allocating/freeing their trace buffers.
--- lib/eal/common/eal_common_trace.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
lib/eal/common/eal_common_trace.c +3 -3
@@ -255,10 +255,9 @@ trace_lcore_mem_dump(FILE *f)struct __rte_trace_header *header;uint32_t count; -if (trace->nb_trace_mem_list ==0 ) -return ; -rte_spinlock_lock (&trace->lock); +if (trace->nb_trace_mem_list ==0 ) + goto out;fprintf (f,"nb_trace_mem_list = %d\n" , trace->nb_trace_mem_list);fprintf (f,"\nTrace mem info\n--------------\n" );for (count =0 ; count < trace->nb_trace_mem_list; count++) {
@@ -269,6 +268,7 @@ trace_lcore_mem_dump(FILE *f) header->stream_header.lcore_id, header->stream_header.thread_name); } +out:rte_spinlock_unlock (&trace->lock); }
Signature · 1 line
2.37.3
Re: [PATCH 5/8] trace: fix race in debug dump
Quoted 8 lines · David Marchand
trace->nb_trace_mem_listaccess must be undertrace->lockto avoid races with threads allocating/freeing their trace buffers.Fixes f6b2d65dcd5d ("trace: implement debug dump")Signed-off-by David Marchand <[email protected]>
Quoted 32 lines
--- lib/eal/common/eal_common_trace.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)lib/eal/common/eal_common_trace.c +3
-4@@ -255,10 +255,9 @@ trace_lcore_mem_dump(FILE *f)struct __rte_trace_header *header;uint32_t count; -if (trace->nb_trace_mem_list ==0 ) -return ; -rte_spinlock_lock (&trace->lock); +if (trace->nb_trace_mem_list ==0 ) + goto out;fprintf (f,"nb_trace_mem_list = %d\n" , trace->nb_trace_mem_list);fprintf (f,"\nTrace mem info\n--------------\n" );for (count =0 ; count < trace->nb_trace_mem_list; count++) {@@ -269,6 +268,7 @@ trace_lcore_mem_dump(FILE *f) header->stream_header.lcore_id, header->stream_header.thread_name); } +out:rte_spinlock_unlock (&trace->lock); } --2.37.3
PATCH 6/8 trace: fix metadata dump
In reply to David MarchandThe API does not describe that metadata dump is conditioned to enabling any trace points.
While at it, merge dump unit tests into the generic trace_autotest to enhance coverage.
--- app/test/test_trace.c | 44 +++++++++------------------ lib/eal/common/eal_common_trace_ctf.c | 3 -- 2 files changed, 15 insertions(+), 32 deletions(-)
app/test/test_trace.c +15 -29
@@ -20,20 +20,6 @@ test_trace(void)return TEST_SKIPPED ; } -static int -test_trace_dump (void ) -{ -printf ("trace_dump not supported on Windows, skipping test\n" ); -return TEST_SKIPPED ; -} - -static int -test_trace_metadata_dump (void ) -{ -printf ("trace_metadata_dump not supported on Windows, skipping test\n" ); -return TEST_SKIPPED ; -} -#else static int32_t
@@ -214,6 +200,19 @@ test_generic_trace_points(void)return TEST_SUCCESS ; } +static int +test_trace_dump (void ) +{ +rte_trace_dump (stdout); +return 0 ; +} + +static int +test_trace_metadata_dump (void ) +{ +return rte_trace_metadata_dump (stdout); +} +static struct unit_test_suite trace_tests = { .suite_name ="trace autotest" , .setup =NULL ,
@@ -226,6 +225,8 @@ static struct unit_test_suite trace_tests = {TEST_CASE (test_trace_point_globbing),TEST_CASE (test_trace_point_regex),TEST_CASE (test_trace_points_lookup), +TEST_CASE (test_trace_dump), +TEST_CASE (test_trace_metadata_dump), TEST_CASES_END() } };
@@ -236,21 +237,6 @@ test_trace(void) return unit_test_suite_runner(&trace_tests); } -static int -test_trace_dump (void ) -{ -rte_trace_dump (stdout); -return 0 ; -} - -static int -test_trace_metadata_dump (void ) -{ -return rte_trace_metadata_dump (stdout); -} -#endif /* !RTE_EXEC_ENV_WINDOWS */ REGISTER_TEST_COMMAND (trace_autotest, test_trace); -REGISTER_TEST_COMMAND (trace_dump, test_trace_dump); -REGISTER_TEST_COMMAND (trace_metadata_dump, test_trace_metadata_dump);
lib/eal/common/eal_common_trace_ctf.c +0 -3
@@ -357,9 +357,6 @@ rte_trace_metadata_dump(FILE *f)char *ctf_meta = trace->ctf_meta;int rc; -if (!rte_trace_is_enabled ()) -return 0 ; -if (ctf_meta ==NULL )return -EINVAL ;
Signature · 1 line
2.37.3
PATCH 7/8 trace: remove limitation on trace point name
In reply to David MarchandThe name of a trace point is provided as a constant string via the RTE_TRACE_POINT_REGISTER macro.
We can rely on the constant string in the binary and simply point at it. There is then no need for a (fixed size) copy.
--- lib/eal/common/eal_common_trace.c | 10 +++------- lib/eal/common/eal_common_trace_utils.c | 2 +- lib/eal/common/eal_trace.h | 3 +-- 3 files changed, 5 insertions(+), 10 deletions(-)
lib/eal/common/eal_common_trace.c +3 -7
@@ -231,7 +231,7 @@ rte_trace_point_lookup(const char *name)return NULL ; STAILQ_FOREACH(tp, &tp_list, next) -if (strncmp (tp->name, name,TRACE_POINT_NAME_SIZE ) ==0 ) +if (strcmp (tp->name, name) ==0 )return tp->handle;return NULL ;
@@ -488,10 +488,7 @@ __rte_trace_point_register(rte_trace_point_t *handle, const char *name, }/* Initialize the trace point */ -if (rte_strscpy (tp->name, name,TRACE_POINT_NAME_SIZE ) <0 ) { -trace_err ("name is too long" ); - goto free; - } + tp->name = name;/* Copy the accumulated fields description and clear it for the next * trace point.
@@ -513,8 +510,7 @@ __rte_trace_point_register(rte_trace_point_t *handle, const char *name,/* All Good !!! */ return 0 ; -free: -free (tp); + fail:if (trace.register_errno ==0 ) trace.register_errno = rte_errno;
lib/eal/common/eal_common_trace_utils.c +1 -1
@@ -42,7 +42,7 @@ trace_entry_compare(const char *name)int count =0 ; STAILQ_FOREACH(tp, tp_list, next) { -if (strncmp (tp->name, name,TRACE_POINT_NAME_SIZE ) ==0 ) +if (strcmp (tp->name, name) ==0 ) count++;if (count >1 ) {trace_err ("found duplicate entry %s" , name);
lib/eal/common/eal_trace.h +1 -2
@@ -24,14 +24,13 @@#define TRACE_PREFIX_LEN 12#define TRACE_DIR_STR_LEN (sizeof("YYYY-mm-dd-AM-HH-MM-SS") + TRACE_PREFIX_LEN) -#define TRACE_POINT_NAME_SIZE 64#define TRACE_CTF_MAGIC 0xC1FC1FC1#define TRACE_MAX_ARGS 32struct trace_point {STAILQ_ENTRY (trace_point) next;rte_trace_point_t *handle; -char name[TRACE_POINT_NAME_SIZE ]; +const char *name;char *ctf_field; };
Signature · 1 line
2.37.3
Re: [PATCH 7/8] trace: remove limitation on trace point name
Quoted 4 lines · David Marchand
The name of a trace point is provided as a constant string via the
RTE_TRACE_POINT_REGISTERmacro.
We can rely on the constant string in the binary and simply point at it.
I am not sure about this. If we compile with -Os (optimized for space) compiler may decide to use stack instead of rodata.
If so, we will have segfaults with specific compiler or compiler build options. Thoughts?
Quoted 80 lines
There is then no need for a (fixed size) copy.
Signed-off-by David Marchand <[email protected]>--- lib/eal/common/eal_common_trace.c | 10 +++------- lib/eal/common/eal_common_trace_utils.c | 2 +- lib/eal/common/eal_trace.h | 3 +-- 3 files changed, 5 insertions(+), 10 deletions(-)lib/eal/common/eal_common_trace.c +3
-7@@ -231,7 +231,7 @@ rte_trace_point_lookup(const char *name)return NULL ; STAILQ_FOREACH(tp, &tp_list, next) -if (strncmp (tp->name, name,TRACE_POINT_NAME_SIZE ) ==0 ) +if (strcmp (tp->name, name) ==0 )return tp->handle;return NULL ;@@ -488,10 +488,7 @@ __rte_trace_point_register(rte_trace_point_t *handle, const char *name, }/* Initialize the trace point */ -if (rte_strscpy (tp->name, name,TRACE_POINT_NAME_SIZE ) <0 ) { -trace_err ("name is too long" ); - goto free; - } + tp->name = name;/* Copy the accumulated fields description and clear it for the next * trace point. @@ -513,8 +510,7 @@ __rte_trace_point_register(rte_trace_point_t *handle, const char *name,/* All Good !!! */ return 0 ; -free: -free (tp); + fail:if (trace.register_errno ==0 ) trace.register_errno = rte_errno;lib/eal/common/eal_common_trace_utils.c +1
-1@@ -42,7 +42,7 @@ trace_entry_compare(const char *name)int count =0 ; STAILQ_FOREACH(tp, tp_list, next) { -if (strncmp (tp->name, name,TRACE_POINT_NAME_SIZE ) ==0 ) +if (strcmp (tp->name, name) ==0 ) count++;if (count >1 ) {trace_err ("found duplicate entry %s" , name);lib/eal/common/eal_trace.h +1
-3@@ -24,14 +24,13 @@#define TRACE_PREFIX_LEN 12#define TRACE_DIR_STR_LEN (sizeof("YYYY-mm-dd-AM-HH-MM-SS") + TRACE_PREFIX_LEN) -#define TRACE_POINT_NAME_SIZE 64#define TRACE_CTF_MAGIC 0xC1FC1FC1#define TRACE_MAX_ARGS 32struct trace_point {STAILQ_ENTRY (trace_point) next;rte_trace_point_t *handle; -char name[TRACE_POINT_NAME_SIZE ]; +const char *name;char *ctf_field; }; --2.37.3
Re: [PATCH 7/8] trace: remove limitation on trace point name
Quoted 4 lines · Jerin Jacob
Quoted 1 line · David Marchand
Quoted 8 lines
Quoted 3 lines
The name of a trace point is provided as a constant string via the
RTE_TRACE_POINT_REGISTERmacro.
We can rely on the constant string in the binary and simply point at it.I am not sure about this. If we compile with -Os (optimized for space) compiler may decide to use stack instead of rodata.
If so, we will have segfaults with specific compiler or compiler build options. Thoughts?
Good point.
We need an explicit storage for the string.
What do you think of:
@@ -20,9 +20,10 @@ RTE_DECLARE_PER_LCORE(volatile int, trace_point_sz);
#define RTE_TRACE_POINT_REGISTER(trace, name) \
rte_trace_point_t __attribute__((section("__rte_trace_point"))) __##trace; \
+static const char __##trace##_name[] = RTE_STR(name); \
RTE_INIT(trace##_init) \
{ \
- __rte_trace_point_register(&__##trace, RTE_STR(name), \
+ __rte_trace_point_register(&__##trace, __##trace##_name, \
(void (*)(void)) trace); \}
Signature · 1 line
David Marchand
Re: [PATCH 7/8] trace: remove limitation on trace point name
Quoted 15 lines · David Marchand
Quoted 4 lines · Jerin Jacob
Quoted 1 line · David Marchand
Quoted 8 lines
Quoted 3 lines
The name of a trace point is provided as a constant string via the
RTE_TRACE_POINT_REGISTERmacro.
We can rely on the constant string in the binary and simply point at it.I am not sure about this. If we compile with -Os (optimized for space) compiler may decide to use stack instead of rodata.
If so, we will have segfaults with specific compiler or compiler build options. Thoughts?
Quoted 4 lines
Good point.
We need an explicit storage for the string.
What do you think of:
This is OK.
Quoted 17 lines
(quoted diff) +2
-2@@ -20,9 +20,10 @@ RTE_DECLARE_PER_LCORE(volatile int, trace_point_sz); #define RTE_TRACE_POINT_REGISTER(trace, name) \ rte_trace_point_t __attribute__((section("__rte_trace_point"))) __##trace; \ +static const char __##trace##_name[] = RTE_STR(name); \ RTE_INIT(trace##_init) \ { \ - __rte_trace_point_register(&__##trace, RTE_STR(name), \ + __rte_trace_point_register(&__##trace, __##trace##_name, \ (void (*)(void)) trace); \ } --David Marchand
PATCH 8/8 trace: remove limitation on directory
In reply to David MarchandRemove arbitrary limit on 12 characters of the file prefix used for the directory where to store the traces.
Simplify the code by relying on dynamic allocations.
--- lib/eal/common/eal_common_trace_utils.c | 68 +++++++++---------------- lib/eal/common/eal_trace.h | 5 +- 2 files changed, 25 insertions(+), 48 deletions(-)
lib/eal/common/eal_common_trace_utils.c +24 -44
@@ -87,11 +87,11 @@ trace_uuid_generate(void) }static int -trace_session_name_generate (char *trace_dir) +trace_session_name_generate (char **trace_dir) { +char date[sizeof ("YYYY-mm-dd-AM-HH-MM-SS" )];struct tm *tm_result;time_t tm; -int rc; tm =time (NULL );if ((int )tm ==-1 )
@@ -101,38 +101,32 @@ trace_session_name_generate(char *trace_dir)if (tm_result ==NULL ) goto fail; - rc =rte_strscpy (trace_dir,eal_get_hugefile_prefix (), -TRACE_PREFIX_LEN ); -if (rc == -E2BIG ) - rc =TRACE_PREFIX_LEN -1 ; - trace_dir[rc++] ='-' ; - - rc =strftime (trace_dir + rc,TRACE_DIR_STR_LEN - rc, -"%Y-%m-%d-%p-%I-%M-%S" , tm_result); -if (rc ==0 ) { +if (strftime (date,sizeof (date),"%Y-%m-%d-%p-%I-%M-%S" , tm_result) ==0 ) { errno =ENOSPC ; goto fail; } -return rc; +if (asprintf (trace_dir,"%s-%s" ,eal_get_hugefile_prefix (), date) ==-1 ) + goto fail; + +return 0 ; fail: rte_errno = errno; -return -rte_errno; +return -1 ; }static int trace_dir_update (const char *str) {struct trace *trace =trace_obj_get (); -int rc, remaining; - - remaining =sizeof (trace->dir) - trace->dir_offset; - rc =rte_strscpy (&trace->dir[0 ] + trace->dir_offset, str, remaining); -if (rc <0 ) - goto fail; +char *dir; +int rc; - trace->dir_offset += rc; -fail: + rc =asprintf (&dir,"%s%s" , trace->dir !=NULL ? trace->dir :"" , str); +if (rc !=-1 ) { +free (trace->dir); + trace->dir = dir; + }return rc; }
@@ -246,22 +240,15 @@ eal_trace_mode_args_save(const char *val)int eal_trace_dir_args_save (char const *val) { -struct trace *trace =trace_obj_get ();char *dir_path;int rc; -if (strlen (val) >=sizeof (trace->dir) -1 ) { -trace_err ("input string is too big" ); -return -ENAMETOOLONG ; - } -if (asprintf (&dir_path,"%s/" , val) ==-1 ) {trace_err ("failed to copy directory: %s" ,strerror (errno));return -ENOMEM ; } rc =trace_dir_update (dir_path); -free (dir_path);return rc; }
@@ -289,10 +276,8 @@ trace_epoch_time_save(void) }static int -trace_dir_default_path_get (char *dir_path) +trace_dir_default_path_get (char **dir_path) { -struct trace *trace =trace_obj_get (); -uint32_t size =sizeof (trace->dir);struct passwd *pwd;char *home_dir;
@@ -308,8 +293,8 @@ trace_dir_default_path_get(char *dir_path) }/* Append dpdk-traces to directory */ -if (snprintf (dir_path, size,"%s/dpdk-traces/" , home_dir) <0 ) -return -ENAMETOOLONG ; +if (asprintf (dir_path,"%s/dpdk-traces/" , home_dir) ==-1 ) +return -ENOMEM ;return 0 ; }
@@ -318,25 +303,19 @@ static inttrace_mkdir (void) {struct trace *trace =trace_obj_get (); -char session[TRACE_DIR_STR_LEN ];static bool already_done; -char *dir_path; +char *session;int rc;if (already_done)return 0 ; -if (!trace->dir_offset) { - dir_path =calloc (1 ,sizeof (trace->dir)); -if (dir_path ==NULL ) { -trace_err ("fail to allocate memory" ); -return -ENOMEM ; - } +if (trace->dir ==NULL ) { +char *dir_path; - rc =trace_dir_default_path_get (dir_path); + rc =trace_dir_default_path_get (&dir_path);if (rc <0 ) {trace_err ("fail to get default path" ); -free (dir_path);return rc; }
@@ -354,10 +333,11 @@ trace_mkdir(void)return -rte_errno; } - rc =trace_session_name_generate (session); + rc =trace_session_name_generate (&session);if (rc <0 )return rc; rc =trace_dir_update (session); +free (session);if (rc <0 )return rc;
lib/eal/common/eal_trace.h +1 -4
@@ -22,8 +22,6 @@ #define trace_crit(fmt, args...) \ RTE_LOG(CRIT, EAL, "%s():%u " fmt "\n", __func__, __LINE__, ## args) -#define TRACE_PREFIX_LEN 12 -#define TRACE_DIR_STR_LEN (sizeof("YYYY-mm-dd-AM-HH-MM-SS") + TRACE_PREFIX_LEN)#define TRACE_CTF_MAGIC 0xC1FC1FC1#define TRACE_MAX_ARGS 32
@@ -50,8 +48,7 @@ struct trace_arg { };struct trace { -char dir[PATH_MAX ]; -int dir_offset; +char *dir;int register_errno;uint32_t status;enum rte_trace_mode mode;
Signature · 1 line
2.37.3
Re: [PATCH 8/8] trace: remove limitation on directory
Quoted 4 lines · David Marchand
Remove arbitrary limit on 12 characters of the file prefix used for the directory where to store the traces.
Simplify the code by relying on dynamic allocations.
Nice one.
Quoted 2 lines
Signed-off-by David Marchand <[email protected]>
Quoted 190 lines
--- lib/eal/common/eal_common_trace_utils.c | 68 +++++++++---------------- lib/eal/common/eal_trace.h | 5 +- 2 files changed, 25 insertions(+), 48 deletions(-)lib/eal/common/eal_common_trace_utils.c +24
-44@@ -87,11 +87,11 @@ trace_uuid_generate(void) }static int -trace_session_name_generate (char *trace_dir) +trace_session_name_generate (char **trace_dir) { +char date[sizeof ("YYYY-mm-dd-AM-HH-MM-SS" )];struct tm *tm_result;time_t tm; -int rc; tm =time (NULL );if ((int )tm ==-1 )@@ -101,38 +101,32 @@ trace_session_name_generate(char *trace_dir)if (tm_result ==NULL ) goto fail; - rc =rte_strscpy (trace_dir,eal_get_hugefile_prefix (), -TRACE_PREFIX_LEN ); -if (rc == -E2BIG ) - rc =TRACE_PREFIX_LEN -1 ; - trace_dir[rc++] ='-' ; - - rc =strftime (trace_dir + rc,TRACE_DIR_STR_LEN - rc, -"%Y-%m-%d-%p-%I-%M-%S" , tm_result); -if (rc ==0 ) { +if (strftime (date,sizeof (date),"%Y-%m-%d-%p-%I-%M-%S" , tm_result) ==0 ) { errno =ENOSPC ; goto fail; } -return rc; +if (asprintf (trace_dir,"%s-%s" ,eal_get_hugefile_prefix (), date) ==-1 ) + goto fail; + +return 0 ; fail: rte_errno = errno; -return -rte_errno; +return -1 ; }static int trace_dir_update (const char *str) {struct trace *trace =trace_obj_get (); -int rc, remaining; - - remaining =sizeof (trace->dir) - trace->dir_offset; - rc =rte_strscpy (&trace->dir[0 ] + trace->dir_offset, str, remaining); -if (rc <0 ) - goto fail; +char *dir; +int rc; - trace->dir_offset += rc; -fail: + rc =asprintf (&dir,"%s%s" , trace->dir !=NULL ? trace->dir :"" , str); +if (rc !=-1 ) { +free (trace->dir); + trace->dir = dir; + }return rc; }@@ -246,22 +240,15 @@ eal_trace_mode_args_save(const char *val)int eal_trace_dir_args_save (char const *val) { -struct trace *trace =trace_obj_get ();char *dir_path;int rc; -if (strlen (val) >=sizeof (trace->dir) -1 ) { -trace_err ("input string is too big" ); -return -ENAMETOOLONG ; - } -if (asprintf (&dir_path,"%s/" , val) ==-1 ) {trace_err ("failed to copy directory: %s" ,strerror (errno));return -ENOMEM ; } rc =trace_dir_update (dir_path); -free (dir_path);return rc; }@@ -289,10 +276,8 @@ trace_epoch_time_save(void) }static int -trace_dir_default_path_get (char *dir_path) +trace_dir_default_path_get (char **dir_path) { -struct trace *trace =trace_obj_get (); -uint32_t size =sizeof (trace->dir);struct passwd *pwd;char *home_dir;@@ -308,8 +293,8 @@ trace_dir_default_path_get(char *dir_path) }/* Append dpdk-traces to directory */ -if (snprintf (dir_path, size,"%s/dpdk-traces/" , home_dir) <0 ) -return -ENAMETOOLONG ; +if (asprintf (dir_path,"%s/dpdk-traces/" , home_dir) ==-1 ) +return -ENOMEM ;return 0 ; }@@ -318,25 +303,19 @@ static inttrace_mkdir (void) {struct trace *trace =trace_obj_get (); -char session[TRACE_DIR_STR_LEN ];static bool already_done; -char *dir_path; +char *session;int rc;if (already_done)return 0 ; -if (!trace->dir_offset) { - dir_path =calloc (1 ,sizeof (trace->dir)); -if (dir_path ==NULL ) { -trace_err ("fail to allocate memory" ); -return -ENOMEM ; - } +if (trace->dir ==NULL ) { +char *dir_path; - rc =trace_dir_default_path_get (dir_path); + rc =trace_dir_default_path_get (&dir_path);if (rc <0 ) {trace_err ("fail to get default path" ); -free (dir_path);return rc; }@@ -354,10 +333,11 @@ trace_mkdir(void)return -rte_errno; } - rc =trace_session_name_generate (session); + rc =trace_session_name_generate (&session);if (rc <0 )return rc; rc =trace_dir_update (session); +free (session);if (rc <0 )return rc;lib/eal/common/eal_trace.h +1
-5@@ -22,8 +22,6 @@ #define trace_crit(fmt, args...) \ RTE_LOG(CRIT, EAL, "%s():%u " fmt "\n", __func__, __LINE__, ## args) -#define TRACE_PREFIX_LEN 12 -#define TRACE_DIR_STR_LEN (sizeof("YYYY-mm-dd-AM-HH-MM-SS") + TRACE_PREFIX_LEN)#define TRACE_CTF_MAGIC 0xC1FC1FC1#define TRACE_MAX_ARGS 32@@ -50,8 +48,7 @@ struct trace_arg { };struct trace { -char dir[PATH_MAX ]; -int dir_offset; +char *dir;int register_errno;uint32_t status;enum rte_trace_mode mode; --2.37.3
v2 cover Trace subsystem fixes
In reply to David MarchandHello,
This series addresses a number of issues and limitations I have identified over time in the trace subsystem.
The main issue was with dynamically enabling trace points which was not working if no trace point had been enabled at rte_eal_init() time.
This is 22.11 material.
We may start thinking about marking this API stable, but this is another topic.
Signature · 28 lines
David Marchand Changes since v1: - split patch 3, - addressed comments on (previously) patch 4, David Marchand (9): trace: fix mode for new trace point trace: fix mode change trace: fix leak with regexp trace: rework loop on trace points trace: fix dynamically enabling trace points trace: fix race in debug dump trace: fix metadata dump trace: remove limitation on trace point name trace: remove limitation on directory app/test/test_trace.c | 67 +++++++------- app/test/test_trace.h | 2 + doc/guides/prog_guide/trace_lib.rst | 14 ++- lib/eal/common/eal_common_trace.c | 111 +++++++++++------------- lib/eal/common/eal_common_trace_ctf.c | 3 - lib/eal/common/eal_common_trace_utils.c | 81 ++++++++--------- lib/eal/common/eal_trace.h | 11 +-- 7 files changed, 136 insertions(+), 153 deletions(-) -- 2.37.3
PATCH v2 1/9 trace: fix mode for new trace point
If an application registers trace points later than rte_eal_init(), changes in the trace point mode were not applied.
--- lib/eal/common/eal_common_trace.c | 1 + 1 file changed, 1 insertion(+)
lib/eal/common/eal_common_trace.c +1 -0
@@ -512,6 +512,7 @@ __rte_trace_point_register(rte_trace_point_t *handle, const char *name,/* Form the trace handle */ *handle = sz; *handle |= trace.nb_trace_points << __RTE_TRACE_FIELD_ID_SHIFT; +trace_mode_set (handle, trace.mode); trace.nb_trace_points++; tp->handle = handle;
Signature · 1 line
2.37.3
Re: [PATCH v2 1/9] trace: fix mode for new trace point
Quoted 8 lines · David Marchand
If an application registers trace points later than
rte_eal_init(), changes in the trace point mode were not applied.Fixes 84c4fae4628f ("trace: implement operation APIs")Signed-off-by David Marchand <[email protected]>
Quoted 19 lines
--- lib/eal/common/eal_common_trace.c | 1 + 1 file changed, 1 insertion(+)lib/eal/common/eal_common_trace.c +1
-1@@ -512,6 +512,7 @@ __rte_trace_point_register(rte_trace_point_t *handle, const char *name,/* Form the trace handle */ *handle = sz; *handle |= trace.nb_trace_points << __RTE_TRACE_FIELD_ID_SHIFT; +trace_mode_set (handle, trace.mode); trace.nb_trace_points++; tp->handle = handle; --2.37.3
RE: [EXT] [PATCH v2 1/9] trace: fix mode for new trace point
In reply to David MarchandQuoted 14 lines
-----Original Message-----
From: David Marchand <[email protected]>
Sent: Tuesday, October 4, 2022 3:14 PM
To: [email protected]
Cc: [email protected]; Jerin Jacob Kollanukkaran <[email protected]>; [email protected]; Sunil Kumar Kori <[email protected]>
Subject: [EXT] [PATCH v2 1/9] trace: fix mode for new trace pointExternal Email
----------------------------------------------------------------------
If an application registers trace points later thanrte_eal_init(), changes in the trace point mode were not applied.
Quoted 8 lines
Fixes 84c4fae4628f ("trace: implement operation APIs")Signed-off-by David Marchand <[email protected]>--- lib/eal/common/eal_common_trace.c | 1 + 1 file changed, 1 insertion(+)
Quoted 16 lines
lib/eal/common/eal_common_trace.c +1
-0@@ -512,6 +512,7 @@ __rte_trace_point_register(rte_trace_point_t *handle, const char *name,/* Form the trace handle */ *handle = sz; *handle |= trace.nb_trace_points << __RTE_TRACE_FIELD_ID_SHIFT; +trace_mode_set (handle, trace.mode); trace.nb_trace_points++;
tp->handle= handle;
--
2.37.3
PATCH v2 2/9 trace: fix mode change
In reply to David MarchandThe API does not state that changing mode should be refused if no trace point is enabled. Remove this limitation.
--- app/test/test_trace.c | 3 --- lib/eal/common/eal_common_trace.c | 3 --- 2 files changed, 6 deletions(-)
app/test/test_trace.c +0 -3
@@ -126,9 +126,6 @@ test_trace_mode(void) current =rte_trace_mode_get (); -if (!rte_trace_is_enabled ()) -return TEST_SKIPPED ; -rte_trace_mode_set (RTE_TRACE_MODE_DISCARD );if (rte_trace_mode_get () !=RTE_TRACE_MODE_DISCARD ) goto failed;
lib/eal/common/eal_common_trace.c +0 -3
@@ -127,9 +127,6 @@ rte_trace_mode_set(enum rte_trace_mode mode) {struct trace_point *tp; -if (!rte_trace_is_enabled ()) -return ; - STAILQ_FOREACH(tp, &tp_list, next)trace_mode_set (tp->handle, mode);
Signature · 1 line
2.37.3
Re: [PATCH v2 2/9] trace: fix mode change
Quoted 18 lines · David Marchand
The API does not state that changing mode should be refused if no trace point is enabled. Remove this limitation.
Fixes 84c4fae4628f ("trace: implement operation APIs")Signed-off-by David Marchand <[email protected]>--- app/test/test_trace.c | 3 --- lib/eal/common/eal_common_trace.c | 3 --- 2 files changed, 6 deletions(-)lib/eal/common/eal_common_trace.c +0
-0
lib/eal/common/eal_common_trace.c rte_trace_mode_set(enum rte_trace_mode mode) · line 131
Quoted 5 lines
lib/eal/common/eal_common_trace.c +0
-2@@ -127,9 +127,6 @@ rte_trace_mode_set(enum rte_trace_mode mode) {struct trace_point *tp; -if (!rte_trace_is_enabled ()) -return ;
Just added pre check to avoid going through this linked list as an optimization. Since it is in slowpath, your changes are OK.
Quoted 7 lines
lib/eal/common/eal_common_trace.c +0
-2- STAILQ_FOREACH(tp, &tp_list, next)trace_mode_set (tp->handle, mode); --2.37.3
RE: [EXT] [PATCH v2 2/9] trace: fix mode change
In reply to David MarchandQuoted 14 lines
-----Original Message-----
From: David Marchand <[email protected]>
Sent: Tuesday, October 4, 2022 3:14 PM
To: [email protected]
Cc: [email protected]; Jerin Jacob Kollanukkaran <[email protected]>; [email protected]; Sunil Kumar Kori <[email protected]>
Subject: [EXT] [PATCH v2 2/9] trace: fix mode changeExternal Email
----------------------------------------------------------------------
The API does not state that changing mode should be refused if no trace point is enabled. Remove this limitation.
Quoted 9 lines
Fixes 84c4fae4628f ("trace: implement operation APIs")Signed-off-by David Marchand <[email protected]>--- app/test/test_trace.c | 3 --- lib/eal/common/eal_common_trace.c | 3 --- 2 files changed, 6 deletions(-)
Quoted 30 lines
app/test/test_trace.c index renamed from app/test/test_trace.c +0
-0
76af79162b..44ac38a4fa100644app/test/test_trace.c +0
-3@@ -126,9 +126,6 @@ test_trace_mode(void) current =rte_trace_mode_get (); -if (!rte_trace_is_enabled ()) -return TEST_SKIPPED ; -rte_trace_mode_set (RTE_TRACE_MODE_DISCARD );if (rte_trace_mode_get () !=RTE_TRACE_MODE_DISCARD ) goto failed;lib/eal/common/eal_common_trace.c +0
-4@@ -127,9 +127,6 @@ rte_trace_mode_set(enum rte_trace_mode mode) {struct trace_point *tp; -if (!rte_trace_is_enabled ()) -return ; - STAILQ_FOREACH(tp, &tp_list, next)trace_mode_set (tp->handle, mode); --2.37.3
PATCH v2 3/9 trace: fix leak with regexp
In reply to David MarchandThe precompiled buffer initialised in regcomp must be freed before leaving rte_trace_regexp.
---
Changes since v1:
- split patch in two, keeping only the backportable fix as patch 3,
--- lib/eal/common/eal_common_trace.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
lib/eal/common/eal_common_trace.c +4 -2
@@ -218,8 +218,10 @@ rte_trace_regexp(const char *regex, bool enable) rc =rte_trace_point_disable (tp->handle); found =1 ; } -if (rc <0 ) -return rc; +if (rc <0 ) { + found =0 ; +break ; + } }regfree (&r);
Signature · 1 line
2.37.3
Re: [PATCH v2 3/9] trace: fix leak with regexp
Quoted 8 lines · David Marchand
The precompiled buffer initialised in regcomp must be freed before leaving
rte_trace_regexp.Fixes 84c4fae4628f ("trace: implement operation APIs")Signed-off-by David Marchand <[email protected]>
Quoted 28 lines
---
Changes since v1:
- split patch in two, keeping only the backportable fix as patch 3,--- lib/eal/common/eal_common_trace.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)lib/eal/common/eal_common_trace.c +4
-3@@ -218,8 +218,10 @@ rte_trace_regexp(const char *regex, bool enable) rc =rte_trace_point_disable (tp->handle); found =1 ; } -if (rc <0 ) -return rc; +if (rc <0 ) { + found =0 ; +break ; + } }regfree (&r); --2.37.3
RE: [EXT] [PATCH v2 3/9] trace: fix leak with regexp
In reply to David MarchandQuoted 17 lines
-----Original Message-----
From: David Marchand <[email protected]>
Sent: Tuesday, October 4, 2022 3:14 PM
To: [email protected]
Cc: [email protected]; Jerin Jacob Kollanukkaran <[email protected]>; [email protected]; Sunil Kumar Kori <[email protected]>
Subject: [EXT] [PATCH v2 3/9] trace: fix leak with regexpExternal Email
----------------------------------------------------------------------
The precompiled buffer initialised in regcomp must be freed before leavingrte_trace_regexp.Fixes 84c4fae4628f ("trace: implement operation APIs")
Quoted 9 lines
Signed-off-by David Marchand <[email protected]>---
Changes since v1:
- split patch in two, keeping only the backportable fix as patch 3,--- lib/eal/common/eal_common_trace.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
Quoted 20 lines
lib/eal/common/eal_common_trace.c +4
-3@@ -218,8 +218,10 @@ rte_trace_regexp(const char *regex, bool enable) rc =rte_trace_point_disable (tp->handle); found =1 ; } -if (rc <0 ) -return rc; +if (rc <0 ) { + found =0 ; +break ; + } }regfree (&r); --2.37.3
PATCH v2 4/9 trace: rework loop on trace points
In reply to David MarchandDirectly skip the block when a trace point does not match the user criteria.
--- lib/eal/common/eal_common_trace.c | 34 +++++++++++++++++-------------- 1 file changed, 19 insertions(+), 15 deletions(-)
lib/eal/common/eal_common_trace.c +19 -15
@@ -186,15 +186,18 @@ rte_trace_pattern(const char *pattern, bool enable)int rc =0 , found =0 ; STAILQ_FOREACH(tp, &tp_list, next) { -if (fnmatch (pattern, tp->name,0 ) ==0 ) { -if (enable) - rc =rte_trace_point_enable (tp->handle); -else - rc =rte_trace_point_disable (tp->handle); - found =1 ; +if (fnmatch (pattern, tp->name,0 ) !=0 ) +continue ; + +if (enable) + rc =rte_trace_point_enable (tp->handle); +else + rc =rte_trace_point_disable (tp->handle); +if (rc <0 ) { + found =0 ; +break ; } -if (rc <0 ) -return rc; + found =1 ; }return rc | found;
@@ -211,17 +214,18 @@ rte_trace_regexp(const char *regex, bool enable)return -EINVAL ; STAILQ_FOREACH(tp, &tp_list, next) { -if (regexec (&r, tp->name,0 ,NULL ,0 ) ==0 ) { -if (enable) - rc =rte_trace_point_enable (tp->handle); -else - rc =rte_trace_point_disable (tp->handle); - found =1 ; - } +if (regexec (&r, tp->name,0 ,NULL ,0 ) !=0 ) +continue ; + +if (enable) + rc =rte_trace_point_enable (tp->handle); +else + rc =rte_trace_point_disable (tp->handle);if (rc <0 ) { found =0 ;break ; } + found =1 ; }regfree (&r);
Signature · 1 line
2.37.3
Re: [PATCH v2 4/9] trace: rework loop on trace points
Quoted 5 lines · David Marchand
Directly skip the block when a trace point does not match the user criteria.
Signed-off-by David Marchand <[email protected]>
Quoted 64 lines
--- lib/eal/common/eal_common_trace.c | 34 +++++++++++++++++-------------- 1 file changed, 19 insertions(+), 15 deletions(-)lib/eal/common/eal_common_trace.c +19
-16@@ -186,15 +186,18 @@ rte_trace_pattern(const char *pattern, bool enable)int rc =0 , found =0 ; STAILQ_FOREACH(tp, &tp_list, next) { -if (fnmatch (pattern, tp->name,0 ) ==0 ) { -if (enable) - rc =rte_trace_point_enable (tp->handle); -else - rc =rte_trace_point_disable (tp->handle); - found =1 ; +if (fnmatch (pattern, tp->name,0 ) !=0 ) +continue ; + +if (enable) + rc =rte_trace_point_enable (tp->handle); +else + rc =rte_trace_point_disable (tp->handle); +if (rc <0 ) { + found =0 ; +break ; } -if (rc <0 ) -return rc; + found =1 ; }return rc | found;@@ -211,17 +214,18 @@ rte_trace_regexp(const char *regex, bool enable)return -EINVAL ; STAILQ_FOREACH(tp, &tp_list, next) { -if (regexec (&r, tp->name,0 ,NULL ,0 ) ==0 ) { -if (enable) - rc =rte_trace_point_enable (tp->handle); -else - rc =rte_trace_point_disable (tp->handle); - found =1 ; - } +if (regexec (&r, tp->name,0 ,NULL ,0 ) !=0 ) +continue ; + +if (enable) + rc =rte_trace_point_enable (tp->handle); +else + rc =rte_trace_point_disable (tp->handle);if (rc <0 ) { found =0 ;break ; } + found =1 ; }regfree (&r); --2.37.3
RE: [EXT] [PATCH v2 4/9] trace: rework loop on trace points
In reply to David MarchandQuoted 10 lines
-----Original Message-----
From: David Marchand <[email protected]>
Sent: Tuesday, October 4, 2022 3:14 PM
To: [email protected]
Cc: [email protected]; Jerin Jacob Kollanukkaran <[email protected]>; Sunil Kumar Kori <[email protected]>
Subject: [EXT] [PATCH v2 4/9] trace: rework loop on trace pointsExternal Email
Quoted 8 lines
----------------------------------------------------------------------
Directly skip the block when a trace point does not match the user criteria.Signed-off-by David Marchand <[email protected]>--- lib/eal/common/eal_common_trace.c | 34 +++++++++++++++++-------------- 1 file changed, 19 insertions(+), 15 deletions(-)
Quoted 5 lines
lib/eal/common/eal_common_trace.c +0
-0
[snip]
Quoted 1 line
2.37.3
PATCH v2 5/9 trace: fix dynamically enabling trace points
In reply to David MarchandEnabling trace points at runtime was not working if no trace point had been enabled first at rte_eal_init() time. The reason was that trace.args reflected the arguments passed to --trace= EAL option.
To fix this:
- the trace subsystem initialisation is updated: trace directory creation is deferred to when traces are dumped (to avoid creating directories that may not be used),
- per lcore memory allocation still relies on rte_trace_is_enabled() but this helper now tracks if any trace point is enabled. The documentation is updated accordingly,
- cleanup helpers must always be called in rte_eal_cleanup() since some trace points might have been enabled and disabled in the lifetime of the DPDK application,
With this fix, we can update the unit test and check that a trace point callback is invoked when expected.
Note:
- the 'trace' global variable might be shadowed with the argument passed to the functions dealing with trace point handles. 'tp' has been used for referring to trace_point object. Prefer 't' for referring to handles,
---
Changes since v1:
- restored level to INFO for trace directory log message,
- moved trace_mkdir() to rte_trace_save,
--- app/test/test_trace.c | 20 ++++++++++ app/test/test_trace.h | 2 + doc/guides/prog_guide/trace_lib.rst | 14 +++++-- lib/eal/common/eal_common_trace.c | 53 ++++++++++--------------- lib/eal/common/eal_common_trace_utils.c | 11 ++++- lib/eal/common/eal_trace.h | 3 +- 6 files changed, 65 insertions(+), 38 deletions(-)
app/test/test_trace.c +20 -0
@@ -9,6 +9,8 @@#include "test.h" #include "test_trace.h" +int app_dpdk_test_tp_count; +#ifdef RTE_EXEC_ENV_WINDOWS static int
@@ -95,8 +97,15 @@ test_trace_point_regex(void)static int32_t test_trace_point_disable_enable (void ) { +int expected;int rc; +/* At tp registration, the associated counter increases once. */ + expected =1 ; +TEST_ASSERT_EQUAL (app_dpdk_test_tp_count, expected, +"Expecting %d, but got %d for app_dpdk_test_tp_count" , + expected, app_dpdk_test_tp_count); + rc =rte_trace_point_disable (&__app_dpdk_test_tp);if (rc <0 ) goto failed;
@@ -104,6 +113,12 @@ test_trace_point_disable_enable(void)if (rte_trace_point_is_enabled (&__app_dpdk_test_tp)) goto failed; +/* No emission expected */ +app_dpdk_test_tp ("app.dpdk.test.tp" ); +TEST_ASSERT_EQUAL (app_dpdk_test_tp_count, expected, +"Expecting %d, but got %d for app_dpdk_test_tp_count" , + expected, app_dpdk_test_tp_count); + rc =rte_trace_point_enable (&__app_dpdk_test_tp);if (rc <0 ) goto failed;
@@ -113,6 +128,11 @@ test_trace_point_disable_enable(void)/* Emit the trace */ app_dpdk_test_tp ("app.dpdk.test.tp" ); + expected++; +TEST_ASSERT_EQUAL (app_dpdk_test_tp_count, expected, +"Expecting %d, but got %d for app_dpdk_test_tp_count" , + expected, app_dpdk_test_tp_count); +return TEST_SUCCESS ; failed:
app/test/test_trace.h +2 -0
@@ -3,10 +3,12 @@*/ #include <rte_trace_point.h> +extern int app_dpdk_test_tp_count;RTE_TRACE_POINT ( app_dpdk_test_tp, RTE_TRACE_POINT_ARGS(const char *str), rte_trace_point_emit_string(str); + app_dpdk_test_tp_count++; ) RTE_TRACE_POINT_FP(
doc/guides/prog_guide/trace_lib.rst +10 -4
@@ -271,10 +271,16 @@ Trace memory The trace memory will be allocated through an internal function ``__rte_trace_mem_per_thread_alloc()``. The trace memory will be allocated per thread to enable lock less trace-emit function. -The memory for the trace memory for DPDK lcores will be allocated on -``rte_eal_init()`` if the trace is enabled through a EAL option. -For non DPDK threads, on the first trace emission, the memory will be -allocated. + +For non lcore threads, the trace memory is allocated on the first trace +emission. + +For lcore threads, if trace points are enabled through a EAL option, the trace +memory is allocated when the threads are known of DPDK +(``rte_eal_init`` for EAL lcores, ``rte_thread_register`` for non-EAL lcores). +Otherwise, when trace points are enabled later in the life of the application, +the behavior is the same as non lcore threads and the trace memory is allocated +on the first trace emission. Trace memory layout ~~~~~~~~~~~~~~~~~~~
lib/eal/common/eal_common_trace.c +22 -31
117 lines not on this page · raw message
lib/eal/common/eal_common_trace_utils.c +10 -1
@@ -314,14 +314,18 @@ trace_dir_default_path_get(char *dir_path)return 0 ; } -int +static int trace_mkdir (void ) {struct trace *trace =trace_obj_get ();char session[TRACE_DIR_STR_LEN ]; +static bool already_done;char *dir_path;int rc; +if (already_done) +return 0 ; +if (!trace->dir_offset) { dir_path =calloc (1 ,sizeof (trace->dir));if (dir_path ==NULL ) {
@@ -365,6 +369,7 @@ trace_mkdir(void) }RTE_LOG (INFO ,EAL ,"Trace dir: %s\n" , trace->dir); + already_done = true;return 0 ; }
@@ -434,6 +439,10 @@ rte_trace_save(void)if (trace->nb_trace_mem_list ==0 )return rc; + rc =trace_mkdir (); +if (rc <0 ) +return rc; + rc =trace_meta_save (trace);if (rc)return rc;
lib/eal/common/eal_trace.h +1 -2
@@ -54,7 +54,7 @@ struct trace {char dir[PATH_MAX ];int dir_offset;int register_errno; -bool status; +uint32_t status;enum rte_trace_mode mode;rte_uuid_t uuid;uint32_t buff_len;
@@ -104,7 +104,6 @@ void trace_uuid_generate(void);int trace_metadata_create (void );void trace_metadata_destroy (void );char *trace_metadata_fixup_field (const char *field); -int trace_mkdir (void );int trace_epoch_time_save (void );void trace_mem_free (void );void trace_mem_per_thread_free (void );
Signature · 1 line
2.37.3
RE: [EXT] [PATCH v2 5/9] trace: fix dynamically enabling trace points
Quoted 53 lines
-----Original Message-----
From: David Marchand <[email protected]>
Sent: Tuesday, October 4, 2022 3:14 PM
To: [email protected]
Cc: [email protected]; Jerin Jacob Kollanukkaran <[email protected]>; [email protected]; Sunil Kumar Kori <[email protected]>
Subject: [EXT] [PATCH v2 5/9] trace: fix dynamically enabling trace pointsExternal Email
----------------------------------------------------------------------
Enabling trace points at runtime was not working if no trace point had been enabled first atrte_eal_init()time. The reason was that trace.args reflected the arguments passed to --trace= EAL option.To fix this:
- the trace subsystem initialisation is updated: trace directory creation is deferred to when traces are dumped (to avoid creating directories that may not be used),
- per lcore memory allocation still relies onrte_trace_is_enabled()but this helper now tracks if any trace point is enabled. The documentation is updated accordingly,
- cleanup helpers must always be called inrte_eal_cleanup()since some trace points might have been enabled and disabled in the lifetime of the DPDK application,With this fix, we can update the unit test and check that a trace point callback is invoked when expected.
Note:
- the 'trace' global variable might be shadowed with the argument passed to the functions dealing with trace point handles. 'tp' has been used for referring totrace_pointobject. Prefer 't' for referring to handles,Fixes 84c4fae4628f ("trace: implement operation APIs")Signed-off-by David Marchand <[email protected]>---
Changes since v1:
- restored level to INFO for trace directory log message,
- movedtrace_mkdir()torte_trace_save,--- app/test/test_trace.c | 20 ++++++++++ app/test/test_trace.h | 2 + doc/guides/prog_guide/trace_lib.rst | 14 +++++-- lib/eal/common/eal_common_trace.c | 53 ++++++++++--------------- lib/eal/common/eal_common_trace_utils.c | 11 ++++- lib/eal/common/eal_trace.h | 3 +- 6 files changed, 65 insertions(+), 38 deletions(-)
[snip]
Quoted 12 lines
lib/eal/common/eal_common_trace_utils.c +1
-1@@ -314,14 +314,18 @@ trace_dir_default_path_get(char *dir_path)return 0 ; } -int +static int trace_mkdir (void )
lib/eal/common/eal_common_trace_utils.c trace_dir_default_path_get(char *dir_path) · line 328
Quoted 10 lines
lib/eal/common/eal_common_trace_utils.c +4
-0{struct trace *trace =trace_obj_get ();char session[TRACE_DIR_STR_LEN ]; +static bool already_done;char *dir_path;int rc; +if (already_done) +return 0 ; +
As trace_mkdir() call is being moved to rte_trace_save() so there won't be another context which will be invoking trace_mkdir(). So is this logic still needed here ?
Quoted 22 lines
lib/eal/common/eal_common_trace_utils.c +5
-0if (!trace->dir_offset) { dir_path =calloc (1 ,sizeof (trace->dir));if (dir_path ==NULL ) {@@ -365,6 +369,7 @@ trace_mkdir(void) }RTE_LOG (INFO ,EAL ,"Trace dir: %s\n" , trace->dir); + already_done = true;return 0 ; }@@ -434,6 +439,10 @@ rte_trace_save(void)if (trace->nb_trace_mem_list ==0 )return rc; + rc =trace_mkdir (); +if (rc <0 ) +return rc; + rc =trace_meta_save (trace);if (rc)return rc;
[snip]
Quoted 1 line
2.37.3
Re: [EXT] [PATCH v2 5/9] trace: fix dynamically enabling trace points
Quoted 19 lines · Sunil Kumar Kori
Quoted 19 lines
lib/eal/common/eal_common_trace_utils.c +2
-1@@ -314,14 +314,18 @@ trace_dir_default_path_get(char *dir_path)return 0 ; } -int +static int trace_mkdir (void ) {struct trace *trace =trace_obj_get ();char session[TRACE_DIR_STR_LEN ]; +static bool already_done;char *dir_path;int rc;
Quoted 6 lines
lib/eal/common/eal_common_trace_utils.c trace_dir_default_path_get(char *dir_path) · line 328
Quoted 3 lines
lib/eal/common/eal_common_trace_utils.c +3
-0+if (already_done) +return 0 ; +As
trace_mkdir()call is being moved torte_trace_save()so there won't be another context which will be invokingtrace_mkdir(). So is this logic still needed here ?
I have in mind a case where an application calls rte_trace_save() multiple times.
Signature · 1 line
David Marchand
Sunil Kumar Kori
Acked-byRE: [EXT] [PATCH v2 5/9] trace: fix dynamically enabling trace points
Quoted 34 lines
-----Original Message-----
From: David Marchand <[email protected]>
Sent: Wednesday, October 12, 2022 3:27 PM
To: Sunil Kumar Kori <[email protected]>
Cc: [email protected]; [email protected]; Jerin Jacob Kollanukkaran <[email protected]>; [email protected]
Subject: Re: [EXT] [PATCH v2 5/9] trace: fix dynamically enabling trace pointsQuoted 19 lines · Sunil Kumar Kori
Quoted 19 lines
lib/eal/common/eal_common_trace_utils.c +2
-1@@ -314,14 +314,18 @@ trace_dir_default_path_get(char *dir_path)return 0 ; } -int +static int trace_mkdir (void ) {struct trace *trace =trace_obj_get ();char session[TRACE_DIR_STR_LEN ]; +static bool already_done;char *dir_path;int rc;Quoted 5 lines
lib/eal/common/eal_common_trace_utils.c trace_dir_default_path_get(char *dir_path) · line 328
Quoted 3 lines
lib/eal/common/eal_common_trace_utils.c +3
-0+if (already_done) +return 0 ; +As
trace_mkdir()call is being moved torte_trace_save()so there won't be
Quoted 5 lines
another context which will be invoking
trace_mkdir().Quoted 1 line
So is this logic still needed here ?
I have in mind a case where an application calls
rte_trace_save()multiple times.
Make sense.
Quoted 4 lines
--
David Marchand
PATCH v2 6/9 trace: fix race in debug dump
In reply to David Marchandtrace->nb_trace_mem_list access must be under trace->lock to avoid races with threads allocating/freeing their trace buffers.
--- lib/eal/common/eal_common_trace.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
lib/eal/common/eal_common_trace.c +3 -3
@@ -259,10 +259,9 @@ trace_lcore_mem_dump(FILE *f)struct __rte_trace_header *header;uint32_t count; -if (trace->nb_trace_mem_list ==0 ) -return ; -rte_spinlock_lock (&trace->lock); +if (trace->nb_trace_mem_list ==0 ) + goto out;fprintf (f,"nb_trace_mem_list = %d\n" , trace->nb_trace_mem_list);fprintf (f,"\nTrace mem info\n--------------\n" );for (count =0 ; count < trace->nb_trace_mem_list; count++) {
@@ -273,6 +272,7 @@ trace_lcore_mem_dump(FILE *f) header->stream_header.lcore_id, header->stream_header.thread_name); } +out:rte_spinlock_unlock (&trace->lock); }
Signature · 1 line
2.37.3
RE: [EXT] [PATCH v2 6/9] trace: fix race in debug dump
Quoted 14 lines
-----Original Message-----
From: David Marchand <[email protected]>
Sent: Tuesday, October 4, 2022 3:14 PM
To: [email protected]
Cc: [email protected]; Jerin Jacob Kollanukkaran <[email protected]>; [email protected]; Sunil Kumar Kori <[email protected]>
Subject: [EXT] [PATCH v2 6/9] trace: fix race in debug dumpExternal Email
----------------------------------------------------------------------
trace->nb_trace_mem_listaccess must be undertrace->lockto avoid races with threads allocating/freeing their trace buffers.
Quoted 8 lines
Fixes f6b2d65dcd5d ("trace: implement debug dump")Signed-off-by David Marchand <[email protected]>--- lib/eal/common/eal_common_trace.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
Quoted 28 lines
lib/eal/common/eal_common_trace.c +2
-3@@ -259,10 +259,9 @@ trace_lcore_mem_dump(FILE *f)struct __rte_trace_header *header;uint32_t count; -if (trace->nb_trace_mem_list ==0 ) -return ; -rte_spinlock_lock (&trace->lock); +if (trace->nb_trace_mem_list ==0 ) + goto out;fprintf (f,"nb_trace_mem_list = %d\n" , trace->nb_trace_mem_list);fprintf (f,"\nTrace mem info\n--------------\n" ); for (count = 0; count < trace->nb_trace_mem_list; count++) { @@ -273,6 +272,7 @@
trace_lcore_mem_dump(FILE *f)lib/eal/common/eal_common_trace.c +1
-1header->stream_header.lcore_id, header->stream_header.thread_name); } +out:rte_spinlock_unlock (&trace->lock); } --2.37.3
PATCH v2 7/9 trace: fix metadata dump
In reply to David MarchandThe API does not describe that metadata dump is conditioned to enabling any trace points.
While at it, merge dump unit tests into the generic trace_autotest to enhance coverage.
--- app/test/test_trace.c | 44 +++++++++------------------ lib/eal/common/eal_common_trace_ctf.c | 3 -- 2 files changed, 15 insertions(+), 32 deletions(-)
app/test/test_trace.c +15 -29
@@ -20,20 +20,6 @@ test_trace(void)return TEST_SKIPPED ; } -static int -test_trace_dump (void ) -{ -printf ("trace_dump not supported on Windows, skipping test\n" ); -return TEST_SKIPPED ; -} - -static int -test_trace_metadata_dump (void ) -{ -printf ("trace_metadata_dump not supported on Windows, skipping test\n" ); -return TEST_SKIPPED ; -} -#else static int32_t
@@ -214,6 +200,19 @@ test_generic_trace_points(void)return TEST_SUCCESS ; } +static int +test_trace_dump (void ) +{ +rte_trace_dump (stdout); +return 0 ; +} + +static int +test_trace_metadata_dump (void ) +{ +return rte_trace_metadata_dump (stdout); +} +static struct unit_test_suite trace_tests = { .suite_name ="trace autotest" , .setup =NULL ,
@@ -226,6 +225,8 @@ static struct unit_test_suite trace_tests = {TEST_CASE (test_trace_point_globbing),TEST_CASE (test_trace_point_regex),TEST_CASE (test_trace_points_lookup), +TEST_CASE (test_trace_dump), +TEST_CASE (test_trace_metadata_dump), TEST_CASES_END() } };
@@ -236,21 +237,6 @@ test_trace(void) return unit_test_suite_runner(&trace_tests); } -static int -test_trace_dump (void ) -{ -rte_trace_dump (stdout); -return 0 ; -} - -static int -test_trace_metadata_dump (void ) -{ -return rte_trace_metadata_dump (stdout); -} -#endif /* !RTE_EXEC_ENV_WINDOWS */ REGISTER_TEST_COMMAND (trace_autotest, test_trace); -REGISTER_TEST_COMMAND (trace_dump, test_trace_dump); -REGISTER_TEST_COMMAND (trace_metadata_dump, test_trace_metadata_dump);
lib/eal/common/eal_common_trace_ctf.c +0 -3
@@ -358,9 +358,6 @@ rte_trace_metadata_dump(FILE *f)char *ctf_meta = trace->ctf_meta;int rc; -if (!rte_trace_is_enabled ()) -return 0 ; -if (ctf_meta ==NULL )return -EINVAL ;
Signature · 1 line
2.37.3
RE: [EXT] [PATCH v2 7/9] trace: fix metadata dump
Quoted 17 lines
-----Original Message-----
From: David Marchand <[email protected]>
Sent: Tuesday, October 4, 2022 3:14 PM
To: [email protected]
Cc: [email protected]; Jerin Jacob Kollanukkaran <[email protected]>; [email protected]; Sunil Kumar Kori <[email protected]>
Subject: [EXT] [PATCH v2 7/9] trace: fix metadata dumpExternal Email
----------------------------------------------------------------------
The API does not describe that metadata dump is conditioned to enabling any trace points.While at it, merge dump unit tests into the generic
trace_autotestto enhance coverage.
Quoted 9 lines
Fixes f6b2d65dcd5d ("trace: implement debug dump")Signed-off-by David Marchand <[email protected]>--- app/test/test_trace.c | 44 +++++++++------------------ lib/eal/common/eal_common_trace_ctf.c | 3 -- 2 files changed, 15 insertions(+), 32 deletions(-)
Quoted 6 lines
app/test/test_trace.c index renamed from app/test/test_trace.c +0
-0
2660f52f1d..6bedf14024100644app/test/test_trace.c +0
-0@@ -20,20 +20,6 @@ test_trace(void)return TEST_SKIPPED ;
[snip]
Quoted 3 lines
--
2.37.3
PATCH v2 8/9 trace: remove limitation on trace point name
In reply to David MarchandThe name of a trace point is provided as a constant string via the RTE_TRACE_POINT_REGISTER macro.
We can rely on the constant string in the binary and simply point at it. There is then no need for a (fixed size) copy.
--- lib/eal/common/eal_common_trace.c | 10 +++------- lib/eal/common/eal_common_trace_utils.c | 2 +- lib/eal/common/eal_trace.h | 3 +-- 3 files changed, 5 insertions(+), 10 deletions(-)
lib/eal/common/eal_common_trace.c +3 -7
@@ -235,7 +235,7 @@ rte_trace_point_lookup(const char *name)return NULL ; STAILQ_FOREACH(tp, &tp_list, next) -if (strncmp (tp->name, name,TRACE_POINT_NAME_SIZE ) ==0 ) +if (strcmp (tp->name, name) ==0 )return tp->handle;return NULL ;
@@ -492,10 +492,7 @@ __rte_trace_point_register(rte_trace_point_t *handle, const char *name, }/* Initialize the trace point */ -if (rte_strscpy (tp->name, name,TRACE_POINT_NAME_SIZE ) <0 ) { -trace_err ("name is too long" ); - goto free; - } + tp->name = name;/* Copy the accumulated fields description and clear it for the next * trace point.
@@ -517,8 +514,7 @@ __rte_trace_point_register(rte_trace_point_t *handle, const char *name,/* All Good !!! */ return 0 ; -free: -free (tp); + fail:if (trace.register_errno ==0 ) trace.register_errno = rte_errno;
lib/eal/common/eal_common_trace_utils.c +1 -1
@@ -42,7 +42,7 @@ trace_entry_compare(const char *name)int count =0 ; STAILQ_FOREACH(tp, tp_list, next) { -if (strncmp (tp->name, name,TRACE_POINT_NAME_SIZE ) ==0 ) +if (strcmp (tp->name, name) ==0 ) count++;if (count >1 ) {trace_err ("found duplicate entry %s" , name);
lib/eal/common/eal_trace.h +1 -2
@@ -24,14 +24,13 @@#define TRACE_PREFIX_LEN 12#define TRACE_DIR_STR_LEN (sizeof("YYYY-mm-dd-AM-HH-MM-SS") + TRACE_PREFIX_LEN) -#define TRACE_POINT_NAME_SIZE 64#define TRACE_CTF_MAGIC 0xC1FC1FC1#define TRACE_MAX_ARGS 32struct trace_point {STAILQ_ENTRY (trace_point) next;rte_trace_point_t *handle; -char name[TRACE_POINT_NAME_SIZE ]; +const char *name;char *ctf_field; };
Signature · 1 line
2.37.3
PATCH v2 9/9 trace: remove limitation on directory
In reply to David MarchandRemove arbitrary limit on 12 characters of the file prefix used for the directory where to store the traces.
Simplify the code by relying on dynamic allocations.
--- lib/eal/common/eal_common_trace_utils.c | 68 +++++++++---------------- lib/eal/common/eal_trace.h | 5 +- 2 files changed, 25 insertions(+), 48 deletions(-)
lib/eal/common/eal_common_trace_utils.c +24 -44
@@ -87,11 +87,11 @@ trace_uuid_generate(void) }static int -trace_session_name_generate (char *trace_dir) +trace_session_name_generate (char **trace_dir) { +char date[sizeof ("YYYY-mm-dd-AM-HH-MM-SS" )];struct tm *tm_result;time_t tm; -int rc; tm =time (NULL );if ((int )tm ==-1 )
@@ -101,38 +101,32 @@ trace_session_name_generate(char *trace_dir)if (tm_result ==NULL ) goto fail; - rc =rte_strscpy (trace_dir,eal_get_hugefile_prefix (), -TRACE_PREFIX_LEN ); -if (rc == -E2BIG ) - rc =TRACE_PREFIX_LEN -1 ; - trace_dir[rc++] ='-' ; - - rc =strftime (trace_dir + rc,TRACE_DIR_STR_LEN - rc, -"%Y-%m-%d-%p-%I-%M-%S" , tm_result); -if (rc ==0 ) { +if (strftime (date,sizeof (date),"%Y-%m-%d-%p-%I-%M-%S" , tm_result) ==0 ) { errno =ENOSPC ; goto fail; } -return rc; +if (asprintf (trace_dir,"%s-%s" ,eal_get_hugefile_prefix (), date) ==-1 ) + goto fail; + +return 0 ; fail: rte_errno = errno; -return -rte_errno; +return -1 ; }static int trace_dir_update (const char *str) {struct trace *trace =trace_obj_get (); -int rc, remaining; - - remaining =sizeof (trace->dir) - trace->dir_offset; - rc =rte_strscpy (&trace->dir[0 ] + trace->dir_offset, str, remaining); -if (rc <0 ) - goto fail; +char *dir; +int rc; - trace->dir_offset += rc; -fail: + rc =asprintf (&dir,"%s%s" , trace->dir !=NULL ? trace->dir :"" , str); +if (rc !=-1 ) { +free (trace->dir); + trace->dir = dir; + }return rc; }
@@ -246,22 +240,15 @@ eal_trace_mode_args_save(const char *val)int eal_trace_dir_args_save (char const *val) { -struct trace *trace =trace_obj_get ();char *dir_path;int rc; -if (strlen (val) >=sizeof (trace->dir) -1 ) { -trace_err ("input string is too big" ); -return -ENAMETOOLONG ; - } -if (asprintf (&dir_path,"%s/" , val) ==-1 ) {trace_err ("failed to copy directory: %s" ,strerror (errno));return -ENOMEM ; } rc =trace_dir_update (dir_path); -free (dir_path);return rc; }
@@ -289,10 +276,8 @@ trace_epoch_time_save(void) }static int -trace_dir_default_path_get (char *dir_path) +trace_dir_default_path_get (char **dir_path) { -struct trace *trace =trace_obj_get (); -uint32_t size =sizeof (trace->dir);struct passwd *pwd;char *home_dir;
@@ -308,8 +293,8 @@ trace_dir_default_path_get(char *dir_path) }/* Append dpdk-traces to directory */ -if (snprintf (dir_path, size,"%s/dpdk-traces/" , home_dir) <0 ) -return -ENAMETOOLONG ; +if (asprintf (dir_path,"%s/dpdk-traces/" , home_dir) ==-1 ) +return -ENOMEM ;return 0 ; }
@@ -318,25 +303,19 @@ static inttrace_mkdir (void) {struct trace *trace =trace_obj_get (); -char session[TRACE_DIR_STR_LEN ];static bool already_done; -char *dir_path; +char *session;int rc;if (already_done)return 0 ; -if (!trace->dir_offset) { - dir_path =calloc (1 ,sizeof (trace->dir)); -if (dir_path ==NULL ) { -trace_err ("fail to allocate memory" ); -return -ENOMEM ; - } +if (trace->dir ==NULL ) { +char *dir_path; - rc =trace_dir_default_path_get (dir_path); + rc =trace_dir_default_path_get (&dir_path);if (rc <0 ) {trace_err ("fail to get default path" ); -free (dir_path);return rc; }
@@ -354,10 +333,11 @@ trace_mkdir(void)return -rte_errno; } - rc =trace_session_name_generate (session); + rc =trace_session_name_generate (&session);if (rc <0 )return rc; rc =trace_dir_update (session); +free (session);if (rc <0 )return rc;
lib/eal/common/eal_trace.h +1 -4
@@ -22,8 +22,6 @@ #define trace_crit(fmt, args...) \ RTE_LOG(CRIT, EAL, "%s():%u " fmt "\n", __func__, __LINE__, ## args) -#define TRACE_PREFIX_LEN 12 -#define TRACE_DIR_STR_LEN (sizeof("YYYY-mm-dd-AM-HH-MM-SS") + TRACE_PREFIX_LEN)#define TRACE_CTF_MAGIC 0xC1FC1FC1#define TRACE_MAX_ARGS 32
@@ -50,8 +48,7 @@ struct trace_arg { };struct trace { -char dir[PATH_MAX ]; -int dir_offset; +char *dir;int register_errno;uint32_t status;enum rte_trace_mode mode;
Signature · 1 line
2.37.3
RE: [EXT] [PATCH v2 9/9] trace: remove limitation on directory
Quoted 15 lines
-----Original Message-----
From: David Marchand <[email protected]>
Sent: Tuesday, October 4, 2022 3:14 PM
To: [email protected]
Cc: [email protected]; Jerin Jacob Kollanukkaran <[email protected]>; Sunil Kumar Kori <[email protected]>
Subject: [EXT] [PATCH v2 9/9] trace: remove limitation on directoryExternal Email
----------------------------------------------------------------------
Remove arbitrary limit on 12 characters of the file prefix used for the directory where to store the traces.
Simplify the code by relying on dynamic allocations.
Quoted 6 lines
Signed-off-by David Marchand <[email protected]>--- lib/eal/common/eal_common_trace_utils.c | 68 +++++++++---------------- lib/eal/common/eal_trace.h | 5 +- 2 files changed, 25 insertions(+), 48 deletions(-)
Quoted 7 lines
lib/eal/common/eal_common_trace_utils.c +0
-0@@ -87,11 +87,11 @@ trace_uuid_generate(void) }
[snip]
Quoted 1 line
2.37.3
v3 cover Trace subsystem fixes
In reply to David MarchandHello,
This series addresses a number of issues and limitations I have identified over time in the trace subsystem.
The main issue was with dynamically enabling trace points which was not working if no trace point had been enabled at rte_eal_init() time.
This is 22.11 material.
We may start thinking about marking this API stable, but this is another topic.
Signature · 32 lines
David Marchand Changes since v2: - fixed trace point name storage, Changes since v1: - split patch 3, - addressed comments on (previously) patch 4, David Marchand (9): trace: fix mode for new trace point trace: fix mode change trace: fix leak with regexp trace: rework loop on trace points trace: fix dynamically enabling trace points trace: fix race in debug dump trace: fix metadata dump trace: remove limitation on trace point name trace: remove limitation on directory app/test/test_trace.c | 67 +++++++------ app/test/test_trace.h | 2 + doc/guides/prog_guide/trace_lib.rst | 14 ++- lib/eal/common/eal_common_trace.c | 111 ++++++++++----------- lib/eal/common/eal_common_trace_ctf.c | 3 - lib/eal/common/eal_common_trace_utils.c | 81 +++++++-------- lib/eal/common/eal_trace.h | 11 +- lib/eal/include/rte_trace_point_register.h | 3 +- 8 files changed, 138 insertions(+), 154 deletions(-) -- 2.37.3
PATCH v3 1/9 trace: fix mode for new trace point
If an application registers trace points later than rte_eal_init(), changes in the trace point mode were not applied.
--- lib/eal/common/eal_common_trace.c | 1 + 1 file changed, 1 insertion(+)
lib/eal/common/eal_common_trace.c +1 -0
@@ -512,6 +512,7 @@ __rte_trace_point_register(rte_trace_point_t *handle, const char *name,/* Form the trace handle */ *handle = sz; *handle |= trace.nb_trace_points << __RTE_TRACE_FIELD_ID_SHIFT; +trace_mode_set (handle, trace.mode); trace.nb_trace_points++; tp->handle = handle;
Signature · 1 line
2.37.3
PATCH v3 2/9 trace: fix mode change
In reply to David MarchandThe API does not state that changing mode should be refused if no trace point is enabled. Remove this limitation.
--- app/test/test_trace.c | 3 --- lib/eal/common/eal_common_trace.c | 3 --- 2 files changed, 6 deletions(-)
app/test/test_trace.c +0 -3
@@ -126,9 +126,6 @@ test_trace_mode(void) current =rte_trace_mode_get (); -if (!rte_trace_is_enabled ()) -return TEST_SKIPPED ; -rte_trace_mode_set (RTE_TRACE_MODE_DISCARD );if (rte_trace_mode_get () !=RTE_TRACE_MODE_DISCARD ) goto failed;
lib/eal/common/eal_common_trace.c +0 -3
@@ -127,9 +127,6 @@ rte_trace_mode_set(enum rte_trace_mode mode) {struct trace_point *tp; -if (!rte_trace_is_enabled ()) -return ; - STAILQ_FOREACH(tp, &tp_list, next)trace_mode_set (tp->handle, mode);
Signature · 1 line
2.37.3
PATCH v3 3/9 trace: fix leak with regexp
In reply to David MarchandThe precompiled buffer initialised in regcomp must be freed before leaving rte_trace_regexp.
---
Changes since v1:
- split patch in two, keeping only the backportable fix as patch 3,
--- lib/eal/common/eal_common_trace.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
lib/eal/common/eal_common_trace.c +4 -2
@@ -218,8 +218,10 @@ rte_trace_regexp(const char *regex, bool enable) rc =rte_trace_point_disable (tp->handle); found =1 ; } -if (rc <0 ) -return rc; +if (rc <0 ) { + found =0 ; +break ; + } }regfree (&r);
Signature · 1 line
2.37.3
PATCH v3 4/9 trace: rework loop on trace points
In reply to David MarchandDirectly skip the block when a trace point does not match the user criteria.
--- lib/eal/common/eal_common_trace.c | 34 +++++++++++++++++-------------- 1 file changed, 19 insertions(+), 15 deletions(-)
lib/eal/common/eal_common_trace.c +19 -15
@@ -186,15 +186,18 @@ rte_trace_pattern(const char *pattern, bool enable)int rc =0 , found =0 ; STAILQ_FOREACH(tp, &tp_list, next) { -if (fnmatch (pattern, tp->name,0 ) ==0 ) { -if (enable) - rc =rte_trace_point_enable (tp->handle); -else - rc =rte_trace_point_disable (tp->handle); - found =1 ; +if (fnmatch (pattern, tp->name,0 ) !=0 ) +continue ; + +if (enable) + rc =rte_trace_point_enable (tp->handle); +else + rc =rte_trace_point_disable (tp->handle); +if (rc <0 ) { + found =0 ; +break ; } -if (rc <0 ) -return rc; + found =1 ; }return rc | found;
@@ -211,17 +214,18 @@ rte_trace_regexp(const char *regex, bool enable)return -EINVAL ; STAILQ_FOREACH(tp, &tp_list, next) { -if (regexec (&r, tp->name,0 ,NULL ,0 ) ==0 ) { -if (enable) - rc =rte_trace_point_enable (tp->handle); -else - rc =rte_trace_point_disable (tp->handle); - found =1 ; - } +if (regexec (&r, tp->name,0 ,NULL ,0 ) !=0 ) +continue ; + +if (enable) + rc =rte_trace_point_enable (tp->handle); +else + rc =rte_trace_point_disable (tp->handle);if (rc <0 ) { found =0 ;break ; } + found =1 ; }regfree (&r);
Signature · 1 line
2.37.3
PATCH v3 5/9 trace: fix dynamically enabling trace points
In reply to David MarchandEnabling trace points at runtime was not working if no trace point had been enabled first at rte_eal_init() time. The reason was that trace.args reflected the arguments passed to --trace= EAL option.
To fix this:
- the trace subsystem initialisation is updated: trace directory creation is deferred to when traces are dumped (to avoid creating directories that may not be used),
- per lcore memory allocation still relies on rte_trace_is_enabled() but this helper now tracks if any trace point is enabled. The documentation is updated accordingly,
- cleanup helpers must always be called in rte_eal_cleanup() since some trace points might have been enabled and disabled in the lifetime of the DPDK application,
With this fix, we can update the unit test and check that a trace point callback is invoked when expected.
Note:
- the 'trace' global variable might be shadowed with the argument passed to the functions dealing with trace point handles. 'tp' has been used for referring to trace_point object. Prefer 't' for referring to handles,
---
Changes since v1:
- restored level to INFO for trace directory log message,
- moved trace_mkdir() to rte_trace_save,
--- app/test/test_trace.c | 20 ++++++++++ app/test/test_trace.h | 2 + doc/guides/prog_guide/trace_lib.rst | 14 +++++-- lib/eal/common/eal_common_trace.c | 53 ++++++++++--------------- lib/eal/common/eal_common_trace_utils.c | 11 ++++- lib/eal/common/eal_trace.h | 3 +- 6 files changed, 65 insertions(+), 38 deletions(-)
app/test/test_trace.c +20 -0
@@ -9,6 +9,8 @@#include "test.h" #include "test_trace.h" +int app_dpdk_test_tp_count; +#ifdef RTE_EXEC_ENV_WINDOWS static int
@@ -95,8 +97,15 @@ test_trace_point_regex(void)static int32_t test_trace_point_disable_enable (void ) { +int expected;int rc; +/* At tp registration, the associated counter increases once. */ + expected =1 ; +TEST_ASSERT_EQUAL (app_dpdk_test_tp_count, expected, +"Expecting %d, but got %d for app_dpdk_test_tp_count" , + expected, app_dpdk_test_tp_count); + rc =rte_trace_point_disable (&__app_dpdk_test_tp);if (rc <0 ) goto failed;
@@ -104,6 +113,12 @@ test_trace_point_disable_enable(void)if (rte_trace_point_is_enabled (&__app_dpdk_test_tp)) goto failed; +/* No emission expected */ +app_dpdk_test_tp ("app.dpdk.test.tp" ); +TEST_ASSERT_EQUAL (app_dpdk_test_tp_count, expected, +"Expecting %d, but got %d for app_dpdk_test_tp_count" , + expected, app_dpdk_test_tp_count); + rc =rte_trace_point_enable (&__app_dpdk_test_tp);if (rc <0 ) goto failed;
@@ -113,6 +128,11 @@ test_trace_point_disable_enable(void)/* Emit the trace */ app_dpdk_test_tp ("app.dpdk.test.tp" ); + expected++; +TEST_ASSERT_EQUAL (app_dpdk_test_tp_count, expected, +"Expecting %d, but got %d for app_dpdk_test_tp_count" , + expected, app_dpdk_test_tp_count); +return TEST_SUCCESS ; failed:
app/test/test_trace.h +2 -0
@@ -3,10 +3,12 @@*/ #include <rte_trace_point.h> +extern int app_dpdk_test_tp_count;RTE_TRACE_POINT ( app_dpdk_test_tp, RTE_TRACE_POINT_ARGS(const char *str), rte_trace_point_emit_string(str); + app_dpdk_test_tp_count++; ) RTE_TRACE_POINT_FP(
doc/guides/prog_guide/trace_lib.rst +10 -4
@@ -271,10 +271,16 @@ Trace memory The trace memory will be allocated through an internal function ``__rte_trace_mem_per_thread_alloc()``. The trace memory will be allocated per thread to enable lock less trace-emit function. -The memory for the trace memory for DPDK lcores will be allocated on -``rte_eal_init()`` if the trace is enabled through a EAL option. -For non DPDK threads, on the first trace emission, the memory will be -allocated. + +For non lcore threads, the trace memory is allocated on the first trace +emission. + +For lcore threads, if trace points are enabled through a EAL option, the trace +memory is allocated when the threads are known of DPDK +(``rte_eal_init`` for EAL lcores, ``rte_thread_register`` for non-EAL lcores). +Otherwise, when trace points are enabled later in the life of the application, +the behavior is the same as non lcore threads and the trace memory is allocated +on the first trace emission. Trace memory layout ~~~~~~~~~~~~~~~~~~~
lib/eal/common/eal_common_trace.c +22 -31
117 lines not on this page · raw message
lib/eal/common/eal_common_trace_utils.c +10 -1
@@ -314,14 +314,18 @@ trace_dir_default_path_get(char *dir_path)return 0 ; } -int +static int trace_mkdir (void ) {struct trace *trace =trace_obj_get ();char session[TRACE_DIR_STR_LEN ]; +static bool already_done;char *dir_path;int rc; +if (already_done) +return 0 ; +if (!trace->dir_offset) { dir_path =calloc (1 ,sizeof (trace->dir));if (dir_path ==NULL ) {
@@ -365,6 +369,7 @@ trace_mkdir(void) }RTE_LOG (INFO ,EAL ,"Trace dir: %s\n" , trace->dir); + already_done = true;return 0 ; }
@@ -434,6 +439,10 @@ rte_trace_save(void)if (trace->nb_trace_mem_list ==0 )return rc; + rc =trace_mkdir (); +if (rc <0 ) +return rc; + rc =trace_meta_save (trace);if (rc)return rc;
lib/eal/common/eal_trace.h +1 -2
@@ -54,7 +54,7 @@ struct trace {char dir[PATH_MAX ];int dir_offset;int register_errno; -bool status; +uint32_t status;enum rte_trace_mode mode;rte_uuid_t uuid;uint32_t buff_len;
@@ -104,7 +104,6 @@ void trace_uuid_generate(void);int trace_metadata_create (void );void trace_metadata_destroy (void );char *trace_metadata_fixup_field (const char *field); -int trace_mkdir (void );int trace_epoch_time_save (void );void trace_mem_free (void );void trace_mem_per_thread_free (void );
Signature · 1 line
2.37.3
RE: [EXT] [PATCH v3 5/9] trace: fix dynamically enabling trace points
Quoted 4 lines
lib/eal/common/eal_common_trace_utils.c +1
-1-int +static int trace_mkdir (void )
lib/eal/common/eal_common_trace_utils.c trace_dir_default_path_get(char *dir_path) · line 328
Quoted 10 lines
lib/eal/common/eal_common_trace_utils.c +4
-0{struct trace *trace =trace_obj_get ();char session[TRACE_DIR_STR_LEN ]; +static bool already_done;char *dir_path;int rc; +if (already_done) +return 0 ; +
Hi David
I was trying out "trace: take live traces via telemetry" patch
I came across following scenario
- Started testpmd with trace=.*
- Executed /trace/save from telemetry script, trace file saved successfully
- Later after stopping application, rte_eal_cleanup() did not save the trace.
With this we lost traces after /trace/save executed
This happened because "already_done" was set after rte_trace_save() called via telemetry. Later rte_eal_cleanup returned from this point without saving later traces.
What is the purpose of already_done flag?
Thanks
Harman
Quoted 8 lines
lib/eal/common/eal_common_trace_utils.c +1
-0if (!trace->dir_offset) { dir_path =calloc (1 ,sizeof (trace->dir));if (dir_path ==NULL ) {@@ -365,6 +369,7 @@ trace_mkdir(void) }RTE_LOG (INFO ,EAL ,"Trace dir: %s\n" , trace->dir); + already_done = true;
Re: [EXT] [PATCH v3 5/9] trace: fix dynamically enabling trace points
Quoted 17 lines · Harman Kalra
Quoted 5 lines
lib/eal/common/eal_common_trace_utils.c +1
-1-int +static int trace_mkdir (void )lib/eal/common/eal_common_trace_utils.c trace_dir_default_path_get(char *dir_path) · line 328
Quoted 10 lines
lib/eal/common/eal_common_trace_utils.c +4
-0{struct trace *trace =trace_obj_get ();char session[TRACE_DIR_STR_LEN ]; +static bool already_done;char *dir_path;int rc; +if (already_done) +return 0 ; +Hi David
Quoted 7 lines
I was trying out "trace: take live traces via telemetry" patch
I came across following scenario
- Started testpmd with trace=.*
- Executed /trace/save from telemetry script, trace file saved successfully
- Later after stopping application,rte_eal_cleanup()did not save the trace.With this we lost traces after /trace/save executed
Sorry, I must be missing something.
What patches did you apply and how are you testing?
With the whole traces fixes series applied first, then the new "trace:
take live traces via telemetry" patch applied, I can't reproduce your issue.
Here is what I did:
$ ./build/app/dpdk-testpmd -c 3 --no-huge -m 40 -a 0:0.0 -d build-gcc/drivers --vdev net_null1 --vdev net_null2 --trace=.* -- --no-mlockall --total-num-mbufs=2048 -ia
--> /trace/save
{"/trace/save": {"Status": "OK", "Path":
"/home/dmarchan/dpdk-traces/rte-2022-10-13-PM-05-44-56"}}
At this point, the trace file contains events until:
...
[17:44:50.738892453] (+0.000000154) lib.eal.mem.malloc: { cpu_id = 0x0, name = "dpdk-testpmd" }, { type = "", size = 0x0, align = 0x0, socket = 0, ptr = 0x0 }
[17:44:50.738892470] (+0.000000017) lib.eal.mem.zmalloc: { cpu_id = 0x0, name = "dpdk-testpmd" }, { type = "", size = 0x0, align = 0x0, socket = 0, ptr = 0x0 }
[17:44:50.738894858] (+0.000002388) lib.eal.mem.malloc: { cpu_id = 0x0, name = "dpdk-testpmd" }, { type = "", size = 0x0, align = 0x0, socket = 0, ptr = 0x0 }
[17:44:50.738894881] (+0.000000023) lib.eal.mem.zmalloc: { cpu_id = 0x0, name = "dpdk-testpmd" }, { type = "", size = 0x0, align = 0x0, socket = 0, ptr = 0x0 }
[17:44:50.738894899] (+0.000000018) lib.ethdev.rxq.setup: { cpu_id = 0x0, name = "dpdk-testpmd" }, { port_id = 0x1, rx_queue_id = 0x0, nb_rx_desc = 0x200, mp = 0x101A9E540, rx_conf_rx_thresh_pthresh = 0x0, rx_conf_rx_thresh_hthresh = 0x0, rx_conf_rx_thresh_wthresh = 0x0, rx_conf_rx_drop_en = 0x0, rx_conf_rx_deferred_start = 0x0, rx_conf_offloads = 0x0, rc = 0 }
[17:44:50.738895490] (+0.000000591) lib.ethdev.start: { cpu_id = 0x0, name = "dpdk-testpmd" }, { port_id = 0x1 } [17:44:50.738908652] (+0.000013162) lib.eal.memzone.lookup: { cpu_id = 0x0, name = "dpdk-testpmd" }, { name = "RTE_METRICS", memzone = 0x0 } [17:44:50.738912231] (+0.000003579) lib.eal.memzone.reserve: { cpu_id = 0x0, name = "dpdk-testpmd" }, { name = "RTE_METRICS", len = 0x15010, socket_id = 0, flags = 0x0, align = 0x40, bound = 0x0, mz = 0x100007168 }
[17:44:50.779538885] (+0.040626654) lib.eal.thread.remote.launch: { cpu_id = 0x0, name = "dpdk-testpmd" }, { f = 0x458130, arg = 0x101C20780, worker_id = 0x1, rc = 0 }
Then, I stop testpmd, and look again at the same trace file:
...
[17:44:50.779538885] (+0.040626654) lib.eal.thread.remote.launch: { cpu_id = 0x0, name = "dpdk-testpmd" }, { f = 0x458130, arg = 0x101C20780, worker_id = 0x1, rc = 0 } [17:45:12.630581221] (+21.851042336) lib.ethdev.stop: { cpu_id = 0x0, name = "dpdk-testpmd" }, { port_id = 0x0, ret = 0 } [17:45:12.630590961] (+0.000009740) lib.ethdev.stop: { cpu_id = 0x0, name = "dpdk-testpmd" }, { port_id = 0x1, ret = 0 } [17:45:12.630601415] (+0.000010454) lib.ethdev.close: { cpu_id = 0x0, name = "dpdk-testpmd" }, { port_id = 0x0 } [17:45:12.630606931] (+0.000005516) lib.eal.mem.free: { cpu_id = 0x0, name = "dpdk-testpmd" }, { ptr = 0x10126D700 } [17:45:12.630618608] (+0.000011677) lib.eal.mem.free: { cpu_id = 0x0, name = "dpdk-testpmd" }, { ptr = 0x10126B680 } [17:45:12.630621015] (+0.000002407) lib.eal.mem.free: { cpu_id = 0x0, name = "dpdk-testpmd" }, { ptr = 0x0 } [17:45:12.630621038] (+0.000000023) lib.eal.mem.free: { cpu_id = 0x0, name = "dpdk-testpmd" }, { ptr = 0x0 } [17:45:12.630621062] (+0.000000024) lib.eal.mem.free: { cpu_id = 0x0, name = "dpdk-testpmd" }, { ptr = 0x102643B40 } [17:45:12.630668837] (+0.000047775) lib.ethdev.close: { cpu_id = 0x0, name = "dpdk-testpmd" }, { port_id = 0x1 } [17:45:12.630671206] (+0.000002369) lib.eal.mem.free: { cpu_id = 0x0, name = "dpdk-testpmd" }, { ptr = 0x101269480 } [17:45:12.630673731] (+0.000002525) lib.eal.mem.free: { cpu_id = 0x0, name = "dpdk-testpmd" }, { ptr = 0x101267400 } [17:45:12.630675638] (+0.000001907) lib.eal.mem.free: { cpu_id = 0x0, name = "dpdk-testpmd" }, { ptr = 0x0 } [17:45:12.630675662] (+0.000000024) lib.eal.mem.free: { cpu_id = 0x0, name = "dpdk-testpmd" }, { ptr = 0x0 } [17:45:12.630675685] (+0.000000023) lib.eal.mem.free: { cpu_id = 0x0, name = "dpdk-testpmd" }, { ptr = 0x10262F940 } [17:45:12.630712155] (+0.000036470) lib.eal.mem.free: { cpu_id = 0x0, name = "dpdk-testpmd" }, { ptr = 0x101C206C0 } [17:45:12.630712692] (+0.000000537) lib.mempool.free: { cpu_id = 0x0, name = "dpdk-testpmd" }, { mempool = 0x101A9E540, mempool_name = "mb_pool_0" }
[17:45:12.630893367] (+0.000180675) lib.eal.mem.free: { cpu_id = 0x0, name = "dpdk-testpmd" }, { ptr = 0x101295F80 } [17:45:12.631196732] (+0.000303365) lib.eal.memzone.free: { cpu_id = 0x0, name = "dpdk-testpmd" }, { name = "MP_mb_pool_0_0", addr = 0x101295F80, rc = 0 }
[17:45:12.631197557] (+0.000000825) lib.eal.mem.free: { cpu_id = 0x0, name = "dpdk-testpmd" }, { ptr = 0x101295EC0 } [17:45:12.631198085] (+0.000000528) lib.mempool.ops.free: { cpu_id = 0x0, name = "dpdk-testpmd" }, { mempool = 0x101A9E540, mempool_name = "mb_pool_0" }
[17:45:12.631201058] (+0.000002973) lib.eal.mem.free: { cpu_id = 0x0, name = "dpdk-testpmd" }, { ptr = 0x101A96280 } [17:45:12.631202316] (+0.000001258) lib.eal.memzone.free: { cpu_id = 0x0, name = "dpdk-testpmd" }, { name = "RG_MP_mb_pool_0", addr = 0x101A96280, rc = 0 }
[17:45:12.631203186] (+0.000000870) lib.eal.mem.free: { cpu_id = 0x0, name = "dpdk-testpmd" }, { ptr = 0x101A9E480 } [17:45:12.631203338] (+0.000000152) lib.eal.mem.free: { cpu_id = 0x0, name = "dpdk-testpmd" }, { ptr = 0x101A9E540 } [17:45:12.631263318] (+0.000059980) lib.eal.memzone.free: { cpu_id = 0x0, name = "dpdk-testpmd" }, { name = "MP_mb_pool_0", addr = 0x101A9E540, rc = 0 }
[17:45:12.631525049] (+0.000261731) lib.eal.mem.free: { cpu_id = 0x0, name = "dpdk-testpmd" }, { ptr = 0x1026ABE80 } [17:45:12.631525323] (+0.000000274) lib.eal.mem.free: { cpu_id = 0x0, name = "dpdk-testpmd" }, { ptr = 0x102687E00 }
Quoted 5 lines
This happened because "
already_done" was set afterrte_trace_save()called via telemetry. Laterrte_eal_cleanupreturned from this point without saving later traces.What is the purpose of
already_doneflag?
already_done is used to create the trace directory once, and log a message with this directory path once.
Signature · 1 line
David Marchand
RE: [EXT] [PATCH v3 5/9] trace: fix dynamically enabling trace points
Quoted 35 lines
-----Original Message-----
From: David Marchand <[email protected]>
Sent: Thursday, October 13, 2022 9:22 PM
To: Harman Kalra <[email protected]>
Cc: [email protected]; Jerin Jacob Kollanukkaran <[email protected]>; Sunil Kumar Kori <[email protected]>; [email protected]
Subject: Re: [EXT] [PATCH v3 5/9] trace: fix dynamically enabling trace pointsQuoted 24 lines · Harman Kalra
Quoted 5 lines
lib/eal/common/eal_common_trace_utils.c +1
-1-int +static int trace_mkdir (void )lib/eal/common/eal_common_trace_utils.c trace_dir_default_path_get(char *dir_path) · line 328
Quoted 10 lines
lib/eal/common/eal_common_trace_utils.c +4
-0{struct trace *trace =trace_obj_get ();char session[TRACE_DIR_STR_LEN ]; +static bool already_done;char *dir_path;int rc; +if (already_done) +return 0 ; +Hi David
I was trying out "trace: take live traces via telemetry" patch I came across following scenario
- Started testpmd with trace=.*
- Executed /trace/save from telemetry script, trace file saved successfully
- Later after stopping application,rte_eal_cleanup()did not save the trace.
Quoted 4 lines
Quoted 1 line
With this we lost traces after /trace/save executed
Sorry, I must be missing something.
What patches did you apply and how are you testing?
I applied the whole trace fixes series and then tested live traces
Quoted 5 lines
With the whole traces fixes series applied first, then the new "trace:
take live traces via telemetry" patch applied, I can't reproduce your issue.
Yes, you replicated the same scenario what I tried.
Sorry, I realized that actually it's not an issue, traces generated after /trace/save are getting appended but in the same file (timestamped on /trace/save) on rte_eal_cleanup().
I assumed that trace dir generated with a timestamp will include all the trace points emitted before that timestamp. But in the above scenario same trace dir includes trace points emitted after this timestamp. I think this is bit confusing. Shall we add a logic where if already_done is set, rename the original trace dir to latest timestamp?
Thanks
Harman
Quoted 14 lines
Quoted 3 lines
This happened because "
already_done" was set afterrte_trace_save()called via telemetry.
Quoted 3 lines
Later
rte_eal_cleanupreturned from this point without saving later traces.What is the purpose of
already_doneflag?
already_doneis used to create the trace directory once, and log a message with this directory path once.--
David Marchand
Re: [EXT] [PATCH v3 5/9] trace: fix dynamically enabling trace points
Quoted 6 lines · Harman Kalra
Quoted 5 lines
With the whole traces fixes series applied first, then the new "trace:
take live traces via telemetry" patch applied, I can't reproduce your issue.
Quoted 8 lines
Yes, you replicated the same scenario what I tried.
Sorry, I realized that actually it's not an issue, traces generated after /trace/save are getting appended but in the same file (timestamped on /trace/save) onrte_eal_cleanup().I assumed that trace dir generated with a timestamp will include all the trace points emitted before that timestamp. But in the above scenario same trace dir includes trace points emitted after this timestamp. I think this is bit confusing. Shall we add a logic where if
already_doneis set, rename the original trace dir to latest timestamp?
Afaiu, the behavior before this series was the same.
An application calling rte_trace_save() would always save to a single directory. One thing that changed though is that the directory is timestamped with the time of the first call to rte_trace_save.
Before the seriesn the timestamp was based on the time when the trace subsystem was initialised.
We can go with what you describe (which makes sense to me). But I'd like to get a ack from traces maintainers before looking into it.
Signature · 1 line
David Marchand
Re: [EXT] [PATCH v3 5/9] trace: fix dynamically enabling trace points
Quoted 25 lines · David Marchand
Quoted 6 lines · Harman Kalra
Quoted 5 lines
With the whole traces fixes series applied first, then the new "trace:
take live traces via telemetry" patch applied, I can't reproduce your issue.Quoted 8 lines
Yes, you replicated the same scenario what I tried.
Sorry, I realized that actually it's not an issue, traces generated after /trace/save are getting appended but in the same file (timestamped on /trace/save) onrte_eal_cleanup().I assumed that trace dir generated with a timestamp will include all the trace points emitted before that timestamp. But in the above scenario same trace dir includes trace points emitted after this timestamp. I think this is bit confusing. Shall we add a logic where if
already_doneis set, rename the original trace dir to latest timestamp?Afaiu, the behavior before this series was the same.
An application callingrte_trace_save()would always save to a single directory. One thing that changed though is that the directory is timestamped with the time of the first call torte_trace_save.
Before the seriesn the timestamp was based on the time when the trace subsystem was initialised.
Quoted 2 lines
We can go with what you describe (which makes sense to me). But I'd like to get a ack from traces maintainers before looking into it.
IMO, We can remove "already_done" logic, whenever, rte_trace_save() called, it creates
the directory of that timestamp and copies the trace buffers. Since we have "overwrite" and "discard"
modes, it is better to not add "already_done" dogic in rte_trace_save().
Quoted 5 lines
--
David Marchand
Re: [EXT] [PATCH v3 5/9] trace: fix dynamically enabling trace points
Quoted 28 lines · Jerin Jacob
Quoted 25 lines · David Marchand
Quoted 6 lines · Harman Kalra
Quoted 5 lines
With the whole traces fixes series applied first, then the new "trace:
take live traces via telemetry" patch applied, I can't reproduce your issue.Quoted 8 lines
Yes, you replicated the same scenario what I tried.
Sorry, I realized that actually it's not an issue, traces generated after /trace/save are getting appended but in the same file (timestamped on /trace/save) onrte_eal_cleanup().I assumed that trace dir generated with a timestamp will include all the trace points emitted before that timestamp. But in the above scenario same trace dir includes trace points emitted after this timestamp. I think this is bit confusing. Shall we add a logic where if
already_doneis set, rename the original trace dir to latest timestamp?Afaiu, the behavior before this series was the same.
An application callingrte_trace_save()would always save to a single directory. One thing that changed though is that the directory is timestamped with the time of the first call torte_trace_save.
Before the seriesn the timestamp was based on the time when the trace subsystem was initialised.
Quoted 8 lines
Quoted 2 lines
We can go with what you describe (which makes sense to me). But I'd like to get a ack from traces maintainers before looking into it.
IMO, We can remove "
already_done" logic, whenever,rte_trace_save()called, it creates
the directory of that timestamp and copies the trace buffers. Since we have "overwrite" and "discard"
modes, it is better to not add "already_done" dogic inrte_trace_save().
Well, it's a bit more difficult than just removing already_done.
Before my changes, the timestamp was decided and the directory created once and for all at init.
On the other hand, every trace_mkdir() call resulted in a trace_dir_update() call.
--> /trace/save
{"/trace/save": {"Status": "OK", "Path":
"/home/dmarchan/dpdk-traces/rte-2022-10-14-AM-08-39-37"}}
--> /trace/save
{"/trace/save": {"Status": "OK", "Path":
"/home/dmarchan/dpdk-traces/rte-2022-10-14-AM-08-39-37rte-2022-10-14-AM-08-39-38"}}
I prototyped a change (which deserves a separate patch). Testing it, there is still one corner case when calling rte_trace_save() twice in the same minute:
--> /trace/save
{"/trace/save": {"Status": "OK", "Path":
"/home/dmarchan/dpdk-traces/rte-2022-10-14-AM-10-11-19"}} --> /trace/save
{"/trace/save": {"Status": "KO", "Path":
"/home/dmarchan/dpdk-traces/rte-2022-10-14-AM-10-11-19"}}
EAL: Trace dir: /home/dmarchan/dpdk-traces/rte-2022-10-14-AM-10-11-19
EAL: trace_mkdir():321 mkdir /home/dmarchan/dpdk-traces/rte-2022-10-14-AM-10-11-19 failed [File exists]
What do you suggest for this?
Signature · 1 line
David Marchand
Re: [EXT] [PATCH v3 5/9] trace: fix dynamically enabling trace points
Quoted 62 lines · David Marchand
Quoted 28 lines · Jerin Jacob
Quoted 25 lines · David Marchand
Quoted 6 lines · Harman Kalra
Quoted 5 lines
With the whole traces fixes series applied first, then the new "trace:
take live traces via telemetry" patch applied, I can't reproduce your issue.Quoted 8 lines
Yes, you replicated the same scenario what I tried.
Sorry, I realized that actually it's not an issue, traces generated after /trace/save are getting appended but in the same file (timestamped on /trace/save) onrte_eal_cleanup().I assumed that trace dir generated with a timestamp will include all the trace points emitted before that timestamp. But in the above scenario same trace dir includes trace points emitted after this timestamp. I think this is bit confusing. Shall we add a logic where if
already_doneis set, rename the original trace dir to latest timestamp?Afaiu, the behavior before this series was the same.
An application callingrte_trace_save()would always save to a single directory. One thing that changed though is that the directory is timestamped with the time of the first call torte_trace_save.
Before the seriesn the timestamp was based on the time when the trace subsystem was initialised.Quoted 8 lines
Quoted 2 lines
We can go with what you describe (which makes sense to me). But I'd like to get a ack from traces maintainers before looking into it.
IMO, We can remove "
already_done" logic, whenever,rte_trace_save()called, it creates
the directory of that timestamp and copies the trace buffers. Since we have "overwrite" and "discard"
modes, it is better to not add "already_done" dogic inrte_trace_save().Well, it's a bit more difficult than just removing
already_done.Before my changes, the timestamp was decided and the directory created once and for all at init.
On the other hand, everytrace_mkdir()call resulted in atrace_dir_update()call.
--> /trace/save
{"/trace/save": {"Status": "OK", "Path":
"/home/dmarchan/dpdk-traces/rte-2022-10-14-AM-08-39-37"}}
--> /trace/save
{"/trace/save": {"Status": "OK", "Path":
"/home/dmarchan/dpdk-traces/rte-2022-10-14-AM-08-39-37rte-2022-10-14-AM-08-39-38"}}I prototyped a change (which deserves a separate patch). Testing it, there is still one corner case when calling
rte_trace_save()twice in the same minute:
--> /trace/save
{"/trace/save": {"Status": "OK", "Path":
"/home/dmarchan/dpdk-traces/rte-2022-10-14-AM-10-11-19"}} --> /trace/save
{"/trace/save": {"Status": "KO", "Path":
"/home/dmarchan/dpdk-traces/rte-2022-10-14-AM-10-11-19"}}
Quoted 6 lines
EAL: Trace dir:
/home/dmarchan/dpdk-traces/rte-2022-10-14-AM-10-11-19
EAL: trace_mkdir():321 mkdir/home/dmarchan/dpdk-traces/rte-2022-10-14-AM-10-11-19failed [File exists]What do you suggest for this?
Top of the tree has "seconds" in trace director creation[1]. That will make it unique in all practical cases.
To make future proof:
We could do either of
1)Even with the second, if a directory exists and wait for 1sec and do from trace_session_name_generate()
2)Add 2 or 3 digits in the name. Have a counter to make it unique if the directory exists.
[1]
rc = strftime(trace_dir + rc, TRACE_DIR_STR_LEN - rc,
"%Y-%m-%d-%p-%I-%M-%S", tm_result);
Quoted 5 lines
--
David Marchand
PATCH v3 6/9 trace: fix race in debug dump
In reply to David Marchandtrace->nb_trace_mem_list access must be under trace->lock to avoid races with threads allocating/freeing their trace buffers.
--- lib/eal/common/eal_common_trace.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
lib/eal/common/eal_common_trace.c +3 -3
@@ -259,10 +259,9 @@ trace_lcore_mem_dump(FILE *f)struct __rte_trace_header *header;uint32_t count; -if (trace->nb_trace_mem_list ==0 ) -return ; -rte_spinlock_lock (&trace->lock); +if (trace->nb_trace_mem_list ==0 ) + goto out;fprintf (f,"nb_trace_mem_list = %d\n" , trace->nb_trace_mem_list);fprintf (f,"\nTrace mem info\n--------------\n" );for (count =0 ; count < trace->nb_trace_mem_list; count++) {
@@ -273,6 +272,7 @@ trace_lcore_mem_dump(FILE *f) header->stream_header.lcore_id, header->stream_header.thread_name); } +out:rte_spinlock_unlock (&trace->lock); }
Signature · 1 line
2.37.3
PATCH v3 7/9 trace: fix metadata dump
In reply to David MarchandThe API does not describe that metadata dump is conditioned to enabling any trace points.
While at it, merge dump unit tests into the generic trace_autotest to enhance coverage.
--- app/test/test_trace.c | 44 +++++++++------------------ lib/eal/common/eal_common_trace_ctf.c | 3 -- 2 files changed, 15 insertions(+), 32 deletions(-)
app/test/test_trace.c +15 -29
@@ -20,20 +20,6 @@ test_trace(void)return TEST_SKIPPED ; } -static int -test_trace_dump (void ) -{ -printf ("trace_dump not supported on Windows, skipping test\n" ); -return TEST_SKIPPED ; -} - -static int -test_trace_metadata_dump (void ) -{ -printf ("trace_metadata_dump not supported on Windows, skipping test\n" ); -return TEST_SKIPPED ; -} -#else static int32_t
@@ -214,6 +200,19 @@ test_generic_trace_points(void)return TEST_SUCCESS ; } +static int +test_trace_dump (void ) +{ +rte_trace_dump (stdout); +return 0 ; +} + +static int +test_trace_metadata_dump (void ) +{ +return rte_trace_metadata_dump (stdout); +} +static struct unit_test_suite trace_tests = { .suite_name ="trace autotest" , .setup =NULL ,
@@ -226,6 +225,8 @@ static struct unit_test_suite trace_tests = {TEST_CASE (test_trace_point_globbing),TEST_CASE (test_trace_point_regex),TEST_CASE (test_trace_points_lookup), +TEST_CASE (test_trace_dump), +TEST_CASE (test_trace_metadata_dump), TEST_CASES_END() } };
@@ -236,21 +237,6 @@ test_trace(void) return unit_test_suite_runner(&trace_tests); } -static int -test_trace_dump (void ) -{ -rte_trace_dump (stdout); -return 0 ; -} - -static int -test_trace_metadata_dump (void ) -{ -return rte_trace_metadata_dump (stdout); -} -#endif /* !RTE_EXEC_ENV_WINDOWS */ REGISTER_TEST_COMMAND (trace_autotest, test_trace); -REGISTER_TEST_COMMAND (trace_dump, test_trace_dump); -REGISTER_TEST_COMMAND (trace_metadata_dump, test_trace_metadata_dump);
lib/eal/common/eal_common_trace_ctf.c +0 -3
@@ -358,9 +358,6 @@ rte_trace_metadata_dump(FILE *f)char *ctf_meta = trace->ctf_meta;int rc; -if (!rte_trace_is_enabled ()) -return 0 ; -if (ctf_meta ==NULL )return -EINVAL ;
Signature · 1 line
2.37.3
PATCH v3 8/9 trace: remove limitation on trace point name
In reply to David MarchandThe name of a trace point is provided as a constant string via the RTE_TRACE_POINT_REGISTER macro.
We can rely on an explicit constant string in the binary and simply point at it.
There is then no need for a (fixed size) copy.
---
Changes since v2:
- stored trace point name in a static variable to make sure the string is put in .data,
--- lib/eal/common/eal_common_trace.c | 10 +++------- lib/eal/common/eal_common_trace_utils.c | 2 +- lib/eal/common/eal_trace.h | 3 +-- lib/eal/include/rte_trace_point_register.h | 3 ++- 4 files changed, 7 insertions(+), 11 deletions(-)
lib/eal/common/eal_common_trace.c +3 -7
@@ -235,7 +235,7 @@ rte_trace_point_lookup(const char *name)return NULL ; STAILQ_FOREACH(tp, &tp_list, next) -if (strncmp (tp->name, name,TRACE_POINT_NAME_SIZE ) ==0 ) +if (strcmp (tp->name, name) ==0 )return tp->handle;return NULL ;
@@ -492,10 +492,7 @@ __rte_trace_point_register(rte_trace_point_t *handle, const char *name, }/* Initialize the trace point */ -if (rte_strscpy (tp->name, name,TRACE_POINT_NAME_SIZE ) <0 ) { -trace_err ("name is too long" ); - goto free; - } + tp->name = name;/* Copy the accumulated fields description and clear it for the next * trace point.
@@ -517,8 +514,7 @@ __rte_trace_point_register(rte_trace_point_t *handle, const char *name,/* All Good !!! */ return 0 ; -free: -free (tp); + fail:if (trace.register_errno ==0 ) trace.register_errno = rte_errno;
lib/eal/common/eal_common_trace_utils.c +1 -1
@@ -42,7 +42,7 @@ trace_entry_compare(const char *name)int count =0 ; STAILQ_FOREACH(tp, tp_list, next) { -if (strncmp (tp->name, name,TRACE_POINT_NAME_SIZE ) ==0 ) +if (strcmp (tp->name, name) ==0 ) count++;if (count >1 ) {trace_err ("found duplicate entry %s" , name);
lib/eal/common/eal_trace.h +1 -2
@@ -24,14 +24,13 @@#define TRACE_PREFIX_LEN 12#define TRACE_DIR_STR_LEN (sizeof("YYYY-mm-dd-AM-HH-MM-SS") + TRACE_PREFIX_LEN) -#define TRACE_POINT_NAME_SIZE 64#define TRACE_CTF_MAGIC 0xC1FC1FC1#define TRACE_MAX_ARGS 32struct trace_point {STAILQ_ENTRY (trace_point) next;rte_trace_point_t *handle; -char name[TRACE_POINT_NAME_SIZE ]; +const char *name;char *ctf_field; };
lib/eal/include/rte_trace_point_register.h +2 -1
@@ -20,9 +20,10 @@ RTE_DECLARE_PER_LCORE(volatile int, trace_point_sz);#define RTE_TRACE_POINT_REGISTER (trace, name) \ rte_trace_point_t __attribute__((section("__rte_trace_point"))) __##trace; \ +static const char __##trace##_name[] = RTE_STR(name); \ RTE_INIT(trace##_init) \ { \ - __rte_trace_point_register(&__##trace, RTE_STR(name), \ + __rte_trace_point_register(&__##trace, __##trace##_name, \ (void (*)(void)) trace); \ }
Signature · 1 line
2.37.3
PATCH v3 9/9 trace: remove limitation on directory
In reply to David MarchandRemove arbitrary limit on 12 characters of the file prefix used for the directory where to store the traces.
Simplify the code by relying on dynamic allocations.
--- lib/eal/common/eal_common_trace_utils.c | 68 +++++++++---------------- lib/eal/common/eal_trace.h | 5 +- 2 files changed, 25 insertions(+), 48 deletions(-)
lib/eal/common/eal_common_trace_utils.c +24 -44
@@ -87,11 +87,11 @@ trace_uuid_generate(void) }static int -trace_session_name_generate (char *trace_dir) +trace_session_name_generate (char **trace_dir) { +char date[sizeof ("YYYY-mm-dd-AM-HH-MM-SS" )];struct tm *tm_result;time_t tm; -int rc; tm =time (NULL );if ((int )tm ==-1 )
@@ -101,38 +101,32 @@ trace_session_name_generate(char *trace_dir)if (tm_result ==NULL ) goto fail; - rc =rte_strscpy (trace_dir,eal_get_hugefile_prefix (), -TRACE_PREFIX_LEN ); -if (rc == -E2BIG ) - rc =TRACE_PREFIX_LEN -1 ; - trace_dir[rc++] ='-' ; - - rc =strftime (trace_dir + rc,TRACE_DIR_STR_LEN - rc, -"%Y-%m-%d-%p-%I-%M-%S" , tm_result); -if (rc ==0 ) { +if (strftime (date,sizeof (date),"%Y-%m-%d-%p-%I-%M-%S" , tm_result) ==0 ) { errno =ENOSPC ; goto fail; } -return rc; +if (asprintf (trace_dir,"%s-%s" ,eal_get_hugefile_prefix (), date) ==-1 ) + goto fail; + +return 0 ; fail: rte_errno = errno; -return -rte_errno; +return -1 ; }static int trace_dir_update (const char *str) {struct trace *trace =trace_obj_get (); -int rc, remaining; - - remaining =sizeof (trace->dir) - trace->dir_offset; - rc =rte_strscpy (&trace->dir[0 ] + trace->dir_offset, str, remaining); -if (rc <0 ) - goto fail; +char *dir; +int rc; - trace->dir_offset += rc; -fail: + rc =asprintf (&dir,"%s%s" , trace->dir !=NULL ? trace->dir :"" , str); +if (rc !=-1 ) { +free (trace->dir); + trace->dir = dir; + }return rc; }
@@ -246,22 +240,15 @@ eal_trace_mode_args_save(const char *val)int eal_trace_dir_args_save (char const *val) { -struct trace *trace =trace_obj_get ();char *dir_path;int rc; -if (strlen (val) >=sizeof (trace->dir) -1 ) { -trace_err ("input string is too big" ); -return -ENAMETOOLONG ; - } -if (asprintf (&dir_path,"%s/" , val) ==-1 ) {trace_err ("failed to copy directory: %s" ,strerror (errno));return -ENOMEM ; } rc =trace_dir_update (dir_path); -free (dir_path);return rc; }
@@ -289,10 +276,8 @@ trace_epoch_time_save(void) }static int -trace_dir_default_path_get (char *dir_path) +trace_dir_default_path_get (char **dir_path) { -struct trace *trace =trace_obj_get (); -uint32_t size =sizeof (trace->dir);struct passwd *pwd;char *home_dir;
@@ -308,8 +293,8 @@ trace_dir_default_path_get(char *dir_path) }/* Append dpdk-traces to directory */ -if (snprintf (dir_path, size,"%s/dpdk-traces/" , home_dir) <0 ) -return -ENAMETOOLONG ; +if (asprintf (dir_path,"%s/dpdk-traces/" , home_dir) ==-1 ) +return -ENOMEM ;return 0 ; }
@@ -318,25 +303,19 @@ static inttrace_mkdir (void) {struct trace *trace =trace_obj_get (); -char session[TRACE_DIR_STR_LEN ];static bool already_done; -char *dir_path; +char *session;int rc;if (already_done)return 0 ; -if (!trace->dir_offset) { - dir_path =calloc (1 ,sizeof (trace->dir)); -if (dir_path ==NULL ) { -trace_err ("fail to allocate memory" ); -return -ENOMEM ; - } +if (trace->dir ==NULL ) { +char *dir_path; - rc =trace_dir_default_path_get (dir_path); + rc =trace_dir_default_path_get (&dir_path);if (rc <0 ) {trace_err ("fail to get default path" ); -free (dir_path);return rc; }
@@ -354,10 +333,11 @@ trace_mkdir(void)return -rte_errno; } - rc =trace_session_name_generate (session); + rc =trace_session_name_generate (&session);if (rc <0 )return rc; rc =trace_dir_update (session); +free (session);if (rc <0 )return rc;
lib/eal/common/eal_trace.h +1 -4
@@ -22,8 +22,6 @@ #define trace_crit(fmt, args...) \ RTE_LOG(CRIT, EAL, "%s():%u " fmt "\n", __func__, __LINE__, ## args) -#define TRACE_PREFIX_LEN 12 -#define TRACE_DIR_STR_LEN (sizeof("YYYY-mm-dd-AM-HH-MM-SS") + TRACE_PREFIX_LEN)#define TRACE_CTF_MAGIC 0xC1FC1FC1#define TRACE_MAX_ARGS 32
@@ -50,8 +48,7 @@ struct trace_arg { };struct trace { -char dir[PATH_MAX ]; -int dir_offset; +char *dir;int register_errno;uint32_t status;enum rte_trace_mode mode;
Signature · 1 line
2.37.3
v4 cover Trace subsystem fixes and more
In reply to David MarchandHello,
This series addresses a number of issues and limitations I have identified over time in the trace subsystem.
The main issue was with dynamically enabling trace points which was not working if no trace point had been enabled at rte_eal_init() time.
This is 22.11 material.
We may start thinking about marking this API stable, but this is another topic.
Signature · 40 lines
David Marchand Changes since v3: - added one more change for creating new trace directory on call to rte_trace_save(), - added the telemetry commands patch in the series, Changes since v2: - fixed trace point name storage, Changes since v1: - split patch 3, - addressed comments on (previously) patch 4, David Marchand (11): trace: fix mode for new trace point trace: fix mode change trace: fix leak with regexp trace: rework loop on trace points trace: fix dynamically enabling trace points trace: fix race in debug dump trace: fix metadata dump trace: remove limitation on trace point name trace: remove limitation on directory trace: create new directory for each trace dump trace: enable trace operations via telemetry app/test/test_trace.c | 67 +++---- app/test/test_trace.h | 2 + doc/guides/prog_guide/trace_lib.rst | 53 +++++- lib/eal/common/eal_common_trace.c | 192 ++++++++++++++------- lib/eal/common/eal_common_trace_ctf.c | 3 - lib/eal/common/eal_common_trace_utils.c | 132 ++++++-------- lib/eal/common/eal_trace.h | 13 +- lib/eal/include/rte_trace_point_register.h | 3 +- lib/telemetry/telemetry_data.c | 1 + 9 files changed, 279 insertions(+), 187 deletions(-) -- 2.37.3
PATCH v4 1/11 trace: fix mode for new trace point
If an application registers trace points later than rte_eal_init(), changes in the trace point mode were not applied.
--- lib/eal/common/eal_common_trace.c | 1 + 1 file changed, 1 insertion(+)
lib/eal/common/eal_common_trace.c +1 -0
@@ -512,6 +512,7 @@ __rte_trace_point_register(rte_trace_point_t *handle, const char *name,/* Form the trace handle */ *handle = sz; *handle |= trace.nb_trace_points << __RTE_TRACE_FIELD_ID_SHIFT; +trace_mode_set (handle, trace.mode); trace.nb_trace_points++; tp->handle = handle;
Signature · 1 line
2.37.3
PATCH v4 2/11 trace: fix mode change
In reply to David MarchandThe API does not state that changing mode should be refused if no trace point is enabled. Remove this limitation.
--- app/test/test_trace.c | 3 --- lib/eal/common/eal_common_trace.c | 3 --- 2 files changed, 6 deletions(-)
app/test/test_trace.c +0 -3
@@ -126,9 +126,6 @@ test_trace_mode(void) current =rte_trace_mode_get (); -if (!rte_trace_is_enabled ()) -return TEST_SKIPPED ; -rte_trace_mode_set (RTE_TRACE_MODE_DISCARD );if (rte_trace_mode_get () !=RTE_TRACE_MODE_DISCARD ) goto failed;
lib/eal/common/eal_common_trace.c +0 -3
@@ -127,9 +127,6 @@ rte_trace_mode_set(enum rte_trace_mode mode) {struct trace_point *tp; -if (!rte_trace_is_enabled ()) -return ; - STAILQ_FOREACH(tp, &tp_list, next)trace_mode_set (tp->handle, mode);
Signature · 1 line
2.37.3
PATCH v4 3/11 trace: fix leak with regexp
In reply to David MarchandThe precompiled buffer initialised in regcomp must be freed before leaving rte_trace_regexp.
---
Changes since v1:
- split patch in two, keeping only the backportable fix as patch 3,
--- lib/eal/common/eal_common_trace.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
lib/eal/common/eal_common_trace.c +4 -2
@@ -218,8 +218,10 @@ rte_trace_regexp(const char *regex, bool enable) rc =rte_trace_point_disable (tp->handle); found =1 ; } -if (rc <0 ) -return rc; +if (rc <0 ) { + found =0 ; +break ; + } }regfree (&r);
Signature · 1 line
2.37.3
PATCH v4 4/11 trace: rework loop on trace points
In reply to David MarchandDirectly skip the block when a trace point does not match the user criteria.
--- lib/eal/common/eal_common_trace.c | 34 +++++++++++++++++-------------- 1 file changed, 19 insertions(+), 15 deletions(-)
lib/eal/common/eal_common_trace.c +19 -15
@@ -186,15 +186,18 @@ rte_trace_pattern(const char *pattern, bool enable)int rc =0 , found =0 ; STAILQ_FOREACH(tp, &tp_list, next) { -if (fnmatch (pattern, tp->name,0 ) ==0 ) { -if (enable) - rc =rte_trace_point_enable (tp->handle); -else - rc =rte_trace_point_disable (tp->handle); - found =1 ; +if (fnmatch (pattern, tp->name,0 ) !=0 ) +continue ; + +if (enable) + rc =rte_trace_point_enable (tp->handle); +else + rc =rte_trace_point_disable (tp->handle); +if (rc <0 ) { + found =0 ; +break ; } -if (rc <0 ) -return rc; + found =1 ; }return rc | found;
@@ -211,17 +214,18 @@ rte_trace_regexp(const char *regex, bool enable)return -EINVAL ; STAILQ_FOREACH(tp, &tp_list, next) { -if (regexec (&r, tp->name,0 ,NULL ,0 ) ==0 ) { -if (enable) - rc =rte_trace_point_enable (tp->handle); -else - rc =rte_trace_point_disable (tp->handle); - found =1 ; - } +if (regexec (&r, tp->name,0 ,NULL ,0 ) !=0 ) +continue ; + +if (enable) + rc =rte_trace_point_enable (tp->handle); +else + rc =rte_trace_point_disable (tp->handle);if (rc <0 ) { found =0 ;break ; } + found =1 ; }regfree (&r);
Signature · 1 line
2.37.3
PATCH v4 5/11 trace: fix dynamically enabling trace points
In reply to David MarchandEnabling trace points at runtime was not working if no trace point had been enabled first at rte_eal_init() time. The reason was that trace.args reflected the arguments passed to --trace= EAL option.
To fix this:
- the trace subsystem initialisation is updated: trace directory creation is deferred to when traces are dumped (to avoid creating directories that may not be used),
- per lcore memory allocation still relies on rte_trace_is_enabled() but this helper now tracks if any trace point is enabled. The documentation is updated accordingly,
- cleanup helpers must always be called in rte_eal_cleanup() since some trace points might have been enabled and disabled in the lifetime of the DPDK application,
With this fix, we can update the unit test and check that a trace point callback is invoked when expected.
Note:
- the 'trace' global variable might be shadowed with the argument passed to the functions dealing with trace point handles. 'tp' has been used for referring to trace_point object. Prefer 't' for referring to handles,
---
Changes since v1:
- restored level to INFO for trace directory log message,
- moved trace_mkdir() to rte_trace_save,
--- app/test/test_trace.c | 20 ++++++++++ app/test/test_trace.h | 2 + doc/guides/prog_guide/trace_lib.rst | 14 +++++-- lib/eal/common/eal_common_trace.c | 53 ++++++++++--------------- lib/eal/common/eal_common_trace_utils.c | 11 ++++- lib/eal/common/eal_trace.h | 3 +- 6 files changed, 65 insertions(+), 38 deletions(-)
app/test/test_trace.c +20 -0
@@ -9,6 +9,8 @@#include "test.h" #include "test_trace.h" +int app_dpdk_test_tp_count; +#ifdef RTE_EXEC_ENV_WINDOWS static int
@@ -95,8 +97,15 @@ test_trace_point_regex(void)static int32_t test_trace_point_disable_enable (void ) { +int expected;int rc; +/* At tp registration, the associated counter increases once. */ + expected =1 ; +TEST_ASSERT_EQUAL (app_dpdk_test_tp_count, expected, +"Expecting %d, but got %d for app_dpdk_test_tp_count" , + expected, app_dpdk_test_tp_count); + rc =rte_trace_point_disable (&__app_dpdk_test_tp);if (rc <0 ) goto failed;
@@ -104,6 +113,12 @@ test_trace_point_disable_enable(void)if (rte_trace_point_is_enabled (&__app_dpdk_test_tp)) goto failed; +/* No emission expected */ +app_dpdk_test_tp ("app.dpdk.test.tp" ); +TEST_ASSERT_EQUAL (app_dpdk_test_tp_count, expected, +"Expecting %d, but got %d for app_dpdk_test_tp_count" , + expected, app_dpdk_test_tp_count); + rc =rte_trace_point_enable (&__app_dpdk_test_tp);if (rc <0 ) goto failed;
@@ -113,6 +128,11 @@ test_trace_point_disable_enable(void)/* Emit the trace */ app_dpdk_test_tp ("app.dpdk.test.tp" ); + expected++; +TEST_ASSERT_EQUAL (app_dpdk_test_tp_count, expected, +"Expecting %d, but got %d for app_dpdk_test_tp_count" , + expected, app_dpdk_test_tp_count); +return TEST_SUCCESS ; failed:
app/test/test_trace.h +2 -0
@@ -3,10 +3,12 @@*/ #include <rte_trace_point.h> +extern int app_dpdk_test_tp_count;RTE_TRACE_POINT ( app_dpdk_test_tp, RTE_TRACE_POINT_ARGS(const char *str), rte_trace_point_emit_string(str); + app_dpdk_test_tp_count++; ) RTE_TRACE_POINT_FP(
doc/guides/prog_guide/trace_lib.rst +10 -4
@@ -271,10 +271,16 @@ Trace memory The trace memory will be allocated through an internal function ``__rte_trace_mem_per_thread_alloc()``. The trace memory will be allocated per thread to enable lock less trace-emit function. -The memory for the trace memory for DPDK lcores will be allocated on -``rte_eal_init()`` if the trace is enabled through a EAL option. -For non DPDK threads, on the first trace emission, the memory will be -allocated. + +For non lcore threads, the trace memory is allocated on the first trace +emission. + +For lcore threads, if trace points are enabled through a EAL option, the trace +memory is allocated when the threads are known of DPDK +(``rte_eal_init`` for EAL lcores, ``rte_thread_register`` for non-EAL lcores). +Otherwise, when trace points are enabled later in the life of the application, +the behavior is the same as non lcore threads and the trace memory is allocated +on the first trace emission. Trace memory layout ~~~~~~~~~~~~~~~~~~~
lib/eal/common/eal_common_trace.c +22 -31
117 lines not on this page · raw message
lib/eal/common/eal_common_trace_utils.c +10 -1
@@ -314,14 +314,18 @@ trace_dir_default_path_get(char *dir_path)return 0 ; } -int +static int trace_mkdir (void ) {struct trace *trace =trace_obj_get ();char session[TRACE_DIR_STR_LEN ]; +static bool already_done;char *dir_path;int rc; +if (already_done) +return 0 ; +if (!trace->dir_offset) { dir_path =calloc (1 ,sizeof (trace->dir));if (dir_path ==NULL ) {
@@ -365,6 +369,7 @@ trace_mkdir(void) }RTE_LOG (INFO ,EAL ,"Trace dir: %s\n" , trace->dir); + already_done = true;return 0 ; }
@@ -434,6 +439,10 @@ rte_trace_save(void)if (trace->nb_trace_mem_list ==0 )return rc; + rc =trace_mkdir (); +if (rc <0 ) +return rc; + rc =trace_meta_save (trace);if (rc)return rc;
lib/eal/common/eal_trace.h +1 -2
@@ -54,7 +54,7 @@ struct trace {char dir[PATH_MAX ];int dir_offset;int register_errno; -bool status; +uint32_t status;enum rte_trace_mode mode;rte_uuid_t uuid;uint32_t buff_len;
@@ -104,7 +104,6 @@ void trace_uuid_generate(void);int trace_metadata_create (void );void trace_metadata_destroy (void );char *trace_metadata_fixup_field (const char *field); -int trace_mkdir (void );int trace_epoch_time_save (void );void trace_mem_free (void );void trace_mem_per_thread_free (void );
Signature · 1 line
2.37.3
PATCH v4 6/11 trace: fix race in debug dump
In reply to David Marchandtrace->nb_trace_mem_list access must be under trace->lock to avoid races with threads allocating/freeing their trace buffers.
--- lib/eal/common/eal_common_trace.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
lib/eal/common/eal_common_trace.c +3 -3
@@ -259,10 +259,9 @@ trace_lcore_mem_dump(FILE *f)struct __rte_trace_header *header;uint32_t count; -if (trace->nb_trace_mem_list ==0 ) -return ; -rte_spinlock_lock (&trace->lock); +if (trace->nb_trace_mem_list ==0 ) + goto out;fprintf (f,"nb_trace_mem_list = %d\n" , trace->nb_trace_mem_list);fprintf (f,"\nTrace mem info\n--------------\n" );for (count =0 ; count < trace->nb_trace_mem_list; count++) {
@@ -273,6 +272,7 @@ trace_lcore_mem_dump(FILE *f) header->stream_header.lcore_id, header->stream_header.thread_name); } +out:rte_spinlock_unlock (&trace->lock); }
Signature · 1 line
2.37.3
PATCH v4 7/11 trace: fix metadata dump
In reply to David MarchandThe API does not describe that metadata dump is conditioned to enabling any trace points.
While at it, merge dump unit tests into the generic trace_autotest to enhance coverage.
--- app/test/test_trace.c | 44 +++++++++------------------ lib/eal/common/eal_common_trace_ctf.c | 3 -- 2 files changed, 15 insertions(+), 32 deletions(-)
app/test/test_trace.c +15 -29
@@ -20,20 +20,6 @@ test_trace(void)return TEST_SKIPPED ; } -static int -test_trace_dump (void ) -{ -printf ("trace_dump not supported on Windows, skipping test\n" ); -return TEST_SKIPPED ; -} - -static int -test_trace_metadata_dump (void ) -{ -printf ("trace_metadata_dump not supported on Windows, skipping test\n" ); -return TEST_SKIPPED ; -} -#else static int32_t
@@ -214,6 +200,19 @@ test_generic_trace_points(void)return TEST_SUCCESS ; } +static int +test_trace_dump (void ) +{ +rte_trace_dump (stdout); +return 0 ; +} + +static int +test_trace_metadata_dump (void ) +{ +return rte_trace_metadata_dump (stdout); +} +static struct unit_test_suite trace_tests = { .suite_name ="trace autotest" , .setup =NULL ,
@@ -226,6 +225,8 @@ static struct unit_test_suite trace_tests = {TEST_CASE (test_trace_point_globbing),TEST_CASE (test_trace_point_regex),TEST_CASE (test_trace_points_lookup), +TEST_CASE (test_trace_dump), +TEST_CASE (test_trace_metadata_dump), TEST_CASES_END() } };
@@ -236,21 +237,6 @@ test_trace(void) return unit_test_suite_runner(&trace_tests); } -static int -test_trace_dump (void ) -{ -rte_trace_dump (stdout); -return 0 ; -} - -static int -test_trace_metadata_dump (void ) -{ -return rte_trace_metadata_dump (stdout); -} -#endif /* !RTE_EXEC_ENV_WINDOWS */ REGISTER_TEST_COMMAND (trace_autotest, test_trace); -REGISTER_TEST_COMMAND (trace_dump, test_trace_dump); -REGISTER_TEST_COMMAND (trace_metadata_dump, test_trace_metadata_dump);
lib/eal/common/eal_common_trace_ctf.c +0 -3
@@ -358,9 +358,6 @@ rte_trace_metadata_dump(FILE *f)char *ctf_meta = trace->ctf_meta;int rc; -if (!rte_trace_is_enabled ()) -return 0 ; -if (ctf_meta ==NULL )return -EINVAL ;
Signature · 1 line
2.37.3
PATCH v4 8/11 trace: remove limitation on trace point name
In reply to David MarchandThe name of a trace point is provided as a constant string via the RTE_TRACE_POINT_REGISTER macro.
We can rely on an explicit constant string in the binary and simply point at it.
There is then no need for a (fixed size) copy.
---
Changes since v2:
- stored trace point name in a static variable to make sure the string is put in .data,
--- lib/eal/common/eal_common_trace.c | 10 +++------- lib/eal/common/eal_common_trace_utils.c | 2 +- lib/eal/common/eal_trace.h | 3 +-- lib/eal/include/rte_trace_point_register.h | 3 ++- 4 files changed, 7 insertions(+), 11 deletions(-)
lib/eal/common/eal_common_trace.c +3 -7
@@ -235,7 +235,7 @@ rte_trace_point_lookup(const char *name)return NULL ; STAILQ_FOREACH(tp, &tp_list, next) -if (strncmp (tp->name, name,TRACE_POINT_NAME_SIZE ) ==0 ) +if (strcmp (tp->name, name) ==0 )return tp->handle;return NULL ;
@@ -492,10 +492,7 @@ __rte_trace_point_register(rte_trace_point_t *handle, const char *name, }/* Initialize the trace point */ -if (rte_strscpy (tp->name, name,TRACE_POINT_NAME_SIZE ) <0 ) { -trace_err ("name is too long" ); - goto free; - } + tp->name = name;/* Copy the accumulated fields description and clear it for the next * trace point.
@@ -517,8 +514,7 @@ __rte_trace_point_register(rte_trace_point_t *handle, const char *name,/* All Good !!! */ return 0 ; -free: -free (tp); + fail:if (trace.register_errno ==0 ) trace.register_errno = rte_errno;
lib/eal/common/eal_common_trace_utils.c +1 -1
@@ -42,7 +42,7 @@ trace_entry_compare(const char *name)int count =0 ; STAILQ_FOREACH(tp, tp_list, next) { -if (strncmp (tp->name, name,TRACE_POINT_NAME_SIZE ) ==0 ) +if (strcmp (tp->name, name) ==0 ) count++;if (count >1 ) {trace_err ("found duplicate entry %s" , name);
lib/eal/common/eal_trace.h +1 -2
@@ -24,14 +24,13 @@#define TRACE_PREFIX_LEN 12#define TRACE_DIR_STR_LEN (sizeof("YYYY-mm-dd-AM-HH-MM-SS") + TRACE_PREFIX_LEN) -#define TRACE_POINT_NAME_SIZE 64#define TRACE_CTF_MAGIC 0xC1FC1FC1#define TRACE_MAX_ARGS 32struct trace_point {STAILQ_ENTRY (trace_point) next;rte_trace_point_t *handle; -char name[TRACE_POINT_NAME_SIZE ]; +const char *name;char *ctf_field; };
lib/eal/include/rte_trace_point_register.h +2 -1
@@ -20,9 +20,10 @@ RTE_DECLARE_PER_LCORE(volatile int, trace_point_sz);#define RTE_TRACE_POINT_REGISTER (trace, name) \ rte_trace_point_t __attribute__((section("__rte_trace_point"))) __##trace; \ +static const char __##trace##_name[] = RTE_STR(name); \ RTE_INIT(trace##_init) \ { \ - __rte_trace_point_register(&__##trace, RTE_STR(name), \ + __rte_trace_point_register(&__##trace, __##trace##_name, \ (void (*)(void)) trace); \ }
Signature · 1 line
2.37.3
Re: [PATCH v4 08/11] trace: remove limitation on trace point name
Quoted 8 lines · David Marchand
The name of a trace point is provided as a constant string via the
RTE_TRACE_POINT_REGISTERmacro.
We can rely on an explicit constant string in the binary and simply point at it.
There is then no need for a (fixed size) copy.Signed-off-by David Marchand <[email protected]>
Quoted 99 lines
---
Changes since v2:
- stored trace point name in a static variable to make sure the string is put in .data,--- lib/eal/common/eal_common_trace.c | 10 +++------- lib/eal/common/eal_common_trace_utils.c | 2 +- lib/eal/common/eal_trace.h | 3 +-- lib/eal/include/rte_trace_point_register.h | 3 ++- 4 files changed, 7 insertions(+), 11 deletions(-)lib/eal/common/eal_common_trace.c +3
-7@@ -235,7 +235,7 @@ rte_trace_point_lookup(const char *name)return NULL ; STAILQ_FOREACH(tp, &tp_list, next) -if (strncmp (tp->name, name,TRACE_POINT_NAME_SIZE ) ==0 ) +if (strcmp (tp->name, name) ==0 )return tp->handle;return NULL ;@@ -492,10 +492,7 @@ __rte_trace_point_register(rte_trace_point_t *handle, const char *name, }/* Initialize the trace point */ -if (rte_strscpy (tp->name, name,TRACE_POINT_NAME_SIZE ) <0 ) { -trace_err ("name is too long" ); - goto free; - } + tp->name = name;/* Copy the accumulated fields description and clear it for the next * trace point. @@ -517,8 +514,7 @@ __rte_trace_point_register(rte_trace_point_t *handle, const char *name,/* All Good !!! */ return 0 ; -free: -free (tp); + fail:if (trace.register_errno ==0 ) trace.register_errno = rte_errno;lib/eal/common/eal_common_trace_utils.c +1
-1@@ -42,7 +42,7 @@ trace_entry_compare(const char *name)int count =0 ; STAILQ_FOREACH(tp, tp_list, next) { -if (strncmp (tp->name, name,TRACE_POINT_NAME_SIZE ) ==0 ) +if (strcmp (tp->name, name) ==0 ) count++;if (count >1 ) {trace_err ("found duplicate entry %s" , name);lib/eal/common/eal_trace.h +1
-2@@ -24,14 +24,13 @@#define TRACE_PREFIX_LEN 12#define TRACE_DIR_STR_LEN (sizeof("YYYY-mm-dd-AM-HH-MM-SS") + TRACE_PREFIX_LEN) -#define TRACE_POINT_NAME_SIZE 64#define TRACE_CTF_MAGIC 0xC1FC1FC1#define TRACE_MAX_ARGS 32struct trace_point {STAILQ_ENTRY (trace_point) next;rte_trace_point_t *handle; -char name[TRACE_POINT_NAME_SIZE ]; +const char *name;char *ctf_field; };lib/eal/include/rte_trace_point_register.h +2
-2@@ -20,9 +20,10 @@ RTE_DECLARE_PER_LCORE(volatile int, trace_point_sz);#define RTE_TRACE_POINT_REGISTER (trace, name) \ rte_trace_point_t __attribute__((section("__rte_trace_point"))) __##trace; \ +static const char __##trace##_name[] = RTE_STR(name); \ RTE_INIT(trace##_init) \ { \ - __rte_trace_point_register(&__##trace, RTE_STR(name), \ + __rte_trace_point_register(&__##trace, __##trace##_name, \ (void (*)(void)) trace); \ } --2.37.3
PATCH v4 9/11 trace: remove limitation on directory
In reply to David MarchandRemove arbitrary limit on 12 characters of the file prefix used for the directory where to store the traces.
Simplify the code by relying on dynamic allocations.
--- lib/eal/common/eal_common_trace_utils.c | 68 +++++++++---------------- lib/eal/common/eal_trace.h | 5 +- 2 files changed, 25 insertions(+), 48 deletions(-)
lib/eal/common/eal_common_trace_utils.c +24 -44
@@ -87,11 +87,11 @@ trace_uuid_generate(void) }static int -trace_session_name_generate (char *trace_dir) +trace_session_name_generate (char **trace_dir) { +char date[sizeof ("YYYY-mm-dd-AM-HH-MM-SS" )];struct tm *tm_result;time_t tm; -int rc; tm =time (NULL );if ((int )tm ==-1 )
@@ -101,38 +101,32 @@ trace_session_name_generate(char *trace_dir)if (tm_result ==NULL ) goto fail; - rc =rte_strscpy (trace_dir,eal_get_hugefile_prefix (), -TRACE_PREFIX_LEN ); -if (rc == -E2BIG ) - rc =TRACE_PREFIX_LEN -1 ; - trace_dir[rc++] ='-' ; - - rc =strftime (trace_dir + rc,TRACE_DIR_STR_LEN - rc, -"%Y-%m-%d-%p-%I-%M-%S" , tm_result); -if (rc ==0 ) { +if (strftime (date,sizeof (date),"%Y-%m-%d-%p-%I-%M-%S" , tm_result) ==0 ) { errno =ENOSPC ; goto fail; } -return rc; +if (asprintf (trace_dir,"%s-%s" ,eal_get_hugefile_prefix (), date) ==-1 ) + goto fail; + +return 0 ; fail: rte_errno = errno; -return -rte_errno; +return -1 ; }static int trace_dir_update (const char *str) {struct trace *trace =trace_obj_get (); -int rc, remaining; - - remaining =sizeof (trace->dir) - trace->dir_offset; - rc =rte_strscpy (&trace->dir[0 ] + trace->dir_offset, str, remaining); -if (rc <0 ) - goto fail; +char *dir; +int rc; - trace->dir_offset += rc; -fail: + rc =asprintf (&dir,"%s%s" , trace->dir !=NULL ? trace->dir :"" , str); +if (rc !=-1 ) { +free (trace->dir); + trace->dir = dir; + }return rc; }
@@ -246,22 +240,15 @@ eal_trace_mode_args_save(const char *val)int eal_trace_dir_args_save (char const *val) { -struct trace *trace =trace_obj_get ();char *dir_path;int rc; -if (strlen (val) >=sizeof (trace->dir) -1 ) { -trace_err ("input string is too big" ); -return -ENAMETOOLONG ; - } -if (asprintf (&dir_path,"%s/" , val) ==-1 ) {trace_err ("failed to copy directory: %s" ,strerror (errno));return -ENOMEM ; } rc =trace_dir_update (dir_path); -free (dir_path);return rc; }
@@ -289,10 +276,8 @@ trace_epoch_time_save(void) }static int -trace_dir_default_path_get (char *dir_path) +trace_dir_default_path_get (char **dir_path) { -struct trace *trace =trace_obj_get (); -uint32_t size =sizeof (trace->dir);struct passwd *pwd;char *home_dir;
@@ -308,8 +293,8 @@ trace_dir_default_path_get(char *dir_path) }/* Append dpdk-traces to directory */ -if (snprintf (dir_path, size,"%s/dpdk-traces/" , home_dir) <0 ) -return -ENAMETOOLONG ; +if (asprintf (dir_path,"%s/dpdk-traces/" , home_dir) ==-1 ) +return -ENOMEM ;return 0 ; }
@@ -318,25 +303,19 @@ static inttrace_mkdir (void) {struct trace *trace =trace_obj_get (); -char session[TRACE_DIR_STR_LEN ];static bool already_done; -char *dir_path; +char *session;int rc;if (already_done)return 0 ; -if (!trace->dir_offset) { - dir_path =calloc (1 ,sizeof (trace->dir)); -if (dir_path ==NULL ) { -trace_err ("fail to allocate memory" ); -return -ENOMEM ; - } +if (trace->dir ==NULL ) { +char *dir_path; - rc =trace_dir_default_path_get (dir_path); + rc =trace_dir_default_path_get (&dir_path);if (rc <0 ) {trace_err ("fail to get default path" ); -free (dir_path);return rc; }
@@ -354,10 +333,11 @@ trace_mkdir(void)return -rte_errno; } - rc =trace_session_name_generate (session); + rc =trace_session_name_generate (&session);if (rc <0 )return rc; rc =trace_dir_update (session); +free (session);if (rc <0 )return rc;
lib/eal/common/eal_trace.h +1 -4
@@ -22,8 +22,6 @@ #define trace_crit(fmt, args...) \ RTE_LOG(CRIT, EAL, "%s():%u " fmt "\n", __func__, __LINE__, ## args) -#define TRACE_PREFIX_LEN 12 -#define TRACE_DIR_STR_LEN (sizeof("YYYY-mm-dd-AM-HH-MM-SS") + TRACE_PREFIX_LEN)#define TRACE_CTF_MAGIC 0xC1FC1FC1#define TRACE_MAX_ARGS 32
@@ -50,8 +48,7 @@ struct trace_arg { };struct trace { -char dir[PATH_MAX ]; -int dir_offset; +char *dir;int register_errno;uint32_t status;enum rte_trace_mode mode;
Signature · 1 line
2.37.3
PATCH v4 10/11 trace: create new directory for each trace dump
In reply to David MarchandRather than always overwrite the content of the trace directory, create new directories for each call to rte_trace_save().
In the unlikely event that multiple rte_trace_save() gets called many times in a single second, try to suffix the name with a digit.
--- lib/eal/common/eal_common_trace.c | 7 ++ lib/eal/common/eal_common_trace_utils.c | 101 ++++++++++-------------- lib/eal/common/eal_trace.h | 2 + 3 files changed, 50 insertions(+), 60 deletions(-)
lib/eal/common/eal_common_trace.c +7 -0
@@ -66,6 +66,9 @@ eal_trace_init(void)if (trace_metadata_create () <0 ) goto fail; +if (trace.rootdir ==NULL &&trace_dir_default_path_get () <0 ) + goto free_meta; +/* Save current epoch timestamp for future use */ if (trace_epoch_time_save () <0 ) goto free_meta;
@@ -91,6 +94,10 @@ eal_trace_fini(void)trace_mem_free ();trace_metadata_destroy ();eal_trace_args_free (); +free (trace.rootdir); + trace.rootdir =NULL ; +free (trace.dir); + trace.dir =NULL ; }bool
lib/eal/common/eal_common_trace_utils.c +41 -60
164 lines not on this page · raw message
lib/eal/common/eal_trace.h +2 -0
@@ -48,6 +48,7 @@ struct trace_arg { };struct trace { +char *rootdir;char *dir;int register_errno;uint32_t status;
@@ -100,6 +101,7 @@ void trace_uuid_generate(void);int trace_metadata_create (void );void trace_metadata_destroy (void );char *trace_metadata_fixup_field (const char *field); +int trace_dir_default_path_get (void );int trace_epoch_time_save (void );void trace_mem_free (void );void trace_mem_per_thread_free (void );
Signature · 1 line
2.37.3
PATCH v4 11/11 trace: enable trace operations via telemetry
In reply to David MarchandRegister telemetry commands to list and configure trace points and later save traces for a running DPDK application.
Note: trace point names contain a '.', so the list of valid characters used in telemetry commands and dictionary keys has been extended.
Example with testpmd running with two net/null ports (startup command from devtools/test-null.sh):
--> /trace/list,lib.ethdev.*
{"/trace/list": {"lib.ethdev.configure": "Disabled",
"lib.ethdev.rxq.setup": "Disabled",
"lib.ethdev.txq.setup": "Disabled",
"lib.ethdev.start": "Disabled",
"lib.ethdev.stop": "Disabled",
"lib.ethdev.close": "Disabled",
"lib.ethdev.rx.burst": "Disabled",
"lib.ethdev.tx.burst": "Disabled"}}--> /trace/enable,lib.ethdev.st*
{"/trace/enable": {"Count": 2}}
--> /trace/enable,lib.ethdev.st*
{"/trace/enable": {"Count": 0}}
--> /trace/list,lib.ethdev.*
{"/trace/list": {"lib.ethdev.configure": "Disabled",
"lib.ethdev.rxq.setup": "Disabled",
"lib.ethdev.txq.setup": "Disabled",
"lib.ethdev.start": "Enabled",
"lib.ethdev.stop": "Enabled",
"lib.ethdev.close": "Disabled",
"lib.ethdev.rx.burst": "Disabled",
"lib.ethdev.tx.burst": "Disabled"}}testpmd> stop
...
testpmd> port stop all
...
testpmd> port start all
...
testpmd> start
...
--> /trace/save
{"/trace/save": {"Status": "OK",
"Path": ".../dpdk-traces/rte-2022-10-12-AM-10-51-48"}}
$ babeltrace .../dpdk-traces/rte-2022-10-12-AM-10-51-48
[10:51:36.229878723] (+?.?????????) lib.ethdev.stop:
{ cpu_id = 0x0, name = "dpdk-testpmd" }, { port_id = 0x0, ret = 0 }
[10:51:36.229880251] (+0.000001528) lib.ethdev.stop:
{ cpu_id = 0x0, name = "dpdk-testpmd" }, { port_id = 0x1, ret = 0 }
[10:51:40.449359774] (+4.219479523) lib.ethdev.start:
{ cpu_id = 0x0, name = "dpdk-testpmd" }, { port_id = 0x0 }
[10:51:40.449377877] (+0.000018103) lib.ethdev.start:
{ cpu_id = 0x0, name = "dpdk-testpmd" }, { port_id = 0x1 }--> /trace/disable,*
{"/trace/disable": {"Count": 2}}
---
Changes since v1:
- added a note in the documentation,
--- doc/guides/prog_guide/trace_lib.rst | 39 +++++++++++++++ lib/eal/common/eal_common_trace.c | 78 +++++++++++++++++++++++++++++ lib/telemetry/telemetry_data.c | 1 + 3 files changed, 118 insertions(+)
doc/guides/prog_guide/trace_lib.rst +39 -0
@@ -233,6 +233,45 @@ This section steps you through the details of generating trace and viewing it. babeltrace $HOME/dpdk-traces/rte-yyyy-mm-dd-[AP]M-hh-mm-ss/ +Configuring traces on a running DPDK application +------------------------------------------------ + +The DPDK trace library can be configured using the Telemetry interface. + +Examples:: + + --> /trace/list,lib.ethdev.* + {"/trace/list": {"lib.ethdev.configure": "Disabled", + "lib.ethdev.rxq.setup": "Disabled", + "lib.ethdev.txq.setup": "Disabled", + "lib.ethdev.start": "Disabled", + "lib.ethdev.stop": "Disabled", + "lib.ethdev.close": "Disabled", + "lib.ethdev.rx.burst": "Disabled", + "lib.ethdev.tx.burst": "Disabled"}} + + --> /trace/enable,lib.ethdev.st* + {"/trace/enable": {"Count": 2}} + --> /trace/enable,lib.ethdev.st* + {"/trace/enable": {"Count": 0}} + + --> /trace/list,lib.ethdev.* + {"/trace/list": {"lib.ethdev.configure": "Disabled", + "lib.ethdev.rxq.setup": "Disabled", + "lib.ethdev.txq.setup": "Disabled", + "lib.ethdev.start": "Enabled", + "lib.ethdev.stop": "Enabled", + "lib.ethdev.close": "Disabled", + "lib.ethdev.rx.burst": "Disabled", + "lib.ethdev.tx.burst": "Disabled"}} + + --> /trace/save + {"/trace/save": {"Status": "OK", + "Path": ".../dpdk-traces/rte-2022-10-12-AM-10-51-48"}} + +For more information on how to use the Telemetry interface, see +the :doc:`../howto/telemetry`. + Implementation details ----------------------
lib/eal/common/eal_common_trace.c +78 -0
87 lines not on this page · raw message
lib/telemetry/telemetry_data.c +1 -0
@@ -106,6 +106,7 @@ valid_name(const char *name) ['a' ... 'z'] = 1, ['_'] = 1, ['/'] = 1, + ['.'] = 1, };while (*name !='\0' ) {if ((size_t )*name >=RTE_DIM (allowed) || allowed[(int )*name] ==0 )
Signature · 1 line
2.37.3
Re: [PATCH v4 00/11] Trace subsystem fixes and more
In reply to David MarchandQuoted 15 lines · David Marchand
Hello,
This series addresses a number of issues and limitations I have identified over time in the trace subsystem.
The main issue was with dynamically enabling trace points which was not working if no trace point had been enabled at
rte_eal_init()time.This is 22.11 material.
We may start thinking about marking this API stable, but this is another topic.
Quoted 7 lines
--
David MarchandChanges since v3:
- added one more change for creating new trace directory on call torte_trace_save(),
- added the telemetry commands patch in the series,
Adding those two patches in the v3 revision was not a good idea. There is more work needed for them, so those changes for telemetry support will be sent separately in a dedicated series.
I applied the fixes (up to patch 9) for which we have acks from maintainers. Thanks for the reviews.
Signature · 1 line
David Marchand