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

Disable SYSLOG_DEFAULT by default #14695

Closed
wants to merge 1 commit into from

Conversation

yamt
Copy link
Contributor

@yamt yamt commented Nov 8, 2024

Summary

Disable SYSLOG_DEFAULT by default because the implementation is problematic.
See #14662 for the discussion. Also, make it depend on EXPERIMENTAL to discourage it.

Instead, enable SYSLOG_CONSOLE for a bit more cases.

An alternative would be to introduce/extend some serialization mechanism (eg. enter_critical_section, which is currently used by the serial driver to interact with interrupts) to cover up_putc users including SYSLOG_DEFAULT. While it works, it doesn't sound attractive to me to introduce this kind of complexity to up_putc, which is supposed to be a very low-level machinary used early in the boot. Also, the implementation of such serialization can be complex because how up_putc works is basically device-specific and how it corresponds to other devices on the system (eg. uarts) isn't obvious to the upper layers.

Impact

this would affect many board configurations.

Testing

tested for esp32s3-devkitc, with a few unrelated patches.

Because the implementation is problematic.
See apache#14662 for the discussion.
Also, make it depend on EXPERIMENTAL to discourage it.

Instead, enable SYSLOG_CONSOLE for a bit more cases.

An alternative would be to introduce/extend some serialization
mechanism (eg. enter_critical_section, which is currently used by
the serial driver to interact with interrupts) to cover up_putc
users including SYSLOG_DEFAULT. While it works, it doesn't sound
attractive to me to introduce this kind of complexity to up_putc,
which is supposed to be a very low-level machinary used early in
the boot. Also, the implementation of such serialization can be
complex because how up_putc works is basically device-specific and
how it corresponds to other devices on the system (eg. uarts) isn't
obvious to the upper layers.
@github-actions github-actions bot added Area: Drivers Drivers issues Size: S The size of the change in this PR is small labels Nov 8, 2024
@nuttxpr
Copy link

nuttxpr commented Nov 8, 2024

[Experimental Bot, please feedback here]

No, this PR does not fully meet the NuttX requirements. Here's why:

  • Insufficient Detail in Summary: While the summary explains why the change is needed, it lacks detail on how SYSLOG_CONSOLE is enabled for more cases. Specifics are crucial.
  • Impact Understated: "This would affect many board configurations" is vague. The impact section needs to be filled out completely with YES/NO answers and descriptions for each category. Consider:
    • User Impact: Will users notice a change in logging behavior? Will configuration files need updating?
    • Build Impact: Are there new Kconfig options?
    • Hardware Impact: Does this affect any specific architectures or boards disproportionately?
    • Documentation Impact: Does documentation need updating to reflect the new default and the EXPERIMENTAL dependency?
    • Security Impact: Are there any potential security implications of disabling the default syslog and relying more on the console?
    • Compatibility Impact: Does this break any existing configurations?
  • Missing Test Details: The testing section is insufficient.
    • Build Hosts: Provide details about the build host OS, CPU architecture, and compiler version.
    • Targets: Be specific about the ESP32S3 configuration used.
    • Logs: "Tested with a few unrelated patches" is unacceptable. Provide actual before-and-after logs demonstrating the change in syslog behavior. Show how the change fixes the issue described in the linked GitHub issue.

In short, the PR needs significantly more detail in the Impact and Testing sections to meet the requirements. The Summary could also benefit from more specifics about the implementation of the SYSLOG_CONSOLE changes.

@@ -267,19 +267,25 @@ config SYSLOG_STREAM

config SYSLOG_CONSOLE
bool "Log to /dev/console"
default !ARCH_LOWPUTC && !SYSLOG_CHAR && !RAMLOG_SYSLOG && !SYSLOG_RPMSG && !SYSLOG_RTT
default !SYSLOG_CHAR && !RAMLOG_SYSLOG && !SYSLOG_RPMSG && !SYSLOG_RTT
Copy link
Contributor

Choose a reason for hiding this comment

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

but console channel doesn't support the output from interrupt. This change will break most panic logic before console can be called from interrupt get fixed.

Copy link
Contributor Author

@yamt yamt Nov 8, 2024

Choose a reason for hiding this comment

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

it's a valid concern.

IMO, using syslog from interrupt is a design mistake.
anyway, it won't be a disaster as syslog_device.c already has a check for that case. (syslog_dev_outputready)

for panic, maybe it's enough to make it fall back to up_putc if g_nx_initstate == OSINIT_PANIC.
as the panic logic should have already stopped moving parts (eg. pause_all_cpu) at that point, it should be ok to use up_putc in that case.

how do you think?

Copy link
Contributor

@xiaoxiang781216 xiaoxiang781216 Nov 8, 2024

