Skip to content

Commit cc00b71

Browse files
sofarahkok
authored andcommitted
Switch on schedstat support where needed. (#16)
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.
1 parent c44d4e4 commit cc00b71

1 file changed

Lines changed: 7 additions & 0 deletions

File tree

src/bootchart.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -307,6 +307,7 @@ int main(int argc, char *argv[]) {
307307
_cleanup_free_ char *build = NULL;
308308
_cleanup_fclose_ FILE *of = NULL;
309309
_cleanup_close_ int sysfd = -1;
310+
int schfd;
310311
struct ps_struct *ps_first;
311312
double graph_start;
312313
double log_start;
@@ -351,6 +352,12 @@ int main(int argc, char *argv[]) {
351352
rlim.rlim_max = 4096;
352353
(void) setrlimit(RLIMIT_NOFILE, &rlim);
353354

355+
schfd = open("/proc/sys/kernel/sched_schedstats", O_WRONLY);
356+
if (schfd >= 0) {
357+
write(schfd, "1\n", 2);
358+
close(schfd);
359+
}
360+
354361
/* start with empty ps LL */
355362
ps_first = new0(struct ps_struct, 1);
356363
if (!ps_first) {

0 commit comments

Comments
 (0)