Skip to content
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

subsys/mgmt/mcumgr: Reduce unnecessary ROM usage #64288

Conversation

besmarsh
Copy link
Contributor

mcumgr's SMP UDP transport was unnecessarily using a potentially large amount of ROM space due to static initialising fields in a config struct that also contains buffers/stacks.

This has been changed to instead initialise fields in the start function, reducing ROM usage by ~5K in the default configuration with IPv4 and IPv6 enabled.

Comment on lines 391 to 396
configs.ipv4.proto = PROTOCOL_IPV6;
configs.ipv4.sock = -1;

Copy link
Collaborator

Choose a reason for hiding this comment

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

This is possibly falsely reducing usage because there are not the right fields

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@nordicjm Sorry, I'm not sure what you mean?

The ROM usage is reduced because by initialising the fields here rather than statically, the configs struct can be statically zero-initialised and doesn't need to go in ROM at all.

Copy link
Collaborator

Choose a reason for hiding this comment

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

These are .ipv4 but this is in the IPv6 section

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ah! Typo, good spot. Fixed now - ROM usage decrease is the same.

@besmarsh besmarsh force-pushed the reduce-large-unnecessary-rom-usage-in-mcumgr branch from f710cf9 to fa47eeb Compare October 24, 2023 12:20
nordicjm
nordicjm previously approved these changes Oct 24, 2023
@nordicjm
Copy link
Collaborator

@besmarsh would you be able to fix compliance issue?

de-nordic
de-nordic previously approved these changes Oct 27, 2023
@fabiobaltieri
Copy link
Member

Error: subsys/mgmt/mcumgr/transport/src/smp_udp.c:81:WARNING: Violation to rule 5.7 (Tag name should be unique) tag: configs

@besmarsh
Copy link
Contributor Author

@besmarsh would you be able to fix compliance issue?

Error: subsys/mgmt/mcumgr/transport/src/smp_udp.c:81:WARNING: Violation to rule 5.7 (Tag name should be unique) tag: configs

Sure, I can have a look. I haven't changed any names though, so should this have been caught before my changes? It looks like a case that slips through the checker.

@fabiobaltieri
Copy link
Member

Sure, I can have a look. I haven't changed any names though, so should this have been caught before my changes? It looks like a case that slips through the checker.

I see, yeah not too sure what the deal is but it's probably worth renaming the structure otherwise this will fire every time you touch this file. It's only used once anyway.

mcumgr's SMP UDP transport was unnecessarily using a potentially large
amount of ROM space due to static initialising fields in a
config struct that also contains buffers/stacks.

This has been changed to instead initialise fields in the start
function, reducing ROM usage by ~5K in the default configuration
with IPv4 and IPv6 enabled.

Signed-off-by: Ben Marsh <[email protected]>
@besmarsh besmarsh dismissed stale reviews from de-nordic and nordicjm via 68a0a18 November 1, 2023 10:00
@besmarsh besmarsh force-pushed the reduce-large-unnecessary-rom-usage-in-mcumgr branch from fa47eeb to 68a0a18 Compare November 1, 2023 10:00
The mcumgr SMP UDP configs struct was causing a unique tag name
violation (rule 5.7).

The struct name has been changed from configs to smp_udp_configs.

Signed-off-by: Ben Marsh <[email protected]>
Copy link
Collaborator

@nordicjm nordicjm left a comment

Choose a reason for hiding this comment

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

Missing signed off in second commit

@besmarsh besmarsh force-pushed the reduce-large-unnecessary-rom-usage-in-mcumgr branch from 68a0a18 to 6982f30 Compare November 1, 2023 10:02
@besmarsh
Copy link
Contributor Author

besmarsh commented Nov 1, 2023

All CI issues resolved.

@fabiobaltieri fabiobaltieri merged commit 18a0952 into zephyrproject-rtos:main Nov 1, 2023
16 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants