Skip to content

Add downstream patch for wait ack in free page hinting#19

Merged
ValentaTomas merged 1 commit into
e2b-dev:mainfrom
kalyazin:fph
May 11, 2026
Merged

Add downstream patch for wait ack in free page hinting#19
ValentaTomas merged 1 commit into
e2b-dev:mainfrom
kalyazin:fph

Conversation

@kalyazin
Copy link
Copy Markdown
Contributor

@kalyazin kalyazin commented May 8, 2026

In order to avoid potential corruption of guest pages due to a race condition under memory pressure in the guest, apply patch when building the kernel.

@cla-bot cla-bot Bot added the cla-signed label May 8, 2026
@cursor
Copy link
Copy Markdown

cursor Bot commented May 8, 2026

PR Summary

High Risk
Touches low-level virtio-balloon hinting synchronization and adds a new negotiated feature bit, which can introduce hangs/perf regressions if the device doesn’t ACK as expected or the feature is mis-negotiated.

Overview
Adds a downstream kernel patch that introduces VIRTIO_BALLOON_F_HINT_WAIT_ON_ACK to make free page hinting wait for a device ACK before moving hinted pages onto the guest’s free-page list.

When the feature is negotiated, the free-page virtqueue uses balloon_ack and the driver blocks after kicking (including start/stop command IDs) until the device returns a buffer; the feature is also validated to depend on VIRTIO_BALLOON_F_FREE_PAGE_HINT and is advertised in the driver feature list.

Reviewed by Cursor Bugbot for commit 5f96bc5. Bugbot is set up for automated code reviews on this repo. Configure here.

@kalyazin
Copy link
Copy Markdown
Contributor Author

kalyazin commented May 8, 2026

PR Summary

Medium Risk Applies an out-of-tree kernel patch that changes virtio-balloon free page hinting behavior and can affect guest memory management/performance if the new feature is negotiated. Build flow now force-resets/cleans the kernel tree per version, which can fail or mask issues if tag resolution is wrong.

Overview The build now force-resets the linux source tree to the resolved tag and applies any patches/<version>/*.patch before running make olddefconfig, which can break builds if get_tag returns empty or if patches don’t apply cleanly.

A new downstream patch for 6.1.158 adds VIRTIO_BALLOON_F_HINT_WAIT_ON_ACK and makes free page hinting wait for a device ACK, which can increase hinting latency and potentially block if the device never acks.

Reviewed by Cursor Bugbot for commit 1baa63b. Bugbot is set up for automated code reviews on this repo. Configure here.

fixed in 7aba4fc

@ValentaTomas ValentaTomas requested a review from bchalios May 8, 2026 17:41
@ValentaTomas ValentaTomas enabled auto-merge (squash) May 9, 2026 02:32
@ValentaTomas ValentaTomas disabled auto-merge May 9, 2026 02:32
Pull in commit b90e190a95c2 ("virtio_balloon: Support wait on ACK for
hinting") by Jack Thomson <jackabt@amazon.com>. Adds a new virtio
feature flag VIRTIO_BALLOON_F_HINT_WAIT_ON_ACK that makes the driver
wait for device ACK before adding hinted ranges to the free_page_list,
enabling MADV_DONTNEED-based RSS reduction. Trades ~30% hinting
duration overhead for the synchronisation guarantee. Applied only to
6.1.158 (the only fc-kernels version we currently want this on).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Signed-off-by: Nikita Kalyazin <nikita.kalyazin@e2b.dev>
@ValentaTomas ValentaTomas merged commit c1a568c into e2b-dev:main May 11, 2026
16 of 19 checks passed
@kalyazin kalyazin deleted the fph branch May 11, 2026 21:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants