Skip to content

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

Open
kalyazin wants to merge 5 commits intoe2b-dev:mainfrom
kalyazin:fph
Open

Add downstream patch for wait ack in free page hinting#19
kalyazin wants to merge 5 commits intoe2b-dev:mainfrom
kalyazin:fph

Conversation

@kalyazin
Copy link
Copy Markdown

@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

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.

kalyazin and others added 5 commits May 8, 2026 16:57
Four folded changes, all aimed at making the build loop safe to run
when source files have been mutated by a previous iteration and
producing clear errors when tag resolution fails:

* Replace `git checkout <tag>` with `git reset --hard <tag>` followed by
  `git clean -fdx` (extracting the tag into a local variable).
* Bail with a clear error if `get_tag` finds no matching tag, so the
  build doesn't fall through to `git reset --hard ""`.
* Move the config copy to after the reset so it isn't clobbered by
  `git clean`.
* Drop the now-redundant `make distclean || true` at the top of the
  script — `git clean -fdx` inside `build_version` strictly subsumes it.

Behavior is identical for the no-patches case (the tag tree is unchanged
so reset is a no-op). Prep work for applying out-of-tree patches.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Signed-off-by: Nikita Kalyazin <nikita.kalyazin@e2b.dev>
Add a `patches/<kernel-version>/` mechanism: any .patch files placed in
that directory are applied with `git apply` after the source tree is
reset to the kernel tag and the .config is copied into place, before
`make olddefconfig`. Versions without a patch directory are built
unmodified, so this commit is a no-op until patches are added.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Signed-off-by: Nikita Kalyazin <nikita.kalyazin@e2b.dev>
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>
Reflow prose paragraphs and bullet items to ≤80 columns. No content
changes; code blocks and URLs are left intact (the markdown link to
model.go remains on a single line).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Signed-off-by: Nikita Kalyazin <nikita.kalyazin@e2b.dev>
Explain where out-of-tree patches live, when they are applied during
the build, and the workflow for adding a new patch via
`git format-patch`.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Signed-off-by: Nikita Kalyazin <nikita.kalyazin@e2b.dev>
@kalyazin
Copy link
Copy Markdown
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
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.

1 participant