Skip to content

Conversation

@mmaka1
Copy link

@mmaka1 mmaka1 commented Feb 19, 2020

This is a preview of fully working uuid-based identification for components and dais.

NOTE: This set of patches depends on #2398, not merged yet, so that commit is included here and will be removed with the rebase operation. If you have any comment regarding 4fb7aff0 [dep] abi: define debug abi version for user space dbg interfaces, please add it to #2398.

Following new features are provided by this PR:

  • Uuid-based identification for components and dais. Adding a new identifier to a driver requires DECLARE_SOF_UUID() declaration visible by the driver definition which refers the uuid by .uid = SOF_UUID() initialization (see the last patch for examples). Nothing more is required (no logger recompilation) to print the associated name in the trace log (uuid is also available there, not printed but it is possible if needed).

  • Output of the logger is reformatted to improve readability of the log.

  • Existing log levels are separated (dedicated values for info and dbg/verbose) and new warning level is defined. <...>_warn() macros are provided as well. Errors are printed in red while warnings are printed in yellow by the logger.

  • Logger converts address of uuid entries into the name and uuid value, printed in blue, if %s format parameter is provided. So that component/dai/task identification is possible at the infrastructure level. E.g. this trace line in comp_new(): trace_event(TRACE_CLASS_COMP, "new component %s pipe %d id %d", drv->uid, comp->pipeline_id, comp->id); gives the following output from the logger (click the image to enlarge):

image

So performance traces may be improved to provide readable identification of the measured target component, scheduler traces may provide immediate task identification etc. Btw assigning uuids to tasks will enable trace context identification for "worker threads" as well.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Confusing comment. Can you detail?

Copy link
Author

Choose a reason for hiding this comment

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

Not mine, just moved that piece of code. Anyway this is some optional version verification against the fw binary (in addition to mandatory ldc version verification).

Copy link
Collaborator

Choose a reason for hiding this comment

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

Didn't seem to be moved, anyway such additional verifications may become incorrect as debug ABI and firmware ABI begin to diverge.

Copy link
Author

Choose a reason for hiding this comment

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

Just look at the original tools/logger/convert.c:433 on the left side, it had been there already. Honestly I do not know what to do with this piece and how it is used by anyone (might be unused and should be just removed, no idea).

Copy link
Collaborator

Choose a reason for hiding this comment

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

Looks like an old misleading comment. You just check the version of the LDC file that it matches with the debug ABI here. I'd say drop the comment, leave the code.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Ah, this check is wrong. It compares with the actual firmware version rather than comparing with either the IPC ABI or the debug ABI. Is the PR with the debug ABI merged already?

Somehow the debug ABI must be exposed in debugfs so that you can properly check it.

Copy link
Author

Choose a reason for hiding this comment

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

No, the debug abi version may be checked as done atm. It is verified between sof-logger and lcd file that is created while compiling the fw, so that consistency is protected and works well. Debug abi patch just replaces main abi version with debug abi version. It guarantees you the format but you are concerned with the content I guess and it is not protected by the abi version. While working on uuid I just moved this second optional verification to separate function because it looked to me like obsolete piece of the code that actually do not offer any additional required protection, so should be replaced (more below) in near future plus I was adding more stuff to convert() and did not want to make it too long. It is actually good that this simple move brought that piece of code to your attention since it, as I mentioned, does not make much sense to me either. Debug data format is protected by the debug abi version but its content is not. In order to have reliable, consistent debug setup, you'd need confirmation that debug data (ldc file in this case) is created of that exact build of the fw that is running on the system and abi version nor build version do not provide that level of protection and replacement is needed. Some kind of fw hash exposed via debug fs that would be compared with a copy inserted into ldc. Since manual control is good enough for me, I am ok to debug w/o anything like that at the moment. But if you are concerned that much, go ahead and implement this control mechanism, would be a good thing to have.

Copy link
Collaborator

Choose a reason for hiding this comment

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

You are correct in the fact that in fact it is firmware version that needs to be checked. Although I have seen that often the logger will simply bail whenever I get firmware and ldc file mismatching other than via the version.

I will look into the dynamic enabling whenever I get the time, right now I will focus on enabling a new NXP platform so I can only review others' work rather than do any of my own for traces, for one or two weeks I think.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Let me know when the PR is out of WIP so I can give a full review again.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Do we really need to say "uid" instead of "uuid" in the macros?

