Skip to content

Conversation

@lyakh
Copy link
Collaborator

@lyakh lyakh commented Mar 4, 2025

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

@lyakh
Copy link
Collaborator Author

lyakh commented Mar 5, 2025

@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


return domain;
}

Copy link
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

scheduler_get_task_info(scheduler_props, data_off_size, &ll_sch->tasks);
zephyr_ll_unlock(ll_sch, &flags);
}

Copy link
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
Copy link
Collaborator Author

lyakh commented Mar 5, 2025

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 <guennadi.liakhovetski@linux.intel.com>
Add cold code path checks to all __cold functions.

Signed-off-by: Guennadi Liakhovetski <guennadi.liakhovetski@linux.intel.com>
Copy link
Contributor

@jsarha jsarha left a comment

Choose a reason for hiding this comment

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

LGTM

@lyakh
Copy link
Collaborator Author

lyakh commented Mar 6, 2025

CI:

"Internal" was clean before the last update and the last update only added comments, so it should be clean now too

Copy link
Collaborator

@kv2019i kv2019i left a comment

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
Copy link
Collaborator Author

lyakh commented Mar 6, 2025

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
43 of 49 checks passed
@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