[v2,2/3] eal: fix trace init fail with long file-prefix
Checks
Commit Message
Bug scenario:
1. start testpmd:
dpdk-testpmd -l 4-6 -a 0000:7d:00.0 --trace=.* \
-file-prefix=trace_autotest -- -i
2. then observed:
EAL: eal_trace_init():94 failed to initialize trace [File exists]
EAL: FATAL: Cannot init trace
EAL: Cannot init trace
EAL: Error - exiting with code: 1
The root cause it that the offset set wrong with long file-prefix and
then lead the strftime return failed.
Fixes: 321dd5f8fa62 ("trace: add internal init and fini interface")
Cc: stable@dpdk.org
Signed-off-by: Chengwen Feng <fengchengwen@huawei.com>
---
lib/eal/common/eal_common_trace_utils.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
Comments
On Tue, Jun 14, 2022 at 8:06 AM Chengwen Feng <fengchengwen@huawei.com> wrote:
>
> Bug scenario:
> 1. start testpmd:
> dpdk-testpmd -l 4-6 -a 0000:7d:00.0 --trace=.* \
> -file-prefix=trace_autotest -- -i
> 2. then observed:
> EAL: eal_trace_init():94 failed to initialize trace [File exists]
This is not directly related to the issue being fixed, but this error
log is really obscure..
Can we enhance this, maybe in a followup patch?
> EAL: FATAL: Cannot init trace
> EAL: Cannot init trace
> EAL: Error - exiting with code: 1
>
> The root cause it that the offset set wrong with long file-prefix and
> then lead the strftime return failed.
>
> Fixes: 321dd5f8fa62 ("trace: add internal init and fini interface")
> Cc: stable@dpdk.org
>
> Signed-off-by: Chengwen Feng <fengchengwen@huawei.com>
Reviewed-by: David Marchand <david.marchand@redhat.com>
And another topic, I see no reason for the limitation/truncation on
the file prefix.
Testing with the last patch of the series, I can see odd directory, like
EAL: Trace dir:
/home/dmarchan/builds/main/build-gcc-shared/app/test/trace_autot-2022-06-15-PM-03-18-39
I'll send a cleanup series for this, later.
On Wed, Jun 15, 2022 at 7:32 PM David Marchand
<david.marchand@redhat.com> wrote:
>
> On Tue, Jun 14, 2022 at 8:06 AM Chengwen Feng <fengchengwen@huawei.com> wrote:
> >
> > Bug scenario:
> > 1. start testpmd:
> > dpdk-testpmd -l 4-6 -a 0000:7d:00.0 --trace=.* \
> > -file-prefix=trace_autotest -- -i
> > 2. then observed:
> > EAL: eal_trace_init():94 failed to initialize trace [File exists]
>
> This is not directly related to the issue being fixed, but this error
> log is really obscure..
> Can we enhance this, maybe in a followup patch?
>
>
> > EAL: FATAL: Cannot init trace
> > EAL: Cannot init trace
> > EAL: Error - exiting with code: 1
> >
> > The root cause it that the offset set wrong with long file-prefix and
> > then lead the strftime return failed.
> >
> > Fixes: 321dd5f8fa62 ("trace: add internal init and fini interface")
> > Cc: stable@dpdk.org
> >
> > Signed-off-by: Chengwen Feng <fengchengwen@huawei.com>
>
> Reviewed-by: David Marchand <david.marchand@redhat.com>
Acked-by: Jerin Jacob <jerinj@marvell.com>
@@ -104,7 +104,7 @@ trace_session_name_generate(char *trace_dir)
rc = rte_strscpy(trace_dir, eal_get_hugefile_prefix(),
TRACE_PREFIX_LEN);
if (rc == -E2BIG)
- rc = TRACE_PREFIX_LEN;
+ rc = TRACE_PREFIX_LEN - 1;
trace_dir[rc++] = '-';
rc = strftime(trace_dir + rc, TRACE_DIR_STR_LEN - rc,