Skip to content

vm/map: fix shared maps allocated calculation#790

Merged
etiaro merged 1 commit into
masterfrom
etiaro/meminfo-fix
Jun 16, 2026
Merged

vm/map: fix shared maps allocated calculation#790
etiaro merged 1 commit into
masterfrom
etiaro/meminfo-fix

Conversation

@etiaro

@etiaro etiaro commented Jun 16, 2026

Copy link
Copy Markdown
Contributor

Description

Implementation was overestimating allocated memory when map memory was fragmented.

TASK: RTOS-1345

Motivation and Context

The result is used in psh mem -s command.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Chore (refactoring, style fixes, git/CI config, submodule management, no code logic changes)

How Has This Been Tested?

  • Already covered by automatic testing.
  • New test added: (add PR link here).
  • Tested by hand on: (list targets here).

Checklist:

  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have added tests to cover my changes.
  • All new and existing linter checks and tests passed.
  • My changes generate no new compilation warnings for any of the targets.

Special treatment

  • This PR needs additional PRs to work (list the PRs, preferably in merge-order).
  • I will merge this PR by myself when appropriate.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Code Review

This pull request updates the free memory calculation in vm/map.c by locking the map and iterating through all of its entries to subtract their sizes from the total map size. The review feedback points out that casting e->size to an int during this subtraction is unnecessary and risks integer truncation or overflow on systems with large mappings, suggesting direct subtraction instead.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

Comment thread vm/map.c Outdated
@etiaro etiaro force-pushed the etiaro/meminfo-fix branch from f1f1bd1 to 1c2621b Compare June 16, 2026 09:35
Implementation was overestimating allocated memory when map was
fragmented.

TASK: RTOS-1345
@etiaro etiaro force-pushed the etiaro/meminfo-fix branch from 1c2621b to 9014bf3 Compare June 16, 2026 09:40
@etiaro etiaro marked this pull request as ready for review June 16, 2026 09:56
@github-actions

Copy link
Copy Markdown

Unit Test Results

10 860 tests  +275   10 190 ✅ +275   53m 3s ⏱️ +55s
   670 suites + 21      670 💤 ±  0 
     1 files   ±  0        0 ❌ ±  0 

Results for commit 9014bf3. ± Comparison against base commit 57b3041.

This pull request removes 3 and adds 278 tests. Note that renamed tests count towards both.
phoenix-rtos-tests/libcache/unit ‑ armv7m4-stm32l4x6-nucleo:phoenix-rtos-tests/libcache/unit
phoenix-rtos-tests/libcache/unit ‑ armv7m7-imxrt106x-evk:phoenix-rtos-tests/libcache/unit
phoenix-rtos-tests/libcache/unit ‑ armv7m7-imxrt117x-evk:phoenix-rtos-tests/libcache/unit
phoenix-rtos-tests/libcache/unit ‑ armv7m4-stm32l4x6-nucleo:phoenix-rtos-tests/libcache/unit.test_callback_err.cache_cleanCallbackErr
phoenix-rtos-tests/libcache/unit ‑ armv7m4-stm32l4x6-nucleo:phoenix-rtos-tests/libcache/unit.test_callback_err.cache_flushCallbackErr
phoenix-rtos-tests/libcache/unit ‑ armv7m4-stm32l4x6-nucleo:phoenix-rtos-tests/libcache/unit.test_callback_err.cache_read_readCallbackErr
phoenix-rtos-tests/libcache/unit ‑ armv7m4-stm32l4x6-nucleo:phoenix-rtos-tests/libcache/unit.test_callback_err.cache_write_readCallbackErr
phoenix-rtos-tests/libcache/unit ‑ armv7m4-stm32l4x6-nucleo:phoenix-rtos-tests/libcache/unit.test_callback_err.cache_write_writeCallbackErr
phoenix-rtos-tests/libcache/unit ‑ armv7m4-stm32l4x6-nucleo:phoenix-rtos-tests/libcache/unit.test_clean.cache_clean_addrOutOfScope
phoenix-rtos-tests/libcache/unit ‑ armv7m4-stm32l4x6-nucleo:phoenix-rtos-tests/libcache/unit.test_clean.cache_clean_addrPartiallyInScope
phoenix-rtos-tests/libcache/unit ‑ armv7m4-stm32l4x6-nucleo:phoenix-rtos-tests/libcache/unit.test_clean.cache_clean_badAddrRange
phoenix-rtos-tests/libcache/unit ‑ armv7m4-stm32l4x6-nucleo:phoenix-rtos-tests/libcache/unit.test_clean.cache_clean_lines
phoenix-rtos-tests/libcache/unit ‑ armv7m4-stm32l4x6-nucleo:phoenix-rtos-tests/libcache/unit.test_deinit.cache_deinit_initalizedCache
…

@etiaro etiaro requested review from a team, adamgreloch, agkaminski, julianuziemblo and ziemleszcz and removed request for adamgreloch, agkaminski, julianuziemblo and ziemleszcz June 16, 2026 10:02
@etiaro etiaro merged commit 24b0e06 into master Jun 16, 2026
51 checks passed
@etiaro etiaro deleted the etiaro/meminfo-fix branch June 16, 2026 11:04
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.

2 participants