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

Kernel: Fix LOCK_DEBUG tracking to work again, move it to use AK::SourceLocation #6601

Merged
merged 6 commits into from
Apr 25, 2021

Conversation

bgianfo
Copy link
Member

@bgianfo bgianfo commented Apr 24, 2021

There are a hand full of changes here, all around improving the LOCK_DEBUG facilities / API.

  • Kernel: Fix LOCK_DEBUG feature to work again

    • UBSAN detected cases where we were calling current_thread->holding_lock
      but current_thread was nullptr.

    • Fix Lock::force_unlock_if_locked to not pass the correct ref delta to
      holding_lock(..).

  • Kernel: Add lock_count to procfs$all when LOCK_DEBUG is enabled.

  • AK: Add default constructor to SourceLocation

  • Kernel: Utilize AK::SourceLocation for LOCK_DEBUG instrumentation.

    The previous LOCKER(..) instrumentation only covered some of the
    cases where a lock is actually acquired. By utilizing the new
    AK::SourceLocation functionality we can now reliably instrument
    all calls to lock automatically.

    Other changes:

    • Tweak the message in Thread::finalize() which dumps leaked lock
      so it's more readable and includes the function information that is
      now available.

    • Make the LOCKER(..) define a no-op, it will be cleaned up in a
      follow up change.

  • Kernel: Remove the now defunct RESTORE_LOCK(..) macro.

  • Kernel: Remove the now defunct LOCKER(..) macro.

@bgianfo bgianfo changed the title Kernel: Fix LOCK_DEBUG tracking to work again. Kernel: Fix LOCK_DEBUG tracking to work again, move it to use AK::SourceLocation Apr 24, 2021
@bgianfo bgianfo changed the title Kernel: Fix LOCK_DEBUG tracking to work again, move it to use AK::SourceLocation Kernel: Fix LOCK_DEBUG tracking to work again, move it to use AK::SourceLocation Apr 24, 2021
@bgianfo bgianfo marked this pull request as ready for review April 24, 2021 22:43
@bgianfo bgianfo force-pushed the fix-lock-debug-for-hang branch 2 times, most recently from 6b7e237 to e45e332 Compare April 25, 2021 01:57
- UBSAN detected cases where we were calling thread->holding_lock(..)
  but current_thread was nullptr.

- Fix Lock::force_unlock_if_locked to not pass the correct ref delta to
  holding_lock(..).
The previous `LOCKER(..)` instrumentation only covered some of the
cases where a lock is actually acquired. By utilizing the new
`AK::SourceLocation` functionality we can now reliably instrument
all calls to lock automatically.

Other changes:
- Tweak the message in `Thread::finalize()` which dumps leaked lock
  so it's more readable and includes the function information that is
  now available.

- Make the `LOCKER(..)` define a no-op, it will be cleaned up in a
  follow up change.
@awesomekling awesomekling merged commit 8d6e9fa into SerenityOS:master Apr 25, 2021
@bgianfo bgianfo deleted the fix-lock-debug-for-hang branch April 25, 2021 07:51
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.

2 participants