commit | 0bc3bcab25532535b793e767a763b3e73e249d79 | [log] [tgz] |
---|---|---|
author | Nick Maniscalco <maniscalco@google.com> | Sat May 11 01:04:23 2024 +0000 |
committer | CQ Bot <fuchsia-internal-scoped@luci-project-accounts.iam.gserviceaccount.com> | Sat May 11 01:04:23 2024 +0000 |
tree | 683dc21631984dea3a0a3ccf40594190a5f86977 | |
parent | 48691ba26761e2b8bf1f0318853133219e0dd366 [diff] |
[kernel][dlog] Use a Timer to allow printing from within the scheduler This change resolves an issue that prevented printf from working within the scheduler, and more generally, whenever there was an active chainlock transaction. printf bottoms out in DLog::Write, which places a record in a buffer and then calls Event::Signal to unblock the notifier thread. Prior to this change, if DLog::Write was called from a context with an existing active chainlock transaction (e.g. from within the scheduler), calling Event::Signal would trigger an assert (can't start a new transaction when you've already got one in progress). To resolve the issue, we update DLog::Write to check for an active chainlock transaction. If there is none, it calls Event::Signal as usual. If there one, DLog::Write will instead set a Timer that will immediately fire once the current CPU has re-enabled interrupts after finishing the current transaction (or during the period in which interrupts are re-enabled during backoff). The Timer callback simply calls Event::Signal on Write's behalf. ~DLog now cancels the Timer to ensure there is no use-after-free. As a small optimization, DLog tracks whether there is a pending Timer (pending_deferred_signal_). Of course, this tracking is not 100% accurate as the Timer callback could be racing with the write. However, because the observation is made in a critical section guarded by the same lock that the dumper thread must ultimately acquire, there is no risk of a "lost wakeup". Fixed: 339440805 Fixed: 331847876 Change-Id: Iad837950e9513547b986fd71fc045b3e407d58c5 Reviewed-on: https://fuchsia-review.googlesource.com/c/fuchsia/+/1045567 Reviewed-by: John Grossman <johngro@google.com> Fuchsia-Auto-Submit: Nick Maniscalco <maniscalco@google.com> Commit-Queue: Auto-Submit <auto-submit@fuchsia-infra.iam.gserviceaccount.com>
Fuchsia is an open source, general purpose operating system supporting modern 64-bit Intel and ARM processors.
We expect everyone interacting with our project to respect our code of conduct.
Read more about Fuchsia's principles.
See Getting Started.
See fuchsia.dev.