Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sof: replace log calls with zephyr logging api #5707

Merged
merged 1 commit into from
Apr 27, 2022

Conversation

aiChaoSONG
Copy link
Collaborator

The log context in zephyr is per file or module.

To use zephyr logging api, LOG_MODULE_REGISTER is used
to register a log context, LOG_MODULE_DECLARE is used
to refer to the registered context.

For function in header file, LOG_MODULE_DECLARE should
be used within that function to avoid context collapse,
a condition one source file have multiple context
registered or declared.

Signed-off-by: Chao Song [email protected]

This PR is moved from #5411, because there are a lot of reviews that not valid anymore, move it here to avoid misleading.

@paulstelian97
Copy link
Collaborator

Looks quite reasonable, but this doesn't work on platforms which haven't migrated to Zephyr yet (we're working on it, it's not done though). So I cannot in good conscience approve this PR right now.

Also some constant string (format string) concatenation and extra arguments to give further info in the comp_info and related logs?

@aiChaoSONG
Copy link
Collaborator Author

Looks quite reasonable, but this doesn't work on platforms which haven't migrated to Zephyr yet

This PR has no impact on existing XTOS implementation, you can keep using XTOS. Once you have done the migration, it should work naturally. If I only do this for Intel platforms, the code will not compile with Zephyr on NXP platforms.

@sys-pt1s
Copy link

Can one of the admins verify this patch?

@aiChaoSONG
Copy link
Collaborator Author

@lgirdwood @lyakh @kv2019i ping?

@lyakh
Copy link
Collaborator

lyakh commented Apr 25, 2022

Do I understand it correctly that with this PR SOF traces are redirected to the Zephyr log, so that sof-logger can no longer read them?

@aiChaoSONG
Copy link
Collaborator Author

@lyakh Yes, exactly, and @keqiaozhang is working on CI to enable cavstool.py script.

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.

We need to have both logging susbsystems live side by side in the short term and have a Kconfig switch to select the correct version.

Kconfig.zephyr-log Outdated Show resolved Hide resolved
@lyakh
Copy link
Collaborator

lyakh commented Apr 26, 2022

@lyakh Yes, exactly, and @keqiaozhang is working on CI to enable cavstool.py script.

@aiChaoSONG was it cavstool.py that had problems like (1) repeating log fragments, making it unusable in most cases, (2) hitting the CPU-DSP memory window as-fast-as-possible which also sometimes was triggering DSP hardware issues? If that's exactly the tool that had those problems and if those problems are still there, perhaps we first should fix them? I understand that we need to unify with Zephyr to only have one logging infrastructure and to have all the logging available via one interface, but at least now sof-logger is mostly usable and you can always look at etrace for Zephyr specific logs. Unless I'm wrong and those issues are already fixed, switching over would make debugging much more difficult again

@aiChaoSONG
Copy link
Collaborator Author

@lyakh I only tested lightweight playback and capture cases, and don't see the issues you mentioned, I only see slight log drop in the message. Maybe we can run stress test after this tool enabled in CI.

@lgirdwood
Copy link
Member

Unless I'm wrong and those issues are already fixed, switching over would make debugging much more difficult again

@aiChaoSONG @lyakh This is why we need the Kconfig. Default is what we are doing today, Select "y" means use the Zephyr logging.

@aiChaoSONG aiChaoSONG force-pushed the use_zph_log branch 2 times, most recently from 78c206e to d4e3eb7 Compare April 26, 2022 13:28
@aiChaoSONG
Copy link
Collaborator Author

@lgirdwood The config config ZEPHYR_LOG is for the feature Default is what we are doing today, Select "y" means use the Zephyr logging.

If and only if Zephyr RTOS is used and config ZEPHYR_LOG is selected, Zephyr logging will be used, otherwise, SOF logging will be used.

Copy link
Collaborator

@lyakh lyakh left a comment

Choose a reason for hiding this comment

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

I presume it has also been manually verified, that this PR isn't breaking sof-logger with Zephyr when the Kconfig option is unselected?

@aiChaoSONG
Copy link
Collaborator Author

Test result with ZEPHYR_LOG=y: https://sof-ci.01.org/sofpr/PR5707/build136/devicetest/

Copy link
Collaborator

@kv2019i kv2019i left a comment

Choose a reason for hiding this comment

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

Looks great @aiChaoSONG ! FYI to @teburd

@aiChaoSONG
Copy link
Collaborator Author

aiChaoSONG commented Apr 27, 2022

@lgirdwood Please wait a few hours until the test is done. thanks. now ZEPHYR_LOG=y is under testing, and I will schedule another test with ZEPHYR_LOG=n after the current test.

The log context in zephyr is per file or module.

To use zephyr logging api, LOG_MODULE_REGISTER is used
to register a log context, LOG_MODULE_DECLARE is used
to refer to the registered context.

For function in header file, LOG_MODULE_DECLARE should
be used within that function to avoid context collapse,
a condition one source file have multiple context
registered or declared.

Signed-off-by: Chao Song <[email protected]>
@aiChaoSONG
Copy link
Collaborator Author

@lgirdwood @kv2019i @lyakh Thanks for the review. Test Summary:

@lgirdwood lgirdwood merged commit f4f9e65 into thesofproject:main Apr 27, 2022
@marc-hb
Copy link
Collaborator

marc-hb commented Apr 28, 2022

At first sight this looks like the most likely suspect for these brand new (and non-Zephyr) hard kernel lockups:

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.

7 participants