Skip to content

Conversation

radekdoulik
Copy link
Member

Implements #117977

Also move the initialization of it and get of page size

Implements dotnet#117977

Also move the initialization of it and get of page size
@github-actions github-actions bot added the needs-area-label An area label is needed to ensure this gets routed to the appropriate area owners label Jul 29, 2025
@radekdoulik radekdoulik added area-PAL-coreclr and removed needs-area-label An area label is needed to ensure this gets routed to the appropriate area owners labels Jul 29, 2025
@radekdoulik radekdoulik modified the milestones: 10.0.0, Future Jul 29, 2025
Co-authored-by: Adeel Mujahid <[email protected]>
Do not care about cleanup
Do not move page size to minipal
Rename the files
Changes which were missed in earlier commits
@jkotas
Copy link
Member

jkotas commented Aug 12, 2025

Thoughts about switching Mono to this implementation too? The current Mono implementation does not look 100% reliable. It does not lock the memory in place, etc.

LGTM otherwise

@radekdoulik radekdoulik marked this pull request as ready for review August 18, 2025 09:10
@Copilot Copilot AI review requested due to automatic review settings August 18, 2025 09:10
Copy link
Contributor

@Copilot 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 implements the migration of FlushProcessWriteBuffers functionality from PAL to the minipal library. The change centralizes memory barrier operations across process-wide threads into a reusable minipal component, removing platform-specific implementations scattered throughout the runtime.

Key changes:

  • Creates new minipal memory barrier API with initialization and execution functions
  • Removes existing FlushProcessWriteBuffers implementations from PAL and runtime components
  • Updates all call sites to use the new minipal API

Reviewed Changes

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

Show a summary per file
File Description
src/native/minipal/memorybarrierprocesswide.h New header defining minipal memory barrier API
src/native/minipal/memorybarrierprocesswide.c Implementation of cross-platform memory barrier functionality
src/native/minipal/CMakeLists.txt Adds new source file to minipal build
src/coreclr/vm/*.cpp Updates call sites to use minipal API instead of FlushProcessWriteBuffers
src/coreclr/pal/src/thread/process.cpp Removes old FlushProcessWriteBuffers implementation
src/coreclr/pal/src/init/pal.cpp Updates initialization to use minipal function
src/coreclr/pal/src/include/pal/process.h Removes old function declaration
src/coreclr/pal/inc/pal.h Removes FlushProcessWriteBuffers export
src/coreclr/nativeaot/Runtime/*.cpp Updates NativeAOT runtime to use minipal API
src/coreclr/gc/*.cpp Updates GC components to use minipal API

@radekdoulik
Copy link
Member Author

Thoughts about switching Mono to this implementation too? The current Mono implementation does not look 100% reliable. It does lock the memory in place, etc.

I have opened sub-issue for it and we can try it in a followup PR #118834

@radekdoulik radekdoulik enabled auto-merge (squash) August 19, 2025 12:20
@radekdoulik radekdoulik merged commit 0b0b4b2 into dotnet:main Aug 19, 2025
159 of 161 checks passed
@simonrozsival
Copy link
Member

/backport to release/10.0

Copy link
Contributor

Started backporting to release/10.0: https://github.com/dotnet/runtime/actions/runs/17152675956

@pavelsavara
Copy link
Member

pavelsavara commented Aug 22, 2025

src/native/minipal/memorybarrierprocesswide.c here broke WASI compilation

Log

 FAILED: minipal/CMakeFiles/minipal_objects.dir/memorybarrierprocesswide.c.obj 
  D:\a\_work\1\s\src\mono\wasi\wasi-sdk\bin\clang.exe --target=wasm32-wasip2 --sysroot=D:/a/_work/1/s/src/mono/wasi/wasi-sdk/share/wasi-sysroot -DCOMPILER_SUPPORTS_W_RESERVED_IDENTIFIER -DHOST_32BIT=1 -DHOST_WASI -DHOST_WASM -DNDEBUG -DTARGET_32BIT -DTARGET_WASI -DTARGET_WASM -DURTBLDENV_FRIENDLY=Retail -D_FILE_OFFSET_BITS=64 -D_TIME_BITS=64 -ID:/a/_work/1/s/src/native -ID:/a/_work/1/s/artifacts/obj/native/net10.0-wasi-Release-wasm/minipal -O3 -DNDEBUG -std=gnu11 -MD -MT minipal/CMakeFiles/minipal_objects.dir/memorybarrierprocesswide.c.obj -MF minipal\CMakeFiles\minipal_objects.dir\memorybarrierprocesswide.c.obj.d -o minipal/CMakeFiles/minipal_objects.dir/memorybarrierprocesswide.c.obj -c D:/a/_work/1/s/src/native/minipal/memorybarrierprocesswide.c
  In file included from D:/a/_work/1/s/src/native/minipal/memorybarrierprocesswide.c:10:
  D:/a/_work/1/s/src/mono/wasi/wasi-sdk/share/wasi-sysroot/include/wasm32-wasip2\sys/mman.h:2:2: error: "WASI lacks a true mmap; to enable minimal mmap emulation, compile with -D_WASI_EMULATED_MMAN and link with -lwasi-emulated-mman"
  
      2 | #error "WASI lacks a true mmap; to enable minimal mmap emulation, \
  
        |  ^
  
  1 error generated.

@github-actions github-actions bot locked and limited conversation to collaborators Sep 22, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants