Skip to content

debugability: logging: Redesign tracing mechanism to enable proper logging - #390

Merged
lgirdwood merged 1 commit into
thesofproject:masterfrom
bkokoszx:debugability_v2
Sep 21, 2018
Merged

lgirdwood merged 1 commit into
thesofproject:masterfrom
bkokoszx:debugability_v2

Conversation

@akloniex

Copy link
Copy Markdown
Member

Declare log_entry structures that are linked to .static_log_entries
section of ELF.
trace_event macros extended to accept additional parameters and unconfined
number of characters.

Signed-off-by: ArturX Kloniecki [email protected]

@bkokoszx
bkokoszx requested a review from mmaka1 September 18, 2018 16:14
@akloniex
akloniex force-pushed the debugability_v2 branch 4 times, most recently from 981feec to 4d362f8 Compare September 18, 2018 17:18

@lgirdwood lgirdwood left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good start, I assume this aligns us with FDK logging formats ? We also need to do the kernel part too, maybe @bardliao can help with kernel.

Comment thread src/platform/apollolake/apollolake.x.in Resolved
Comment thread src/include/sof/trace.h Resolved
Comment thread src/include/sof/trace.h Outdated

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This struct should be defined outside the macro.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Every occurrence of trace_event macro defines new anonymous type, that is then linked to separate section of ELF, and, for this purpose, needs to be part of a macro, AFAIK.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok, now I see - each structure is anon variable size and placed by the linker in a memory region. Probably best to comment this above the macro. Btw, it looks like the structure can be better aligned and compressed. There are some variables that could be uint16_t and all int32_t types should be aligned on 32bits (one is placed after a variable size char array).

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since these are never actually processed/loaded by the DSP, and are only read by external tools, I believe that we should optimize for ease of processing, rather than squeeze every bit possible.

Comment thread src/include/sof/trace.h Resolved
Comment thread src/include/sof/trace.h Resolved
Comment thread src/lib/trace.c Resolved
Comment thread src/lib/trace.c Outdated

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

memcpy ?

Comment thread src/lib/trace.c Outdated

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will cause a memory barrier for every read/write of dst. Probably better if we invalidate and writeback manually after copy?

Comment thread src/lib/trace.c Outdated

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

whee does 2 come from ? should it be a sizeof or macro ?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Each log_entry_header is followed by address of log_entry and then by up to 3 parameters, all as payload.
Call to this function is a result of macro expansion with 1 parameter (as function name should suggest), which brings payload size to 2 dwords.
Same pattern applies to all flavours of _trace_event function.

We could pass this value to the function, as it's actually calculated earlier, as part of macro expansion, to determine which variant of the function to call, or create a macro to determine size of buffer in a function-like fashion.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've created a macro to cover appearance of magic numbers and attached a comment that should make it easier to wrap head around.

Comment thread src/lib/trace.c Outdated

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We have to be careful as not all DSP architecture can allocate dynamically on the stack. It also seems like there is a lot of duplication in these function amd we could reuse if we passed or detected number of args.

@akloniex
akloniex force-pushed the debugability_v2 branch 2 times, most recently from d72dec3 to 592b68f Compare September 20, 2018 19:13
…gging.

Declare log_entry structures that are linked to .static_log_entries
section of ELF.
trace_event macros extended to accept additional arguments and unconfined
number of characters.

Signed-off-by: ArturX Kloniecki <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants