diff options
author | Sanjay Singh Rawat <sanjay.rawat@linaro.org> | 2014-04-30 10:29:29 +0530 |
---|---|---|
committer | Sanjay Singh Rawat <sanjay.rawat@linaro.org> | 2014-05-04 21:09:42 +0530 |
commit | 06d73f367333d580babdc71de183bffb92d58977 (patch) | |
tree | 74e90e660ceed5acded58bda856abc2d7065a407 | |
parent | b828ed7fd88499ef50076b5eb8b36b07335ea4ad (diff) |
cpuidle_killer: allocate per cpu process array dynamically
currently percpu process array is set to 2, for cpus >2 test
results in segfault
Signed-off-by: Sanjay Singh Rawat <sanjay.rawat@linaro.org>
-rw-r--r-- | cpuidle/cpuidle_killer.c | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/cpuidle/cpuidle_killer.c b/cpuidle/cpuidle_killer.c index 5e7320f..8ca51a6 100644 --- a/cpuidle/cpuidle_killer.c +++ b/cpuidle/cpuidle_killer.c @@ -102,9 +102,9 @@ int isonline(int cpu) int main(int argc, char *argv[]) { - int ret, i, nrcpus = 2; + int ret, i, nrcpus; int nrsleeps, delay; - pid_t pids[nrcpus]; + pid_t *pids; struct timex timex = { 0 }; if (adjtimex(&timex) < 0) { @@ -121,6 +121,11 @@ int main(int argc, char *argv[]) } fprintf(stderr, "found %d cpu(s)\n", nrcpus); + pids = (pid_t *) calloc(nrcpus, sizeof(pid_t)); + if (pids == NULL) { + fprintf(stderr, "error: calloc failed\n"); + return 1; + } for (i = 0; i < nrcpus; i++) { |