-
Notifications
You must be signed in to change notification settings - Fork 7k
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
Bluetooth: Controller: Support Link Time Optimizations (LTO) #70251
Conversation
Is this really the way we want to go? Certain subsystems enabling LTO by default, other don't? |
LTO has been introduced recently and not enabled for default across the builds probably for a reason? Atleast, for the Bluetooth Controller included builds, i am not observing any regression in my (may be limited) manual testing. Suggestions welcome if we want all builds to be Link Time Optimized. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it's too early to automatically enable LTO, even for a subsystem. We are still seeing issues like #70305
Users can enable the setting if they want it manually, I don't really see the value in having it automatically set. Which, I would assume, would then cause problems if they use a debug build and try to step through the bluetooth code |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it's too early to automatically enable LTO, even for a subsystem. We are still seeing issues like #70305
I agree, considering the complexity of Zephyr, the need for whole-archive, link post-processing, etc. then I think there are too many variables to enable this per-default.
Although this has been tested for a single sub-system, then what happens when that subsystem is combined with the myriad of other options / subsystems / SoCs which may not have been verified to work properly with LTO ?
Also, having this config option inside a sub-system can give the false impression that the setting only applies to part of the build, which is not the case.
Technically, if using partial linking of subsystems before a final linking it would be possible to apply lto on just part of the linking (gcc/ld) on a subsystem, but that's not what this setting does, and would be a completely different task 🙂 .
config BT_CTLR_LTO | ||
bool "Link Time Optimization" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is not a good location for this setting.
It may give the impression that LTO is only applied on this subsystem, which is actually not the case.
Enabling LTO here will enable LTO for the Zephyr build.
One may say, of course, that should be obvious
, but in Zephyr we are actually having parts which could be using LTO while other parts would not be using it, for example for the TF-M secure build.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have now added depends on ARM && BT_HCI_RAW
, this will restrict LTO to samples/application that build only the controller subsystem (aka hci_uart, hci_ipc... and so on) with a HCI transport.
And on the hci_ipc for now needs reduced code space usage in-order to support ISO features and be able to have spare space for DFU.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed && BT_HCI_RAW
as normal samples/application would like to use LTO.
c32dc9e
to
63c627f
Compare
2521a0e
to
d17a985
Compare
@@ -598,12 +598,29 @@ config BT_CTLR_DYNAMIC_INTERRUPTS | |||
permit use of SoC's peripheral for custom use when Bluetooth is not | |||
enabled. | |||
|
|||
choice | |||
prompt "Optimazation options" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like a typo snuck in here: "Optimazation" -> "Optimization"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, just realized that moving to choice
means I need to also have the optimize for space which would be the alternative when optimize for speed need to be disabled (and no LTO) for the Controller.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are some interdependencies that looks messy to me.
Currently it's possible to set LTO
and BT_CTLR_OPTIMIZE_FOR_SPEED
90d01e9
to
59dd08c
Compare
894d284
to
fecb9fa
Compare
@henrikbrixandersen and @tejlmand Any chance you can take a second look as to if the concerns are addressed? |
Remove legacy LL optimize for speed dependency required to support encryption feature in Controller where crypto was performed in highest priority ISRs to setup encryption in 3 radio events (this now requires 5 radio events in split LL). Signed-off-by: Vinayak Kariappa Chettimada <[email protected]>
fecb9fa
to
5d40111
Compare
Support for using Link Time Optimization (LTO) when building application with open source Bluetooth Low Energy Controller. This reduces code space usage. Current Memory Usage at the time of this PR (hci_ipc): BT_CTLR_OPTIMIZE_FOR_SPEED: Memory region Used Size Region Size %age Used FLASH: 260112 B 256 KB 99.22% RAM: 60136 B 64 KB 91.76% SRAM1: 0 B 64 KB 0.00% IDT_LIST: 0 B 32 KB 0.00% BT_CTLR_OPTIMIZE_FOR_SIZE: Memory region Used Size Region Size %age Used FLASH: 232292 B 256 KB 88.61% RAM: 60128 B 64 KB 91.75% SRAM1: 0 B 64 KB 0.00% IDT_LIST: 0 B 32 KB 0.00% BT_CTLR_OPTIMIZE_FOR_APP_DEFAULT: Memory region Used Size Region Size %age Used FLASH: 232292 B 256 KB 88.61% RAM: 60128 B 64 KB 91.75% SRAM1: 0 B 64 KB 0.00% IDT_LIST: 0 B 32 KB 0.00% BT_CTLR_LTO: Memory region Used Size Region Size %age Used FLASH: 221484 B 256 KB 84.49% RAM: 60120 B 64 KB 91.74% SRAM1: 0 B 64 KB 0.00% IDT_LIST: 0 B 32 KB 0.00% Signed-off-by: Vinayak Kariappa Chettimada <[email protected]>
Added build time coverage for added new Controller optimization related Kconfigs. New Kconfigs are either covered in samples.yaml or in the tests/bluetooth/init conf files. Signed-off-by: Vinayak Kariappa Chettimada <[email protected]>
Use Link Time Optimisation (LTO) when building Controller with Isochronous channels support. nRF53x SoCs has 256KB flash and using speed optimisation, which is the default today, overflows flash when adding new features related to ISO support. Signed-off-by: Vinayak Kariappa Chettimada <[email protected]>
5d40111
to
4ad6817
Compare
Support for using Link Time Optimization (LTO) when
building application with open source Bluetooth Low
Energy Controller. This reduces code space usage.
Use Link Time Optimisation (LTO) when building Controller
with Isochronous channels support.
nRF53x SoCs has 256KB flash and using speed optimisation,
which is the default today, overflows flash when adding
new features related to ISO support.
Signed-off-by: Vinayak Kariappa Chettimada [email protected]