-
Notifications
You must be signed in to change notification settings - Fork 3k
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
uVisor: Standardize available legacy heap and stack #3692
Conversation
/* Heap 1/4 of ram and stack 1/8 */ | ||
__stack_size__ = 0x8000; | ||
__heap_size__ = 0x10000; | ||
__stack_size__ = 0x400; |
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.
@Patater In both 3 files, it's probably a good idea to add a short comment stating that:
- These values do not affect the actually available heap for an app (they only guarantee a min).
- They do not affect the
main
stack size. - They are set that way because of uVisor.
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.
(or the changes might be lost in future updates).
33775d9
to
139c051
Compare
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.
👍 LGTM
/morph test |
I had to restart jenkins CI, as it was green but not reported here. |
__heap_size__ = 0x10000; | ||
/* With the RTOS in use, this does not affect the main stack size. The size of | ||
* the stack where main runs is determined via the RTOS. */ | ||
__stack_size__ = 0x400; |
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 fine for mbed 5. However, in case RTOS is not used (mbed 2), this radically decreasing stack size for MCU like k64f.
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 agree, without RTOS, the stack for the main function is reduced a lot. With RTOS, having this be large is a waste of memory, as the user application can never use this RAM (the RTOS uses it for its stack).
It's almost like we need two different linker scripts, one for with RTOS and one for without, unless we can come up with a good balanced number that isn't too bad of a choice for either platform. Any suggestions?
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.
The linker scripts already contain a conditional assignment like the following:
HEAP_SIZE = DEFINED(__heap_size__) ? __heap_size__ : 0x0400;
STACK_SIZE = DEFINED(__stack_size__) ? __stack_size__ : 0x0400;
so we could define those symbols somewhere else. In that way we can also define them depending on RTOS being used or not. @0xc0170 do you agree? What's the best place to place those definitions?
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.
Actually, doesn't the stack just start at the top of SRAM and grow down until it hits the heap? So, this would be a minimum stack size with mbed 2.
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.
True. So this should not be an issue @0xc0170
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.
Yes, I believe so.
LGTM
Result: FAILUREYour command has finished executing! Here's what you wrote!
OutputTest failed! |
The failure was caused by Windows 10 installing an update in the middle of a test. Even though I disabled it Microsoft still pushes them through sometimes it looks like 🙄 /morph test |
Result: SUCCESSYour command has finished executing! Here's what you wrote!
OutputAll builds and test passed! |
@Patater Can you resolve the conflict? |
With the RTOS, the STACK_SIZE specified here is unrelated to the stack size available for the main thread (that runs pre_main). Save memory by reducing the stack size to a more reasonable amount. On uVisor, HEAP_SIZE is both a minimum available and maximum available heap size. The heap can't grow beyond the end of the heap into the neighboring stack. On all uVisor-supported platforms, guarantee at least 0x6000 bytes of heap space. This increases the portability of uVisor applications as the memory available for legacy heap allocations is guaranteed. This helps to avoid out of memory errors on platforms that were previously guaranteeing less memory.
139c051
to
378655f
Compare
Rebased |
Looks like the native equeue test failed in Travis?
The test of concern being |
Huh, never seen that before. The timing of the test uses a delta of 10 milliseconds, so it's possible it may fail if the server is under significant load. Nothing in this pr is related to those tests at all. Restarted, considering the number of times those tests have been ran, I doubt it will be reproducible. |
Test seems to be ok now 👍 |
/morph test-nightly |
Result: SUCCESSYour command has finished executing! Here's what you wrote!
OutputAll builds and test passed! |
Ready for merge? |
We've intentionally moved away from hardcoded heap sizes rather giving the heap remaining RAM. If uVisor enforces this should we use uVisor specific symbols? |
@Patater @AlessandroA what do you think? |
Yes, uVisor can't protect a fine-grained, dynamically-sized heap. Additionally, applications are expected to use the uVisor-provided page heap. For these two reasons, the "legacy" heap is capped at the minimum heap size specified by Note that when |
Ports for Upcoming Targets Fixes and Changes 3432: Target STM USBHOST support ARMmbed/mbed-os#3432 3181: NUCLEO_F207ZG extending PeripheralPins.c: all available alternate functions can be used now ARMmbed/mbed-os#3181 3626: NUCLEO_F412ZG : Add USB Device +Host ARMmbed/mbed-os#3626 3628: Fix warnings ARMmbed/mbed-os#3628 3629: STM32: L0 LL layer ARMmbed/mbed-os#3629 3632: IDE Export support for platform VK_RZ_A1H ARMmbed/mbed-os#3632 3642: Missing IRQ pin fix for platform VK_RZ_A1H ARMmbed/mbed-os#3642 3664: Fix ncs36510 sleep definitions ARMmbed/mbed-os#3664 3655: [STM32F4] Modify folder structure ARMmbed/mbed-os#3655 3657: [STM32L4] Modify folder structure ARMmbed/mbed-os#3657 3658: [STM32F3] Modify folder structure ARMmbed/mbed-os#3658 3685: STM32: I2C: reset state machine ARMmbed/mbed-os#3685 3692: uVisor: Standardize available legacy heap and stack ARMmbed/mbed-os#3692 3621: Fix for #2884, LPC824: export to LPCXpresso, target running with wron ARMmbed/mbed-os#3621 3649: [STM32F7] Modify folder structure ARMmbed/mbed-os#3649 3695: Enforce device_name is valid in targets.json ARMmbed/mbed-os#3695 3723: NCS36510: spi_format function bug fix ARMmbed/mbed-os#3723
With the RTOS, the STACK_SIZE specified here is unrelated to the stack
size available for the main thread (that runs pre_main). Save memory by
reducing the stack size to a more reasonable amount.
On uVisor, HEAP_SIZE is both a minimum available and maximum available
heap size. The heap can't grow beyond the end of the heap into the
neighboring stack. On all uVisor-supported platforms, guarantee at least
0x6000 bytes of heap space. This increases the portability of uVisor
applications as the memory available for legacy heap allocations is
guaranteed. This helps to avoid out of memory errors on platforms that
were previously guaranteeing less memory.
Status
READY
@0xc0170 @AlessandroA