Skip to content

DRAM: add debugging for cold code violations - #9873

Merged
lgirdwood merged 2 commits into
thesofproject:mainfrom
lyakh:dram_assert
Mar 6, 2025
Merged

lgirdwood merged 2 commits into
thesofproject:mainfrom
lyakh:dram_assert

Conversation

@lyakh

@lyakh lyakh commented Mar 4, 2025

Copy link
Copy Markdown
Collaborator

Add assertions to check that cold code isn't called on hot paths

@lyakh

lyakh commented Mar 5, 2025

Copy link
Copy Markdown
Collaborator Author

@lgirdwood @kv2019i this PR adds a useful debugging feature, but if we keep adding that assertion to all __cold functions, it will be some potentially non-negligible overhead. Even for debug builds. I'd still have it enabled at least temporarily while we actively add cold functions. Once that's mostly stable, we can switch it off and then only switch on occasionally, e.g. when adding new cold functions, or just keep it on until performance becomes a problem

Comment thread src/schedule/zephyr_domain.c Outdated

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

can we have a comment here describing the API call

Comment thread src/schedule/zephyr_ll.c Outdated

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

ditto, a comment to describe the call

lyakh added 2 commits March 5, 2025 15:41
It is important not to run in DRAM code, that can be called on hot
paths, i.e. in LL-scheduler context. Add a Kconfig option to catch
such cases and enable it in debug builds.

Signed-off-by: Guennadi Liakhovetski <[email protected]>
Add cold code path checks to all __cold functions.

Signed-off-by: Guennadi Liakhovetski <[email protected]>

@jsarha jsarha left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM

@kv2019i kv2019i left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Do you envision this becoming a hard rule that any function marked with __cold must have this assert? This does add new boilerplate to audio modules that people may find distracting and/or add to the learning curve. OTOH, this is a nice debugging tool, so net positive I think.

@lyakh

lyakh commented Mar 6, 2025

Copy link
Copy Markdown
Collaborator Author

Do you envision this becoming a hard rule that any function marked with __cold must have this assert? This does add new boilerplate to audio modules that people may find distracting and/or add to the learning curve. OTOH, this is a nice debugging tool, so net positive I think.

@kv2019i I'm rather flexible about this. I think we should in the beginning put them everywhere. But then I don't think it must be a hard rule. We can grep the code from time to time and add any missing ones. Since production builds won't have that enabled, there will be no run-time difference apart from CI runs.

@lgirdwood
lgirdwood merged commit 50d0c92 into thesofproject:main Mar 6, 2025
@lyakh
lyakh deleted the dram_assert branch March 6, 2025 13:24
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.

4 participants