Skip to content

Conversation

@marc-hb
Copy link
Collaborator

@marc-hb marc-hb commented May 26, 2021

2 cosmetic commits + this "atomic" one:

Fixes bad commit b284ac3 ("debugability: Macro Metaprogramming
Refactor") that accidentally swapped mtrace_event() and
mtrace_event_atomic()

Before that accidental inversion, _trace_event_mboxN() functions invoked
spin_lock_irq() whereas _trace_even_mbox_atomicN() did NOT take
locks. That was consistent with the non-mbox, DMA variants of these
functions. As explained in the message of commit 3dca7b7 ("trace:
dma: Add atomic and nowait DMA tracing support."), functions with the
_atomic() suffix,, are meant to be used in atomic contexts where the
lock is already taken.

Searching for spin_lock_irq() in the code after the bad commit shows
that the logic was inverted for the _mbox variants: the lock became used
for the _atomic() variants.

The reasons why I can't reproduce any actual issue are likely the same
reasons why this inversion was never noticed:

  • no multicore
  • very little use of trace_.*_atomic variants
  • spin_lock_irq() is re-entrant?

I merely noticed the inconsistency with DMA tracing while trying to
solve unrelated issues in the same places.

The non-mbox, DMA variants were not affected by the bad commit because
for DMA the lock was and is managed in a different file: dma-trace.c.

Searching "spin_lock_irq" in later commit b12a662 ("trace:
Remove metaprogramming from trace implementation") shows that it
preserved this inversion across this second refactor; it left the bug
untouched.

marc-hb added 3 commits May 26, 2021 02:45
Set the error code in "ret" and only exit the loop so we don't lose the
optional warnings at the end of the loop.

Signed-off-by: Marc Herbert <marc.herbert@intel.com>
Because why not.

Signed-off-by: Marc Herbert <marc.herbert@intel.com>
Fixes bad commit b284ac3 ("debugability: Macro Metaprogramming
Refactor") that accidentally swapped mtrace_event() and
mtrace_event_atomic()

Before that accidental inversion, _trace_event_mboxN() functions invoked
spin_lock_irq() whereas _trace_even_mbox_atomicN() did NOT take
locks. That was consistent with the non-mbox, DMA variants of these
functions. As explained in the message of commit 3dca7b7 ("trace:
dma: Add atomic and nowait DMA tracing support."), functions with the
`_atomic()` suffix,, are meant to be used in atomic contexts where the
lock is _already_ taken.

Searching for spin_lock_irq() in the code after the bad commit shows
that the logic was inverted for the _mbox variants: the lock became used
for the _atomic() variants.

The reasons why I can't reproduce any actual issue are likely the same
reasons why this inversion was never noticed:

- no multicore
- very little use of trace_.*_atomic variants
- spin_lock_irq() is re-entrant?

I merely noticed the inconsistency with DMA tracing while trying to
solve unrelated issues in the same places.

The non-mbox, DMA variants were not affected by the bad commit because
for DMA the lock was and is managed in a different file: dma-trace.c.

Searching "spin_lock_irq" in later commit b12a662 ("trace:
Remove metaprogramming from trace implementation") shows that it
preserved this inversion across this second refactor; it left the bug
untouched.

Signed-off-by: Marc Herbert <marc.herbert@intel.com>
@marc-hb marc-hb marked this pull request as ready for review May 26, 2021 04:18
@marc-hb marc-hb requested review from akloniex and bkokoszx as code owners May 26, 2021 04:18
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.

Last patch will be needed for rc3 and maybe TGL13. @keyonjie @slawblauciak @mwasko

@marc-hb marc-hb requested a review from iuliana-prodan May 26, 2021 16:29
@lgirdwood lgirdwood merged commit 2cbeabe into thesofproject:main May 27, 2021
@marc-hb marc-hb deleted the mtrace-atomic branch June 27, 2021 19:36
@marc-hb marc-hb mentioned this pull request Jul 19, 2021
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