Skip to content

Revert "lkl: Implement lkl_printf and lkl_bug internally"#627

Open
tavip wants to merge 1 commit intolkl:masterfrom
tavip:revert-lkl-printf
Open

Revert "lkl: Implement lkl_printf and lkl_bug internally"#627
tavip wants to merge 1 commit intolkl:masterfrom
tavip:revert-lkl-printf

Conversation

@tavip
Copy link
Copy Markdown
Member

@tavip tavip commented Apr 25, 2026

This reverts commit 486afba.

lkl_printf is called before Linux is initialized in several instances and this use-case is the main reason for this API's existence. Unfortunately, and suprisingly, the Linux vsnprintf uses WARN* macros which will prints information about the CPU, current process, stack trace etc. and some of this information does require Linux to be initialized.

This reverts commit 486afba.

lkl_printf is called before Linux is initialized in several instances
and this use-case is the main reason for this API's
existence. Unfortunately, and suprisingly, the Linux vsnprintf uses
WARN* macros which will prints information about the CPU, current
process, stack trace etc. and some of this information does require
Linux to be initialized.

Signed-off-by: Octavian Purdila <tavip@google.com>
@tavip tavip requested review from ddiss and thehajime April 25, 2026 06:12
@tavip
Copy link
Copy Markdown
Member Author

tavip commented Apr 25, 2026

@lrh2000 If we really want to keep this we need to add a new Kconfig option and disable WARN_ON when that is selected. I want to avoid this as it adds maintenance effort to us. As mention in the original thread adding support via host_ops for your environment is the canonical way.

@lrh2000
Copy link
Copy Markdown

lrh2000 commented Apr 27, 2026

@lrh2000

Thanks for the mention!

If we really want to keep this we need to add a new Kconfig option and disable WARN_ON when that is selected. I want to avoid this as it adds maintenance effort to us.

OK. I saw the problem. Thanks for your explanation. I agree that if Linux methods require access to the process context, then the original commit is simply buggy. Disabling WARN_ON also does not seem to be an elegant solution.

As mention in the original thread adding support via host_ops for your environment is the canonical way.

In addition to adding support via host_ops, which has already been done in my environment, we will have to implement printf-related functionality manually in an environment without libc.

It's unfortunate because printf functionality is not very trivial. This creates duplicate code and complexity.

However, I cannot think of a better approach at the moment. I understand the decision made in this PR.

@lrh2000
Copy link
Copy Markdown

lrh2000 commented Apr 27, 2026

maintenance effort

A bit off-topic. But a big thanks for this! I just noticed that the recent PRs created by you bumped the kernel version, and I'm excited to see that we're bumping versions to catch the latest LTS!

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.

3 participants