-
Notifications
You must be signed in to change notification settings - Fork 5.2k
Simplify numasupport #84207
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
Merged
Merged
Simplify numasupport #84207
Changes from 5 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
420c0b8
Simplify numasupport
am11 7d9414f
short-circuit
am11 ce2b507
Address CR feedback: more cleanups
am11 af2144e
Address CR feedback
am11 fcb4ea0
Cleanup from QUIC readme
am11 1cb92f9
Address CR feedback: early bail for < 2 NUMA nodes
am11 55049e5
Fix node numbering, which is 0-based
am11 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
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
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
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
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
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 |
---|---|---|
@@ -0,0 +1,81 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
|
||
#include "numasupport.h" | ||
|
||
#include <stdlib.h> | ||
#include <unistd.h> | ||
#include <errno.h> | ||
#include <stdio.h> | ||
#include <dirent.h> | ||
#include <string.h> | ||
#include <sys/syscall.h> | ||
#include <minipal/utils.h> | ||
|
||
// The highest NUMA node available | ||
int g_highestNumaNode = 0; | ||
// Is numa available | ||
bool g_numaAvailable = false; | ||
|
||
#ifdef TARGET_LINUX | ||
static int GetNodeNum(const char* path, bool firstOnly) | ||
{ | ||
DIR *dir; | ||
struct dirent *entry; | ||
int result = -1; | ||
|
||
dir = opendir(path); | ||
if (dir) | ||
{ | ||
while ((entry = readdir(dir)) != NULL) | ||
{ | ||
if (strncmp(entry->d_name, "node", STRING_LENGTH("node"))) | ||
continue; | ||
|
||
int nodeNum = strtoul(entry->d_name + STRING_LENGTH("node"), NULL, 0); | ||
if (result < nodeNum) | ||
result = nodeNum; | ||
|
||
if (firstOnly) | ||
break; | ||
} | ||
|
||
closedir(dir); | ||
} | ||
|
||
return result; | ||
} | ||
#endif | ||
|
||
void NUMASupportInitialize() | ||
{ | ||
#ifdef TARGET_LINUX | ||
if (syscall(__NR_get_mempolicy, NULL, NULL, 0, 0, 0) < 0 && errno == ENOSYS) | ||
return; | ||
|
||
g_numaAvailable = true; | ||
g_highestNumaNode = GetNodeNum("/sys/devices/system/node", false); | ||
#endif | ||
} | ||
|
||
int GetNumaNodeNumByCpu(int cpu) | ||
{ | ||
#ifdef TARGET_LINUX | ||
char path[64]; | ||
if (snprintf(path, sizeof(path), "/sys/devices/system/cpu/cpu%d", cpu) < 0) | ||
return -1; | ||
|
||
return GetNodeNum(path, true); | ||
#else | ||
return -1; | ||
#endif | ||
} | ||
|
||
long BindMemoryPolicy(void* start, unsigned long len, const unsigned long* nodemask, unsigned long maxnode) | ||
{ | ||
#ifdef TARGET_LINUX | ||
return syscall(__NR_mbind, (long)start, len, 1, (long)nodemask, maxnode, 0); | ||
#else | ||
return -1; | ||
#endif | ||
} |
This file was deleted.
Oops, something went wrong.
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 was deleted.
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The original (dynamic) code was disabling NUMA if there was just one NUMA node. In that case, it is useless to add complexities related to NUMA. I think we should do it here too.