-
Notifications
You must be signed in to change notification settings - Fork 5.4k
Exclude cgroup implementation from non-Linux Unix builds #126738
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
Copilot
wants to merge
6
commits into
main
Choose a base branch
from
copilot/exclude-cgroup-variants-non-linux
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+65
−40
Open
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
a1c1573
Initial plan
Copilot 689c080
Exclude cgroup code from non-Linux Unix builds using TARGET_LINUX/TAR…
Copilot bdf2f36
Move PAL_GetCpuLimit into both branches of the TARGET_LINUX/TARGET_AN…
Copilot da6f367
Extend single TARGET_LINUX guard to cover GetRestrictedPhysicalMemory…
Copilot 2445c5b
Move TARGET_LINUX guard before includes; remove redundant platform-co…
Copilot 1ab725d
Restore original variable declaration order in GetPhysicalMemoryUsed …
Copilot File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -10,31 +10,24 @@ Module Name: | |
| Abstract: | ||
| Read cpu limits for the current process | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It would be nice to dedup these files too, not doing that in this PR (we have separate issue for that). |
||
| --*/ | ||
| #ifdef __FreeBSD__ | ||
| #define _WITH_GETLINE | ||
| #endif | ||
|
|
||
| #include <cstdint> | ||
| #include "cgroupcpu.h" | ||
|
|
||
| #if defined(TARGET_LINUX) || defined(TARGET_ANDROID) | ||
|
|
||
| #include <cstddef> | ||
| #include <cassert> | ||
| #include <unistd.h> | ||
| #include <stdlib.h> | ||
| #include <stdio.h> | ||
| #include <string.h> | ||
| #include <sys/resource.h> | ||
| #if defined(__APPLE__) || defined(__FreeBSD__) | ||
| #include <sys/param.h> | ||
| #include <sys/mount.h> | ||
| #elif !defined(__HAIKU__) | ||
| #include <sys/vfs.h> | ||
| #endif | ||
| #include <errno.h> | ||
| #include <limits> | ||
|
|
||
| #include "config.gc.h" | ||
|
|
||
| #include "cgroupcpu.h" | ||
|
|
||
| #define CGROUP2_SUPER_MAGIC 0x63677270 | ||
|
|
||
| #define BASE_TEN 10 | ||
|
|
@@ -90,10 +83,6 @@ class CGroup | |
| // modes because both of those involve cgroup v1 controllers managing | ||
| // resources. | ||
|
|
||
| #if !HAVE_NON_LEGACY_STATFS | ||
| return 0; | ||
| #else | ||
|
|
||
| struct statfs stats; | ||
| int result = statfs("/sys/fs/cgroup", &stats); | ||
| if (result != 0) | ||
|
|
@@ -110,7 +99,6 @@ class CGroup | |
| // been seen in the wild. | ||
| return 1; | ||
| } | ||
| #endif | ||
| } | ||
|
|
||
| static bool IsCGroup1CpuSubsystem(const char *strTok){ | ||
|
|
@@ -510,3 +498,16 @@ bool GetCpuLimit(uint32_t* val) | |
|
|
||
| return CGroup::GetCpuLimit(val); | ||
| } | ||
|
|
||
| #else // !(TARGET_LINUX || TARGET_ANDROID) | ||
|
|
||
| void InitializeCpuCGroup() | ||
| { | ||
| } | ||
|
|
||
| bool GetCpuLimit(uint32_t* val) | ||
| { | ||
jkotas marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| return false; | ||
| } | ||
|
|
||
| #endif // TARGET_LINUX || TARGET_ANDROID | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.