Choose a reason for hiding this comment

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

it's a valid concern.

IMO, using syslog from interrupt is a design mistake.

Why is it mistake? If syslog can't support the interrupt, what's other kernel facility could do?

anyway, it won't be a disaster as syslog_device.c already has a check for that case. (syslog_dev_outputready)

Different syslog channel has the different capability: uputc/ramlog/rpmsg support interrupt, console/device/file doesn't support. Since the default syslog(uputc) support the interrupt before, the change need keep this behavior, otherwise all board will break.

for panic, maybe it's enough to make it fall back to up_putc if g_nx_initstate == OSINIT_PANIC. as the panic logic should have already stopped moving parts (eg. pause_all_cpu) at that point, it should be ok to use up_putc in that case.

panic is just one case; driver may output log in interrupt too.

how do you think?

I think the default syslog channel need support the output from interrupt to handle all possible case. So, I would suggest improving syslog console to support the interrupt before making it as default. serial driver framework already contains the special code to handle the interrupt case, so there is no block issue to improve it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

it's a valid concern.
IMO, using syslog from interrupt is a design mistake.

Why is it mistake? If syslog can't support the interrupt, what's other kernel facility could do?

syslog is an api for ordinary applications.
it isn't free for an api to be prepared to be used by interrupts. eg. complex locking.
yes, it's simpler to have a separate api for interrupts, IMO.

anyway, it won't be a disaster as syslog_device.c already has a check for that case. (syslog_dev_outputready)

Different syslog channel has the different capability: uputc/ramlog/rpmsg support interrupt, console/device/file doesn't support. Since the default syslog(uputc) support the interrupt before, the change need keep this behavior, otherwise all board will break.

for panic, maybe it's enough to make it fall back to up_putc if g_nx_initstate == OSINIT_PANIC. as the panic logic should have already stopped moving parts (eg. pause_all_cpu) at that point, it should be ok to use up_putc in that case.

panic is just one case; driver may output log in interrupt too.

how do you think?

I think the default syslog channel need support the output from interrupt to handle all possible case. So, I would suggest improving syslog console to support the interrupt before making it as default. serial driver framework already contains the special code to handle the interrupt case, so there is no block issue to improve it.

have you read #14662?

do you prefer to sprinkle more serialization in syslog and/or up_putc?

Copy link
Contributor

@xiaoxiang781216 xiaoxiang781216 Nov 9, 2024

Choose a reason for hiding this comment

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

it's a valid concern.
IMO, using syslog from interrupt is a design mistake.

Why is it mistake? If syslog can't support the interrupt, what's other kernel facility could do?

syslog is an api for ordinary applications. it isn't free for an api to be prepared to be used by interrupts. eg. complex locking.

if so, do you plan to remove the capability that sem can be posted and mqueue can be sent from interrupt handler?
These extensions which make POSIX API can work from interrupt context are compatible extension in OS context.

yes, it's simpler to have a separate api for interrupts, IMO.

You still need fulfill the requirement I said before that the new function need work in the interrupt context.

anyway, it won't be a disaster as syslog_device.c already has a check for that case. (syslog_dev_outputready)

Different syslog channel has the different capability: uputc/ramlog/rpmsg support interrupt, console/device/file doesn't support. Since the default syslog(uputc) support the interrupt before, the change need keep this behavior, otherwise all board will break.

for panic, maybe it's enough to make it fall back to up_putc if g_nx_initstate == OSINIT_PANIC. as the panic logic should have already stopped moving parts (eg. pause_all_cpu) at that point, it should be ok to use up_putc in that case.

panic is just one case; driver may output log in interrupt too.

how do you think?

I think the default syslog channel need support the output from interrupt to handle all possible case. So, I would suggest improving syslog console to support the interrupt before making it as default. serial driver framework already contains the special code to handle the interrupt case, so there is no block issue to improve it.

have you read #14662?

You can fix up_putc in what you want, but syslog can be called from the interrupt context must been keep as before until you provide a new api(e.g. printk) which can be called from the interrupt context and replace all syslog call in the code base.

do you prefer to sprinkle more serialization in syslog and/or up_putc?

I also want to drop up_putc from syslog too, but I have to point out that you can't simply switch the syslog channel to console by default since it breaks ALL log from panic and interrupt.

So, let me change the patch to draft until you find a way to fix this problem.

Copy link
Contributor

@xiaoxiang781216 xiaoxiang781216 Nov 11, 2024

Choose a reason for hiding this comment

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

syslog can be called from the interrupt context must been keep as before

why are you pretending like we have a working implementation of syslog which meets your requirements?

In production, we normally use ramlog or rpmsg syslog. In development, we use the default syslog with interrupt buffer.

