Skip to content

Conversation

@iddm
Copy link

@iddm iddm commented Jun 20, 2025

This allows the compute instances to have the tools (for now just perf and the kernel headers) available in the guest VM, so that the VM can use those. These tools are required to be passed through only because they are tied to the kernel version they were built for. However, for the future, we are not limited to only such a use case and can basically include anything.

@iddm iddm requested a review from Copilot June 20, 2025 11:01
@iddm iddm self-assigned this Jun 20, 2025
@iddm iddm marked this pull request as draft June 20, 2025 11:01
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR enhances the neonvm project by building and passing the perf binary to the neonvm runner. The changes include adding a new tools path configuration in the runner and disks modules, updating Dockerfiles to copy the tools binary, and modifying the Makefile to handle the tools artifacts.

Reviewed Changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
neonvm-runner/cmd/main.go Introduced a new constant and flag for tools path; updated the call to setupVMDisks.
neonvm-runner/cmd/disks.go Updated setupVMDisks to accept a Config object; added a block to generate an ISO for tools.
neonvm-runner/Dockerfile Copied the tools directory and created a symlink for the perf binary.
neonvm-kernel/Dockerfile Extended package installations and added build steps to compile and copy the perf binary.
neonvm-kernel/.gitignore Updated to ignore the tools directory.
Makefile Modified to remove previous tools and copy the updated tools from the Docker image.
.github/workflows/build-images.yaml Updated to copy the tools directory from the image.

@iddm iddm force-pushed the iddm/include-perf-into-linux-image branch 2 times, most recently from 8b414fb to 52bc4c9 Compare June 26, 2025 10:39
@iddm iddm marked this pull request as ready for review June 26, 2025 11:22
@iddm iddm requested a review from mikhail-sakhnov June 26, 2025 11:40
Copy link
Member

@petuhovskiy petuhovskiy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Would be nice to try running this perf on staging, both on x86/ARM, for postgres 15/16/17, to confirm that it's working in all possible configurations.

@myrrc myrrc self-requested a review June 30, 2025 13:09
@iddm iddm force-pushed the iddm/include-perf-into-linux-image branch 2 times, most recently from f381d63 to 221018d Compare June 30, 2025 20:39
@iddm iddm requested a review from mikhail-sakhnov July 1, 2025 08:48
Copy link
Member

@sharnoff sharnoff left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Left some comments -- broadly looks ok, mostly just some specifics

@iddm iddm force-pushed the iddm/include-perf-into-linux-image branch from bd11834 to a64c2a6 Compare July 8, 2025 11:07
@iddm iddm changed the title neonvm: build and pass perf binary to neonvm runner neonvm: build and pass kernel tools to neonvm runner Jul 9, 2025
@iddm
Copy link
Author

iddm commented Jul 9, 2025

Added kernel headers.

Copy link
Member

@sharnoff sharnoff left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm!

@sharnoff sharnoff removed their assignment Jul 16, 2025
@iddm
Copy link
Author

iddm commented Jul 24, 2025

In the known place will require this as well:

-    ignore=["autoscaling/neonvm-kernel/vmlinuz"],
+    ignore=["autoscaling/neonvm-kernel/vmlinuz", "autoscaling/neonvm-kernel/tools"],

@iddm
Copy link
Author

iddm commented Jul 24, 2025

Please do not merge this PR without me. I need to test that the headers and the kheaders.ko.zst are properly placed in the directories which are looked for by the bcc-profile at runtime.

@iddm iddm force-pushed the iddm/include-perf-into-linux-image branch from 762496c to d1f2ab1 Compare July 28, 2025 11:55
@iddm
Copy link
Author

iddm commented Aug 2, 2025

As we have changed in the compute to also allow using eBPFs, as well as there has been a long-awaiting request to support eBPFs fully, there are a bit more changes required now. In my last commit which I have just pushed, I have enabled the required kernel configuration options to enable us to use eBPFs at runtime successfully. The eBPFs now compile just fine, as some of those even work, but not all of them. This is due to the reason that some of the bpf headers require a kernel header file GEN-reg-for-each.h or something like that. This header is only generated for the x86 architecture and is not required for aarch64, so the latter should just work.

To pack the "tools", which now includes:

  1. perf binary.
  2. kernel headers and modules necessary for eBPFs and other kernel tools.

I had to make an adjustment in the ISO9660-generating code and change the version suffix of the kernel release name. First, the code for ISO9660 generation, which had existed before my changes, didn't recursively go through the contentPath and didn't package anything what isn't a file. In order to simplify the things, I made it work recursively over all the directories in the contentPath to include every single file from there, so to fully pack the contentPath into an iso-file. However, due to our naming of the kernel release, it wasn't possible to pack the things into the iso file as-is, as the ISO standard require no more than 31 characters per path entry, and our kernel release name for twice or even more than that. So I changed the version suffix to a much smaller one, still helpful, and also got approvals from the others from the autoscaling team.

I am going to leave for a couple of weeks now, so this is a list of the things i'll do once I come back:

  1. Change the arm64 kernel configuration file accordingly, to enable the same features as I have enabled for x86.
  2. Make sure the x86 required headers are generated and properly copied into the modules tree.

The testing can be done by tilt up full, and using the autoscaling changes and the compute changes.

@iddm
Copy link
Author

iddm commented Aug 20, 2025

The Iso9660, besides having character limits and other limits, also requires lower-casing the file names, for some reason. And our Go dependency for that did that as well. I thought about creating a vfat or ext4 image from the go code and it worked to some degree, but it was taking too much time, what would have influenced the startup time of the computes. So I opted in for another approach, which is to create the ext4 disk image file when building the kernel, and from the Go code simply passing it to qemu, so that we have it immediately and we require no additional work, almost not changing the startup performance of the computes at all.

The current approach allows the files to (obviously) have correct names and does not impose any other restrictions.

I tested the built kernel module and the headers with a compute, using bptrace, execsnoop-bpfcc and even our compute code, all seem to have worked. Will perform additional (proper) testing tomorrow, but we are almost there now.

iddm added 6 commits August 21, 2025 12:08
Fix the build issues of perf

Fix arm64 builds

Pass the tools through qemu to the compute.

Symlink perf to /usr/bin

Remove the commented out code.

Remove the tools directory when building kernel

Fix the way the tools are passed through to the VM

Mount and symlink the tools to /usr/local/bin inside the VM

Separate stages for kernel and the tools builds

Move the tools closer to vmlinuz

Try without arm64 ubuntu env

Don't symlink perf to $PATH.

Removes symlinking the perf binary to /usr/local/bin and
mounts it to '/neonvm/tools' instead.

Add kernel headers

Enable kheaders

Provide the kernel headers and kheaders.ko.zst
@iddm iddm force-pushed the iddm/include-perf-into-linux-image branch from 0f76b84 to 073c883 Compare August 21, 2025 10:08
@iddm iddm requested a review from sharnoff August 21, 2025 10:09
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.

5 participants