Skip to content
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

linux, checking THP current system settings. #494

Open
wants to merge 1 commit into
base: dev
Choose a base branch
from

Conversation

devnexen
Copy link
Contributor

No description provided.

Copy link
Collaborator

@daanx daanx left a comment

Choose a reason for hiding this comment

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

Thanks for adding this (the current pipeline failure is due to an earlier commit of mine I think for Windows). I added some inline comments. Also, as I understand, the madvise call is only needed if the setting is madvise ?

src/os.c Outdated
@@ -237,13 +242,27 @@ void _mi_os_init() {

#else // generic unix

static void os_detect_transparent_huge_pages(void) {
#if defined(MADV_HUGEPAGE)
int fd = open("/sys/kernel/mm/transparent_hugepage/enabled", O_RDONLY);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is this path always fixed? I read here that it can also be /sys/kernel/mm/redhat_transparent_hugepage/enabled for example?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ah good to know

src/os.c Outdated
close(fd);
if (nread >= 1) {
// in some configurations, it can occur (e.g. embedded)
if (!strstr(buf, "[never]")) os_transparent_huge_pages = true;
Copy link
Collaborator

Choose a reason for hiding this comment

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

What are the valid contents here? I guess always, madvise and never.
But it seems also [never] is valid? Should we just check for madvise perhaps?

src/os.c Outdated

for (i = 0; i < sizeof(paths) / sizeof(paths[0]); i ++) {
fd = open(paths[i], O_RDONLY);
if (fd > 0) break;
Copy link
Contributor

Choose a reason for hiding this comment

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

open can return 0, that's a valid value, not an error.
So I would change that check to fd >= 0

Copy link
Contributor Author

Choose a reason for hiding this comment

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

in general yes even tough stdin might not be closed yet at this early stage but nevertheless I made it less ambiguous.

@daanx
Copy link
Collaborator

daanx commented Dec 16, 2021

Ah, this is starting to look rather complicated and it is unclear whether we actually need it. Currently, it is only called if we cannot do it directly and via madvise without failing on an error. That seems robust enough?

@devnexen
Copy link
Contributor Author

I see your point, that is fine if you prefer not merging it.

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.

3 participants