Skip to content

Compositor: a window's buffers map at fixed ranges - #134

Merged
aoinoikaz merged 1 commit into
mainfrom
compositor-buffer-ranges
Nov 12, 2026
Merged

aoinoikaz merged 1 commit into
mainfrom
compositor-buffer-ranges

Conversation

@aoinoikaz

@aoinoikaz aoinoikaz commented Nov 12, 2026 •

Copy link
Copy Markdown
Contributor

The compositor maps each buffer a window gives at an address no mapping has used, so a client that gives buffers in a loop uses up its address space, after which every give fails until the compositor restarts. Nothing says what happens to a buffer the kernel's table of 128 mappings has no room for.

Each of a window's three buffer numbers keeps one range of 128 MiB. A buffer given under a number is mapped at that range's start once the buffer the range held is unmapped. The rules refuse the number of the buffer being read first, so no pixel a frame reads is unmapped.

The table is as it was. display.md D6 counts what the compositor holds of it, 7 + 2s for a screen of s sections, and says which screens have room for three, two and one buffers of their own size: up to 24, 30 and 40 sections. A buffer with no room is refused by name: buffer map failed status=7 or buffer size read failed status=7, nothing of it left mapped, its window closed with reason=buffer. A screen of more than 60 sections, as 7680 x 4320 is, takes the table with the compositor's own mappings, so the compositor ends and the console takes the display. #78 lifts the table.

Checked: tools/check-mapping.c under the sanitizers, where a million gives leave the addresses as they were and 11 deliberate breaks of the library are each caught; 75 of 75 files against SHA256SUMS; the window boot under TCG.

Not checked: a boot at 7680 x 4320, which the firmware here does not set, so that case is derived, and simulated with a table filled by hand. No boot gives a second buffer under a number.

Closes #105

Base automatically changed from compositor-budgets to main November 12, 2026 17:36
The compositor mapped each buffer a window gave at the next address no
mapping had used and unmapped the one it replaced, so a client giving
buffers in a loop walked its address space upward until every give
failed. It keeps one range of 128 MiB for each buffer number, and a
buffer given under a number is mapped at that range's start once the
buffer the range held is unmapped. The rules refuse the number of the
buffer being read first, so no pixel a frame reads is unmapped.

lib/mapping.c holds the ranges: mapping_range_reserve keeps one,
mapping_range_image maps an image in it in place of the one it holds,
and mapping_range_clear unmaps what it holds. mapping_image maps
through the same code, gives back no size, which nothing read, and
leaves the next address where it was when an image is refused.

The kernel's table of 128 mappings for a process is as it was.
display.md D6 counts what the compositor holds of it at each screen
size, 11, 23 and 27 at the sizes the boots run and 135 at 7680 x 4320,
says which screens have room for one, two and three buffers of their
own size, and names how a buffer with no room is refused: its status
line, 7 for ERR_NO_MEMORY, nothing of it left mapped, and its window
closed for the reason buffer.

tools/check-mapping.c checks the ranges on the host, over stubs that
keep a process's mappings as the kernel does, its table of 128 among
them. A million images given to one range, to the ranges in turn, and
to ranges and at section counts drawn at random leave the addresses
used as they were, with one image's sections mapped in a range at a
time. An image the table has no room for, and one refused at each of
its sections, leaves nothing mapped and its range fit for the next.
@aoinoikaz
aoinoikaz force-pushed the compositor-buffer-ranges branch from 0532dba to 7562f9d Compare November 12, 2026 17:36
@aoinoikaz
aoinoikaz merged commit 3d98413 into main Nov 12, 2026
22 checks passed
@aoinoikaz
aoinoikaz deleted the compositor-buffer-ranges branch November 12, 2026 18: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.

Compositor: window buffer mappings reuse no address space and cap at 128

1 participant