unsigned long long last_reported_time;
unsigned long long last_read_time;
struct io_stats io_stats;
- unsigned long last_sequence;
unsigned long skips, nskips;
unsigned long long seq_skips, seq_nskips;
-
- struct rb_root rb_last;
- unsigned long rb_last_entries;
+ unsigned int max_depth[2];
+ unsigned int cur_depth[2];
struct rb_root rb_track;
unsigned int cpu_map_max;
struct per_cpu_info *cpus;
- struct skip_info *skips_head;
- struct skip_info *skips_tail;
};
struct per_process_info {
static int ndevices;
static struct per_dev_info *devices;
static char *get_dev_name(struct per_dev_info *, char *, int);
+static int trace_rb_insert_last(struct per_dev_info *, struct trace *);
FILE *ofp = NULL;
static char *output_name;
static unsigned long long genesis_time;
static unsigned long long last_allowed_time;
-static unsigned int smallest_seq_read;
static unsigned long long stopwatch_start; /* start from zero by default */
static unsigned long long stopwatch_end = -1ULL; /* "infinity" */
#define CPU_IDX(cpu) ((cpu) / CPUS_PER_LONG)
#define CPU_BIT(cpu) ((cpu) & (CPUS_PER_LONG - 1))
-static void insert_skip(struct per_dev_info *pdi, unsigned long start,
+static void resize_cpu_info(struct per_dev_info *pdi, int cpu)
+{
+ struct per_cpu_info *cpus = pdi->cpus;
+ int ncpus = pdi->ncpus;
+ int new_count = cpu + 1;
+ int new_space, size;
+ char *new_start;
+
+ size = new_count * sizeof(struct per_cpu_info);
+ cpus = realloc(cpus, size);
+ if (!cpus) {
+ char name[20];
+ fprintf(stderr, "Out of memory, CPU info for device %s (%d)\n",
+ get_dev_name(pdi, name, sizeof(name)), size);
+ exit(1);
+ }
+
+ new_start = (char *)cpus + (ncpus * sizeof(struct per_cpu_info));
+ new_space = (new_count - ncpus) * sizeof(struct per_cpu_info);
+ memset(new_start, 0, new_space);
+
+ pdi->ncpus = new_count;
+ pdi->cpus = cpus;
+
+ for (new_count = 0; new_count < pdi->ncpus; new_count++) {
+ struct per_cpu_info *pci = &pdi->cpus[new_count];
+
+ if (!pci->fd) {
+ pci->fd = -1;
+ memset(&pci->rb_last, 0, sizeof(pci->rb_last));
+ pci->rb_last_entries = 0;
+ pci->last_sequence = -1;
+ }
+ }
+}
+
+static struct per_cpu_info *get_cpu_info(struct per_dev_info *pdi, int cpu)
+{
+ struct per_cpu_info *pci;
+
+ if (cpu >= pdi->ncpus)
+ resize_cpu_info(pdi, cpu);
+
+ pci = &pdi->cpus[cpu];
+ pci->cpu = cpu;
+ return pci;
+}
+
+
+static int resize_devices(char *name)
+{
+ int size = (ndevices + 1) * sizeof(struct per_dev_info);
+
+ devices = realloc(devices, size);
+ if (!devices) {
+ fprintf(stderr, "Out of memory, device %s (%d)\n", name, size);
+ return 1;
+ }
+ memset(&devices[ndevices], 0, sizeof(struct per_dev_info));
+ devices[ndevices].name = name;
+ ndevices++;
+ return 0;
+}
+
+static struct per_dev_info *get_dev_info(dev_t dev)
+{
+ struct per_dev_info *pdi;
+ int i;
+
+ for (i = 0; i < ndevices; i++) {
+ if (!devices[i].dev)
+ devices[i].dev = dev;
+ if (devices[i].dev == dev)
+ return &devices[i];
+ }
+
+ if (resize_devices(NULL))
+ return NULL;
+
+ pdi = &devices[ndevices - 1];
+ pdi->dev = dev;
+ pdi->first_reported_time = 0;
+ pdi->last_read_time = 0;
+
+ return pdi;
+}
+
+static void insert_skip(struct per_cpu_info *pci, unsigned long start,
unsigned long end)
{
struct skip_info *sip;
- for (sip = pdi->skips_tail; sip != NULL; sip = sip->prev) {
+ for (sip = pci->skips_tail; sip != NULL; sip = sip->prev) {
if (end == (sip->start - 1)) {
sip->start = start;
return;
sip->start = start;
sip->end = end;
sip->prev = sip->next = NULL;
- if (pdi->skips_tail == NULL)
- pdi->skips_head = pdi->skips_tail = sip;
+ if (pci->skips_tail == NULL)
+ pci->skips_head = pci->skips_tail = sip;
else {
- sip->prev = pdi->skips_tail;
- pdi->skips_tail->next = sip;
- pdi->skips_tail = sip;
+ sip->prev = pci->skips_tail;
+ pci->skips_tail->next = sip;
+ pci->skips_tail = sip;
}
}
-static void remove_sip(struct per_dev_info *pdi, struct skip_info *sip)
+static void remove_sip(struct per_cpu_info *pci, struct skip_info *sip)
{
if (sip->prev == NULL) {
if (sip->next == NULL)
- pdi->skips_head = pdi->skips_tail = NULL;
+ pci->skips_head = pci->skips_tail = NULL;
else {
- pdi->skips_head = sip->next;
+ pci->skips_head = sip->next;
sip->next->prev = NULL;
}
} else if (sip->next == NULL) {
- pdi->skips_tail = sip->prev;
+ pci->skips_tail = sip->prev;
sip->prev->next = NULL;
} else {
sip->prev->next = sip->next;
}
#define IN_SKIP(sip,seq) (((sip)->start <= (seq)) && ((seq) <= sip->end))
-static int check_current_skips(struct per_dev_info *pdi, unsigned long seq)
+static int check_current_skips(struct per_cpu_info *pci, unsigned long seq)
{
struct skip_info *sip;
- for (sip = pdi->skips_tail; sip != NULL; sip = sip->prev) {
- if (IN_SKIP(sip,seq)) {
+ for (sip = pci->skips_tail; sip != NULL; sip = sip->prev) {
+ if (IN_SKIP(sip, seq)) {
if (sip->start == seq) {
if (sip->end == seq)
- remove_sip(pdi,sip);
+ remove_sip(pci, sip);
else
sip->start += 1;
} else if (sip->end == seq)
sip->end -= 1;
else {
sip->end = seq - 1;
- insert_skip(pdi,seq+1,sip->end);
+ insert_skip(pci, seq + 1, sip->end);
}
return 1;
}
}
+
return 0;
}
static void collect_pdi_skips(struct per_dev_info *pdi)
{
struct skip_info *sip;
+ int cpu;
pdi->skips = 0;
pdi->seq_skips = 0;
- for (sip = pdi->skips_head; sip != NULL; sip = sip->next) {
- pdi->skips += 1;
- pdi->seq_skips += (sip->end - sip->start + 1);
- if (verbose)
- fprintf(stderr, "(%d,%d): skipping %lu -> %lu\n",
- MAJOR(pdi->dev), MINOR(pdi->dev),
- sip->start, sip->end);
+
+ for (cpu = 0; cpu < pdi->ncpus; cpu++) {
+ struct per_cpu_info *pci = &pdi->cpus[cpu];
+
+ for (sip = pci->skips_head; sip != NULL; sip = sip->next) {
+ pdi->skips++;
+ pdi->seq_skips += (sip->end - sip->start + 1);
+ if (verbose)
+ fprintf(stderr,"(%d,%d): skipping %lu -> %lu\n",
+ MAJOR(pdi->dev), MINOR(pdi->dev),
+ sip->start, sip->end);
+ }
}
}
return ppi;
}
-static inline int trace_rb_insert(struct trace *t, struct rb_root *root,
- int check_time)
+/*
+ * struct trace and blktrace allocation cache, we do potentially
+ * millions of mallocs for these structures while only using at most
+ * a few thousand at the time
+ */
+static inline void t_free(struct trace *t)
+{
+ if (t_alloc_cache < 1024) {
+ t->next = t_alloc_list;
+ t_alloc_list = t;
+ t_alloc_cache++;
+ } else
+ free(t);
+}
+
+static inline struct trace *t_alloc(void)
+{
+ struct trace *t = t_alloc_list;
+
+ if (t) {
+ t_alloc_list = t->next;
+ t_alloc_cache--;
+ return t;
+ }
+
+ return malloc(sizeof(*t));
+}
+
+static inline void bit_free(struct blk_io_trace *bit)
+{
+ if (bit_alloc_cache < 1024 && !bit->pdu_len) {
+ /*
+ * abuse a 64-bit field for a next pointer for the free item
+ */
+ bit->time = (__u64) (unsigned long) bit_alloc_list;
+ bit_alloc_list = (struct blk_io_trace *) bit;
+ bit_alloc_cache++;
+ } else
+ free(bit);
+}
+
+static inline struct blk_io_trace *bit_alloc(void)
+{
+ struct blk_io_trace *bit = bit_alloc_list;
+
+ if (bit) {
+ bit_alloc_list = (struct blk_io_trace *) (unsigned long) \
+ bit->time;
+ bit_alloc_cache--;
+ return bit;
+ }
+
+ return malloc(sizeof(*bit));
+}
+
+static inline void __put_trace_last(struct per_dev_info *pdi, struct trace *t)
+{
+ struct per_cpu_info *pci = get_cpu_info(pdi, t->bit->cpu);
+
+ rb_erase(&t->rb_node, &pci->rb_last);
+ pci->rb_last_entries--;
+
+ bit_free(t->bit);
+ t_free(t);
+}
+
+static void put_trace(struct per_dev_info *pdi, struct trace *t)
+{
+ rb_erase(&t->rb_node, &rb_sort_root);
+ rb_sort_entries--;
+
+ trace_rb_insert_last(pdi, t);
+}
+
+static inline int trace_rb_insert(struct trace *t, struct rb_root *root)
{
struct rb_node **p = &root->rb_node;
struct rb_node *parent = NULL;
__t = rb_entry(parent, struct trace, rb_node);
- if (check_time) {
- if (t->bit->time < __t->bit->time) {
- p = &(*p)->rb_left;
- continue;
- } else if (t->bit->time > __t->bit->time) {
- p = &(*p)->rb_right;
- continue;
- }
- }
- if (t->bit->device < __t->bit->device)
+ if (t->bit->time < __t->bit->time)
+ p = &(*p)->rb_left;
+ else if (t->bit->time > __t->bit->time)
+ p = &(*p)->rb_right;
+ else if (t->bit->device < __t->bit->device)
p = &(*p)->rb_left;
else if (t->bit->device > __t->bit->device)
p = &(*p)->rb_right;
static inline int trace_rb_insert_sort(struct trace *t)
{
- if (!trace_rb_insert(t, &rb_sort_root, 1)) {
+ if (!trace_rb_insert(t, &rb_sort_root)) {
rb_sort_entries++;
return 0;
}
return 1;
}
-static inline int trace_rb_insert_last(struct per_dev_info *pdi,struct trace *t)
+static int trace_rb_insert_last(struct per_dev_info *pdi, struct trace *t)
{
- if (!trace_rb_insert(t, &pdi->rb_last, 1)) {
- pdi->rb_last_entries++;
- return 0;
+ struct per_cpu_info *pci = get_cpu_info(pdi, t->bit->cpu);
+
+ if (trace_rb_insert(t, &pci->rb_last))
+ return 1;
+
+ pci->rb_last_entries++;
+
+ if (pci->rb_last_entries > rb_batch * pdi->nfiles) {
+ struct rb_node *n = rb_first(&pci->rb_last);
+
+ t = rb_entry(n, struct trace, rb_node);
+ __put_trace_last(pdi, t);
}
- return 1;
+ return 0;
}
static struct trace *trace_rb_find(dev_t device, unsigned long sequence,
return NULL;
}
-static inline struct trace *trace_rb_find_sort(dev_t dev, unsigned long seq)
-{
- return trace_rb_find(dev, seq, &rb_sort_root, 1);
-}
-
static inline struct trace *trace_rb_find_last(struct per_dev_info *pdi,
+ struct per_cpu_info *pci,
unsigned long seq)
{
- return trace_rb_find(pdi->dev, seq, &pdi->rb_last, 0);
+ return trace_rb_find(pdi->dev, seq, &pci->rb_last, 0);
}
static inline int track_rb_insert(struct per_dev_info *pdi,struct io_track *iot)
return &ppi->io_stats;
}
-static void resize_cpu_info(struct per_dev_info *pdi, int cpu)
-{
- struct per_cpu_info *cpus = pdi->cpus;
- int ncpus = pdi->ncpus;
- int new_count = cpu + 1;
- int new_space, size;
- char *new_start;
-
- size = new_count * sizeof(struct per_cpu_info);
- cpus = realloc(cpus, size);
- if (!cpus) {
- char name[20];
- fprintf(stderr, "Out of memory, CPU info for device %s (%d)\n",
- get_dev_name(pdi, name, sizeof(name)), size);
- exit(1);
- }
-
- new_start = (char *)cpus + (ncpus * sizeof(struct per_cpu_info));
- new_space = (new_count - ncpus) * sizeof(struct per_cpu_info);
- memset(new_start, 0, new_space);
-
- pdi->ncpus = new_count;
- pdi->cpus = cpus;
-}
-
-static struct per_cpu_info *get_cpu_info(struct per_dev_info *pdi, int cpu)
-{
- struct per_cpu_info *pci;
-
- if (cpu >= pdi->ncpus)
- resize_cpu_info(pdi, cpu);
-
- pci = &pdi->cpus[cpu];
- pci->cpu = cpu;
- return pci;
-}
-
-
-static int resize_devices(char *name)
-{
- int size = (ndevices + 1) * sizeof(struct per_dev_info);
-
- devices = realloc(devices, size);
- if (!devices) {
- fprintf(stderr, "Out of memory, device %s (%d)\n", name, size);
- return 1;
- }
- memset(&devices[ndevices], 0, sizeof(struct per_dev_info));
- devices[ndevices].name = name;
- ndevices++;
- return 0;
-}
-
-static struct per_dev_info *get_dev_info(dev_t dev)
-{
- struct per_dev_info *pdi;
- int i;
-
- for (i = 0; i < ndevices; i++) {
- if (!devices[i].dev)
- devices[i].dev = dev;
- if (devices[i].dev == dev)
- return &devices[i];
- }
-
- if (resize_devices(NULL))
- return NULL;
-
- pdi = &devices[ndevices - 1];
- pdi->dev = dev;
- pdi->first_reported_time = 0;
- pdi->last_sequence = -1;
- pdi->last_read_time = 0;
- memset(&pdi->rb_last, 0, sizeof(pdi->rb_last));
- pdi->rb_last_entries = 0;
-
- pdi->skips_head = pdi->skips_tail = NULL;
-
- return pdi;
-}
-
static char *get_dev_name(struct per_dev_info *pdi, char *buffer, int size)
{
if (pdi->name)
static void dump_trace_fs(struct blk_io_trace *t, struct per_dev_info *pdi,
struct per_cpu_info *pci)
{
- int w = t->action & BLK_TC_ACT(BLK_TC_WRITE);
+ int w = (t->action & BLK_TC_ACT(BLK_TC_WRITE)) != 0;
int act = t->action & 0xffff;
switch (act) {
log_generic(pci, t, "S");
break;
case __BLK_TA_REQUEUE:
+ pdi->cur_depth[w]--;
account_requeue(t, pci, w);
log_queue(pci, t, "R");
break;
case __BLK_TA_ISSUE:
account_issue(t, pci, w);
+ pdi->cur_depth[w]++;
+ if (pdi->cur_depth[w] > pdi->max_depth[w])
+ pdi->max_depth[w] = pdi->cur_depth[w];
log_issue(pdi, pci, t, "D");
break;
case __BLK_TA_COMPLETE:
+ pdi->cur_depth[w]--;
account_c(t, pci, w, t->bytes);
log_complete(pdi, pci, t, "C");
break;
return dst;
}
-static void dump_io_stats(struct io_stats *ios, char *msg)
+static void dump_io_stats(struct per_dev_info *pdi, struct io_stats *ios,
+ char *msg)
{
static char x[256], y[256];
fprintf(ofp, " Writes Completed: %s, %siB\n", size_cnv(x, ios->cwrites, 0), size_cnv(y, ios->cwrite_kb, 1));
fprintf(ofp, " Read Merges: %'8lu%8c\t", ios->mreads, ' ');
fprintf(ofp, " Write Merges: %'8lu\n", ios->mwrites);
+ if (pdi) {
+ fprintf(ofp, " Read depth: %'8u%8c\t", pdi->max_depth[0], ' ');
+ fprintf(ofp, " Write depth: %'8u\n", pdi->max_depth[1]);
+ }
fprintf(ofp, " IO unplugs: %'8lu%8c\t", ios->io_unplugs, ' ');
fprintf(ofp, " Timer unplugs: %'8lu\n", ios->timer_unplugs);
}
else
sprintf(name, "%s (%u)", ppi->name, ppi->pid);
- dump_io_stats(&ppi->io_stats, name);
+ dump_io_stats(NULL, &ppi->io_stats, name);
dump_wait_stats(ppi);
ppi = ppi->list_next;
}
snprintf(line, sizeof(line) - 1, "CPU%d (%s):",
j, get_dev_name(pdi, name, sizeof(name)));
- dump_io_stats(ios, line);
+ dump_io_stats(pdi, ios, line);
pci_events++;
}
fprintf(ofp, "\n");
snprintf(line, sizeof(line) - 1, "Total (%s):",
get_dev_name(pdi, name, sizeof(name)));
- dump_io_stats(&total, line);
+ dump_io_stats(NULL, &total, line);
}
wrate = rrate = 0;
}
}
-/*
- * struct trace and blktrace allocation cache, we do potentially
- * millions of mallocs for these structures while only using at most
- * a few thousand at the time
- */
-static inline void t_free(struct trace *t)
-{
- if (t_alloc_cache < 1024) {
- t->next = t_alloc_list;
- t_alloc_list = t;
- t_alloc_cache++;
- } else
- free(t);
-}
-
-static inline struct trace *t_alloc(void)
-{
- struct trace *t = t_alloc_list;
-
- if (t) {
- t_alloc_list = t->next;
- t_alloc_cache--;
- return t;
- }
-
- return malloc(sizeof(*t));
-}
-
-static inline void bit_free(struct blk_io_trace *bit)
-{
- if (bit_alloc_cache < 1024 && !bit->pdu_len) {
- /*
- * abuse a 64-bit field for a next pointer for the free item
- */
- bit->time = (__u64) (unsigned long) bit_alloc_list;
- bit_alloc_list = (struct blk_io_trace *) bit;
- bit_alloc_cache++;
- } else
- free(bit);
-}
-
-static inline struct blk_io_trace *bit_alloc(void)
-{
- struct blk_io_trace *bit = bit_alloc_list;
-
- if (bit) {
- bit_alloc_list = (struct blk_io_trace *) (unsigned long) \
- bit->time;
- bit_alloc_cache--;
- return bit;
- }
-
- return malloc(sizeof(*bit));
-}
-
static void find_genesis(void)
{
struct trace *t = trace_list;
*/
static int sort_entries(unsigned long long *youngest)
{
+ struct per_dev_info *pdi = NULL;
+ struct per_cpu_info *pci = NULL;
struct trace *t;
if (!genesis_time)
if (bit->time < *youngest || !*youngest)
*youngest = bit->time;
- if (bit->sequence < smallest_seq_read)
- smallest_seq_read = bit->sequence;
+ if (!pdi || pdi->dev != bit->device) {
+ pdi = get_dev_info(bit->device);
+ pci = NULL;
+ }
+
+ if (!pci || pci->cpu != bit->cpu)
+ pci = get_cpu_info(pdi, bit->cpu);
+
+ if (bit->sequence < pci->smallest_seq_read)
+ pci->smallest_seq_read = bit->sequence;
if (check_stopwatch(bit)) {
bit_free(bit);
return 0;
}
-static inline void __put_trace_last(struct per_dev_info *pdi, struct trace *t)
-{
- rb_erase(&t->rb_node, &pdi->rb_last);
- pdi->rb_last_entries--;
-
- bit_free(t->bit);
- t_free(t);
-}
-
-static void put_trace(struct per_dev_info *pdi, struct trace *t)
-{
- rb_erase(&t->rb_node, &rb_sort_root);
- rb_sort_entries--;
-
- trace_rb_insert_last(pdi, t);
-
- if (pdi->rb_last_entries > rb_batch * pdi->nfiles) {
- struct rb_node *n = rb_first(&pdi->rb_last);
-
- t = rb_entry(n, struct trace, rb_node);
- __put_trace_last(pdi, t);
- }
-}
-
/*
* to continue, we must have traces from all online cpus in the tree
*/
static int check_sequence(struct per_dev_info *pdi, struct trace *t, int force)
{
- unsigned long expected_sequence = pdi->last_sequence + 1;
struct blk_io_trace *bit = t->bit;
+ unsigned long expected_sequence;
+ struct per_cpu_info *pci;
struct trace *__t;
+ pci = get_cpu_info(pdi, bit->cpu);
+ expected_sequence = pci->last_sequence + 1;
+
if (!expected_sequence) {
/*
* 1 should be the first entry, just allow it
*/
if (bit->sequence == 1)
return 0;
+ if (bit->sequence == pci->smallest_seq_read)
+ return 0;
return check_cpu_map(pdi);
}
* we may not have seen that sequence yet. if we are not doing
* the final run, break and wait for more entries.
*/
- if (expected_sequence < smallest_seq_read) {
- __t = trace_rb_find_last(pdi, expected_sequence);
+ if (expected_sequence < pci->smallest_seq_read) {
+ __t = trace_rb_find_last(pdi, pci, expected_sequence);
if (!__t)
goto skip;
return 1;
} else {
skip:
- if (check_current_skips(pdi,bit->sequence))
+ if (check_current_skips(pci, bit->sequence))
return 0;
- insert_skip(pdi,expected_sequence,bit->sequence-1);
+ if (expected_sequence < bit->sequence)
+ insert_skip(pci, expected_sequence, bit->sequence - 1);
return 0;
}
}
t = rb_entry(n, struct trace, rb_node);
bit = t->bit;
- if (!pdi || pdi->dev != bit->device)
+ if (!pdi || pdi->dev != bit->device) {
pdi = get_dev_info(bit->device);
+ pci = NULL;
+ }
if (!pdi) {
fprintf(stderr, "Unknown device ID? (%d,%d)\n",
if (!force && bit->time > last_allowed_time)
break;
- pdi->last_sequence = bit->sequence;
-
check_time(pdi, bit);
if (!pci || pci->cpu != bit->cpu)
pci = get_cpu_info(pdi, bit->cpu);
+ pci->last_sequence = bit->sequence;
+
pci->nelems++;
- if (bit->action & (act_mask << BLK_TC_SHIFT))
+ if (bit->action & (act_mask << BLK_TC_SHIFT))
dump_trace(bit, pci, pdi);
put_trace(pdi, t);
}
}
-static int read_data(int fd, void *buffer, int bytes, int block)
+static int read_data(int fd, void *buffer, int bytes, int block, int *fdblock)
{
int ret, bytes_left, fl;
void *p;
- fl = fcntl(fd, F_GETFL);
+ if (block != *fdblock) {
+ fl = fcntl(fd, F_GETFL);
- if (!block)
- fcntl(fd, F_SETFL, fl | O_NONBLOCK);
- else
- fcntl(fd, F_SETFL, fl & ~O_NONBLOCK);
+ if (!block) {
+ *fdblock = 0;
+ fcntl(fd, F_SETFL, fl | O_NONBLOCK);
+ } else {
+ *fdblock = 1;
+ fcntl(fd, F_SETFL, fl & ~O_NONBLOCK);
+ }
+ }
bytes_left = bytes;
p = buffer;
if (!ret)
return 1;
else if (ret < 0) {
- if (errno != EAGAIN)
+ if (errno != EAGAIN) {
perror("read");
+ return -1;
+ }
- return -1;
+ /*
+ * never do partial reads. we can return if we
+ * didn't read anything and we should not block,
+ * otherwise wait for data
+ */
+ if ((bytes_left == bytes) && !block)
+ return 1;
+
+ usleep(10);
+ continue;
} else {
p += ret;
bytes_left -= ret;
return 0;
}
-static int read_events(int fd, int always_block)
+static int read_events(int fd, int always_block, int *fdblock)
{
struct per_dev_info *pdi = NULL;
unsigned int events = 0;
while (!is_done() && events < rb_batch) {
struct blk_io_trace *bit;
struct trace *t;
- int pdu_len;
+ int pdu_len, should_block, ret;
__u32 magic;
bit = bit_alloc();
- if (read_data(fd, bit, sizeof(*bit), !events || always_block)) {
+ should_block = !events || always_block;
+
+ ret = read_data(fd, bit, sizeof(*bit), should_block, fdblock);
+ if (ret) {
bit_free(bit);
+ if (!events && ret < 0)
+ events = ret;
break;
}
if (pdu_len) {
void *ptr = realloc(bit, sizeof(*bit) + pdu_len);
- if (read_data(fd, ptr + sizeof(*bit), pdu_len, 1)) {
+ if (read_data(fd, ptr + sizeof(*bit), pdu_len, 1, fdblock)) {
bit_free(ptr);
break;
}
for (i = 0; i < ndevices; i++) {
pdi = &devices[i];
pdi->nfiles = 0;
- pdi->last_sequence = -1;
for (j = 0;; j++) {
struct stat st;
pci = get_cpu_info(pdi, j);
pci->cpu = j;
pci->fd = -1;
+ pci->fdblock = -1;
p = strdup(pdi->name);
dname = dirname(p);
events_added = 0;
last_allowed_time = -1ULL;
- smallest_seq_read = -1U;
for (i = 0; i < ndevices; i++) {
pdi = &devices[i];
+ pdi->last_read_time = -1ULL;
for (j = 0; j < pdi->nfiles; j++) {
if (pci->fd == -1)
continue;
- events = read_events(pci->fd, 1);
- if (!events) {
+ pci->smallest_seq_read = -1;
+
+ events = read_events(pci->fd, 1, &pci->fdblock);
+ if (events <= 0) {
cpu_mark_offline(pdi, pci->cpu);
close(pci->fd);
pci->fd = -1;
static int do_stdin(void)
{
unsigned long long youngest;
- int fd, events;
+ int fd, events, fdblock;
last_allowed_time = -1ULL;
fd = dup(STDIN_FILENO);
return -1;
}
- while ((events = read_events(fd, 0)) != 0) {
+ fdblock = -1;
+ while ((events = read_events(fd, 0, &fdblock)) > 0) {
+#if 0
smallest_seq_read = -1U;
+#endif
if (sort_entries(&youngest))
break;
static void handle_sigint(__attribute__((__unused__)) int sig)
{
done = 1;
- show_stats();
}
/*
"\t-o Output file. If not given, output is stdout\n" \
"\t-b stdin read batching\n" \
"\t-s Show per-program io statistics\n" \
- "\t-n Hash processes by name, not pid\n" \
+ "\t-h Hash processes by name, not pid\n" \
"\t-t Track individual ios. Will tell you the time a request took\n" \
"\t to get queued, to get dispatched, and to get completed\n" \
"\t-q Quiet. Don't display any stats at the end of the trace\n" \