aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNathan Zimmer <nzimmer@sgi.com>2013-04-15 09:53:32 -0500
committerJens Axboe <axboe@kernel.dk>2013-08-01 12:13:26 -0600
commit28fa9f69a23f70e4371fb483beb2d4881dbd074d (patch)
treeab8962cd9a160bbf36507a73bcffe57dd2278990
parentcd0ae0f6bc3d72e89d0b258aa2040437b75d4ef2 (diff)
downloadblktrace-28fa9f69a23f70e4371fb483beb2d4881dbd074d.tar.gz
verify_blkparse: Change max_cpus to deal with systems larger the 512
verify_blkpars has troubles with systems larger then 512. Also there is issue in the scanning code causing the cpu number to be truncated to the first two digits. i.e cpu 542 would be read as 54. Cc: Jens Axboe <axboe@kernel.dk> Signed-off-by: Nathan Zimmer <nzimmer@sgi.com> Signed-off-by: Jens Axboe <axboe@kernel.dk>
-rw-r--r--verify_blkparse.c23
1 files changed, 19 insertions, 4 deletions
diff --git a/verify_blkparse.c b/verify_blkparse.c
index aae8d7c..5689f43 100644
--- a/verify_blkparse.c
+++ b/verify_blkparse.c
@@ -3,18 +3,33 @@
#include <fcntl.h>
#include <string.h>
#include <unistd.h>
-
-#define MAX_CPUS (512)
+#include <errno.h>
int main(int argc, char *argv[])
{
double this_time, last_time;
char line[256], last_line[256], *p;
int major, minor, cpu, nr, alias;
+ long MAX_CPUS;
unsigned long long total_entries;
- unsigned int last_seq[MAX_CPUS], seq;
+ unsigned int *last_seq;
+ unsigned int seq;
FILE *f;
+#ifdef _SC_NPROCESSORS_CONF
+ MAX_CPUS = sysconf(_SC_NPROCESSORS_CONF);
+ if (MAX_CPUS < 1)
+ {
+ fprintf(stderr, "Could not determine number of CPUs online:\n%s\n",
+ strerror (errno));
+ fprintf(stderr, "Assuming 1024\n");
+ MAX_CPUS = 1024;
+ }
+#else
+ MAX_CPUS = CPU_SETSIZE;
+#endif
+
+ last_seq = malloc( sizeof(unsigned int) * MAX_CPUS );
for (nr = 0; nr < MAX_CPUS; nr++)
last_seq[nr] = -1;
@@ -33,7 +48,7 @@ int main(int argc, char *argv[])
alias = nr = 0;
total_entries = 0;
while ((p = fgets(line, sizeof(line), f)) != NULL) {
- if (sscanf(p, "%3d,%3d %2d %8d %lf", &major, &minor, &cpu, &seq, &this_time) != 5)
+ if (sscanf(p, "%3d,%3d %5d %8d %lf", &major, &minor, &cpu, &seq, &this_time) != 5)
break;
if (this_time < last_time) {