diff options
| author | Steven Rostedt <srostedt@redhat.com> | 2010-09-20 12:41:29 -0400 |
|---|---|---|
| committer | Steven Rostedt <rostedt@goodmis.org> | 2010-09-20 12:41:29 -0400 |
| commit | 296971a9f44762c409adc60c9f13fb5ceb9ad5ae (patch) | |
| tree | 29b04ba47b91b13091f143bb153d3e8889ab46c4 | |
| parent | cc00bd8493547dd9a6f03f42647156a57bbb2cc4 (diff) | |
trace-cmd: Use sysconf to figure out # of CPUs
Use the POSIX sysconf instead of the hack to figure out the number of
CPUs the current machine has.
Suggested-by: Russell King <linux@arm.linux.org.uk>
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
| -rw-r--r-- | trace-cmd.c | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/trace-cmd.c b/trace-cmd.c index 6fbac8c..cce499a 100644 --- a/trace-cmd.c +++ b/trace-cmd.c | |||
| @@ -981,6 +981,13 @@ static int count_cpus(void) | |||
| 981 | size_t n; | 981 | size_t n; |
| 982 | int r; | 982 | int r; |
| 983 | 983 | ||
| 984 | cpus = sysconf(_SC_NPROCESSORS_ONLN); | ||
| 985 | if (cpus > 0) | ||
| 986 | return cpus; | ||
| 987 | |||
| 988 | warning("sysconf could not determine number of CPUS"); | ||
| 989 | |||
| 990 | /* Do the hack to figure out # of CPUS */ | ||
| 984 | n = 1024; | 991 | n = 1024; |
| 985 | pn = &n; | 992 | pn = &n; |
| 986 | pbuf = buf; | 993 | pbuf = buf; |
