Skip to content

kernel: keep K_HEAP_MEM_POOL_SIZE defined when Gale replaces mempool.c (gale#401) - #1

Merged
avrabe merged 1 commit into
gale/sem-replacementfrom
fix/gale-mempool-keeps-heap-size
Sep 17, 2026
Merged

avrabe merged 1 commit into
gale/sem-replacementfrom
fix/gale-mempool-keeps-heap-size

Conversation

@avrabe

@avrabe avrabe commented Sep 17, 2026 •

Copy link
Copy Markdown

The Gale patch to kernel/CMakeLists.txt skipped the entire CONFIG_KERNEL_MEM_POOL block when CONFIG_GALE_KERNEL_MEMPOOL=y. That block also holds the only definition of K_HEAP_MEM_POOL_SIZE (zephyr_compile_definitions; checked across the tree). gale_mempool.c defines k_malloc, k_calloc, k_realloc, k_aligned_alloc and k_thread_system_pool_assign only under that macro, while kernel.h declares k_malloc unconditionally. So with Gale every mem-pool build declared k_malloc and never defined it: undefined reference to k_malloc (gale#401). kernel.h guards only k_thread_system_pool_assign with the macro. That makes kernel.threads.thread_stack's implicit declaration a likely second symptom, not yet confirmed.

Only mempool.c is now conditional; the heap-size computation is unchanged.

Review: independent read-only review confirmed six of seven claims (single definition site, block skipped on base, balanced if/endif, non-Gale behaviour identical, no duplicate symbols, no other changes). It refuted the original description's claim that kernel.h guards k_malloc, corrected above.

Compliance check: Gitlint's line length is fixed. The remaining failures are fork-wide, not this change: no gale commit on gale/sem-replacement carries Signed-off-by (all 7 were pushed directly), and the undefined-Kconfig findings are the CONFIG_GALE_KERNEL_* symbols that the external gale module defines.

Not built here. gale's upstream-vs-gale job clones gale/sem-replacement by name, so it measures this once merged. That same property means a merge changes every gale CI run immediately.

🤖 Generated with Claude Code

https://claude.ai/code/session_011QG86sovTbfnPNY9SfhSmo

The Gale patch skipped the whole CONFIG_KERNEL_MEM_POOL block when
CONFIG_GALE_KERNEL_MEMPOOL=y. That block does two things: adds mempool.c,
and defines K_HEAP_MEM_POOL_SIZE for the whole build, the only place it is
defined. gale_mempool.c defines k_malloc (and k_calloc, k_realloc,
k_aligned_alloc, k_thread_system_pool_assign) only under it, while kernel.h
declares k_malloc unconditionally. So with Gale every
CONFIG_KERNEL_MEM_POOL build declared k_malloc but never defined it:
'undefined reference to k_malloc'.

Only the source file is now conditional; the size computation and the
definition are unchanged and always run with CONFIG_KERNEL_MEM_POOL.

Measured in gale's upstream-vs-gale kernel delta (gale#401): the
benchmark.kernel.core and benchmark.kernel.latency* suites.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_011QG86sovTbfnPNY9SfhSmo
@avrabe
avrabe force-pushed the fix/gale-mempool-keeps-heap-size branch from c770980 to 3be234c Compare September 17, 2026 17:39
@avrabe
avrabe merged commit 9550d25 into gale/sem-replacement Sep 17, 2026
8 of 9 checks passed
@avrabe
avrabe deleted the fix/gale-mempool-keeps-heap-size branch September 17, 2026 17:53
avrabe added a commit to pulseengine/gale that referenced this pull request Sep 18, 2026
…e that the pin stays reachable) (#405)

* fix(ci): pin the Zephyr fork by revision — CI cloned a branch nothing recorded

All 15 `west init` sites cloned pulseengine/zephyr by BRANCH name
(`--mr gale/sem-replacement`), so a run's Zephyr was whatever that branch
held at the time and no gale commit recorded it. gale#401's 38 -> 0 kernel
delta spanned exactly such a change (pulseengine/zephyr#1 merged mid-issue):
the runs are honest, but not reproducible from gale's history alone.

The revision now lives in .github/zephyr-fork-pin, read by every site, with
a refusal if the file is empty. Taking a fork change becomes a reviewable
bump, like any other pin. Pinned at 9550d256 (current branch head).

New kill-criteria gate `zephyr-fork-pin`: the pin must be 40-hex AND still
reachable from gale/sem-replacement (compare status identical|ahead), so a
rebase or force-push on the fork fails here rather than in every Zephyr job
at once. It carries its own negative control — an unreachable revision must
be rejected by the same query. Both arms verified against the live fork:
identical for the pin, ahead for its parent, 404 for a fabricated sha. The
control branches on gh's EXIT STATUS: gh prints the 404 body to stdout, so
a string compare would have failed the gate for the wrong reason.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_011QG86sovTbfnPNY9SfhSmo

* fix(ci): apply the fork pin after clone — west init --mr cannot take a SHA

The first version passed the pinned revision to west init. west runs
'git clone --branch <rev>', which takes a branch or tag, so every Zephyr job
failed at once: 'fatal: Remote branch 9550d256... not found in upstream
origin' (56 checks).

Each of the 15 sites now inits on gale/sem-replacement, then fetches and
checks out the pinned revision in the manifest repo (<workspace>/zephyr,
per the fork's west.yml 'self: path: zephyr') BEFORE west update reads it,
and asserts HEAD equals the pin — an unpinned build would otherwise look
identical in the log.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_011QG86sovTbfnPNY9SfhSmo

---------

Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
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.

1 participant