⚠ This page is served via a proxy. Original site: https://github.com
This service does not collect credentials or authentication data.
Skip to content

Conversation

@jserv
Copy link
Contributor

@jserv jserv commented Jan 28, 2026

This implements Two-Level Segregated Fit (TLSF) allocator optimized for real-time scenarios:

  • O(1) malloc/free via bitmap-based segregated free lists
  • Branchless clz/ctz using mask-based shifts for RV32I compatibility
  • Immediate coalescing on free() to minimize fragmentation
  • Configurable FL_INDEX_MAX via CONFIG_TLSF_FL_INDEX_MAX
  • Bounds validation in block_remove/block_insert with panic on corruption
  • Sentinel placement validation in mo_heap_init
  • Block header sanity checks in free() to detect double-free

Test coverage:

  • Block coalescing verification
  • Realloc in-place growth
  • Block splitting logic
  • Heap exhaustion handling
  • FL/SL boundary allocations
  • Alignment verification
  • Bitmap stress tests

Summary by cubic

Replaced the first-fit allocator with a TLSF allocator to get O(1) malloc/free, lower fragmentation, and stronger corruption checks. API stays the same; adds extensive tests and a config knob for tuning.

  • New Features

    • TLSF with bitmap free lists: O(1) malloc/free, immediate coalescing, better in-place realloc.
    • RV32I-friendly: branchless clz/ctz replacements.
    • Configurable CONFIG_TLSF_FL_INDEX_MAX (default 28) to tune max alloc size vs. metadata.
    • Safety hardening: range checks with panic on corruption, sentinel and header validation, double-free detection.
    • New tests for coalescing, splitting, FL/SL boundaries, alignment, heap exhaustion, and bitmap stress.
  • Migration

    • No API changes; malloc/free/calloc/realloc work as before.
    • Review CONFIG_TLSF_FL_INDEX_MAX for your heap size (e.g., 24≈16MB, 28≈256MB, 30≈1GB).
    • Ensure mo_heap_init is given a zone large enough for TLSF headers; sentinel placement is validated at runtime.

Written for commit 48bb991. Summary will update on new commits.

cubic-dev-ai[bot]

This comment was marked as resolved.

This implements Two-Level Segregated Fit (TLSF) allocator optimized for
real-time scenarios:
- O(1) malloc/free via bitmap-based segregated free lists
- Branchless clz/ctz using mask-based shifts for RV32I compatibility
- Immediate coalescing on free() to minimize fragmentation
- Configurable FL_INDEX_MAX via CONFIG_TLSF_FL_INDEX_MAX
- Bounds validation in block_remove/block_insert with panic on corruption
- Sentinel placement validation in mo_heap_init
- Block header sanity checks in free() to detect double-free

Test coverage:
- Block coalescing verification
- Realloc in-place growth
- Block splitting logic
- Heap exhaustion handling
- FL/SL boundary allocations
- Alignment verification
- Bitmap stress tests
@github-actions
Copy link

Linmo CI Test Results

Overall Status: ✅ passed
Timestamp: 2026-01-28T19:01:06+00:00
Commit: 9cf086c

Toolchain Results

Toolchain Build Crash Test Functional
GNU ✅ passed ✅ passed ✅ passed
LLVM ✅ passed ⏭️ skipped ⏭️ skipped

Application Tests

App GNU LLVM
cond ✅ passed ⏭️ skipped
coop ✅ passed ⏭️ skipped
cpubench ✅ passed ⏭️ skipped
echo ✅ passed ⏭️ skipped
hello ✅ passed ⏭️ skipped
mqueues ✅ passed ⏭️ skipped
mutex ✅ passed ⏭️ skipped
pipes ✅ passed ⏭️ skipped
pipes_small ✅ passed ⏭️ skipped
pipes_struct ✅ passed ⏭️ skipped
prodcons ✅ passed ⏭️ skipped
progress ✅ passed ⏭️ skipped
rtsched ✅ passed ⏭️ skipped
semaphore ✅ passed ⏭️ skipped
suspend ✅ passed ⏭️ skipped
test64 ✅ passed ⏭️ skipped
test_libc ✅ passed ⏭️ skipped
timer ✅ passed ⏭️ skipped
timer_kill ✅ passed ⏭️ skipped
umode ⚠️ ⏭️ skipped

Functional Test Details

Test GNU LLVM
mutex:data_consistency ✅ passed ⏭️ skipped
mutex:fairness ✅ passed ⏭️ skipped
mutex:mutual_exclusion ✅ passed ⏭️ skipped
mutex:overall ✅ passed ⏭️ skipped
semaphore:overall ✅ passed ⏭️ skipped
umode:[exception]_illegal_instruction ✅ passed ⚠️
umode:pass:_sys_tid()_returned ✅ passed ⚠️
umode:pass:_sys_uptime()_returned ✅ passed ⚠️

Report generated from test-summary.toml

@sysprog21 sysprog21 deleted a comment from github-actions bot Jan 28, 2026
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