Skip to content

config: enabling madvise syscalls for user mode deallocations#133

Merged
benhillis merged 1 commit into
microsoft:product/hcl-main/6.12from
dpaliulis-msft:user/dpaliulis/enabling_madvise_syscalls
May 20, 2026
Merged

config: enabling madvise syscalls for user mode deallocations#133
benhillis merged 1 commit into
microsoft:product/hcl-main/6.12from
dpaliulis-msft:user/dpaliulis/enabling_madvise_syscalls

Conversation

@dpaliulis-msft
Copy link
Copy Markdown
Contributor

MiMalloc, the allocator for OpenHCL, uses madvise syscalls to decommit memory. With madvise disabled in the kernel, madvise never triggers, causing the physical memory to not be cleaned on a decommit. This results in a memory leak. This change enables madvise syscalls, allowing memory to be properly freed when decommits are invoked by MiMalloc. Lab tests show that this change introduces some initial memory overhead, but resolves the issue of memory growth with the memory leak repro.

Copilot AI review requested due to automatic review settings May 12, 2026 19:36
@dpaliulis-msft dpaliulis-msft changed the title Enabling mAdvise syscalls Enabling madvise syscalls May 12, 2026
Copy link
Copy Markdown

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 enables CONFIG_ADVISE_SYSCALLS in the OpenHCL kernel configs so madvise() (used by MiMalloc to decommit memory) is available, allowing physical pages to be reclaimed and preventing memory growth from decommit operations being ignored.

Changes:

  • Enable CONFIG_ADVISE_SYSCALLS=y for the x64 HCL kernel config.
  • Enable CONFIG_ADVISE_SYSCALLS=y for the arm64 HCL kernel config.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
Microsoft/hcl-x64.config Enables ADVISE_SYSCALLS so MiMalloc’s madvise()-based decommit can free memory on x64.
Microsoft/hcl-arm64.config Enables ADVISE_SYSCALLS so MiMalloc’s madvise()-based decommit can free memory on arm64.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@benhillis
Copy link
Copy Markdown
Member

Can you also submit a similar fix to the 6.18 branch please?

@dpaliulis-msft
Copy link
Copy Markdown
Contributor Author

Can you also submit a similar fix to the 6.18 branch please?

Yes, here is the PR for 6.18: PR 134

benhillis
benhillis previously approved these changes May 13, 2026
@saurabh-sengar saurabh-sengar self-requested a review May 16, 2026 11:40
Copy link
Copy Markdown
Collaborator

@saurabh-sengar saurabh-sengar left a comment

Choose a reason for hiding this comment

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

Can we please add the details of changes in commit message

@dpaliulis-msft dpaliulis-msft force-pushed the user/dpaliulis/enabling_madvise_syscalls branch from fd0f07f to 601360f Compare May 18, 2026 19:17
@dpaliulis-msft dpaliulis-msft changed the title Enabling madvise syscalls config: enabling madvise syscalls for user mode deallocations May 18, 2026
@dpaliulis-msft
Copy link
Copy Markdown
Contributor Author

Can we please add the details of changes in commit message

I have updated the commit subject and message with more substantial information on the changes.

saurabh-sengar
saurabh-sengar previously approved these changes May 20, 2026
smalis-msft
smalis-msft previously approved these changes May 20, 2026
@benhillis benhillis changed the base branch from project/hcl-dev/6.12 to product/hcl-main/6.12 May 20, 2026 20:32
@benhillis benhillis dismissed stale reviews from smalis-msft, saurabh-sengar, and themself May 20, 2026 20:32

The base branch was changed.

This config change includes madvise.o in the final build image, enabling madvise syscalls. This is necessary because MiMalloc (the allocator for OpenHCL) uses madvise syscalls to deallocate memory. Without this change, madvise is excluded from the final build image resulting in the syscalls for deallocating memory from the user mode being unrecognized by the kernel. This results in a major memory leak where no user mode process is able to free physical memory. OpenHCL builds with the kernel with this fix indicate steady memory usage in a reproduction scenario that would otherwise expose the memory leak.
Copilot AI review requested due to automatic review settings May 20, 2026 20:52
@dpaliulis-msft dpaliulis-msft force-pushed the user/dpaliulis/enabling_madvise_syscalls branch from 601360f to 6cd2986 Compare May 20, 2026 20:52
Copy link
Copy Markdown

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

Copilot reviewed 2 out of 2 changed files in this pull request and generated no new comments.

@benhillis benhillis merged commit 9218fd5 into microsoft:product/hcl-main/6.12 May 20, 2026
10 of 11 checks passed
benhillis added a commit to microsoft/openvmm that referenced this pull request May 22, 2026
This change updates the OpenHCL kernel to the latest version which
contains this patch:
microsoft/OHCL-Linux-Kernel#133

Huge props to @dpaliulis-msft for debugging this!

Co-authored-by: Ben Hillis <benhill@ntdev.microsoft.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.

5 participants