dotnet / runtime

.NET is a cross-platform runtime for cloud, mobile, desktop, and IoT apps.
https://docs.microsoft.com/dotnet/core/
MIT License
15.12k stars 4.7k forks source link

Deduplicate cgroup code #99171

Open AustinWise opened 7 months ago

AustinWise commented 7 months ago

It appears this code has been copy-pasted 4 times:

I'm guessing a good place to put a consolidated implementation is in src/native/minipal/.

There is also a fifth copy written in C# at src/libraries/Common/src/Interop/Linux/cgroups/Interop.cgroups.cs. I'm not sure if it is worthwhile to change the C# code to delegated to a common unmanaged implementation.

jkotas commented 7 months ago

cc @janvorli

janvorli commented 7 months ago

I'm guessing a good place to put a consolidated implementation is in src/native/minipal/.

Yes, we've already moved the utf8 code there from the coreclr PAL in the past.

I was actually not aware that mono used a clone of that code too. If there are any differences, I believe the files in src/coreclr/pal/src/misc/cgroup.cpp and src/coreclr/gc/unix/cgroup.cpp should be the source of truth.