Skip to content

Conversation

@lyakh
Copy link
Collaborator

@lyakh lyakh commented Jan 30, 2026

Trace context isn't used when building LLEXT, move it to monolithic build part. In many cases this eliminates the entire module's .data section.

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR optimizes memory usage in LLEXT (Loadable EXTensions) builds by moving trace context declarations from global scope to monolithic build sections. The trace contexts are only needed when building modules directly into the base firmware, not when building loadable extensions.

Changes:

  • Removed global DECLARE_TR_CTX declarations from 38 audio module files
  • Re-added DECLARE_TR_CTX declarations within #else blocks (non-LLEXT/monolithic builds) where DECLARE_MODULE_ADAPTER is used
  • Removed EXPORT_SYMBOL(tflm_tr) from tensorflow module as it's no longer globally accessible

Reviewed changes

Copilot reviewed 38 out of 38 changed files in this pull request and generated no comments.

Show a summary per file
File Description
src/debug/tester/tester.c Moved DECLARE_TR_CTX to monolithic build section after SOF_LLEXT_BUILDINFO
src/audio/up_down_mixer/up_down_mixer.c Moved DECLARE_TR_CTX to end of file before DECLARE_MODULE_ADAPTER
src/audio/tone/tone-ipc4.c Moved DECLARE_TR_CTX to monolithic build section after SOF_LLEXT_BUILDINFO
src/audio/tone/tone-ipc3.c Moved DECLARE_TR_CTX before comp_driver definition (no LLEXT support)
src/audio/tensorflow/tflm-classify.c Removed DECLARE_TR_CTX and EXPORT_SYMBOL(tflm_tr), re-added in monolithic section
src/audio/template/template.c Moved DECLARE_TR_CTX to monolithic build section with explanatory comment
src/audio/tdfb/tdfb.c Moved DECLARE_TR_CTX to monolithic build section after SOF_LLEXT_BUILDINFO
src/audio/stft_process/stft_process.c Moved DECLARE_TR_CTX to monolithic build section after SOF_LLEXT_BUILDINFO
src/audio/sound_dose/sound_dose.c Moved DECLARE_TR_CTX to monolithic build section after SOF_LLEXT_BUILDINFO
src/audio/smart_amp/smart_amp.c Moved DECLARE_TR_CTX to end of file before DECLARE_MODULE_ADAPTER
src/audio/selector/selector.c Moved DECLARE_TR_CTX declarations for both IPC3 and IPC4 sections appropriately
src/audio/multiband_drc/multiband_drc.c Moved DECLARE_TR_CTX to monolithic build section after SOF_LLEXT_BUILDINFO
src/audio/module_adapter/module/waves/waves.c Moved DECLARE_TR_CTX to monolithic build section after SOF_LLEXT_BUILDINFO
src/audio/module_adapter/module/passthrough.c Moved DECLARE_TR_CTX to end of file before DECLARE_MODULE_ADAPTER
src/audio/module_adapter/module/modules.c Removed DECLARE_TR_CTX (not needed as no DECLARE_MODULE_ADAPTER)
src/audio/module_adapter/module/dolby/dax.c Moved DECLARE_TR_CTX to monolithic build section after SOF_LLEXT_BUILDINFO
src/audio/module_adapter/module/cadence.c Moved DECLARE_TR_CTX to end of file before DECLARE_MODULE_ADAPTER
src/audio/mixin_mixout/mixin_mixout.c Moved both mixin_tr and mixout_tr DECLARE_TR_CTX to monolithic build section
src/audio/mixer/mixer.c Moved DECLARE_TR_CTX to end of file before DECLARE_MODULE_ADAPTER
src/audio/mfcc/mfcc.c Moved DECLARE_TR_CTX to monolithic build section after SOF_LLEXT_BUILDINFO
src/audio/level_multiplier/level_multiplier.c Moved DECLARE_TR_CTX to monolithic build section after SOF_LLEXT_BUILDINFO
src/audio/kpb.c Moved DECLARE_TR_CTX before comp_driver definition
src/audio/igo_nr/igo_nr.c Moved DECLARE_TR_CTX to monolithic build section after SOF_LLEXT_BUILDINFO
src/audio/host-zephyr.c Moved DECLARE_TR_CTX before comp_driver definition
src/audio/host-legacy.c Moved DECLARE_TR_CTX before comp_driver definition
src/audio/google/google_rtc_audio_processing.c Moved DECLARE_TR_CTX to monolithic build section after SOF_LLEXT_BUILDINFO
src/audio/google/google_hotword_detect.c Moved DECLARE_TR_CTX before comp_driver definition
src/audio/google/google_ctc_audio_processing.c Moved DECLARE_TR_CTX to monolithic build section after SOF_LLEXT_BUILDINFO
src/audio/eq_iir/eq_iir.c Moved DECLARE_TR_CTX to monolithic build section after SOF_LLEXT_BUILDINFO
src/audio/eq_fir/eq_fir.c Moved DECLARE_TR_CTX to monolithic build section after SOF_LLEXT_BUILDINFO
src/audio/dcblock/dcblock.c Moved DECLARE_TR_CTX to monolithic build section after SOF_LLEXT_BUILDINFO
src/audio/dai-zephyr.c Moved DECLARE_TR_CTX before comp_driver definition
src/audio/dai-legacy.c Moved DECLARE_TR_CTX before comp_driver definition
src/audio/crossover/crossover.c Moved DECLARE_TR_CTX to monolithic build section after SOF_LLEXT_BUILDINFO
src/audio/copier/copier_ipcgtw.c Removed DECLARE_TR_CTX (not needed as no DECLARE_MODULE_ADAPTER)
src/audio/copier/copier.c Moved DECLARE_TR_CTX before DECLARE_MODULE_ADAPTER
src/audio/codec/dts/dts.c Moved DECLARE_TR_CTX to monolithic build section after SOF_LLEXT_BUILDINFO
src/audio/aria/aria.c Moved DECLARE_TR_CTX to monolithic build section after SOF_LLEXT_BUILDINFO

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@lyakh
Copy link
Collaborator Author

lyakh commented Feb 2, 2026

@lrudyX please confirm that QB failures are unrelated. This PR should have no runtime effects, as long as you don't use Tensor Flow

@lrudyX
Copy link

lrudyX commented Feb 2, 2026

@lrudyX please confirm that QB failures are unrelated. This PR should have no runtime effects, as long as you don't use Tensor Flow

AEC tests failed, unfortunately I think those are related.

Copy link
Contributor

@tmleman tmleman left a comment

Choose a reason for hiding this comment

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

If you had mentioned in the commit message that ipcgtw_comp_tr and intel_codec_tr are not used anywhere, I wouldn't have to check why they were treated differently 😉

BTW, the CI failures are caused by these changes:

[    0.581580] <inf> llext: llext_load: Loaded extension RTC_AEC
[    0.581686] <err> lib_manager: llext_manager_load_module: .bss 0x33e00 @0xa068b000 isn't within writable data 0x0 @(nil)!
[    0.581778] <err> lib_manager: lib_manager_module_create: lib_manager_allocate_module() failed!
[    0.581820] <err> ipc: ipc4_init_module_instance: error: failed to init module 1000 : 0
[    0.581848] <err> ipc: ipc_cmd: ipc4: MODULE_MSG failed with err 104

@lyakh
Copy link
Collaborator Author

lyakh commented Feb 2, 2026

[    0.581580] <inf> llext: llext_load: Loaded extension RTC_AEC
[    0.581686] <err> lib_manager: llext_manager_load_module: .bss 0x33e00 @0xa068b000 isn't within writable data 0x0 @(nil)!
[    0.581778] <err> lib_manager: lib_manager_module_create: lib_manager_allocate_module() failed!
[    0.581820] <err> ipc: ipc4_init_module_instance: error: failed to init module 1000 : 0
[    0.581848] <err> ipc: ipc_cmd: ipc4: MODULE_MSG failed with err 104

aah, nice! This is a separate bug, but uncovered by these changes. Let me fix.

If a module has .bss and no .data the sanity check will fail. Add a
check for that case.

Signed-off-by: Guennadi Liakhovetski <[email protected]>
Trace context isn't used when building LLEXT, move it to monolithic
build part. In many cases this eliminates the entire module's .data
section.

Signed-off-by: Guennadi Liakhovetski <[email protected]>
@lgirdwood lgirdwood merged commit add83b8 into thesofproject:main Feb 2, 2026
44 of 52 checks passed
@lyakh lyakh deleted the trace branch February 2, 2026 14:42
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.

5 participants