Switch on schedstat support where needed.#16
Merged
sofar merged 1 commit intosystemd:masterfrom Sep 14, 2016
sofar:pr2
Merged
Conversation
| (void) setrlimit(RLIMIT_NOFILE, &rlim); | ||
|
|
||
| schfd = open("/proc/sys/kernel/sched_schedstats", O_WRONLY); | ||
| if (schfd) |
Member
There was a problem hiding this comment.
Isn't it better to close this file immediately? Keeping the fd open until the end of main seems a bit wasteful…
Contributor
Author
There was a problem hiding this comment.
Yeah, we're probably fine not using autoclose here, I'll update this to close right away.
Contributor
Author
|
Updated with both comments addressed. |
| schfd = open("/proc/sys/kernel/sched_schedstats", O_WRONLY); | ||
| if (schfd >= 0) | ||
| write(schfd, "1\n", 2); | ||
| close(schfd); |
Member
There was a problem hiding this comment.
Please don't hate me ;)
Can you move the close underneath the if too?
Contributor
Author
There was a problem hiding this comment.
I'd hate it if you hadn't said that, cuz it's obviously not nice like this. :)
Newer kernels have schedstat disabled by default unless turned on at runtime or through a kernel parameter/syscall. We should turn this on irregardless if we can. If the kernel is too old, any errors in this code will be ignored as schedstat should be enabled already. Fixes #12.
Contributor
Author
|
a7478a4b09867a0bee999fe41ad0a95387839444 |
sofar
added a commit
that referenced
this pull request
Sep 14, 2016
Newer kernels have schedstat disabled by default unless turned on at runtime or through a kernel parameter/syscall. We should turn this on irregardless if we can. If the kernel is too old, any errors in this code will be ignored as schedstat should be enabled already. Fixes #12.
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Newer kernels have schedstat disabled by default unless turned on
at runtime or through a kernel parameter/syscall. We should turn
this on irregardless if we can.
If the kernel is too old, any errors in this code will be ignored
as schedstat should be enabled already.
Fixes #12.