Copy link
Collaborator

@paulstelian97 paulstelian97 Feb 19, 2020

Choose a reason for hiding this comment

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

This extra whitespace can live in a separate cleanup commit? Although I feel it's actually unnecessary.

Copy link
Author

Choose a reason for hiding this comment

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

Fixed

Copy link
Collaborator

@paulstelian97 paulstelian97 left a comment

Choose a reason for hiding this comment

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

Other than that, this is really good work, I'll wait until every component has a UUID and look into it.

Copy link
Member

Choose a reason for hiding this comment

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

would this be part of the information reported after FW_READY or as part of the extended manifest you rmentioned?

Copy link
Author

Choose a reason for hiding this comment

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

Note: this patch originally appears in #2374. Duplicated here as a dependency to allow early comments on the uuid work (which is mentioned in the description). So any conversation regarding that one should be probably moved to #2374.

This new piece is completely symmetrical to other existing data attached to the fw_ready atm. So I added this to fw_ready ipc payload as well until extended manifest is implemented and then should be moved like other static fw-ready payload pieces (1. consistency, 2. complete bundle in one place to be moved).

Copy link
Member

Choose a reason for hiding this comment

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

should it be *uid then? Or uintptr_t?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Probably uintptr_t, the thing is we do not want to actually dereference this address because it points to a section that will not be uploaded to the DSP. Similar to trace messages.

Copy link
Author

Choose a reason for hiding this comment

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