you just don't care occasional deadlock during development? or, you are lucky and have not been suffered by the issue?

We don't hit the deadlock since the driver already do the protection.

because you don't care SMP?

No, we care SMP a lot (actually, all recent SMP improvement come from us, and more will come in), since we already chip more than 400 million products.

if so, do you plan to remove the capability that sem can be posted and mqueue can be sent from interrupt handler?

no. (at least for now.)
this PR just disables a functionality which is broken. (just because leaving it enabled hurts users. i received complaints from users.) if you want to use it and you don't care the breakage, you can still enable it.

But the syslog console which can't be called from panic/assert/interrupt need be fixed or more another approach is provided before we merge this patch.

why? you can use ramlog or whatever as you said, can't you?

Yes, I can change to ramlog in my defconfig, and you can change to console in your defconfig too, but you can't change the default setting in master branch since all defconfig expect syslog can be called from panic/assert/interrupt.

but panic/assert need work in production.

it's a valid concern and i already proposed a possible solution earlier in this thread: #14695 (comment)

But we need an implementation, not just a proposal before switching.

your response to my proposal was just "panic is just one case; driver may output log in interrupt too." i thought you meant the approach was not acceptable at all for you. what's the point to write an implementation just to be dismissed?

I don't oppose this patch, but all current syslog in kernel need migrate to the interrupt safe approach before we merge this one.

Copy link
Contributor

Choose a reason for hiding this comment

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

this PR just disables a functionality which is broken. (just because leaving it enabled hurts users. i received complaints from users.)
if you want to use it and you don't care the breakage, you can still enable it.

With this change you will have other users complaining why logging from interrupts doesn't work by default. Satisfying some users at the expense of others is not the solution, especially considering that there are more platform without SMP.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

syslog can be called from the interrupt context must been keep as before

why are you pretending like we have a working implementation of syslog which meets your requirements?

In production, we normally use ramlog or rpmsg syslog. In development, we use the default syslog with interrupt buffer.

you just don't care occasional deadlock during development? or, you are lucky and have not been suffered by the issue?

We don't hit the deadlock since the driver already do the protection.

which driver are you talking about?
you have a fix in your local tree, you mean?
or, in up_putc implementation for your target? (which target is it?)

because you don't care SMP?

No, we care SMP a lot (actually, all recent SMP improvement come from us, and more will come in), since we already chip more than 400 million products.

if so, do you plan to remove the capability that sem can be posted and mqueue can be sent from interrupt handler?

no. (at least for now.)
this PR just disables a functionality which is broken. (just because leaving it enabled hurts users. i received complaints from users.) if you want to use it and you don't care the breakage, you can still enable it.

But the syslog console which can't be called from panic/assert/interrupt need be fixed or more another approach is provided before we merge this patch.

why? you can use ramlog or whatever as you said, can't you?

Yes, I can change to ramlog in my defconfig, and you can change to console in your defconfig too, but you can't change the default setting in master branch since all defconfig expect syslog can be called from panic/assert/interrupt.

IMO, the default should be something safe.

Copy link
Contributor

@xiaoxiang781216 xiaoxiang781216 Nov 11, 2024

Choose a reason for hiding this comment

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

We don't hit the deadlock since the driver already do the protection.

which driver are you talking about? you have a fix in your local tree, you mean? or, in up_putc implementation for your target? (which target is it?)

Yes, it's in the local tree, since the chip vendor doesn't want to upstream their code to community.

Yes, I can change to ramlog in my defconfig, and you can change to console in your defconfig too, but you can't change the default setting in master branch since all defconfig expect syslog can be called from panic/assert/interrupt.

IMO, the default should be something safe.

it depends on the context: SMP safe or interrupt safe. Since the default config is interrupt safe for a long time ago, we need keep this default behavior. So, I suggest making console syslog work in the interrupt context, which isn't hard to do, so we can switch to it and remove the default syslog channel directly.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

i submitted a (hopefully) less controversial alternative: #14722

@xiaoxiang781216 xiaoxiang781216 marked this pull request as draft November 9, 2024 14:57
@xiaoxiang781216
Copy link
Contributor

@yamt do you want to continue:

  1. Improve syslog console to support the output from interrupt
  2. Change the default syslog channel to console

or close this PR directly?

@yamt
Copy link
Contributor Author

yamt commented Nov 12, 2024

@yamt do you want to continue:

1. Improve syslog console to support the output from interrupt

2. Change the default syslog channel to console

or close this PR directly?

for a longer term, i still tend to think we should retire up_putc at least for the syslog purpose.
but let me close this for now as i already have a lot of other todos.

@yamt yamt closed this Nov 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: Drivers Drivers issues Size: S The size of the change in this PR is small
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants