Merge branch 'add-P'
[blktrace.git] / blktrace.h
index 13d6e03ac8b7fc93105c424d3a369fa47911817b..816ce613715aef82ecda29dc70d0c1e03c89a7fc 100644 (file)
@@ -18,6 +18,7 @@
 #define DOUBLE_TO_NANO_ULL(d)  ((unsigned long long)((d) * 1000000000))
 
 #define min(a, b)      ((a) < (b) ? (a) : (b))
+#define max(a, b)      ((a) > (b) ? (a) : (b))
 
 #define t_sec(t)       ((t)->bytes >> 9)
 #define t_kb(t)                ((t)->bytes >> 10)
@@ -30,6 +31,10 @@ struct io_stats {
        unsigned long ireads, iwrites, rrqueue, wrqueue;
        unsigned long long qread_kb, qwrite_kb, cread_kb, cwrite_kb;
        unsigned long long iread_kb, iwrite_kb;
+       unsigned long long mread_kb, mwrite_kb;
+       unsigned long qreads_pc, qwrites_pc, ireads_pc, iwrites_pc;
+       unsigned long rrqueue_pc, wrqueue_pc, creads_pc, cwrites_pc;
+       unsigned long long qread_kb_pc, qwrite_kb_pc, iread_kb_pc, iwrite_kb_pc;
        unsigned long io_unplugs, timer_unplugs;
 };
 
@@ -54,9 +59,10 @@ struct per_cpu_info {
 
 extern FILE *ofp;
 extern int data_is_native;
+extern struct timespec abs_start_time;
 
 #define CHECK_MAGIC(t)         (((t)->magic & 0xffffff00) == BLK_IO_TRACE_MAGIC)
-#define SUPPORTED_VERSION      (0x06)
+#define SUPPORTED_VERSION      (0x07)
 
 #if __BYTE_ORDER == __LITTLE_ENDIAN
 #define be16_to_cpu(x)         __bswap_16(x)
@@ -103,29 +109,24 @@ static inline void trace_to_cpu(struct blk_io_trace *t)
        t->bytes        = be32_to_cpu(t->bytes);
        t->action       = be32_to_cpu(t->action);
        t->pid          = be32_to_cpu(t->pid);
-       t->cpu          = be32_to_cpu(t->cpu);
+       t->device       = be32_to_cpu(t->device);
+       t->cpu          = be16_to_cpu(t->cpu);
        t->error        = be16_to_cpu(t->error);
        t->pdu_len      = be16_to_cpu(t->pdu_len);
-       t->device       = be32_to_cpu(t->device);
-       /* t->comm is a string (endian neutral) */
 }
 
 /*
  * check whether data is native or not
  */
-static inline int check_data_endianness(struct blk_io_trace *bit)
+static inline int check_data_endianness(u32 magic)
 {
-       u32 magic;
-
-       if ((bit->magic & 0xffffff00) == BLK_IO_TRACE_MAGIC) {
-               fprintf(stderr, "data is native\n");
+       if ((magic & 0xffffff00) == BLK_IO_TRACE_MAGIC) {
                data_is_native = 1;
                return 0;
        }
 
-       magic = __bswap_32(bit->magic);
+       magic = __bswap_32(magic);
        if ((magic & 0xffffff00) == BLK_IO_TRACE_MAGIC) {
-               fprintf(stderr, "data is not native\n");
                data_is_native = 0;
                return 0;
        }
@@ -139,5 +140,6 @@ extern void process_fmt(char *, struct per_cpu_info *, struct blk_io_trace *,
                        unsigned long long, int, unsigned char *);
 extern int valid_act_opt(int);
 extern int find_mask_map(char *);
+extern char *find_process_name(pid_t);
 
 #endif