I was concerned with this type too. However, at some point the uid (named w/o double u to make a slight difference with uuid that is a part of the structure that uid points to) must be converted to a type with fixed size being a part of the interface consumed by a program compiled and running on another cpu. Since the uid is not interpreted internally by the dsp code, I decided to use the target type immediately and pass it through the trace stack. This probably could be an offset inside the section instead of absolute address, computed from a linker variable if possible, to justify the type used by interface and to avoid issues with 64-bit addressing however I am not sure if such flexibility is really required.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Absolute address is fine (it is used for the trace format message and number of parameters), so I'd insist on uintptr_t. I'm not sure what the format is (I'll look real quick).

Copy link
Collaborator

Choose a reason for hiding this comment

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

Came back, it is stored as uint32_t in that header. I don't like that but that section will be in the 32-bit range anyway even if we potentially would move to 64-bit DSPs or other cores (Zephyr!), the address for these sections would be in memory that shouldn't be dereferenced.

Guess I'll allow uint32_t due to the precedent.

@mmaka1 mmaka1 force-pushed the uuid-in-logs branch 3 times, most recently from 933a9e2 to a992d68 Compare February 21, 2020 14:14
@lgirdwood
Copy link
Member

@mmaka1 some ninor CI comments on aligngment and memcpy.

Copy link
Member

@lgirdwood lgirdwood left a comment

Choose a reason for hiding this comment

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

Looks good, just need some more comments for doxygen since logging is important client feature.

Copy link
Member

Choose a reason for hiding this comment

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

Maybe a small explanation in the comments about how this is formed and constructed. Doxygen should be able to pick this up too.

Copy link
Author

Choose a reason for hiding this comment

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

Brief description added.

@mmaka1
Copy link
Author

mmaka1 commented Feb 24, 2020

@mmaka1 some ninor CI comments on aligngment and memcpy.

Alignment issue is in the #2398. It is duplicated here as a dependency and will be removed once #2398 is merged. (Btw, this is the only reason why this one is still tagged as WIP)

memcpy() had been used in the user space application code. Should checkpatch complain about this?

@mmaka1
Copy link
Author

mmaka1 commented Feb 27, 2020

SOFCI TEST

@lgirdwood
Copy link
Member

@fredoh9 the CI failed tests for suspend, but there is nothing in the FW logs, otherwise its ok.

@mmaka1 mmaka1 changed the title [WIP] Uuids in logs Uuids in logs Feb 28, 2020
@mmaka1
Copy link
Author

mmaka1 commented Feb 28, 2020

@fredoh9 @lgirdwood CI consistently fails inside pm-runtime test on cnl family and I am not able to find anything in the log. Stream is stopped and released after aplay is killed but there is no trace of GLB_PM_MSG: CTX_SAVE message initiated by the driver after the t/o. I am not able to reproduce it on my local systems, ctx_save is always there.

@lgirdwood
Copy link
Member

@fredoh9 I'm also seeing a broken pipe error in some of the test logs too (in other PRs), could CI be at fault here and these all be related ?

@fredoh9
Copy link
Contributor

fredoh9 commented Feb 28, 2020

@mmaka1 @lgirdwood In this case, runtime pm status is not 'suspended' after 10 seconds later from aplay stop. I'm scanning daily test results with PR test's one also. I will get back to you.

@lgirdwood
Copy link
Member

@mmaka1 lets try CI again when the conflict is fixed.

@fredoh9
Copy link
Contributor

fredoh9 commented Feb 28, 2020

SOFCI TEST

@fredoh9
Copy link
Contributor

fredoh9 commented Feb 28, 2020

I don't see any runtime pm test glitches in this week.
I re-triggered the CI DEVICE TEST again. I will be monitoring the result closely.

@fredoh9
Copy link
Contributor

fredoh9 commented Feb 28, 2020

GitHub pull request #2410 of commit eeca85d719c2104eab23859688d0d02d455a1cb5, has merge conflicts.
This is failed due to merge conflict. so no device test.
@mmaka1 can you fix the conflict and re-push the patch again?

@mmaka1
Copy link
Author

mmaka1 commented Mar 2, 2020

@fredoh9 Conflict is resolved. Same failures, are there any more detailed logs from the failing systems available?

Marcin Maka added 12 commits March 5, 2020 16:47
Optional fw version verification moved to separate function
in order to modularize code of convert().

Signed-off-by: Marcin Maka <marcin.maka@linux.intel.com>
Unique identification in form of Guid is much more
scalable for fw parts (components, dais, ...) then
existing ids and trace class ids.

Signed-off-by: Marcin Maka <marcin.maka@linux.intel.com>
New trace entry parameter is defined: uuid of the source.
Technically, this is an address of uuid entry linked
inside a special section in elf.

Has_ids is removed from the static log entry since eventually
all entries will use uuids and -1 detection is good enough
detection for those who still do not provide ids.

Note: both changes are done in a single patch to avoid two
major dbg-abi version bumps.

Signed-off-by: Marcin Maka <marcin.maka@linux.intel.com>
Content of static uuid section is appended to the ldc file
along with a new special header by rimage.

New ldc file part is read by the logger to decode
uuid pointers provided in traces into nice names.

Signed-off-by: Marcin Maka <marcin.maka@linux.intel.com>
All new definitions are included in ldc file and are
used by the logger automatically.

Signed-off-by: Marcin Maka <marcin.maka@linux.intel.com>
TRACE_CLASS ids used by parts switch to uuid-based logging
marked as unused.

Signed-off-by: Marcin Maka <marcin.maka@linux.intel.com>
Log entry parameters format is compacted to reserve more
space for the text.

Max entry location length is increased to 24 characters.

Timestamp and component name/id use colors to improve
readability.

Signed-off-by: Marcin Maka <marcin.maka@linux.intel.com>
Two new levels: warning and info defined since
existing critical+verbose seems not enough.

Signed-off-by: Marcin Maka <marcin.maka@linux.intel.com>
Both had logged on VERBOSE level so far.
Non-verbose trace switched to INFO level.

Signed-off-by: Marcin Maka <marcin.maka@linux.intel.com>
Implemented for generic and device tracing with warn postfix
translated to LOG_LEVEL_WARNING.

Signed-off-by: Marcin Maka <marcin.maka@linux.intel.com>
Warning traces prefixed and painted in yellow.

Signed-off-by: Marcin Maka <marcin.maka@linux.intel.com>
Log entry format is scanned by the logger and if %s is found,
then corresponding parameter is interpreted as address
of static uuid entry. The original address is replaced by
formatted uuid namen and value, painted in blue, before
fprintf() is called.

Signed-off-by: Marcin Maka <marcin.maka@linux.intel.com>
@mmaka1 mmaka1 force-pushed the uuid-in-logs branch 2 times, most recently from 019cb77 to ff3078f Compare March 5, 2020 18:36
@tlauda tlauda merged commit 93cf630 into thesofproject:master Mar 6, 2020
@mmaka1 mmaka1 deleted the uuid-in-logs branch March 6, 2020 09:23
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.

6 participants