* Recent changes (master)
@ 2013-03-20 5:00 Jens Axboe
2013-08-02 4:00 ` Jens Axboe
` (37 more replies)
0 siblings, 38 replies; 45+ messages in thread
From: Jens Axboe @ 2013-03-20 5:00 UTC (permalink / raw)
To: linux-btrace
The following changes since commit d6918c8832793b4205ed3bfede78c2f915c23385:
blktrace 1.0.5 (2012-02-27 08:22:17 +0100)
are available in the git repository at:
git://git.kernel.dk/blktrace.git master
Ivan Dyukov (1):
More accurate calculation of the total read/write values
blkparse.c | 87 ++++++++++++++++++++++++++++++++++++++++++++++++++---------
blktrace.h | 4 +++
2 files changed, 77 insertions(+), 14 deletions(-)
---
Diff of recent changes:
diff --git a/blkparse.c b/blkparse.c
index a7ff0f7..a27b3ed 100644
--- a/blkparse.c
+++ b/blkparse.c
@@ -1182,9 +1182,11 @@ static inline void __account_m(struct io_stats *ios, struct blk_io_trace *t,
if (rw) {
ios->mwrites++;
ios->mwrite_kb += t_kb(t);
+ ios->mwrite_b += t_b(t);
} else {
ios->mreads++;
ios->mread_kb += t_kb(t);
+ ios->mread_b += t_b(t);
}
}
@@ -1206,9 +1208,11 @@ static inline void __account_pc_queue(struct io_stats *ios,
if (rw) {
ios->qwrites_pc++;
ios->qwrite_kb_pc += t_kb(t);
+ ios->qwrite_b_pc += t_b(t);
} else {
ios->qreads_pc++;
ios->qread_kb += t_kb(t);
+ ios->qread_b_pc += t_b(t);
}
}
@@ -1230,9 +1234,11 @@ static inline void __account_pc_issue(struct io_stats *ios, int rw,
if (rw) {
ios->iwrites_pc++;
ios->iwrite_kb_pc += bytes >> 10;
+ ios->iwrite_b_pc += bytes & 1023;
} else {
ios->ireads_pc++;
ios->iread_kb_pc += bytes >> 10;
+ ios->iread_b_pc += bytes & 1023;
}
}
@@ -1254,9 +1260,11 @@ static inline void __account_pc_requeue(struct io_stats *ios,
if (rw) {
ios->wrqueue_pc++;
ios->iwrite_kb_pc -= t_kb(t);
+ ios->iwrite_b_pc -= t_b(t);
} else {
ios->rrqueue_pc++;
ios->iread_kb_pc -= t_kb(t);
+ ios->iread_b_pc -= t_b(t);
}
}
@@ -1298,9 +1306,11 @@ static inline void __account_queue(struct io_stats *ios, struct blk_io_trace *t,
if (rw) {
ios->qwrites++;
ios->qwrite_kb += t_kb(t);
+ ios->qwrite_b += t_b(t);
} else {
ios->qreads++;
ios->qread_kb += t_kb(t);
+ ios->qread_b += t_b(t);
}
}
@@ -1321,9 +1331,11 @@ static inline void __account_c(struct io_stats *ios, int rw, int bytes)
if (rw) {
ios->cwrites++;
ios->cwrite_kb += bytes >> 10;
+ ios->cwrite_b += bytes & 1023;
} else {
ios->creads++;
ios->cread_kb += bytes >> 10;
+ ios->cread_b += bytes & 1023;
}
}
@@ -1345,9 +1357,11 @@ static inline void __account_issue(struct io_stats *ios, int rw,
if (rw) {
ios->iwrites++;
ios->iwrite_kb += bytes >> 10;
+ ios->iwrite_b += bytes & 1023;
} else {
ios->ireads++;
ios->iread_kb += bytes >> 10;
+ ios->iread_b += bytes & 1023;
}
}
@@ -1389,9 +1403,11 @@ static inline void __account_requeue(struct io_stats *ios,
if (rw) {
ios->wrqueue++;
ios->iwrite_kb -= t_kb(t);
+ ios->iwrite_b -= t_b(t);
} else {
ios->rrqueue++;
ios->iread_kb -= t_kb(t);
+ ios->iread_b -= t_b(t);
}
}
@@ -1654,26 +1670,55 @@ static void dump_io_stats(struct per_dev_info *pdi, struct io_stats *ios,
fprintf(ofp, "%s\n", msg);
- fprintf(ofp, " Reads Queued: %s, %siB\t", size_cnv(x, ios->qreads, 0), size_cnv(y, ios->qread_kb, 1));
- fprintf(ofp, " Writes Queued: %s, %siB\n", size_cnv(x, ios->qwrites, 0), size_cnv(y, ios->qwrite_kb, 1));
- fprintf(ofp, " Read Dispatches: %s, %siB\t", size_cnv(x, ios->ireads, 0), size_cnv(y, ios->iread_kb, 1));
- fprintf(ofp, " Write Dispatches: %s, %siB\n", size_cnv(x, ios->iwrites, 0), size_cnv(y, ios->iwrite_kb, 1));
+ fprintf(ofp, " Reads Queued: %s, %siB\t",
+ size_cnv(x, ios->qreads, 0),
+ size_cnv(y, ios->qread_kb + (ios->qread_b>>10), 1));
+ fprintf(ofp, " Writes Queued: %s, %siB\n",
+ size_cnv(x, ios->qwrites, 0),
+ size_cnv(y, ios->qwrite_kb + (ios->qwrite_b>>10), 1));
+ fprintf(ofp, " Read Dispatches: %s, %siB\t",
+ size_cnv(x, ios->ireads, 0),
+ size_cnv(y, ios->iread_kb + (ios->iread_b>>10), 1));
+ fprintf(ofp, " Write Dispatches: %s, %siB\n",
+ size_cnv(x, ios->iwrites, 0),
+ size_cnv(y, ios->iwrite_kb + (ios->iwrite_b>>10), 1));
fprintf(ofp, " Reads Requeued: %s\t\t", size_cnv(x, ios->rrqueue, 0));
fprintf(ofp, " Writes Requeued: %s\n", size_cnv(x, ios->wrqueue, 0));
- fprintf(ofp, " Reads Completed: %s, %siB\t", size_cnv(x, ios->creads, 0), size_cnv(y, ios->cread_kb, 1));
- fprintf(ofp, " Writes Completed: %s, %siB\n", size_cnv(x, ios->cwrites, 0), size_cnv(y, ios->cwrite_kb, 1));
- fprintf(ofp, " Read Merges: %s, %siB\t", size_cnv(x, ios->mreads, 0), size_cnv(y, ios->mread_kb, 1));
- fprintf(ofp, " Write Merges: %s, %siB\n", size_cnv(x, ios->mwrites, 0), size_cnv(y, ios->mwrite_kb, 1));
+ fprintf(ofp, " Reads Completed: %s, %siB\t",
+ size_cnv(x, ios->creads, 0),
+ size_cnv(y, ios->cread_kb + (ios->cread_b>>10), 1));
+ fprintf(ofp, " Writes Completed: %s, %siB\n",
+ size_cnv(x, ios->cwrites, 0),
+ size_cnv(y, ios->cwrite_kb + (ios->cwrite_b>>10), 1));
+ fprintf(ofp, " Read Merges: %s, %siB\t",
+ size_cnv(x, ios->mreads, 0),
+ size_cnv(y, ios->mread_kb + (ios->mread_b>>10), 1));
+ fprintf(ofp, " Write Merges: %s, %siB\n",
+ size_cnv(x, ios->mwrites, 0),
+ size_cnv(y, ios->mwrite_kb + (ios->mwrite_b>>10), 1));
if (pdi) {
fprintf(ofp, " Read depth: %'8u%8c\t", pdi->max_depth[0], ' ');
fprintf(ofp, " Write depth: %'8u\n", pdi->max_depth[1]);
}
if (ios->qreads_pc || ios->qwrites_pc || ios->ireads_pc || ios->iwrites_pc ||
ios->rrqueue_pc || ios->wrqueue_pc || ios->creads_pc || ios->cwrites_pc) {
- fprintf(ofp, " PC Reads Queued: %s, %siB\t", size_cnv(x, ios->qreads_pc, 0), size_cnv(y, ios->qread_kb_pc, 1));
- fprintf(ofp, " PC Writes Queued: %s, %siB\n", size_cnv(x, ios->qwrites_pc, 0), size_cnv(y, ios->qwrite_kb_pc, 1));
- fprintf(ofp, " PC Read Disp.: %s, %siB\t", size_cnv(x, ios->ireads_pc, 0), size_cnv(y, ios->iread_kb_pc, 1));
- fprintf(ofp, " PC Write Disp.: %s, %siB\n", size_cnv(x, ios->iwrites_pc, 0), size_cnv(y, ios->iwrite_kb_pc, 1));
+ fprintf(ofp, " PC Reads Queued: %s, %siB\t",
+ size_cnv(x, ios->qreads_pc, 0),
+ size_cnv(y,
+ ios->qread_kb_pc + (ios->qread_b_pc>>10), 1));
+ fprintf(ofp, " PC Writes Queued: %s, %siB\n",
+ size_cnv(x, ios->qwrites_pc, 0),
+ size_cnv(y,
+ ios->qwrite_kb_pc + (ios->qwrite_b_pc>>10), 1));
+ fprintf(ofp, " PC Read Disp.: %s, %siB\t",
+ size_cnv(x, ios->ireads_pc, 0),
+ size_cnv(y,
+ ios->iread_kb_pc + (ios->iread_b_pc>>10), 1));
+ fprintf(ofp, " PC Write Disp.: %s, %siB\n",
+ size_cnv(x, ios->iwrites_pc, 0),
+ size_cnv(y,
+ ios->iwrite_kb_pc + (ios->iwrite_b_pc>>10),
+ 1));
fprintf(ofp, " PC Reads Req.: %s\t\t", size_cnv(x, ios->rrqueue_pc, 0));
fprintf(ofp, " PC Writes Req.: %s\n", size_cnv(x, ios->wrqueue_pc, 0));
fprintf(ofp, " PC Reads Compl.: %s\t\t", size_cnv(x, ios->creads_pc, 0));
@@ -1808,6 +1853,14 @@ static void show_device_and_cpu_stats(void)
total.iwrite_kb += ios->iwrite_kb;
total.mread_kb += ios->mread_kb;
total.mwrite_kb += ios->mwrite_kb;
+ total.qread_b += ios->qread_b;
+ total.qwrite_b += ios->qwrite_b;
+ total.cread_b += ios->cread_b;
+ total.cwrite_b += ios->cwrite_b;
+ total.iread_b += ios->iread_b;
+ total.iwrite_b += ios->iwrite_b;
+ total.mread_b += ios->mread_b;
+ total.mwrite_b += ios->mwrite_b;
total.qreads_pc += ios->qreads_pc;
total.qwrites_pc += ios->qwrites_pc;
@@ -1821,6 +1874,10 @@ static void show_device_and_cpu_stats(void)
total.qwrite_kb_pc += ios->qwrite_kb_pc;
total.iread_kb_pc += ios->iread_kb_pc;
total.iwrite_kb_pc += ios->iwrite_kb_pc;
+ total.qread_b_pc += ios->qread_b_pc;
+ total.qwrite_b_pc += ios->qwrite_b_pc;
+ total.iread_b_pc += ios->iread_b_pc;
+ total.iwrite_b_pc += ios->iwrite_b_pc;
total.timer_unplugs += ios->timer_unplugs;
total.io_unplugs += ios->io_unplugs;
@@ -1841,8 +1898,10 @@ static void show_device_and_cpu_stats(void)
wrate = rrate = 0;
msec = (pdi->last_reported_time - pdi->first_reported_time) / 1000000;
if (msec) {
- rrate = 1000 * total.cread_kb / msec;
- wrate = 1000 * total.cwrite_kb / msec;
+ rrate = ((1000 * total.cread_kb) + total.cread_b) /
+ msec;
+ wrate = ((1000 * total.cwrite_kb) + total.cwrite_b) /
+ msec;
}
fprintf(ofp, "\nThroughput (R/W): %'LuKiB/s / %'LuKiB/s\n",
diff --git a/blktrace.h b/blktrace.h
index 5da6dbc..380aec7 100644
--- a/blktrace.h
+++ b/blktrace.h
@@ -23,6 +23,7 @@
#define t_sec(t) ((t)->bytes >> 9)
#define t_kb(t) ((t)->bytes >> 10)
+#define t_b(t) ((t)->bytes & 1023)
typedef __u32 u32;
typedef __u8 u8;
@@ -31,11 +32,14 @@ struct io_stats {
unsigned long qreads, qwrites, creads, cwrites, mreads, mwrites;
unsigned long ireads, iwrites, rrqueue, wrqueue;
unsigned long long qread_kb, qwrite_kb, cread_kb, cwrite_kb;
+ unsigned long long qread_b, qwrite_b, cread_b, cwrite_b;
unsigned long long iread_kb, iwrite_kb;
unsigned long long mread_kb, mwrite_kb;
+ unsigned long long mread_b, mwrite_b, iread_b, iwrite_b;
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 long qread_b_pc, qwrite_b_pc, iread_b_pc, iwrite_b_pc;
unsigned long io_unplugs, timer_unplugs;
};
^ permalink raw reply related [flat|nested] 45+ messages in thread
* Recent changes (master)
2013-03-20 5:00 Jens Axboe
@ 2013-08-02 4:00 ` Jens Axboe
2013-12-04 4:56 ` Jens Axboe
` (36 subsequent siblings)
37 siblings, 0 replies; 45+ messages in thread
From: Jens Axboe @ 2013-08-02 4:00 UTC (permalink / raw)
To: linux-btrace
The following changes since commit cd0ae0f6bc3d72e89d0b258aa2040437b75d4ef2:
More accurate calculation of the total read/write values (2013-03-19 08:16:27 -0600)
are available in the git repository at:
git://git.kernel.dk/blktrace.git master
Nathan Zimmer (5):
verify_blkparse: Change max_cpus to deal with systems larger the 512
btreplay: Machines are now large enough that holes need to be dealt with
btreplay: use sysconf to get the number of configured cpus
blktrace: use number of configured cpus instead of online cpus
blktrace blkreplay: convert to use a dynamic cpu_set_t
blktrace.c | 20 +++++++++++++-------
btreplay/btreplay.c | 51 +++++++++++++++++++++++++++++++++++----------------
verify_blkparse.c | 23 +++++++++++++++++++----
3 files changed, 67 insertions(+), 27 deletions(-)
---
Diff of recent changes:
diff --git a/blktrace.c b/blktrace.c
index 89aaaac..7e64c94 100644
--- a/blktrace.c
+++ b/blktrace.c
@@ -621,13 +621,19 @@ static void dpp_free(struct devpath *dpp)
static int lock_on_cpu(int cpu)
{
- cpu_set_t cpu_mask;
-
- CPU_ZERO(&cpu_mask);
- CPU_SET(cpu, &cpu_mask);
- if (sched_setaffinity(0, sizeof(cpu_mask), &cpu_mask) < 0)
+ cpu_set_t * cpu_mask;
+ size_t size;
+ cpu_mask = CPU_ALLOC(ncpus);
+ size = CPU_ALLOC_SIZE(ncpus);
+
+ CPU_ZERO_S(size, cpu_mask);
+ CPU_SET_S(cpu, size, cpu_mask);
+ if (sched_setaffinity(0, size, cpu_mask) < 0) {
+ CPU_FREE(cpu_mask);
return errno;
+ }
+ CPU_FREE(cpu_mask);
return 0;
}
@@ -2656,9 +2662,9 @@ int main(int argc, char *argv[])
setlocale(LC_NUMERIC, "en_US");
pagesize = getpagesize();
- ncpus = sysconf(_SC_NPROCESSORS_ONLN);
+ ncpus = sysconf(_SC_NPROCESSORS_CONF);
if (ncpus < 0) {
- fprintf(stderr, "sysconf(_SC_NPROCESSORS_ONLN) failed %d/%s\n",
+ fprintf(stderr, "sysconf(_SC_NPROCESSORS_CONF) failed %d/%s\n",
errno, strerror(errno));
ret = 1;
goto out;
diff --git a/btreplay/btreplay.c b/btreplay/btreplay.c
index 20494e0..5444010 100644
--- a/btreplay/btreplay.c
+++ b/btreplay/btreplay.c
@@ -502,19 +502,34 @@ static inline void start_iter(void)
*/
static void get_ncpus(void)
{
- cpu_set_t cpus;
-
- if (sched_getaffinity(getpid(), sizeof(cpus), &cpus)) {
+#ifdef _SC_NPROCESSORS_CONF
+ ncpus = sysconf(_SC_NPROCESSORS_CONF);
+#else
+ int nrcpus = 4096;
+ cpu_set_t * cpus;
+
+realloc:
+ cpus = CPU_ALLOC(nrcpus);
+ size = CPU_ALLOC_SIZE(nrcpus);
+ CPU_ZERO_S(size, cpus);
+
+ if (sched_getaffinity(getpid(), size, cpus)) {
+ if( errno = EINVAL && nrcpus < (4096<<4) ) {
+ CPU_FREE(cpus);
+ nrcpus <= 1;
+ goto realloc;
+ }
fatal("sched_getaffinity", ERR_SYSCALL, "Can't get CPU info\n");
/*NOTREACHED*/
}
- /*
- * XXX This assumes (perhaps wrongly) that there are no /holes/
- * XXX in the mask.
- */
- for (ncpus = 0; ncpus < CPU_SETSIZE && CPU_ISSET(ncpus, &cpus); ncpus++)
- ;
+ ncpus = -1;
+ for (last_cpu = 0; last_cpu < CPU_SETSIZE && CPU_ISSET(last_cpu, &cpus); last_cpu++)
+ if (CPU_ISSET( last_cpu, &cpus) )
+ ncpus = last_cpu;
+ ncpus++;
+ CPU_FREE(cpus);
+#endif
if (ncpus = 0) {
fatal(NULL, ERR_SYSCALL, "Insufficient number of CPUs\n");
/*NOTREACHED*/
@@ -527,25 +542,29 @@ static void get_ncpus(void)
*/
static void pin_to_cpu(struct thr_info *tip)
{
- cpu_set_t cpus;
+ cpu_set_t *cpus;
+ size_t size;
+
+ cpus = CPU_ALLOC(ncpus);
+ size = CPU_ALLOC_SIZE(ncpus);
assert(0 <= tip->cpu && tip->cpu < ncpus);
- CPU_ZERO(&cpus);
- CPU_SET(tip->cpu, &cpus);
- if (sched_setaffinity(getpid(), sizeof(cpus), &cpus)) {
+ CPU_ZERO_S(ncpus, cpus);
+ CPU_SET_S(tip->cpu, size, cpus);
+ if (sched_setaffinity(getpid(), size, cpus)) {
fatal("sched_setaffinity", ERR_SYSCALL, "Failed to pin CPU\n");
/*NOTREACHED*/
}
if (verbose > 1) {
int i;
- cpu_set_t now;
+ cpu_set_t *now = CPU_ALLOC(ncpus);
- (void)sched_getaffinity(getpid(), sizeof(now), &now);
+ (void)sched_getaffinity(getpid(), size, now);
fprintf(tip->vfp, "Pinned to CPU %02d ", tip->cpu);
for (i = 0; i < ncpus; i++)
- fprintf(tip->vfp, "%1d", CPU_ISSET(i, &now));
+ fprintf(tip->vfp, "%1d", CPU_ISSET_S(i, size, now));
fprintf(tip->vfp, "\n");
}
}
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) {
^ permalink raw reply related [flat|nested] 45+ messages in thread
* Recent changes (master)
2013-03-20 5:00 Jens Axboe
2013-08-02 4:00 ` Jens Axboe
@ 2013-12-04 4:56 ` Jens Axboe
2014-04-12 12:00 ` Jens Axboe
` (35 subsequent siblings)
37 siblings, 0 replies; 45+ messages in thread
From: Jens Axboe @ 2013-12-04 4:56 UTC (permalink / raw)
To: linux-btrace
The following changes since commit 0a915aabe88ff98786a88f30d2e062ef34d0826c:
blktrace blkreplay: convert to use a dynamic cpu_set_t (2013-08-01 12:13:26 -0600)
are available in the git repository at:
git://git.kernel.dk/blktrace.git master
Eiichi Tsukata (1):
blktrace bno_plot.py: output comprehensive message when gnuplot not found
btt/bno_plot.py | 5 ++---
1 files changed, 2 insertions(+), 3 deletions(-)
---
Diff of recent changes:
diff --git a/btt/bno_plot.py b/btt/bno_plot.py
index 19dfdfd..aa92480 100644
--- a/btt/bno_plot.py
+++ b/btt/bno_plot.py
@@ -114,13 +114,12 @@ if __name__ = '__main__':
pid = os.fork()
if pid = 0:
- cmd = '/usr/bin/gnuplot %s/plot.cmds -' % tmpdir
+ cmd = 'gnuplot %s/plot.cmds -' % tmpdir
if verbose: print 'Executing %s' % cmd
- cmd = cmd.split(None)
os.chdir(tmpdir)
- os.execvp(cmd[0], cmd)
+ os.system(cmd)
sys.exit(1)
os.waitpid(pid, 0)
^ permalink raw reply related [flat|nested] 45+ messages in thread
* Recent changes (master)
2013-03-20 5:00 Jens Axboe
2013-08-02 4:00 ` Jens Axboe
2013-12-04 4:56 ` Jens Axboe
@ 2014-04-12 12:00 ` Jens Axboe
2014-09-09 12:00 ` Jens Axboe
` (34 subsequent siblings)
37 siblings, 0 replies; 45+ messages in thread
From: Jens Axboe @ 2014-04-12 12:00 UTC (permalink / raw)
To: linux-btrace
The following changes since commit 3726f669cd305741e35ae759e0b21f3b04084e4e:
blktrace bno_plot.py: output comprehensive message when gnuplot not found (2013-12-03 19:25:21 -0700)
are available in the git repository at:
git://git.kernel.dk/blktrace.git master
for you to fetch changes up to ce9ded7165b846598b28107ceb2864ae1ad4b652:
remove unused barrier.h (2014-04-11 07:45:54 -0600)
----------------------------------------------------------------
Riku Voipio (1):
remove unused barrier.h
barrier.h | 33 ---------------------------------
1 file changed, 33 deletions(-)
delete mode 100644 barrier.h
---
Diff of recent changes:
diff --git a/barrier.h b/barrier.h
deleted file mode 100644
index 14d06b5..0000000
--- a/barrier.h
+++ /dev/null
@@ -1,33 +0,0 @@
-#ifndef BARRIER_H
-#define BARRIER_H
-
-#if defined(__ia64__)
- #define store_barrier() asm volatile ("mf" ::: "memory")
-#elif defined(__x86_64__)
- #define store_barrier() asm volatile("sfence" ::: "memory")
-#elif defined(__i386__)
- #define store_barrier() asm volatile ("": : :"memory")
-#elif defined(__ppc__) || defined(__powerpc__)
- #define store_barrier() asm volatile ("eieio" : : : "memory")
-#elif defined(__s390__) || defined(__s390x__)
- #define store_barrier() asm volatile ("bcr 15,0" : : : "memory")
-#elif defined(__alpha__)
- #define store_barrier() asm volatile("wmb": : :"memory")
-#elif defined(__hppa__)
- #define store_barrier() asm volatile("":::"memory")
-#elif defined(__sparc__)
- #define store_barrier() asm volatile("":::"memory")
-#elif defined(__m68000__) || defined(__m68k__) || defined(mc68000) || defined(_M_M68K)
- #define store_barrier() asm volatile("":::"memory")
-#elif defined(__mips__) /* also mipsel */
- #define store_barrier() do { } while(0)
-#elif defined(__arm__)
- /* taken from linux/arch/arm/kernel/entry-armv.S, thanks to pbrook! */
- typedef void (__kernel_dmb_t)(void);
- #define __kernel_dmb (*(__kernel_dmb_t *)0xffff0fa0)
- #define store_barrier() __kernel_dmb()
-#else
- #error Define store_barrier() for your CPU
-#endif
-
-#endif
^ permalink raw reply related [flat|nested] 45+ messages in thread
* Recent changes (master)
2013-03-20 5:00 Jens Axboe
` (2 preceding siblings ...)
2014-04-12 12:00 ` Jens Axboe
@ 2014-09-09 12:00 ` Jens Axboe
2014-09-26 12:00 ` Jens Axboe
` (33 subsequent siblings)
37 siblings, 0 replies; 45+ messages in thread
From: Jens Axboe @ 2014-09-09 12:00 UTC (permalink / raw)
To: linux-btrace
The following changes since commit ce9ded7165b846598b28107ceb2864ae1ad4b652:
remove unused barrier.h (2014-04-11 07:45:54 -0600)
are available in the git repository at:
git://git.kernel.dk/blktrace.git master
for you to fetch changes up to 838361c6cfb1319eadd59daaf9074dcdb92746e6:
signal condition variable at end of stop_tracers (2014-09-08 08:15:58 -0600)
----------------------------------------------------------------
Robert Schiele (1):
signal condition variable at end of stop_tracers
blktrace.c | 1 +
1 file changed, 1 insertion(+)
---
Diff of recent changes:
diff --git a/blktrace.c b/blktrace.c
index 7e64c94..3c8fb4c 100644
--- a/blktrace.c
+++ b/blktrace.c
@@ -1913,6 +1913,7 @@ static void stop_tracers(void)
struct tracer *tp = list_entry(p, struct tracer, head);
tp->is_done = 1;
}
+ pthread_cond_broadcast(&mt_cond);
}
static void del_tracers(void)
^ permalink raw reply related [flat|nested] 45+ messages in thread
* Recent changes (master)
2013-03-20 5:00 Jens Axboe
` (3 preceding siblings ...)
2014-09-09 12:00 ` Jens Axboe
@ 2014-09-26 12:00 ` Jens Axboe
2015-02-19 13:00 ` Jens Axboe
` (32 subsequent siblings)
37 siblings, 0 replies; 45+ messages in thread
From: Jens Axboe @ 2014-09-26 12:00 UTC (permalink / raw)
To: linux-btrace
The following changes since commit fe311e7c01593444f397d6d012ec212c4b22f514:
Makefile: ensure that iowatcher gets cleaned (2014-09-24 14:49:04 -0600)
are available in the git repository at:
git://git.kernel.dk/blktrace.git master
for you to fetch changes up to 2cf87e6092da7b36d5ef10c830ddf12d9e18121d:
iowatcher: wrap system() in a checker function (2014-09-25 15:17:06 -0600)
----------------------------------------------------------------
Andrew Price (4):
iowatcher: Add iowatcher to .gitignore
iowatcher: Move iowatcher.1 into doc directory
iowatcher: Remove iowatcher/README
Add iowatcher requirements to README
Chris Mason (2):
iowatcher: fixup the Makefile
iowatcher: check the return value from write()
Jens Axboe (3):
Merge git://git.kernel.org/pub/scm/linux/kernel/git/mason/blktrace
Merge branch 'for-upstream' of https://github.com/andyprice/blktrace
iowatcher: wrap system() in a checker function
.gitignore | 1 +
README | 2 +
{iowatcher => doc}/iowatcher.1 | 0
iowatcher/Makefile | 2 +-
iowatcher/README | 97 ------------------------------------
iowatcher/main.c | 20 ++++++--
iowatcher/plot.c | 107 ++++++++++++++++++++++------------------
7 files changed, 77 insertions(+), 152 deletions(-)
rename {iowatcher => doc}/iowatcher.1 (100%)
delete mode 100644 iowatcher/README
---
Diff of recent changes:
diff --git a/.gitignore b/.gitignore
index 2436e34..87a5d2d 100644
--- a/.gitignore
+++ b/.gitignore
@@ -11,3 +11,4 @@ verify_blkparse
btt/btt
btt/doc/btt.pdf
doc/blktrace.pdf
+iowatcher/iowatcher
diff --git a/README b/README
index f52f48d..d7d1fbf 100644
--- a/README
+++ b/README
@@ -31,6 +31,8 @@ your browser to:
http://git.kernel.dk/
+A blktrace visualization tool, iowatcher, was added to blktrace in version
+1.1.0. It requires librsvg and either png2theora or ffmpeg to generate movies.
Usage
-----
diff --git a/doc/iowatcher.1 b/doc/iowatcher.1
new file mode 100644
index 0000000..3044abf
--- /dev/null
+++ b/doc/iowatcher.1
@@ -0,0 +1,162 @@
+.TH iowatcher "1" "April 2014" "iowatcher" "User Commands"
+
+.SH NAME
+iowatcher - Create visualizations from blktrace results
+
+.SH SYNOPSIS
+.B iowatcher
+\fI[options]\fR [--] \fI[program arguments ...]\fR
+
+.SH DESCRIPTION
+iowatcher graphs the results of a blktrace run. It can graph the result of an existing blktrace, start a new blktrace, or start a new blktrace and a benchmark run. It can then create an image or movie of the IO from a given trace. iowatcher can produce either SVG files or movies in mp4 format (with ffmpeg) or ogg format (with png2theora).
+
+.SH OPTIONS
+.TP
+\fB--help\fP
+Print a brief usage summary.
+.TP
+\fB-d, --device\fP \fIdevice\fP
+Controls which device you are tracing. You can only trace one device at a time for now. It is sent directly to blktrace, and only needed when you are making a new trace.
+.TP
+\fB-D, --blktrace-destination\fP \fIdestination\fP
+Destination for blktrace.
+.TP
+\fB-p, --prog\fP
+Run a program while blktrace is run. The program and its arguments must be
+specified after all other options. Note that this option previously required
+the program to be given as a single argument but it now tells \fBiowatcher\fP
+to expect extra arguments which it should be run during the trace.
+.TP
+\fB--\fP
+End option parsing. If \fB--prog\fP is specified, everything after \fB--\fP is
+the program to be run. This can be useful if the program name could otherwise
+be mistaken for an option.
+.TP
+\fB-K, --keep-movie-svgs\fP
+Keep the SVG files generated for movie mode.
+.TP
+\fB-t, --trace\fP \fIpath\fP
+Specify the name of the file or directory in which blktrace output is located.
+\fBiowatcher\fP uses a dump from blkparse, so this option tries to guess the
+name of the corresponding per-CPU blktrace data files if the dump file doesn't
+already exist. To add multiple traces to a given graph, you can specify
+\fB--trace\fP more than once. If \fIpath\fP is a directory, \fBiowatcher\fP
+will use the name of the directory as the base name of the dump file and all
+trace files found inside the directory will be processed.
+.TP
+\fB-l, --label\fP \fIlabel\fP
+Sets a label in the graph for a trace file. The labels are added in the same order as the trace files.
+.TP
+\fB-m, --movie\fP \fI[style]\fP
+Create a movie. The file format depends on the extension used in the \fB-o\fP
+\fIfile\fP option. If you specify an .ogv or .ogg extension, the result will
+be Ogg Theora video, if png2theora is available. If you use an .mp4 extension,
+the result will be an mp4 video if ffmpeg is available. You can use any other
+extension, but the end result will be an mp4. The accepted \fIstyle\fP values
+are \fBspindle\fP for a circular disc-like effect (default) or \fBrect\fP for a
+rectangular graph style.
+.TP
+\fB-T, --title\fP \fItitle\fP
+Set a \fItitle\fP to be placed at the top of the graph.
+.TP
+\fB-o, --output\fP \fIfile\fP
+Output filename for the SVG image or video. The video format used will depend
+on the file name extension. See \fB--movie\fP for details.
+.TP
+\fB-r, --rolling\fP \fIseconds\fP
+Control the duration for the rolling average. \fBiowatcher\fP tries to smooth out bumpy graphs by averaging the current second with seconds from the past. Larger numbers here give you flatter graphs.
+.TP
+\fB-h, --height\fP \fIheight\fP
+Set the height of each graph
+.TP
+\fB-w, --width\fP \fIwidth\fP
+Set the width of each graph
+.TP
+\fB-c, --columns\fP \fIcolumns\fP
+Number of columns in graph output
+.TP
+\fB-x, --xzoom\fP \fImin:max\fP
+Limit processed time range to \fImin:max\fP.
+.TP
+\fB-y, --yzoom\fP \fImin:max\fP
+Limit processed sectors to \fImin:max\fP.
+.TP
+\fB-a, --io-plot-action\fP \fIaction\fP
+Plot \fIaction\fP (one of Q, D, or C) in the IO graph.
+.TP
+\fB-P, --per-process-io\fP
+Distinguish between processes in the IO graph.
+.TP
+\fB-O, --only-graph\fP \fIgraph\fP
+Add a single graph to the output (see section \fBGRAPHS\fP for options). By
+default all graphs are included. Use \fB-O\fP to generate only the required
+graphs. \fB-O\fP may be used more than once.
+.TP
+\fB-N, --no-graph\fP \fItype\fP
+Remove a single graph from the output (see section \fBGRAPHS\fP for options).
+This option may be used more than once.
+.SH GRAPHS
+Values accepted by the \fB-O\fP and \fB-N\fP options are:
+
+ io, tput, latency, queue_depth, iops, cpu-sys, cpu-io, cpu-irq, cpu-user, cpu-soft
+
+.SH EXAMPLES
+Generate graph from the existing trace.dump:
+.PP
+.RS
+# iowatcher -t trace
+.RE
+.PP
+Skip the IO graph:
+.PP
+.RS
+# iowatcher -t trace.dump -o trace.svg -N io
+.RE
+.PP
+Only graph tput and latency:
+.PP
+.RS
+# iowatcher -t trace.dump -o trace.svg -O tput -O latency
+.RE
+.PP
+Generate a graph from two runs, and label them:
+.PP
+.RS
+# iowatcher -t ext4.dump -t xfs.dump -l Ext4 -l XFS -o trace.svg
+.RE
+.PP
+Run a fio benchmark and store the trace in trace.dump, add a title to the top, use /dev/sda for blktrace:
+.PP
+.RS
+# iowatcher -d /dev/sda -t trace.dump -T 'Fio Benchmark' -p fio some_job_file
+.RE
+.PP
+Make a movie from an existing trace:
+.PP
+.RS
+# iowatcher -t trace --movie -o trace.mp4
+.RE
+
+.SH AUTHORS
+iowatcher was created and is maintained by Chris Mason.
+
+This man page was largely written by Andrew Price based on Chris's original README.
+
+.SH COPYRIGHT
+This program is free software; you can redistribute it and/or modify it under
+the terms of the GNU General Public License v2 as published by the Free
+Software Foundation.
+
+This program is distributed in the hope that it will be useful, but WITHOUT ANY
+WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+PARTICULAR PURPOSE. See the GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License along with
+this program; if not, write to the Free Software Foundation, Inc., 51 Franklin
+Street, Fifth Floor, Boston, MA 02110-1301 USA
+
+.SH "SEE ALSO"
+.BR blktrace (8),
+.BR blkparse (1),
+.BR fio (1),
+.BR mpstat (1)
diff --git a/iowatcher/Makefile b/iowatcher/Makefile
index e0f34b2..3551ea0 100644
--- a/iowatcher/Makefile
+++ b/iowatcher/Makefile
@@ -1,5 +1,5 @@
CC = gcc
-CFLAGS = -Wall -O0 -g -W
+CFLAGS = -Wall -O2 -g -W -Wunused-result
ALL_CFLAGS = $(CFLAGS) -D_GNU_SOURCE -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITSd
PROGS = iowatcher
diff --git a/iowatcher/README b/iowatcher/README
deleted file mode 100644
index 83db494..0000000
--- a/iowatcher/README
+++ /dev/null
@@ -1,97 +0,0 @@
-iowatcher graphs the results of a blktrace run. It has a few different modes:
-
- * Graph the result of an existing blktrace
-
- * Start a new blktrace
-
- * Start a new blktrace and a benchmark run
-
- * Make a movie of the IO from a given trace (only mp4 for now)
-
-Output:
-
- iowatcher can produce either svg files or mp4 movies. Most browsers
- can view the svg files, or you can use rsvg-view-3 from librsvg.
- rsvg-convert can turn the svgs into many other formats.
-
-Building:
-
- Type make and make install. We need ffmpeg or png2theora, and
- librsvg to make movies, otherwise there are no dependencies.
-
-The basic options:
-
- -d controls which device you are tracing. You can only trace one device
- at a time for now. It is sent directly to blktrace, and only
- needed when you are making a new trace.
-
- -t controls the name of the blktrace file. iowatcher uses a dump from
- blkparse, so -t tries to guess the name of the corresponding
- per CPU blktrace data files if the dump file doesn't already exist.
-
- If you want more than one trace in a given graph, you can specify
- -t more than once.
-
- -F Add a fio bandwidth log graph. You need to run fio --bandwidth-log
- to get one of these, and then pass either the read log or the write
- log into iowatcher.
-
- -l Sets a label in the graph for a trace file. The labels are added in
- the same order the trace files are added.
-
- -m Create a movie. The file format depends on the extension used in the
- -o filename.* option. If you specify an .ogv or .ogg extension, the
- result will be Ogg Theora video, if png2theora is available.
- If you use an .mp4 extension, the result will be an mp4 video if
- ffmpeg is avilable. You can use any other extension, but the end
- result will be an mp4.
-
- You can use --movie=spindle or --movie=rect, which changes the
- style of the IO mapping.
-
- -T Set a title for the graph. This goes at the top of the image.
-
- -o output filename. The default is trace.svg. iowatcher is
- only able to create svg for now.
-
- -r control the duration in seconds for the rolling average.
- iowatcher tries to smooth out bumpy graphs by averaging the
- current second with seconds from the past. Longer numbers here
- give you flatter graphs.
-
- -P add per-process tags to the IO. Each process responsible for
- submitting the IO gets a different color.
-
- -O add a single graph to the output. By default all the graphs
- are included, but with -O you get only the graphs you ask for.
- -O may be used more than once.
-
- -N remove a single graph from the output. This may also be used more
- than once.
-
- Choices for -O and -N are:
- io, fio, tput, latency, queue_depth, iops, cpu-sys, cpu-io,
- cpu-irq, cpu-user, cpu-soft
-
-Examples:
-
- # generate graph from the existing trace.dump
- iowatcher -t trace.dump -o trace.svg
-
- # skip the IO graph
- iowatcher -t trace.dump -o trace.svg -N io
-
- # only graph tput and latency
- iowatcher -t trace.dump -o trace.svg -O tput -O latency
-
- # generate a graph from two runs, and label them
- iowatcher -t ext4.dump -t xfs.dump -l Ext4 -l XFS -o trace.svg
-
- # Run a fio benchmark and store the trace in trace.dump
- # add a title to the top. Use /dev/sda for blktrace
- iowatcher -d /dev/sda -t trace.dump -T 'Fio Benchmark' -p 'fio some_job_file'
-
- # Make a movie from an existing trace
- iowatcher -t trace --movie -o trace.mp4
-
-Please email chris.mason@fusionio.com with any questions
diff --git a/iowatcher/iowatcher.1 b/iowatcher/iowatcher.1
deleted file mode 100644
index 3044abf..0000000
--- a/iowatcher/iowatcher.1
+++ /dev/null
@@ -1,162 +0,0 @@
-.TH iowatcher "1" "April 2014" "iowatcher" "User Commands"
-
-.SH NAME
-iowatcher - Create visualizations from blktrace results
-
-.SH SYNOPSIS
-.B iowatcher
-\fI[options]\fR [--] \fI[program arguments ...]\fR
-
-.SH DESCRIPTION
-iowatcher graphs the results of a blktrace run. It can graph the result of an existing blktrace, start a new blktrace, or start a new blktrace and a benchmark run. It can then create an image or movie of the IO from a given trace. iowatcher can produce either SVG files or movies in mp4 format (with ffmpeg) or ogg format (with png2theora).
-
-.SH OPTIONS
-.TP
-\fB--help\fP
-Print a brief usage summary.
-.TP
-\fB-d, --device\fP \fIdevice\fP
-Controls which device you are tracing. You can only trace one device at a time for now. It is sent directly to blktrace, and only needed when you are making a new trace.
-.TP
-\fB-D, --blktrace-destination\fP \fIdestination\fP
-Destination for blktrace.
-.TP
-\fB-p, --prog\fP
-Run a program while blktrace is run. The program and its arguments must be
-specified after all other options. Note that this option previously required
-the program to be given as a single argument but it now tells \fBiowatcher\fP
-to expect extra arguments which it should be run during the trace.
-.TP
-\fB--\fP
-End option parsing. If \fB--prog\fP is specified, everything after \fB--\fP is
-the program to be run. This can be useful if the program name could otherwise
-be mistaken for an option.
-.TP
-\fB-K, --keep-movie-svgs\fP
-Keep the SVG files generated for movie mode.
-.TP
-\fB-t, --trace\fP \fIpath\fP
-Specify the name of the file or directory in which blktrace output is located.
-\fBiowatcher\fP uses a dump from blkparse, so this option tries to guess the
-name of the corresponding per-CPU blktrace data files if the dump file doesn't
-already exist. To add multiple traces to a given graph, you can specify
-\fB--trace\fP more than once. If \fIpath\fP is a directory, \fBiowatcher\fP
-will use the name of the directory as the base name of the dump file and all
-trace files found inside the directory will be processed.
-.TP
-\fB-l, --label\fP \fIlabel\fP
-Sets a label in the graph for a trace file. The labels are added in the same order as the trace files.
-.TP
-\fB-m, --movie\fP \fI[style]\fP
-Create a movie. The file format depends on the extension used in the \fB-o\fP
-\fIfile\fP option. If you specify an .ogv or .ogg extension, the result will
-be Ogg Theora video, if png2theora is available. If you use an .mp4 extension,
-the result will be an mp4 video if ffmpeg is available. You can use any other
-extension, but the end result will be an mp4. The accepted \fIstyle\fP values
-are \fBspindle\fP for a circular disc-like effect (default) or \fBrect\fP for a
-rectangular graph style.
-.TP
-\fB-T, --title\fP \fItitle\fP
-Set a \fItitle\fP to be placed at the top of the graph.
-.TP
-\fB-o, --output\fP \fIfile\fP
-Output filename for the SVG image or video. The video format used will depend
-on the file name extension. See \fB--movie\fP for details.
-.TP
-\fB-r, --rolling\fP \fIseconds\fP
-Control the duration for the rolling average. \fBiowatcher\fP tries to smooth out bumpy graphs by averaging the current second with seconds from the past. Larger numbers here give you flatter graphs.
-.TP
-\fB-h, --height\fP \fIheight\fP
-Set the height of each graph
-.TP
-\fB-w, --width\fP \fIwidth\fP
-Set the width of each graph
-.TP
-\fB-c, --columns\fP \fIcolumns\fP
-Number of columns in graph output
-.TP
-\fB-x, --xzoom\fP \fImin:max\fP
-Limit processed time range to \fImin:max\fP.
-.TP
-\fB-y, --yzoom\fP \fImin:max\fP
-Limit processed sectors to \fImin:max\fP.
-.TP
-\fB-a, --io-plot-action\fP \fIaction\fP
-Plot \fIaction\fP (one of Q, D, or C) in the IO graph.
-.TP
-\fB-P, --per-process-io\fP
-Distinguish between processes in the IO graph.
-.TP
-\fB-O, --only-graph\fP \fIgraph\fP
-Add a single graph to the output (see section \fBGRAPHS\fP for options). By
-default all graphs are included. Use \fB-O\fP to generate only the required
-graphs. \fB-O\fP may be used more than once.
-.TP
-\fB-N, --no-graph\fP \fItype\fP
-Remove a single graph from the output (see section \fBGRAPHS\fP for options).
-This option may be used more than once.
-.SH GRAPHS
-Values accepted by the \fB-O\fP and \fB-N\fP options are:
-
- io, tput, latency, queue_depth, iops, cpu-sys, cpu-io, cpu-irq, cpu-user, cpu-soft
-
-.SH EXAMPLES
-Generate graph from the existing trace.dump:
-.PP
-.RS
-# iowatcher -t trace
-.RE
-.PP
-Skip the IO graph:
-.PP
-.RS
-# iowatcher -t trace.dump -o trace.svg -N io
-.RE
-.PP
-Only graph tput and latency:
-.PP
-.RS
-# iowatcher -t trace.dump -o trace.svg -O tput -O latency
-.RE
-.PP
-Generate a graph from two runs, and label them:
-.PP
-.RS
-# iowatcher -t ext4.dump -t xfs.dump -l Ext4 -l XFS -o trace.svg
-.RE
-.PP
-Run a fio benchmark and store the trace in trace.dump, add a title to the top, use /dev/sda for blktrace:
-.PP
-.RS
-# iowatcher -d /dev/sda -t trace.dump -T 'Fio Benchmark' -p fio some_job_file
-.RE
-.PP
-Make a movie from an existing trace:
-.PP
-.RS
-# iowatcher -t trace --movie -o trace.mp4
-.RE
-
-.SH AUTHORS
-iowatcher was created and is maintained by Chris Mason.
-
-This man page was largely written by Andrew Price based on Chris's original README.
-
-.SH COPYRIGHT
-This program is free software; you can redistribute it and/or modify it under
-the terms of the GNU General Public License v2 as published by the Free
-Software Foundation.
-
-This program is distributed in the hope that it will be useful, but WITHOUT ANY
-WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
-PARTICULAR PURPOSE. See the GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License along with
-this program; if not, write to the Free Software Foundation, Inc., 51 Franklin
-Street, Fifth Floor, Boston, MA 02110-1301 USA
-
-.SH "SEE ALSO"
-.BR blktrace (8),
-.BR blkparse (1),
-.BR fio (1),
-.BR mpstat (1)
diff --git a/iowatcher/main.c b/iowatcher/main.c
index cbf6c9a..2797afb 100644
--- a/iowatcher/main.c
+++ b/iowatcher/main.c
@@ -1016,12 +1016,22 @@ static void plot_queue_depth(struct plot *plot, unsigned int min_seconds,
total_graphs_written++;
}
+static void system_check(const char *cmd)
+{
+ if (system(cmd) < 0) {
+ int err = errno;
+
+ fprintf(stderr, "system exec failed (%d): %s\n", err, cmd);
+ exit(1);
+ }
+}
+
static void convert_movie_files(char *movie_dir)
{
fprintf(stderr, "Converting svg files in %s\n", movie_dir);
snprintf(line, line_len, "find %s -name \\*.svg | xargs -I{} -n 1 -P 8 rsvg-convert -o {}.png {}",
movie_dir);
- system(line);
+ system_check(line);
}
static void mencode_movie(char *movie_dir)
@@ -1030,7 +1040,7 @@ static void mencode_movie(char *movie_dir)
snprintf(line, line_len, "ffmpeg -r 20 -y -i %s/%%10d-%s.svg.png -b:v 250k "
"-vcodec %s %s", movie_dir, output_filename, ffmpeg_codec,
output_filename);
- system(line);
+ system_check(line);
}
static void tencode_movie(char *movie_dir)
@@ -1038,7 +1048,7 @@ static void tencode_movie(char *movie_dir)
fprintf(stderr, "Creating movie %s with png2theora\n", movie_dir);
snprintf(line, line_len, "png2theora -o %s %s/%%010d-%s.svg.png",
output_filename, movie_dir, output_filename);
- system(line);
+ system_check(line);
}
static void encode_movie(char *movie_dir)
@@ -1060,10 +1070,10 @@ static void cleanup_movie(char *movie_dir)
}
fprintf(stderr, "Removing movie dir %s\n", movie_dir);
snprintf(line, line_len, "rm %s/*", movie_dir);
- system(line);
+ system_check(line);
snprintf(line, line_len, "rmdir %s", movie_dir);
- system(line);
+ system_check(line);
}
static void plot_io_movie(struct plot *plot)
diff --git a/iowatcher/plot.c b/iowatcher/plot.c
index 8dd112d..012d4f9 100644
--- a/iowatcher/plot.c
+++ b/iowatcher/plot.c
@@ -249,6 +249,20 @@ static double rolling_avg(struct graph_line_pair *data, int index, int distance)
return sum / distance;
}
+static void write_check(int fd, char *buf, size_t size)
+{
+ ssize_t ret;
+
+ ret = write(fd, buf, size);
+ if (ret != (ssize_t)size) {
+ if (ret < 0)
+ perror("write failed");
+ else
+ fprintf(stderr, "error: short write\n");
+ exit(1);
+ }
+}
+
void write_svg_header(int fd)
{
char *spaces = " \n";
@@ -275,17 +289,17 @@ void write_svg_header(int fd)
final_width = 0;
final_height = 0;
- write(fd, header, strlen(header));
+ write_check(fd, header, strlen(header));
/* write a bunch of spaces so we can stuff in the width and height later */
- write(fd, spaces, strlen(spaces));
- write(fd, spaces, strlen(spaces));
- write(fd, spaces, strlen(spaces));
-
- write(fd, defs_start, strlen(defs_start));
- write(fd, filter1, strlen(filter1));
- write(fd, filter2, strlen(filter2));
- write(fd, filter3, strlen(filter3));
- write(fd, defs_close, strlen(defs_close));
+ write_check(fd, spaces, strlen(spaces));
+ write_check(fd, spaces, strlen(spaces));
+ write_check(fd, spaces, strlen(spaces));
+
+ write_check(fd, defs_start, strlen(defs_start));
+ write_check(fd, filter1, strlen(filter1));
+ write_check(fd, filter2, strlen(filter2));
+ write_check(fd, filter3, strlen(filter3));
+ write_check(fd, defs_close, strlen(defs_close));
}
/* svg y offset for the traditional 0,0 (bottom left corner) of the plot */
@@ -329,7 +343,6 @@ static int axis_x_off(int x)
*/
void setup_axis(struct plot *plot)
{
- int ret;
int len;
int fd = plot->fd;
int bump_height = tick_font_size * 3 + axis_label_font_size;
@@ -351,7 +364,7 @@ void setup_axis(struct plot *plot)
plot->start_y_offset, plot->total_width + 40,
plot->total_height + 20);
len = strlen(line);
- write(fd, line, len);
+ write_check(fd, line, len);
snprintf(line, line_len, "<rect x=\"%d\" y=\"%d\" width=\"%d\" "
"filter=\"url(#shadow)\" "
@@ -359,7 +372,7 @@ void setup_axis(struct plot *plot)
plot->start_x_offset + 15,
plot->start_y_offset, plot->total_width, plot->total_height);
len = strlen(line);
- write(fd, line, len);
+ write_check(fd, line, len);
plot->total_height += 20;
plot->total_width += 20;
@@ -370,18 +383,14 @@ void setup_axis(struct plot *plot)
/* create an svg object for all our coords to be relative against */
snprintf(line, line_len, "<svg x=\"%d\" y=\"%d\">\n", plot->start_x_offset, plot->start_y_offset);
- write(fd, line, strlen(line));
+ write_check(fd, line, strlen(line));
snprintf(line, 1024, "<path d=\"M%d %d h %d V %d H %d Z\" stroke=\"black\" stroke-width=\"2\" fill=\"none\"/>\n",
axis_x(), axis_y(),
graph_width + graph_inner_x_margin * 2, axis_y_off(graph_height) - graph_inner_y_margin,
axis_x());
len = strlen(line);
- ret = write(fd, line, len);
- if (ret != len) {
- fprintf(stderr, "failed to write svg axis\n");
- exit(1);
- }
+ write_check(fd, line, len);
}
/*
@@ -410,7 +419,7 @@ void setup_axis_spindle(struct plot *plot)
plot->start_y_offset, plot->total_width + 10,
plot->total_height + 20);
len = strlen(line);
- write(fd, line, len);
+ write_check(fd, line, len);
snprintf(line, line_len, "<rect x=\"%d\" y=\"%d\" width=\"%d\" "
"filter=\"url(#shadow)\" "
@@ -419,7 +428,7 @@ void setup_axis_spindle(struct plot *plot)
plot->start_y_offset, plot->total_width - 30,
plot->total_height);
len = strlen(line);
- write(fd, line, len);
+ write_check(fd, line, len);
plot->total_height += 20;
if (plot->total_height + plot->start_y_offset > final_height)
@@ -429,7 +438,7 @@ void setup_axis_spindle(struct plot *plot)
/* create an svg object for all our coords to be relative against */
snprintf(line, line_len, "<svg x=\"%d\" y=\"%d\">\n", plot->start_x_offset, plot->start_y_offset);
- write(fd, line, strlen(line));
+ write_check(fd, line, strlen(line));
}
@@ -451,7 +460,7 @@ void set_plot_title(struct plot *plot, char *title)
snprintf(line, line_len, "<rect x=\"0\" y=\"%d\" width=\"%d\" height=\"%d\" fill=\"white\" stroke=\"none\"/>",
plot->start_y_offset, plot->total_width + 40, plot_title_height + 20);
len = strlen(line);
- write(fd, line, len);
+ write_check(fd, line, len);
snprintf(line, line_len, "<text x=\"%d\" y=\"%d\" font-family=\"%s\" font-size=\"%d\" "
"font-weight=\"bold\" fill=\"black\" style=\"text-anchor: %s\">%s</text>\n",
@@ -460,7 +469,7 @@ void set_plot_title(struct plot *plot, char *title)
font_family, plot_title_font_size, "middle", title);
plot->start_y_offset += plot_title_height;
len = strlen(line);
- write(fd, line, len);
+ write_check(fd, line, len);
}
#define TICK_MINI_STEPS 3
@@ -516,7 +525,7 @@ void set_xticks(struct plot *plot, int num_ticks, int first, int last)
if (i != 0) {
snprintf(line, line_len, "<rect x=\"%d\" y=\"%d\" width=\"2\" height=\"%d\" style=\"stroke:none;fill:black;\"/>\n",
tick_x, tick_y, graph_tick_len);
- write(plot->fd, line, strlen(line));
+ write_check(plot->fd, line, strlen(line));
anchor = middle;
} else {
anchor = start;
@@ -533,7 +542,7 @@ void set_xticks(struct plot *plot, int num_ticks, int first, int last)
"fill=\"black\" style=\"text-anchor: %s\">%.2f</text>\n",
tick_x, text_y, font_family, tick_font_size, anchor,
first + step * i);
- write(plot->fd, line, strlen(line));
+ write_check(plot->fd, line, strlen(line));
}
tick_x += pixels_per_tick;
}
@@ -549,7 +558,7 @@ void set_xticks(struct plot *plot, int num_ticks, int first, int last)
"fill=\"black\" style=\"text-anchor: middle\">%.2f</text>\n",
axis_x_off(graph_width - 2),
text_y, font_family, tick_font_size, (double)last);
- write(plot->fd, line, strlen(line));
+ write_check(plot->fd, line, strlen(line));
}
}
@@ -568,7 +577,7 @@ void set_ylabel(struct plot *plot, char *label)
(int)axis_y_off(graph_height / 2),
axis_label_font_size, "middle", label);
len = strlen(line);
- write(fd, line, len);
+ write_check(fd, line, len);
}
void set_xlabel(struct plot *plot, char *label)
@@ -583,7 +592,7 @@ void set_xlabel(struct plot *plot, char *label)
font_family,
axis_label_font_size, "middle", label);
len = strlen(line);
- write(fd, line, len);
+ write_check(fd, line, len);
}
@@ -607,7 +616,7 @@ void set_yticks(struct plot *plot, int num_ticks, int first, int last, char *uni
"style=\"stroke:lightgray;stroke-width:2;stroke-dasharray:9,12;\"/>\n",
tick_x, axis_y_off(tick_y),
axis_x_off(graph_width), axis_y_off(tick_y));
- write(plot->fd, line, strlen(line));
+ write_check(plot->fd, line, strlen(line));
}
snprintf(line, line_len, "<text x=\"%d\" y=\"%d\" font-family=\"%s\" font-size=\"%d\" "
@@ -615,13 +624,13 @@ void set_yticks(struct plot *plot, int num_ticks, int first, int last, char *uni
text_x,
axis_y_off(tick_y - tick_font_size / 2),
font_family, tick_font_size, anchor, first + step * i, units);
- write(plot->fd, line, strlen(line));
+ write_check(plot->fd, line, strlen(line));
tick_y += pixels_per_tick;
}
snprintf(line, line_len, "<text x=\"%d\" y=\"%d\" font-family=\"%s\" font-size=\"%d\" "
"fill=\"black\" style=\"text-anchor: %s\">%d%s</text>\n",
text_x, axis_y_off(graph_height), font_family, tick_font_size, anchor, last, units);
- write(plot->fd, line, strlen(line));
+ write_check(plot->fd, line, strlen(line));
}
void set_plot_label(struct plot *plot, char *label)
@@ -635,14 +644,14 @@ void set_plot_label(struct plot *plot, char *label)
plot_label_height / 2,
font_family, plot_label_font_size, "middle", label);
len = strlen(line);
- write(fd, line, len);
+ write_check(fd, line, len);
}
static void close_svg(int fd)
{
char *close_line = "</svg>\n";
- write(fd, close_line, strlen(close_line));
+ write_check(fd, close_line, strlen(close_line));
}
int close_plot(struct plot *plot)
@@ -680,10 +689,10 @@ int close_plot_file(struct plot *plot)
snprintf(line, line_len, "<svg xmlns=\"http://www.w3.org/2000/svg\" "
"width=\"%d\" height=\"%d\">\n",
final_width, final_height);
- write(plot->fd, line, strlen(line));
+ write_check(plot->fd, line, strlen(line));
snprintf(line, line_len, "<rect x=\"0\" y=\"0\" width=\"%d\" "
"height=\"%d\" fill=\"white\"/>\n", final_width, final_height);
- write(plot->fd, line, strlen(line));
+ write_check(plot->fd, line, strlen(line));
close(plot->fd);
plot->fd = 0;
return 0;
@@ -788,19 +797,19 @@ int svg_line_graph(struct plot *plot, struct graph_line_data *gld, char *color,
if (!thresh1 && !thresh2) {
if (!printed_header) {
- write(fd, start, strlen(start));
+ write_check(fd, start, strlen(start));
printed_header = 1;
}
/* in full line mode, everything in the graph is connected */
snprintf(line, line_len, "%c %d %d ", c, axis_x_off(x), axis_y_off(val));
c = 'L';
- write(fd, line, strlen(line));
+ write_check(fd, line, strlen(line));
printed_lines = 1;
} else if (avg > thresh1 || avg > thresh2) {
int len = 10;
if (!printed_header) {
- write(fd, start, strlen(start));
+ write_check(fd, start, strlen(start));
printed_header = 1;
}
@@ -814,14 +823,14 @@ int svg_line_graph(struct plot *plot, struct graph_line_data *gld, char *color,
*/
snprintf(line, line_len, "M %d %d h %d ", axis_x_off(x),
axis_y_off(val), len);
- write(fd, line, strlen(line));
+ write_check(fd, line, strlen(line));
printed_lines = 1;
}
}
if (printed_lines) {
snprintf(line, line_len, "\" fill=\"none\" stroke=\"%s\" stroke-width=\"2\"/>\n", color);
- write(fd, line, strlen(line));
+ write_check(fd, line, strlen(line));
}
if (plot->timeline)
svg_write_time_line(plot, plot->timeline);
@@ -835,17 +844,17 @@ void svg_write_time_line(struct plot *plot, int col)
"style=\"stroke:black;stroke-width:2;\"/>\n",
axis_x_off(col), axis_y_off(0),
axis_x_off(col), axis_y_off(graph_height));
- write(plot->fd, line, strlen(line));
+ write_check(plot->fd, line, strlen(line));
}
-static int svg_add_io(int fd, double row, double col, double width, double height, char *color)
+static void svg_add_io(int fd, double row, double col, double width, double height, char *color)
{
float rx = 0;
snprintf(line, line_len, "<rect x=\"%.2f\" y=\"%.2f\" width=\"%.1f\" height=\"%.1f\" "
"rx=\"%.2f\" style=\"stroke:none;fill:%s;stroke-width:0\"/>\n",
axis_x_off_double(col), axis_y_off_double(row), width, height, rx, color);
- return write(fd, line, strlen(line));
+ write_check(fd, line, strlen(line));
}
int svg_io_graph_movie_array(struct plot *plot, struct pid_plot_history *pph)
@@ -902,11 +911,11 @@ int svg_io_graph_movie_array_spindle(struct plot *plot, struct pid_plot_history
"stroke=\"black\" stroke-width=\"6\" "
"r=\"%.2f\" fill=\"none\"/>\n",
spindle_steps * 1.2, center_x, center_y, center_x, center_y, graph_width_extra / 2);
- write(plot->fd, line, strlen(line));
+ write_check(plot->fd, line, strlen(line));
snprintf(line, line_len, "<circle cx=\"%.2f\" cy=\"%.2f\" "
"stroke=\"none\" fill=\"red\" r=\"%.2f\"/>\n</g>\n",
axis_x_off_double(graph_width_extra), center_y, 4.5);
- write(plot->fd, line, strlen(line));
+ write_check(plot->fd, line, strlen(line));
spindle_steps += 0.01;
radius = floor(radius / 2);
@@ -930,7 +939,7 @@ int svg_io_graph_movie_array_spindle(struct plot *plot, struct pid_plot_history
axis_x_off_double(graph_width_extra / 2 + radius) + 8, center_y,
radius, radius, pph->color);
- write(plot->fd, line, strlen(line));
+ write_check(plot->fd, line, strlen(line));
}
return 0;
}
@@ -1047,9 +1056,9 @@ void svg_write_legend(struct plot *plot)
legend_width,
plot->legend_index * legend_font_size + legend_font_size / 2 + 12);
- write(plot->fd, line, strlen(line));
+ write_check(plot->fd, line, strlen(line));
for (i = 0; i < plot->legend_index; i++) {
- write(plot->fd, plot->legend_lines[i],
+ write_check(plot->fd, plot->legend_lines[i],
strlen(plot->legend_lines[i]));
free(plot->legend_lines[i]);
}
^ permalink raw reply related [flat|nested] 45+ messages in thread
* Recent changes (master)
2013-03-20 5:00 Jens Axboe
` (4 preceding siblings ...)
2014-09-26 12:00 ` Jens Axboe
@ 2015-02-19 13:00 ` Jens Axboe
2015-08-21 12:00 ` Jens Axboe
` (31 subsequent siblings)
37 siblings, 0 replies; 45+ messages in thread
From: Jens Axboe @ 2015-02-19 13:00 UTC (permalink / raw)
To: linux-btrace
The following changes since commit 2cf87e6092da7b36d5ef10c830ddf12d9e18121d:
iowatcher: wrap system() in a checker function (2014-09-25 15:17:06 -0600)
are available in the git repository at:
git://git.kernel.dk/blktrace.git master
for you to fetch changes up to 88d38b4d0a5b33332fa80d7028a87c0717bb5d75:
Refer to sda instead of hda in man pages (2015-02-18 08:50:02 -0800)
----------------------------------------------------------------
Olaf Hering (1):
Refer to sda instead of hda in man pages
doc/blkparse.1 | 2 +-
doc/blktrace.8 | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
---
Diff of recent changes:
diff --git a/doc/blkparse.1 b/doc/blkparse.1
index 9193dbe..be9b34b 100644
--- a/doc/blkparse.1
+++ b/doc/blkparse.1
@@ -530,7 +530,7 @@ device and sector offset.
.SH EXAMPLES
-To trace the i/o on the device \fI/dev/hda\fB and parse the output to human
+To trace the i/o on the device \fI/dev/sda\fB and parse the output to human
readable form, use the following command:
% blktrace \-d /dev/sda \-o \- | blkparse \-i \-
diff --git a/doc/blktrace.8 b/doc/blktrace.8
index b5e69b7..df464be 100644
--- a/doc/blktrace.8
+++ b/doc/blktrace.8
@@ -236,7 +236,7 @@ sends the command data block as a payload so that blkparse can decode it.
.SH EXAMPLES
-To trace the i/o on the device \fI/dev/hda\fR and parse the output to human
+To trace the i/o on the device \fI/dev/sda\fR and parse the output to human
readable form, use the following command:
% blktrace \-d /dev/sda \-o \- | blkparse \-i \-
^ permalink raw reply related [flat|nested] 45+ messages in thread
* Recent changes (master)
2013-03-20 5:00 Jens Axboe
` (5 preceding siblings ...)
2015-02-19 13:00 ` Jens Axboe
@ 2015-08-21 12:00 ` Jens Axboe
2015-09-16 12:00 ` Jens Axboe
` (30 subsequent siblings)
37 siblings, 0 replies; 45+ messages in thread
From: Jens Axboe @ 2015-08-21 12:00 UTC (permalink / raw)
To: linux-btrace
The following changes since commit 88d38b4d0a5b33332fa80d7028a87c0717bb5d75:
Refer to sda instead of hda in man pages (2015-02-18 08:50:02 -0800)
are available in the git repository at:
git://git.kernel.dk/blktrace.git master
for you to fetch changes up to 2564a6029e55d6a0507ebb28a5a01f5dffb0bd56:
btreplay: Fix typo in scaling up the dynamic cpu set size. (2015-08-20 08:58:08 -0700)
----------------------------------------------------------------
Josef Cejka (1):
btreplay: Fix typo in scaling up the dynamic cpu set size.
btreplay/btreplay.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
---
Diff of recent changes:
diff --git a/btreplay/btreplay.c b/btreplay/btreplay.c
index 5444010..f762279 100644
--- a/btreplay/btreplay.c
+++ b/btreplay/btreplay.c
@@ -516,7 +516,7 @@ realloc:
if (sched_getaffinity(getpid(), size, cpus)) {
if( errno = EINVAL && nrcpus < (4096<<4) ) {
CPU_FREE(cpus);
- nrcpus <= 1;
+ nrcpus <<= 1;
goto realloc;
}
fatal("sched_getaffinity", ERR_SYSCALL, "Can't get CPU info\n");
^ permalink raw reply related [flat|nested] 45+ messages in thread
* Recent changes (master)
2013-03-20 5:00 Jens Axboe
` (6 preceding siblings ...)
2015-08-21 12:00 ` Jens Axboe
@ 2015-09-16 12:00 ` Jens Axboe
2016-01-09 13:00 ` Jens Axboe
` (29 subsequent siblings)
37 siblings, 0 replies; 45+ messages in thread
From: Jens Axboe @ 2015-09-16 12:00 UTC (permalink / raw)
To: linux-btrace
The following changes since commit 2564a6029e55d6a0507ebb28a5a01f5dffb0bd56:
btreplay: Fix typo in scaling up the dynamic cpu set size. (2015-08-20 08:58:08 -0700)
are available in the git repository at:
git://git.kernel.dk/blktrace.git master
for you to fetch changes up to dd093eb1c48e0d86b835758b96a9886fb7773aa4:
Fix warnings on newer gcc (2015-09-15 08:48:06 -0600)
----------------------------------------------------------------
Jens Axboe (1):
Fix warnings on newer gcc
Khem Raj (1):
include sys/types.h for dev_t definition
blkiomon.c | 2 +-
blktrace.h | 1 +
btreplay/btreplay.c | 4 ++--
3 files changed, 4 insertions(+), 3 deletions(-)
---
Diff of recent changes:
diff --git a/blkiomon.c b/blkiomon.c
index a895f65..f8b0c9d 100644
--- a/blkiomon.c
+++ b/blkiomon.c
@@ -198,7 +198,7 @@ static struct dstat *blkiomon_find_dstat(struct rb_search *search, __u32 device)
static struct dstat *blkiomon_get_dstat(__u32 device)
{
struct dstat *dstat;
- struct rb_search search;
+ struct rb_search search = { 0, };
pthread_mutex_lock(&dstat_mutex);
diff --git a/blktrace.h b/blktrace.h
index 380aec7..944fc08 100644
--- a/blktrace.h
+++ b/blktrace.h
@@ -5,6 +5,7 @@
#include <limits.h>
#include <byteswap.h>
#include <endian.h>
+#include <sys/types.h>
#include "blktrace_api.h"
#include "rbtree.h"
diff --git a/btreplay/btreplay.c b/btreplay/btreplay.c
index f762279..2a1e1cc 100644
--- a/btreplay/btreplay.c
+++ b/btreplay/btreplay.c
@@ -646,7 +646,7 @@ static void find_input_devs(char *idir)
static void read_map_devs(char *file_name)
{
FILE *fp;
- char *from_dev, *to_dev;
+ char from_dev[256], to_dev[256];
fp = fopen(file_name, "r");
if (!fp) {
@@ -654,7 +654,7 @@ static void read_map_devs(char *file_name)
/*NOTREACHED*/
}
- while (fscanf(fp, "%as %as", &from_dev, &to_dev) = 2) {
+ while (fscanf(fp, "%s %s", from_dev, to_dev) = 2) {
struct map_dev *mdp = malloc(sizeof(*mdp));
mdp->from_dev = from_dev;
^ permalink raw reply related [flat|nested] 45+ messages in thread
* Recent changes (master)
2013-03-20 5:00 Jens Axboe
` (7 preceding siblings ...)
2015-09-16 12:00 ` Jens Axboe
@ 2016-01-09 13:00 ` Jens Axboe
2016-02-10 13:00 ` Jens Axboe
` (28 subsequent siblings)
37 siblings, 0 replies; 45+ messages in thread
From: Jens Axboe @ 2016-01-09 13:00 UTC (permalink / raw)
To: linux-btrace
The following changes since commit dd093eb1c48e0d86b835758b96a9886fb7773aa4:
Fix warnings on newer gcc (2015-09-15 08:48:06 -0600)
are available in the git repository at:
git://git.kernel.dk/blktrace.git master
for you to fetch changes up to 8a1209713563b4dedea962909c18b941fb09d01a:
Add the "-a discard" filter option to the blktrace.8 man page (2016-01-08 11:46:03 -0700)
----------------------------------------------------------------
John Groves (1):
Add the "-a discard" filter option to the blktrace.8 man page
doc/blktrace.8 | 2 ++
1 file changed, 2 insertions(+)
---
Diff of recent changes:
diff --git a/doc/blktrace.8 b/doc/blktrace.8
index df464be..68f5e15 100644
--- a/doc/blktrace.8
+++ b/doc/blktrace.8
@@ -202,6 +202,8 @@ line options.
.br
\fIcomplete\fR: completed by driver
.br
+\fIdiscard\fR: discard / trim traces
+.br
\fIfs\fR: requests
.br
\fIissue\fR: issued to driver
^ permalink raw reply related [flat|nested] 45+ messages in thread
* Recent changes (master)
2013-03-20 5:00 Jens Axboe
` (8 preceding siblings ...)
2016-01-09 13:00 ` Jens Axboe
@ 2016-02-10 13:00 ` Jens Axboe
2016-04-26 12:00 ` Jens Axboe
` (27 subsequent siblings)
37 siblings, 0 replies; 45+ messages in thread
From: Jens Axboe @ 2016-02-10 13:00 UTC (permalink / raw)
To: linux-btrace
The following changes since commit 8a1209713563b4dedea962909c18b941fb09d01a:
Add the "-a discard" filter option to the blktrace.8 man page (2016-01-08 11:46:03 -0700)
are available in the git repository at:
git://git.kernel.dk/blktrace.git master
for you to fetch changes up to 80c4041b2e7a7d5afb75df563bf51bb27773c095:
blktrace: Use number of online CPUs (2016-02-09 08:17:50 -0700)
----------------------------------------------------------------
Abutalib Aghayev (1):
blktrace: Use number of online CPUs
blktrace.c | 4 ++--
btreplay/btreplay.c | 4 ++--
verify_blkparse.c | 4 ++--
3 files changed, 6 insertions(+), 6 deletions(-)
---
Diff of recent changes:
diff --git a/blktrace.c b/blktrace.c
index 3c8fb4c..b445524 100644
--- a/blktrace.c
+++ b/blktrace.c
@@ -2663,9 +2663,9 @@ int main(int argc, char *argv[])
setlocale(LC_NUMERIC, "en_US");
pagesize = getpagesize();
- ncpus = sysconf(_SC_NPROCESSORS_CONF);
+ ncpus = sysconf(_SC_NPROCESSORS_ONLN);
if (ncpus < 0) {
- fprintf(stderr, "sysconf(_SC_NPROCESSORS_CONF) failed %d/%s\n",
+ fprintf(stderr, "sysconf(_SC_NPROCESSORS_ONLN) failed %d/%s\n",
errno, strerror(errno));
ret = 1;
goto out;
diff --git a/btreplay/btreplay.c b/btreplay/btreplay.c
index 2a1e1cc..6d19564 100644
--- a/btreplay/btreplay.c
+++ b/btreplay/btreplay.c
@@ -502,8 +502,8 @@ static inline void start_iter(void)
*/
static void get_ncpus(void)
{
-#ifdef _SC_NPROCESSORS_CONF
- ncpus = sysconf(_SC_NPROCESSORS_CONF);
+#ifdef _SC_NPROCESSORS_ONLN
+ ncpus = sysconf(_SC_NPROCESSORS_ONLN);
#else
int nrcpus = 4096;
cpu_set_t * cpus;
diff --git a/verify_blkparse.c b/verify_blkparse.c
index 5689f43..3f3e92a 100644
--- a/verify_blkparse.c
+++ b/verify_blkparse.c
@@ -16,8 +16,8 @@ int main(int argc, char *argv[])
unsigned int seq;
FILE *f;
-#ifdef _SC_NPROCESSORS_CONF
- MAX_CPUS = sysconf(_SC_NPROCESSORS_CONF);
+#ifdef _SC_NPROCESSORS_ONLN
+ MAX_CPUS = sysconf(_SC_NPROCESSORS_ONLN);
if (MAX_CPUS < 1)
{
fprintf(stderr, "Could not determine number of CPUs online:\n%s\n",
^ permalink raw reply related [flat|nested] 45+ messages in thread
* Recent changes (master)
2013-03-20 5:00 Jens Axboe
` (9 preceding siblings ...)
2016-02-10 13:00 ` Jens Axboe
@ 2016-04-26 12:00 ` Jens Axboe
2016-05-04 12:00 ` Jens Axboe
` (26 subsequent siblings)
37 siblings, 0 replies; 45+ messages in thread
From: Jens Axboe @ 2016-04-26 12:00 UTC (permalink / raw)
To: linux-btrace
The following changes since commit 80c4041b2e7a7d5afb75df563bf51bb27773c095:
blktrace: Use number of online CPUs (2016-02-09 08:17:50 -0700)
are available in the git repository at:
git://git.kernel.dk/blktrace.git master
for you to fetch changes up to cbd4bc0a3f6386cd000cb842b9f1f6325e301623:
btreplay: remove timestamps (2016-04-25 08:54:34 -0600)
----------------------------------------------------------------
Olaf Hering (1):
btreplay: remove timestamps
Roman Pen (3):
btreplay: fix memory corruption caused by CPU_ZERO_S
btreplay: fix sched_{set|get}affinity
btreplay: make Ctrl-C work
btreplay/btrecord.c | 3 ---
btreplay/btreplay.c | 15 ++++++---------
2 files changed, 6 insertions(+), 12 deletions(-)
---
Diff of recent changes:
diff --git a/btreplay/btrecord.c b/btreplay/btrecord.c
index 3646257..a07ca07 100644
--- a/btreplay/btrecord.c
+++ b/btreplay/btrecord.c
@@ -18,8 +18,6 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
-static char build_date[] = __DATE__ " at "__TIME__;
-
#include <assert.h>
#include <fcntl.h>
#include <stdio.h>
@@ -449,7 +447,6 @@ void handle_args(int argc, char *argv[])
case 'V':
fprintf(stderr, "btrecord -- version %s\n",
my_btversion);
- fprintf(stderr, " Built on %s\n", build_date);
exit(0);
/*NOTREACHED*/
diff --git a/btreplay/btreplay.c b/btreplay/btreplay.c
index 6d19564..edaf81f 100644
--- a/btreplay/btreplay.c
+++ b/btreplay/btreplay.c
@@ -18,8 +18,6 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
-static char build_date[] = __DATE__ " at "__TIME__;
-
#include <assert.h>
#include <errno.h>
#include <fcntl.h>
@@ -275,7 +273,7 @@ static inline int is_send_done(struct thr_info *tip)
*/
static inline int is_reap_done(struct thr_info *tip)
{
- return tip->send_done && tip->naios_out = 0;
+ return signal_done || (tip->send_done && tip->naios_out = 0);
}
/**
@@ -513,7 +511,7 @@ realloc:
size = CPU_ALLOC_SIZE(nrcpus);
CPU_ZERO_S(size, cpus);
- if (sched_getaffinity(getpid(), size, cpus)) {
+ if (sched_getaffinity(0, size, cpus)) {
if( errno = EINVAL && nrcpus < (4096<<4) ) {
CPU_FREE(cpus);
nrcpus <<= 1;
@@ -550,18 +548,19 @@ static void pin_to_cpu(struct thr_info *tip)
assert(0 <= tip->cpu && tip->cpu < ncpus);
- CPU_ZERO_S(ncpus, cpus);
+ CPU_ZERO_S(size, cpus);
CPU_SET_S(tip->cpu, size, cpus);
- if (sched_setaffinity(getpid(), size, cpus)) {
+ if (sched_setaffinity(0, size, cpus)) {
fatal("sched_setaffinity", ERR_SYSCALL, "Failed to pin CPU\n");
/*NOTREACHED*/
}
+ assert(tip->cpu = sched_getcpu());
if (verbose > 1) {
int i;
cpu_set_t *now = CPU_ALLOC(ncpus);
- (void)sched_getaffinity(getpid(), size, now);
+ (void)sched_getaffinity(0, size, now);
fprintf(tip->vfp, "Pinned to CPU %02d ", tip->cpu);
for (i = 0; i < ncpus; i++)
fprintf(tip->vfp, "%1d", CPU_ISSET_S(i, size, now));
@@ -1558,8 +1557,6 @@ static void handle_args(int argc, char *argv[])
case 'V':
fprintf(stderr, "btreplay -- version %s\n",
my_btversion);
- fprintf(stderr, " Built on %s\n",
- build_date);
exit(0);
/*NOTREACHED*/
^ permalink raw reply related [flat|nested] 45+ messages in thread
* Recent changes (master)
2013-03-20 5:00 Jens Axboe
` (10 preceding siblings ...)
2016-04-26 12:00 ` Jens Axboe
@ 2016-05-04 12:00 ` Jens Axboe
2016-05-06 12:00 ` Jens Axboe
` (25 subsequent siblings)
37 siblings, 0 replies; 45+ messages in thread
From: Jens Axboe @ 2016-05-04 12:00 UTC (permalink / raw)
To: linux-btrace
The following changes since commit cbd4bc0a3f6386cd000cb842b9f1f6325e301623:
btreplay: remove timestamps (2016-04-25 08:54:34 -0600)
are available in the git repository at:
git://git.kernel.dk/blktrace.git master
for you to fetch changes up to d1422556dbff03e982aeb2faf5893b4363621bee:
btt/unplug_hist: fix bad memset (2016-05-03 08:34:50 -0600)
----------------------------------------------------------------
Jens Axboe (1):
btt/unplug_hist: fix bad memset
btt/unplug_hist.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
---
Diff of recent changes:
diff --git a/btt/unplug_hist.c b/btt/unplug_hist.c
index 89995de..be16b69 100644
--- a/btt/unplug_hist.c
+++ b/btt/unplug_hist.c
@@ -34,11 +34,11 @@ void *unplug_hist_alloc(struct d_info *dip)
{
struct hist_bkt *hbp;
- if (unplug_hist_name = NULL) return NULL;
+ if (unplug_hist_name = NULL)
+ return NULL;
- hbp = malloc(sizeof(*hbp));
+ hbp = calloc(1, sizeof(*hbp));
hbp->dip = dip;
- memset(hbp->hist, 0, NBKTS * sizeof(int));
return hbp;
}
^ permalink raw reply related [flat|nested] 45+ messages in thread
* Recent changes (master)
2013-03-20 5:00 Jens Axboe
` (11 preceding siblings ...)
2016-05-04 12:00 ` Jens Axboe
@ 2016-05-06 12:00 ` Jens Axboe
2016-05-20 12:00 ` Jens Axboe
` (24 subsequent siblings)
37 siblings, 0 replies; 45+ messages in thread
From: Jens Axboe @ 2016-05-06 12:00 UTC (permalink / raw)
To: linux-btrace
The following changes since commit d1422556dbff03e982aeb2faf5893b4363621bee:
btt/unplug_hist: fix bad memset (2016-05-03 08:34:50 -0600)
are available in the git repository at:
git://git.kernel.dk/blktrace.git master
for you to fetch changes up to 7644909627859a9d9d837df8b2ecf21a169f0ff0:
Fixup graph name in help text (2016-05-05 09:20:18 -0600)
----------------------------------------------------------------
Jan Kara (9):
Better max estimate for line graphs
Use maximum over all traces for queue depth
Process notify events outside of given interval
iowatcher: Use queue events if issue not available
btt: Replace overlapping IO
Zero sectors are strange
Don't prepend blktrace destination dir if we didn't run blktrace
Separate prefix in legend with space
Fixup graph name in help text
btt/dip_rb.c | 6 ++++--
iowatcher/blkparse.c | 16 ++++++++++++--
iowatcher/main.c | 59 +++++++++++++++++++++++++++++++++-------------------
iowatcher/plot.c | 28 +++++++++++++++++++++----
iowatcher/plot.h | 1 +
5 files changed, 81 insertions(+), 29 deletions(-)
---
Diff of recent changes:
diff --git a/btt/dip_rb.c b/btt/dip_rb.c
index 867a97b..2aa7ffc 100644
--- a/btt/dip_rb.c
+++ b/btt/dip_rb.c
@@ -37,8 +37,10 @@ int rb_insert(struct rb_root *root, struct io *iop)
p = &(*p)->rb_left;
else if (s > __s)
p = &(*p)->rb_right;
- else
- return 0;
+ else {
+ rb_replace_node(parent, &iop->rb_node, root);
+ return 1;
+ }
}
rb_link_node(&iop->rb_node, parent, p);
diff --git a/iowatcher/blkparse.c b/iowatcher/blkparse.c
index ef33d5b..c7d1d65 100644
--- a/iowatcher/blkparse.c
+++ b/iowatcher/blkparse.c
@@ -1097,8 +1097,19 @@ void add_pending_io(struct trace *trace, struct graph_line_data *gld)
return;
if (action = __BLK_TA_QUEUE) {
- if (trace->found_issue || trace->found_completion)
- hash_queued_io(trace->io);
+ if (io->sector = 0)
+ return;
+ if (trace->found_issue || trace->found_completion) {
+ pio = hash_queued_io(trace->io);
+ /*
+ * When there are no ISSUE events count depth and
+ * latency at least from queue events
+ */
+ if (pio && !trace->found_issue) {
+ pio->dispatch_time = io->time;
+ goto account_io;
+ }
+ }
return;
}
if (action = __BLK_TA_REQUEUE) {
@@ -1118,6 +1129,7 @@ void add_pending_io(struct trace *trace, struct graph_line_data *gld)
free(pio);
}
+account_io:
ios_in_flight++;
seconds = SECONDS(io->time);
diff --git a/iowatcher/main.c b/iowatcher/main.c
index 2797afb..54325fb 100644
--- a/iowatcher/main.c
+++ b/iowatcher/main.c
@@ -328,7 +328,10 @@ static void read_traces(void)
char *path = NULL;
list_for_each_entry(tf, &all_traces, list) {
- path = join_path(blktrace_dest_dir, tf->filename);
+ if (num_blktrace_devices)
+ path = join_path(blktrace_dest_dir, tf->filename);
+ else
+ path = strdup(tf->filename);
trace = open_trace(path);
if (!trace)
@@ -429,9 +432,9 @@ static void read_trace_events(void)
first_record(trace);
do {
+ check_record(trace);
if (SECONDS(get_record_time(trace)) > tf->max_seconds)
continue;
- check_record(trace);
add_tput(trace, tf->tput_writes_gld, tf->tput_reads_gld);
add_iop(trace, tf->iop_gld);
add_io(trace, tf);
@@ -774,7 +777,7 @@ static void plot_tput(struct plot *plot, unsigned int min_seconds,
struct trace_file *tf;
char *units;
char line[128];
- u64 max = 0;
+ u64 max = 0, val;
if (active_graphs[TPUT_GRAPH_INDEX] = 0)
return;
@@ -783,10 +786,12 @@ static void plot_tput(struct plot *plot, unsigned int min_seconds,
svg_alloc_legend(plot, num_traces * 2);
list_for_each_entry(tf, &all_traces, list) {
- if (tf->tput_writes_gld->max > max)
- max = tf->tput_writes_gld->max;
- if (tf->tput_reads_gld->max > max)
- max = tf->tput_reads_gld->max;
+ val = line_graph_roll_avg_max(tf->tput_writes_gld);
+ if (val > max)
+ max = val;
+ val = line_graph_roll_avg_max(tf->tput_reads_gld);
+ if (val > max)
+ max = val;
}
list_for_each_entry(tf, &all_traces, list) {
if (tf->tput_writes_gld->max > 0)
@@ -810,12 +815,12 @@ static void plot_tput(struct plot *plot, unsigned int min_seconds,
if (tf->tput_writes_gld->max > 0) {
svg_line_graph(plot, tf->tput_writes_gld, tf->writes_color, 0, 0);
if (with_legend)
- svg_add_legend(plot, tf->label, "Writes", tf->writes_color);
+ svg_add_legend(plot, tf->label, " Writes", tf->writes_color);
}
if (tf->tput_reads_gld->max > 0) {
svg_line_graph(plot, tf->tput_reads_gld, tf->reads_color, 0, 0);
if (with_legend)
- svg_add_legend(plot, tf->label, "Reads", tf->reads_color);
+ svg_add_legend(plot, tf->label, " Reads", tf->reads_color);
}
}
@@ -835,7 +840,7 @@ static void plot_fio_tput(struct plot *plot,
struct trace_file *tf;
char *units;
char line[128];
- u64 max = 0;
+ u64 max = 0, val;
if (num_fio_traces = 0 || active_graphs[FIO_GRAPH_INDEX] = 0)
return;
@@ -844,8 +849,9 @@ static void plot_fio_tput(struct plot *plot,
svg_alloc_legend(plot, num_fio_traces);
list_for_each_entry(tf, &fio_traces, list) {
- if (tf->fio_gld->max > max)
- max = tf->fio_gld->max;
+ val = line_graph_roll_avg_max(tf->fio_gld);
+ if (val > max)
+ max = val;
}
list_for_each_entry(tf, &fio_traces, list) {
@@ -988,6 +994,7 @@ static void plot_queue_depth(struct plot *plot, unsigned int min_seconds,
unsigned int max_seconds)
{
struct trace_file *tf;
+ u64 max = 0, val;
if (active_graphs[QUEUE_DEPTH_GRAPH_INDEX] = 0)
return;
@@ -997,9 +1004,17 @@ static void plot_queue_depth(struct plot *plot, unsigned int min_seconds,
if (num_traces > 1)
svg_alloc_legend(plot, num_traces);
- tf = list_entry(all_traces.next, struct trace_file, list);
+ list_for_each_entry(tf, &all_traces, list) {
+ val = line_graph_roll_avg_max(tf->queue_depth_gld);
+ if (val > max)
+ max = val;
+ }
+
+ list_for_each_entry(tf, &all_traces, list)
+ tf->queue_depth_gld->max = max;
+
set_ylabel(plot, "Pending IO");
- set_yticks(plot, num_yticks, 0, tf->queue_depth_gld->max, "");
+ set_yticks(plot, num_yticks, 0, max, "");
set_xticks(plot, num_xticks, min_seconds, max_seconds);
list_for_each_entry(tf, &all_traces, list) {
@@ -1190,7 +1205,7 @@ static void plot_latency(struct plot *plot, unsigned int min_seconds,
struct trace_file *tf;
char *units;
char line[128];
- u64 max = 0;
+ u64 max = 0, val;
if (active_graphs[LATENCY_GRAPH_INDEX] = 0)
return;
@@ -1199,8 +1214,9 @@ static void plot_latency(struct plot *plot, unsigned int min_seconds,
svg_alloc_legend(plot, num_traces);
list_for_each_entry(tf, &all_traces, list) {
- if (tf->latency_gld->max > max)
- max = tf->latency_gld->max;
+ val = line_graph_roll_avg_max(tf->latency_gld);
+ if (val > max)
+ max = val;
}
list_for_each_entry(tf, &all_traces, list)
@@ -1236,14 +1252,15 @@ static void plot_iops(struct plot *plot, unsigned int min_seconds,
{
struct trace_file *tf;
char *units;
- u64 max = 0;
+ u64 max = 0, val;
if (active_graphs[IOPS_GRAPH_INDEX] = 0)
return;
list_for_each_entry(tf, &all_traces, list) {
- if (tf->iop_gld->max > max)
- max = tf->iop_gld->max;
+ val = line_graph_roll_avg_max(tf->iop_gld);
+ if (val > max)
+ max = val;
}
list_for_each_entry(tf, &all_traces, list)
@@ -1345,7 +1362,7 @@ static void print_usage(void)
"\t-C (--codec): ffmpeg codec. Use ffmpeg -codecs to list\n"
"\t-r (--rolling): number of seconds in the rolling averge\n"
"\t-T (--title): graph title\n"
- "\t-N (--no-graph): skip a single graph (io, tput, latency, queue_depth, \n"
+ "\t-N (--no-graph): skip a single graph (io, tput, latency, queue-depth, \n"
"\t\t\tiops, cpu-sys, cpu-io, cpu-irq cpu-soft cpu-user)\n"
"\t-O (--only-graph): add a single graph to the output\n"
"\t-h (--height): set the height of each graph\n"
diff --git a/iowatcher/plot.c b/iowatcher/plot.c
index 012d4f9..372406b 100644
--- a/iowatcher/plot.c
+++ b/iowatcher/plot.c
@@ -759,6 +759,29 @@ void scale_line_graph_time(u64 *max, char **units)
*max /= div;
}
+static int rolling_span(struct graph_line_data *gld)
+{
+ if (rolling_avg_secs)
+ return rolling_avg_secs;
+ return (gld->stop_seconds - gld->min_seconds) / 25;
+}
+
+
+double line_graph_roll_avg_max(struct graph_line_data *gld)
+{
+ unsigned int i;
+ int rolling;
+ double avg, max = 0;
+
+ rolling = rolling_span(gld);
+ for (i = gld->min_seconds; i < gld->stop_seconds; i++) {
+ avg = rolling_avg(gld->data, i, rolling);
+ if (avg > max)
+ max = avg;
+ }
+ return max;
+}
+
int svg_line_graph(struct plot *plot, struct graph_line_data *gld, char *color, int thresh1, int thresh2)
{
unsigned int i;
@@ -776,10 +799,8 @@ int svg_line_graph(struct plot *plot, struct graph_line_data *gld, char *color,
if (thresh1 && thresh2)
rolling = 0;
- else if (rolling_avg_secs)
- rolling = rolling_avg_secs;
else
- rolling = (gld->stop_seconds - gld->min_seconds) / 25;
+ rolling = rolling_span(gld);
for (i = gld->min_seconds; i < gld->stop_seconds; i++) {
avg = rolling_avg(gld->data, i, rolling);
@@ -795,7 +816,6 @@ int svg_line_graph(struct plot *plot, struct graph_line_data *gld, char *color,
x = (double)(i - gld->min_seconds) / xscale;
if (!thresh1 && !thresh2) {
-
if (!printed_header) {
write_check(fd, start, strlen(start));
printed_header = 1;
diff --git a/iowatcher/plot.h b/iowatcher/plot.h
index 7e87b1d..d65bbcf 100644
--- a/iowatcher/plot.h
+++ b/iowatcher/plot.h
@@ -137,6 +137,7 @@ char *pick_fio_color(void);
char *pick_cpu_color(void);
void reset_cpu_color(void);
int svg_io_graph(struct plot *plot, struct graph_dot_data *gdd);
+double line_graph_roll_avg_max(struct graph_line_data *gld);
int svg_line_graph(struct plot *plot, struct graph_line_data *gld, char *color, int thresh1, int thresh2);
struct graph_line_data *alloc_line_data(unsigned int min_seconds, unsigned int max_seconds, unsigned int stop_seconds);
struct graph_dot_data *alloc_dot_data(unsigned int min_seconds, unsigned int max_seconds, u64 min_offset, u64 max_offset, unsigned int stop_seconds, char *color, char *label);
^ permalink raw reply related [flat|nested] 45+ messages in thread
* Recent changes (master)
2013-03-20 5:00 Jens Axboe
` (12 preceding siblings ...)
2016-05-06 12:00 ` Jens Axboe
@ 2016-05-20 12:00 ` Jens Axboe
2016-08-24 12:00 ` Jens Axboe
` (23 subsequent siblings)
37 siblings, 0 replies; 45+ messages in thread
From: Jens Axboe @ 2016-05-20 12:00 UTC (permalink / raw)
To: linux-btrace
The following changes since commit 7644909627859a9d9d837df8b2ecf21a169f0ff0:
Fixup graph name in help text (2016-05-05 09:20:18 -0600)
are available in the git repository at:
git://git.kernel.dk/blktrace.git master
for you to fetch changes up to 86596c7579c6e374e6e24c2b14398b0808a93f18:
blktrace: remove -k from manpage synopsis (2016-05-19 15:57:22 -0600)
----------------------------------------------------------------
Eric Sandeen (1):
blktrace: remove -k from manpage synopsis
doc/blktrace.8 | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
---
Diff of recent changes:
diff --git a/doc/blktrace.8 b/doc/blktrace.8
index 68f5e15..820b03a 100644
--- a/doc/blktrace.8
+++ b/doc/blktrace.8
@@ -6,7 +6,7 @@ blktrace \- generate traces of the i/o traffic on block devices
.SH SYNOPSIS
-.B blktrace \-d \fIdev\fR [ \-r \fIdebugfs_path\fR ] [ \-o \fIoutput\fR ] [\-k ] [ \-w \fItime\fR ] [ \-a \fIaction\fR ] [ \-A \fIaction_mask\fR ] [ \-v ]
+.B blktrace \-d \fIdev\fR [ \-r \fIdebugfs_path\fR ] [ \-o \fIoutput\fR ] [ \-w \fItime\fR ] [ \-a \fIaction\fR ] [ \-A \fIaction_mask\fR ] [ \-v ]
.br
^ permalink raw reply related [flat|nested] 45+ messages in thread
* Recent changes (master)
2013-03-20 5:00 Jens Axboe
` (13 preceding siblings ...)
2016-05-20 12:00 ` Jens Axboe
@ 2016-08-24 12:00 ` Jens Axboe
2017-01-27 13:00 ` Jens Axboe
` (22 subsequent siblings)
37 siblings, 0 replies; 45+ messages in thread
From: Jens Axboe @ 2016-08-24 12:00 UTC (permalink / raw)
To: linux-btrace
The following changes since commit 86596c7579c6e374e6e24c2b14398b0808a93f18:
blktrace: remove -k from manpage synopsis (2016-05-19 15:57:22 -0600)
are available in the git repository at:
git://git.kernel.dk/blktrace.git master
for you to fetch changes up to d1ab783430f5a832e973ed9a293da146c04c6702:
iowatcher: link with -lrt (2016-08-23 08:45:45 -0600)
----------------------------------------------------------------
Thomas Petazzoni (1):
iowatcher: link with -lrt
iowatcher/Makefile | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
---
Diff of recent changes:
diff --git a/iowatcher/Makefile b/iowatcher/Makefile
index 3551ea0..e013556 100644
--- a/iowatcher/Makefile
+++ b/iowatcher/Makefile
@@ -19,7 +19,7 @@ all: $(ALL)
$(CC) -o $*.o -c $(ALL_CFLAGS) $<
iowatcher: blkparse.o plot.o main.o tracers.o mpstat.o fio.o
- $(CC) $(ALL_CFLAGS) -o $@ $(filter %.o,$^) -lm
+ $(CC) $(ALL_CFLAGS) -o $@ $(filter %.o,$^) -lm -lrt
depend:
@$(CC) -MM $(ALL_CFLAGS) *.c 1> .depend
^ permalink raw reply related [flat|nested] 45+ messages in thread
* Recent changes (master)
2013-03-20 5:00 Jens Axboe
` (14 preceding siblings ...)
2016-08-24 12:00 ` Jens Axboe
@ 2017-01-27 13:00 ` Jens Axboe
2017-11-05 13:00 ` Jens Axboe
` (21 subsequent siblings)
37 siblings, 0 replies; 45+ messages in thread
From: Jens Axboe @ 2017-01-27 13:00 UTC (permalink / raw)
To: linux-btrace
The following changes since commit d1ab783430f5a832e973ed9a293da146c04c6702:
iowatcher: link with -lrt (2016-08-23 08:45:45 -0600)
are available in the git repository at:
git://git.kernel.dk/blktrace.git master
for you to fetch changes up to 8772bc4fb049bdd879de5952d6f291a34112fae0:
blktrace: Create empty output files for non-existent cpus (2017-01-26 10:06:05 -0700)
----------------------------------------------------------------
Jan Kara (3):
blktrace: Add support for sparse CPU numbers
blktrace: Reorganize creation of output file name
blktrace: Create empty output files for non-existent cpus
blktrace.c | 191 ++++++++++++++++++++++++++++++++++++++++++++++++++-----------
1 file changed, 156 insertions(+), 35 deletions(-)
---
Diff of recent changes:
diff --git a/blktrace.c b/blktrace.c
index b445524..e8f2f87 100644
--- a/blktrace.c
+++ b/blktrace.c
@@ -274,7 +274,9 @@ static char blktrace_version[] = "2.0.0";
int data_is_native = -1;
static int ndevs;
+static int max_cpus;
static int ncpus;
+static cpu_set_t *online_cpus;
static int pagesize;
static int act_mask = ~0U;
static int kill_running_trace;
@@ -623,8 +625,9 @@ static int lock_on_cpu(int cpu)
{
cpu_set_t * cpu_mask;
size_t size;
- cpu_mask = CPU_ALLOC(ncpus);
- size = CPU_ALLOC_SIZE(ncpus);
+
+ cpu_mask = CPU_ALLOC(max_cpus);
+ size = CPU_ALLOC_SIZE(max_cpus);
CPU_ZERO_S(size, cpu_mask);
CPU_SET_S(cpu, size, cpu_mask);
@@ -882,7 +885,7 @@ static int net_send_header(int fd, int cpu, char *buts_name, int len)
strncpy(hdr.buts_name, buts_name, sizeof(hdr.buts_name));
hdr.buts_name[sizeof(hdr.buts_name) - 1] = '\0';
hdr.cpu = cpu;
- hdr.max_cpus = ncpus;
+ hdr.max_cpus = max_cpus;
hdr.len = len;
hdr.cl_id = getpid();
hdr.buf_size = buf_size;
@@ -1026,9 +1029,12 @@ static int net_setup_client(void)
static int open_client_connections(void)
{
int cpu;
+ size_t alloc_size = CPU_ALLOC_SIZE(max_cpus);
cl_fds = calloc(ncpus, sizeof(*cl_fds));
- for (cpu = 0; cpu < ncpus; cpu++) {
+ for (cpu = 0; cpu < max_cpus; cpu++) {
+ if (!CPU_ISSET_S(cpu, alloc_size, online_cpus))
+ continue;
cl_fds[cpu] = net_setup_client();
if (cl_fds[cpu] < 0)
goto err;
@@ -1046,8 +1052,11 @@ static void close_client_connections(void)
{
if (cl_fds) {
int cpu, *fdp;
+ size_t alloc_size = CPU_ALLOC_SIZE(max_cpus);
- for (cpu = 0, fdp = cl_fds; cpu < ncpus; cpu++, fdp++) {
+ for (cpu = 0, fdp = cl_fds; cpu < max_cpus; cpu++, fdp++) {
+ if (!CPU_ISSET_S(cpu, alloc_size, online_cpus))
+ continue;
if (*fdp >= 0) {
net_send_drops(*fdp);
net_close_connection(fdp);
@@ -1071,7 +1080,7 @@ static void setup_buts(void)
buts.act_mask = act_mask;
if (ioctl(dpp->fd, BLKTRACESETUP, &buts) >= 0) {
- dpp->ncpus = ncpus;
+ dpp->ncpus = max_cpus;
dpp->buts_name = strdup(buts.name);
if (dpp->stats)
free(dpp->stats);
@@ -1155,7 +1164,7 @@ static void free_tracer_heads(struct devpath *dpp)
int cpu;
struct tracer_devpath_head *hd;
- for (cpu = 0, hd = dpp->heads; cpu < ncpus; cpu++, hd++) {
+ for (cpu = 0, hd = dpp->heads; cpu < max_cpus; cpu++, hd++) {
if (hd->prev)
free(hd->prev);
@@ -1177,8 +1186,8 @@ static int setup_tracer_devpaths(void)
struct tracer_devpath_head *hd;
struct devpath *dpp = list_entry(p, struct devpath, head);
- dpp->heads = calloc(ncpus, sizeof(struct tracer_devpath_head));
- for (cpu = 0, hd = dpp->heads; cpu < ncpus; cpu++, hd++) {
+ dpp->heads = calloc(max_cpus, sizeof(struct tracer_devpath_head));
+ for (cpu = 0, hd = dpp->heads; cpu < max_cpus; cpu++, hd++) {
INIT_LIST_HEAD(&hd->head);
pthread_mutex_init(&hd->mutex, NULL);
hd->prev = NULL;
@@ -1426,7 +1435,7 @@ static void __process_trace_bufs(void)
struct devpath *dpp = list_entry(p, struct devpath, head);
struct tracer_devpath_head *hd = dpp->heads;
- for (cpu = 0; cpu < ncpus; cpu++, hd++) {
+ for (cpu = 0; cpu < max_cpus; cpu++, hd++) {
pthread_mutex_lock(&hd->mutex);
if (list_empty(&hd->head)) {
pthread_mutex_unlock(&hd->mutex);
@@ -1493,30 +1502,25 @@ static inline int net_sendfile_data(struct tracer *tp, struct io_info *iop)
return net_sendfile(iop);
}
-static int fill_ofname(struct io_info *iop, int cpu)
+static int fill_ofname(char *dst, int dstlen, char *subdir, char *buts_name,
+ int cpu)
{
int len;
struct stat sb;
- char *dst = iop->ofn;
if (output_dir)
- len = snprintf(iop->ofn, sizeof(iop->ofn), "%s/", output_dir);
+ len = snprintf(dst, dstlen, "%s/", output_dir);
else
- len = snprintf(iop->ofn, sizeof(iop->ofn), "./");
+ len = snprintf(dst, dstlen, "./");
- if (net_mode = Net_server) {
- struct cl_conn *nc = iop->nc;
-
- len += sprintf(dst + len, "%s-", nc->ch->hostname);
- len += strftime(dst + len, 64, "%F-%T/",
- gmtime(&iop->dpp->cl_connect_time));
- }
+ if (subdir)
+ len += snprintf(dst + len, dstlen - len, "%s", subdir);
- if (stat(iop->ofn, &sb) < 0) {
+ if (stat(dst, &sb) < 0) {
if (errno != ENOENT) {
fprintf(stderr,
"Destination dir %s stat failed: %d/%s\n",
- iop->ofn, errno, strerror(errno));
+ dst, errno, strerror(errno));
return 1;
}
/*
@@ -1524,20 +1528,20 @@ static int fill_ofname(struct io_info *iop, int cpu)
* trying to create the directory at once. It's harmless
* to let them try, so just detect the problem and move on.
*/
- if (mkdir(iop->ofn, 0755) < 0 && errno != EEXIST) {
+ if (mkdir(dst, 0755) < 0 && errno != EEXIST) {
fprintf(stderr,
"Destination dir %s can't be made: %d/%s\n",
- iop->ofn, errno, strerror(errno));
+ dst, errno, strerror(errno));
return 1;
}
}
if (output_name)
- snprintf(iop->ofn + len, sizeof(iop->ofn), "%s.blktrace.%d",
+ snprintf(dst + len, dstlen - len, "%s.blktrace.%d",
output_name, cpu);
else
- snprintf(iop->ofn + len, sizeof(iop->ofn), "%s.blktrace.%d",
- iop->dpp->buts_name, cpu);
+ snprintf(dst + len, dstlen - len, "%s.blktrace.%d",
+ buts_name, cpu);
return 0;
}
@@ -1558,8 +1562,23 @@ static int set_vbuf(struct io_info *iop, int mode, size_t size)
static int iop_open(struct io_info *iop, int cpu)
{
+ char hostdir[MAXPATHLEN + 64];
+
iop->ofd = -1;
- if (fill_ofname(iop, cpu))
+ if (net_mode = Net_server) {
+ struct cl_conn *nc = iop->nc;
+ int len;
+
+ len = snprintf(hostdir, sizeof(hostdir), "%s-",
+ nc->ch->hostname);
+ len += strftime(hostdir + len, sizeof(hostdir) - len, "%F-%T/",
+ gmtime(&iop->dpp->cl_connect_time));
+ } else {
+ hostdir[0] = 0;
+ }
+
+ if (fill_ofname(iop->ofn, sizeof(iop->ofn), hostdir,
+ iop->dpp->buts_name, cpu))
return 1;
iop->ofp = my_fopen(iop->ofn, "w+");
@@ -1874,16 +1893,49 @@ static int start_tracer(int cpu)
return 0;
}
+static int create_output_files(int cpu)
+{
+ char fname[MAXPATHLEN + 64];
+ struct list_head *p;
+ FILE *f;
+
+ __list_for_each(p, &devpaths) {
+ struct devpath *dpp = list_entry(p, struct devpath, head);
+
+ if (fill_ofname(fname, sizeof(fname), NULL, dpp->buts_name,
+ cpu))
+ return 1;
+ f = my_fopen(fname, "w+");
+ if (!f)
+ return 1;
+ fclose(f);
+ }
+ return 0;
+}
+
static void start_tracers(void)
{
- int cpu;
+ int cpu, started = 0;
struct list_head *p;
+ size_t alloc_size = CPU_ALLOC_SIZE(max_cpus);
- for (cpu = 0; cpu < ncpus; cpu++)
+ for (cpu = 0; cpu < max_cpus; cpu++) {
+ if (!CPU_ISSET_S(cpu, alloc_size, online_cpus)) {
+ /*
+ * Create fake empty output files so that other tools
+ * like blkparse don't have to bother with sparse CPU
+ * number space.
+ */
+ if (create_output_files(cpu))
+ break;
+ continue;
+ }
if (start_tracer(cpu))
break;
+ started++;
+ }
- wait_tracers_ready(cpu);
+ wait_tracers_ready(started);
__list_for_each(p, &tracers) {
struct tracer *tp = list_entry(p, struct tracer, head);
@@ -2657,15 +2709,83 @@ static int run_tracers(void)
return 0;
}
+static cpu_set_t *get_online_cpus(void)
+{
+ FILE *cpus;
+ cpu_set_t *set;
+ size_t alloc_size;
+ int cpuid, prevcpuid = -1;
+ char nextch;
+ int n, ncpu, curcpu = 0;
+ int *cpu_nums;
+
+ ncpu = sysconf(_SC_NPROCESSORS_CONF);
+ if (ncpu < 0)
+ return NULL;
+
+ cpu_nums = malloc(sizeof(int)*ncpu);
+ if (!cpu_nums) {
+ errno = ENOMEM;
+ return NULL;
+ }
+
+ /*
+ * There is no way to easily get maximum CPU number. So we have to
+ * parse the file first to find it out and then create appropriate
+ * cpuset
+ */
+ cpus = my_fopen("/sys/devices/system/cpu/online", "r");
+ for (;;) {
+ n = fscanf(cpus, "%d%c", &cpuid, &nextch);
+ if (n <= 0)
+ break;
+ if (n = 2 && nextch = '-') {
+ prevcpuid = cpuid;
+ continue;
+ }
+ if (prevcpuid = -1)
+ prevcpuid = cpuid;
+ while (prevcpuid <= cpuid) {
+ /* More CPUs listed than configured? */
+ if (curcpu >= ncpu) {
+ errno = EINVAL;
+ return NULL;
+ }
+ cpu_nums[curcpu++] = prevcpuid++;
+ }
+ prevcpuid = -1;
+ }
+ fclose(cpus);
+
+ ncpu = curcpu;
+ max_cpus = cpu_nums[ncpu - 1] + 1;
+
+ /* Now that we have maximum cpu number, create a cpuset */
+ set = CPU_ALLOC(max_cpus);
+ if (!set) {
+ errno = ENOMEM;
+ return NULL;
+ }
+ alloc_size = CPU_ALLOC_SIZE(max_cpus);
+ CPU_ZERO_S(alloc_size, set);
+
+ for (curcpu = 0; curcpu < ncpu; curcpu++)
+ CPU_SET_S(cpu_nums[curcpu], alloc_size, set);
+
+ free(cpu_nums);
+
+ return set;
+}
+
int main(int argc, char *argv[])
{
int ret = 0;
setlocale(LC_NUMERIC, "en_US");
pagesize = getpagesize();
- ncpus = sysconf(_SC_NPROCESSORS_ONLN);
- if (ncpus < 0) {
- fprintf(stderr, "sysconf(_SC_NPROCESSORS_ONLN) failed %d/%s\n",
+ online_cpus = get_online_cpus();
+ if (!online_cpus) {
+ fprintf(stderr, "cannot get online cpus %d/%s\n",
errno, strerror(errno));
ret = 1;
goto out;
@@ -2674,6 +2794,7 @@ int main(int argc, char *argv[])
goto out;
}
+ ncpus = CPU_COUNT_S(CPU_ALLOC_SIZE(max_cpus), online_cpus);
if (ndevs > 1 && output_name && strcmp(output_name, "-") != 0) {
fprintf(stderr, "-o not supported with multiple devices\n");
ret = 1;
^ permalink raw reply related [flat|nested] 45+ messages in thread
* Recent changes (master)
2013-03-20 5:00 Jens Axboe
` (15 preceding siblings ...)
2017-01-27 13:00 ` Jens Axboe
@ 2017-11-05 13:00 ` Jens Axboe
2017-11-06 13:00 ` Jens Axboe
` (20 subsequent siblings)
37 siblings, 0 replies; 45+ messages in thread
From: Jens Axboe @ 2017-11-05 13:00 UTC (permalink / raw)
To: linux-btrace
The following changes since commit 8772bc4fb049bdd879de5952d6f291a34112fae0:
blktrace: Create empty output files for non-existent cpus (2017-01-26 10:06:05 -0700)
are available in the git repository at:
git://git.kernel.dk/blktrace.git master
for you to fetch changes up to cca113f2fe0759b91fd6a0e10fdcda2c28f18a7e:
Blktrace 1.2.0 (2017-11-04 22:13:06 -0600)
----------------------------------------------------------------
Jens Axboe (2):
blktrace: abort if device ioctl setup fails
Blktrace 1.2.0
blkparse.c | 2 +-
blktrace.c | 12 +++++++++---
2 files changed, 10 insertions(+), 4 deletions(-)
---
Diff of recent changes:
diff --git a/blkparse.c b/blkparse.c
index ab5edc2..227cc44 100644
--- a/blkparse.c
+++ b/blkparse.c
@@ -36,7 +36,7 @@
#include "rbtree.h"
#include "jhash.h"
-static char blkparse_version[] = "1.1.0";
+static char blkparse_version[] = "1.2.0";
struct skip_info {
unsigned long start, end;
diff --git a/blktrace.c b/blktrace.c
index e8f2f87..e048f68 100644
--- a/blktrace.c
+++ b/blktrace.c
@@ -1066,9 +1066,10 @@ static void close_client_connections(void)
}
}
-static void setup_buts(void)
+static int setup_buts(void)
{
struct list_head *p;
+ int ret = 0;
__list_for_each(p, &devpaths) {
struct blk_user_trace_setup buts;
@@ -1086,10 +1087,14 @@ static void setup_buts(void)
free(dpp->stats);
dpp->stats = calloc(dpp->ncpus, sizeof(*dpp->stats));
memset(dpp->stats, 0, dpp->ncpus * sizeof(*dpp->stats));
- } else
+ } else {
fprintf(stderr, "BLKTRACESETUP(2) %s failed: %d/%s\n",
dpp->path, errno, strerror(errno));
+ ret++;
+ }
}
+
+ return ret;
}
static void start_buts(void)
@@ -2676,7 +2681,8 @@ static int run_tracers(void)
if (net_mode = Net_client)
printf("blktrace: connecting to %s\n", hostname);
- setup_buts();
+ if (setup_buts())
+ return 1;
if (use_tracer_devpaths()) {
if (setup_tracer_devpaths())
^ permalink raw reply related [flat|nested] 45+ messages in thread
* Recent changes (master)
2013-03-20 5:00 Jens Axboe
` (16 preceding siblings ...)
2017-11-05 13:00 ` Jens Axboe
@ 2017-11-06 13:00 ` Jens Axboe
2017-11-08 13:00 ` Jens Axboe
` (19 subsequent siblings)
37 siblings, 0 replies; 45+ messages in thread
From: Jens Axboe @ 2017-11-06 13:00 UTC (permalink / raw)
To: linux-btrace
The following changes since commit cca113f2fe0759b91fd6a0e10fdcda2c28f18a7e:
Blktrace 1.2.0 (2017-11-04 22:13:06 -0600)
are available in the git repository at:
git://git.kernel.dk/blktrace.git master
for you to fetch changes up to 07d76e12aa46fa0bad4b736d581ec5aca62264f7:
btt/devs: silence warning on sprintf overflow (2017-11-05 08:54:41 -0700)
----------------------------------------------------------------
Jens Axboe (2):
jhash: fix annoying gcc fall through warnings
btt/devs: silence warning on sprintf overflow
btt/devs.c | 2 +-
jhash.h | 34 ++++++++++++++++------------------
2 files changed, 17 insertions(+), 19 deletions(-)
---
Diff of recent changes:
diff --git a/btt/devs.c b/btt/devs.c
index ccaae87..12ce2ca 100644
--- a/btt/devs.c
+++ b/btt/devs.c
@@ -108,7 +108,7 @@ void dip_exit(void)
static inline FILE *open_pit(struct d_info *dip)
{
FILE *fp;
- char str[256];
+ char str[272];
sprintf(str, "%s_pit.dat", dip->dip_name);
if ((fp = my_fopen(str, "w")) = NULL)
diff --git a/jhash.h b/jhash.h
index 4cebd23..a4d3106 100644
--- a/jhash.h
+++ b/jhash.h
@@ -73,22 +73,21 @@ static inline u32 jhash(const void *key, u32 length, u32 initval)
k += 12;
}
- /* last block: affect all 32 bits of (c) */
- /* all the case statements fall through */
+ /* Last block: affect all 32 bits of (c) */
switch (length) {
- case 12: c += (u32)k[11]<<24;
- case 11: c += (u32)k[10]<<16;
- case 10: c += (u32)k[9]<<8;
- case 9 : c += k[8];
- case 8 : b += (u32)k[7]<<24;
- case 7 : b += (u32)k[6]<<16;
- case 6 : b += (u32)k[5]<<8;
- case 5 : b += k[4];
- case 4 : a += (u32)k[3]<<24;
- case 3 : a += (u32)k[2]<<16;
- case 2 : a += (u32)k[1]<<8;
- case 1 : a += k[0];
- __jhash_final(a, b, c);
+ case 12: c += (u32)k[11]<<24; /* fall through */
+ case 11: c += (u32)k[10]<<16; /* fall through */
+ case 10: c += (u32)k[9]<<8; /* fall through */
+ case 9: c += k[8]; /* fall through */
+ case 8: b += (u32)k[7]<<24; /* fall through */
+ case 7: b += (u32)k[6]<<16; /* fall through */
+ case 6: b += (u32)k[5]<<8; /* fall through */
+ case 5: b += k[4]; /* fall through */
+ case 4: a += (u32)k[3]<<24; /* fall through */
+ case 3: a += (u32)k[2]<<16; /* fall through */
+ case 2: a += (u32)k[1]<<8; /* fall through */
+ case 1: a += k[0];
+ __jhash_final(a, b, c);
case 0 :
break;
}
@@ -117,10 +116,9 @@ static inline u32 jhash2(u32 *k, u32 length, u32 initval)
}
/* handle the last 3 u32's */
- /* all the case statements fall through */
switch (length) {
- case 3: c += k[2];
- case 2: b += k[1];
+ case 3: c += k[2]; /* fall through */
+ case 2: b += k[1]; /* fall through */
case 1: a += k[0];
__jhash_final(a, b, c);
case 0: /* case 0: nothing left to add */
^ permalink raw reply related [flat|nested] 45+ messages in thread
* Recent changes (master)
2013-03-20 5:00 Jens Axboe
` (17 preceding siblings ...)
2017-11-06 13:00 ` Jens Axboe
@ 2017-11-08 13:00 ` Jens Axboe
2018-01-24 13:00 ` Jens Axboe
` (18 subsequent siblings)
37 siblings, 0 replies; 45+ messages in thread
From: Jens Axboe @ 2017-11-08 13:00 UTC (permalink / raw)
To: linux-btrace
The following changes since commit 07d76e12aa46fa0bad4b736d581ec5aca62264f7:
btt/devs: silence warning on sprintf overflow (2017-11-05 08:54:41 -0700)
are available in the git repository at:
git://git.kernel.dk/blktrace.git master
for you to fetch changes up to 8fc451c6b0b9a7db7c376ea6865c35321e561f00:
btt: Fix overlapping IO stats. (2017-11-07 11:25:38 -0700)
----------------------------------------------------------------
Gwendal Grignou (1):
btt: Fix overlapping IO stats.
btt/dip_rb.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
---
Diff of recent changes:
diff --git a/btt/dip_rb.c b/btt/dip_rb.c
index 2aa7ffc..6efef6c 100644
--- a/btt/dip_rb.c
+++ b/btt/dip_rb.c
@@ -57,7 +57,7 @@ struct io *rb_find_sec(struct rb_root *root, __u64 sec)
__iop = rb_entry(n, struct io, rb_node);
if (sec < BIT_START(__iop))
n = n->rb_left;
- else if (sec >= BIT_END(__iop))
+ else if (sec > BIT_START(__iop))
n = n->rb_right;
else
return __iop;
@@ -82,7 +82,7 @@ void rb_foreach(struct rb_node *n, struct io *iop,
}
if (iop_s < this_s)
rb_foreach(n->rb_left, iop, fnc, head);
- if (this_e < iop_e)
+ if ((this_e < iop_e) || (this_s < iop_s))
rb_foreach(n->rb_right, iop, fnc, head);
}
}
^ permalink raw reply related [flat|nested] 45+ messages in thread
* Recent changes (master)
2013-03-20 5:00 Jens Axboe
` (18 preceding siblings ...)
2017-11-08 13:00 ` Jens Axboe
@ 2018-01-24 13:00 ` Jens Axboe
2018-01-25 13:00 ` Jens Axboe
` (17 subsequent siblings)
37 siblings, 0 replies; 45+ messages in thread
From: Jens Axboe @ 2018-01-24 13:00 UTC (permalink / raw)
To: linux-btrace
The following changes since commit 8fc451c6b0b9a7db7c376ea6865c35321e561f00:
btt: Fix overlapping IO stats. (2017-11-07 11:25:38 -0700)
are available in the git repository at:
git://git.kernel.dk/blktrace.git master
for you to fetch changes up to 519fd9a5d08d85f3d9cb4192d624fe8351e40232:
fix parallel build failures (2018-01-23 15:59:13 -0700)
----------------------------------------------------------------
Robin H. Johnson (2):
respect LDFLAGS when linking programs
fix parallel build failures
Makefile | 34 +++++++++++++++-------------------
btreplay/Makefile | 4 ++--
btt/Makefile | 2 +-
iowatcher/Makefile | 2 +-
4 files changed, 19 insertions(+), 23 deletions(-)
---
Diff of recent changes:
diff --git a/Makefile b/Makefile
index fdbded0..5917814 100644
--- a/Makefile
+++ b/Makefile
@@ -4,41 +4,37 @@ ALL_CFLAGS = $(CFLAGS) -D_GNU_SOURCE -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITSd
PROGS = blkparse blktrace verify_blkparse blkrawverify blkiomon
LIBS = -lpthread
SCRIPTS = btrace
+SUBDIRS = btreplay btt iowatcher
-ALL = $(PROGS) $(SCRIPTS) btt/btt btreplay/btrecord btreplay/btreplay \
+ALL = $(PROGS) $(SCRIPTS)
+INSTALL_ALL = $(ALL) btt/btt btreplay/btrecord btreplay/btreplay \
btt/bno_plot.py iowatcher/iowatcher
-all: $(ALL)
+all: $(ALL) $(SUBDIRS)
-btt/btt:
- $(MAKE) -C btt
-
-iowatcher/iowatcher:
- $(MAKE) -C iowatcher
-
-btreplay/btrecord:
- $(MAKE) -C btreplay
-
-btreplay/btreplay:
- $(MAKE) -C btreplay
+# We always descend into subdirs because they contain their own dependency
+# information which we don't track in this top level Makefile.
+$(SUBDIRS):
+ $(MAKE) -C $@
+.PHONY: $(SUBDIRS)
%.o: %.c
$(CC) -o $*.o -c $(ALL_CFLAGS) $<
blkparse: blkparse.o blkparse_fmt.o rbtree.o act_mask.o
- $(CC) $(ALL_CFLAGS) -o $@ $(filter %.o,$^)
+ $(CC) $(ALL_CFLAGS) $(LDFLAGS) -o $@ $(filter %.o,$^)
blktrace: blktrace.o act_mask.o
- $(CC) $(ALL_CFLAGS) -o $@ $(filter %.o,$^) $(LIBS)
+ $(CC) $(ALL_CFLAGS) $(LDFLAGS) -o $@ $(filter %.o,$^) $(LIBS)
verify_blkparse: verify_blkparse.o
- $(CC) $(ALL_CFLAGS) -o $@ $(filter %.o,$^)
+ $(CC) $(ALL_CFLAGS) $(LDFLAGS) -o $@ $(filter %.o,$^)
blkrawverify: blkrawverify.o
- $(CC) $(ALL_CFLAGS) -o $@ $(filter %.o,$^)
+ $(CC) $(ALL_CFLAGS) $(LDFLAGS) -o $@ $(filter %.o,$^)
blkiomon: blkiomon.o rbtree.o
- $(CC) $(ALL_CFLAGS) -o $@ $(filter %.o,$^) $(LIBS) -lrt
+ $(CC) $(ALL_CFLAGS) $(LDFLAGS) -o $@ $(filter %.o,$^) $(LIBS) -lrt
$(PROGS): | depend
@@ -85,7 +81,7 @@ install: all
$(INSTALL) -m 755 -d $(DESTDIR)$(bindir)
$(INSTALL) -m 755 -d $(DESTDIR)$(mandir)/man1
$(INSTALL) -m 755 -d $(DESTDIR)$(mandir)/man8
- $(INSTALL) -m 755 $(ALL) $(DESTDIR)$(bindir)
+ $(INSTALL) -m 755 $(INSTALL_ALL) $(DESTDIR)$(bindir)
$(INSTALL) -m 644 doc/*.1 $(DESTDIR)$(mandir)/man1
$(INSTALL) -m 644 doc/*.8 $(DESTDIR)$(mandir)/man8
diff --git a/btreplay/Makefile b/btreplay/Makefile
index 2998182..f574a29 100644
--- a/btreplay/Makefile
+++ b/btreplay/Makefile
@@ -32,10 +32,10 @@ clean: docsclean
$(CC) $(CFLAGS) -c -o $*.o $<
btrecord: btrecord.o
- $(CC) $(CFLAGS) -o $@ $(filter %.o,$^)
+ $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $(filter %.o,$^)
btreplay: btreplay.o
- $(CC) $(CFLAGS) -o $@ $(filter %.o,$^) $(LIBS)
+ $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $(filter %.o,$^) $(LIBS)
depend:
@$(CC) -MM $(CFLAGS) *.c 1> .depend
diff --git a/btt/Makefile b/btt/Makefile
index df7a3de..3207557 100644
--- a/btt/Makefile
+++ b/btt/Makefile
@@ -38,7 +38,7 @@ clean: docsclean
$(CC) $(CFLAGS) -c -o $*.o $<
btt: $(OBJS)
- $(CC) $(CFLAGS) -o $@ $(filter %.o,$^) $(LIBS)
+ $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $(filter %.o,$^) $(LIBS)
ifneq ($(wildcard .depend),)
include .depend
diff --git a/iowatcher/Makefile b/iowatcher/Makefile
index e013556..a224a08 100644
--- a/iowatcher/Makefile
+++ b/iowatcher/Makefile
@@ -19,7 +19,7 @@ all: $(ALL)
$(CC) -o $*.o -c $(ALL_CFLAGS) $<
iowatcher: blkparse.o plot.o main.o tracers.o mpstat.o fio.o
- $(CC) $(ALL_CFLAGS) -o $@ $(filter %.o,$^) -lm -lrt
+ $(CC) $(ALL_CFLAGS) $(LDFLAGS) -o $@ $(filter %.o,$^) -lm -lrt
depend:
@$(CC) -MM $(ALL_CFLAGS) *.c 1> .depend
^ permalink raw reply related [flat|nested] 45+ messages in thread
* Recent changes (master)
2013-03-20 5:00 Jens Axboe
` (19 preceding siblings ...)
2018-01-24 13:00 ` Jens Axboe
@ 2018-01-25 13:00 ` Jens Axboe
2018-04-10 12:00 ` Jens Axboe
` (16 subsequent siblings)
37 siblings, 0 replies; 45+ messages in thread
From: Jens Axboe @ 2018-01-25 13:00 UTC (permalink / raw)
To: linux-btrace
The following changes since commit 519fd9a5d08d85f3d9cb4192d624fe8351e40232:
fix parallel build failures (2018-01-23 15:59:13 -0700)
are available in the git repository at:
git://git.kernel.dk/blktrace.git master
for you to fetch changes up to e63098f39398bde67be9b64a49deece1c60614df:
blktrace: don't stop tracer if not setup trace successfully (2018-01-24 08:40:52 -0700)
----------------------------------------------------------------
weiping zhang (1):
blktrace: don't stop tracer if not setup trace successfully
blktrace.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
---
Diff of recent changes:
diff --git a/blktrace.c b/blktrace.c
index e048f68..d0d271f 100644
--- a/blktrace.c
+++ b/blktrace.c
@@ -112,6 +112,7 @@ struct devpath {
struct cl_host *ch;
u32 cl_id;
time_t cl_connect_time;
+ int setup_done; /* ioctl BLKTRACESETUP done */
struct io_info *ios;
};
@@ -1083,6 +1084,7 @@ static int setup_buts(void)
if (ioctl(dpp->fd, BLKTRACESETUP, &buts) >= 0) {
dpp->ncpus = max_cpus;
dpp->buts_name = strdup(buts.name);
+ dpp->setup_done = 1;
if (dpp->stats)
free(dpp->stats);
dpp->stats = calloc(dpp->ncpus, sizeof(*dpp->stats));
@@ -1285,7 +1287,8 @@ static void rel_devpaths(void)
struct devpath *dpp = list_entry(p, struct devpath, head);
list_del(&dpp->head);
- __stop_trace(dpp->fd);
+ if (dpp->setup_done)
+ __stop_trace(dpp->fd);
close(dpp->fd);
if (dpp->heads)
^ permalink raw reply related [flat|nested] 45+ messages in thread
* Recent changes (master)
2013-03-20 5:00 Jens Axboe
` (20 preceding siblings ...)
2018-01-25 13:00 ` Jens Axboe
@ 2018-04-10 12:00 ` Jens Axboe
2018-05-03 12:00 ` Jens Axboe
` (15 subsequent siblings)
37 siblings, 0 replies; 45+ messages in thread
From: Jens Axboe @ 2018-04-10 12:00 UTC (permalink / raw)
To: linux-btrace
The following changes since commit e63098f39398bde67be9b64a49deece1c60614df:
blktrace: don't stop tracer if not setup trace successfully (2018-01-24 08:40:52 -0700)
are available in the git repository at:
git://git.kernel.dk/blktrace.git master
for you to fetch changes up to 93d9e5b5082258f3570dbc56202276284575fc11:
blkparse: add documetation for 'R' requeue request (2018-04-09 08:36:43 -0600)
----------------------------------------------------------------
Weiping Zhang (2):
blkparse: remove duplicated entry for flag M
blkparse: add documetation for 'R' requeue request
doc/blkparse.1 | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
---
Diff of recent changes:
diff --git a/doc/blkparse.1 b/doc/blkparse.1
index be9b34b..cb21fea 100644
--- a/doc/blkparse.1
+++ b/doc/blkparse.1
@@ -243,10 +243,6 @@ Same as the back merge, except this i/o ends where a previously inserted
requests starts.
.HP 4
-\fBM --front or back merge\fR
-One of the above
-
-.HP 4
\fBM -- front or back merge\fR
One of the above.
@@ -289,6 +285,10 @@ this and will clone lots of i/o.
For stacked devices, incoming i/o is remapped to device below it in the i/o
stack. The remap action details what exactly is being remapped to what.
+.HP 4
+\fBR -- requeue\fR
+Put a request back on queue.
+
^ permalink raw reply related [flat|nested] 45+ messages in thread
* Recent changes (master)
2013-03-20 5:00 Jens Axboe
` (21 preceding siblings ...)
2018-04-10 12:00 ` Jens Axboe
@ 2018-05-03 12:00 ` Jens Axboe
2018-05-17 12:00 ` Jens Axboe
` (14 subsequent siblings)
37 siblings, 0 replies; 45+ messages in thread
From: Jens Axboe @ 2018-05-03 12:00 UTC (permalink / raw)
To: linux-btrace
The following changes since commit 93d9e5b5082258f3570dbc56202276284575fc11:
blkparse: add documetation for 'R' requeue request (2018-04-09 08:36:43 -0600)
are available in the git repository at:
git://git.kernel.dk/blktrace.git master
for you to fetch changes up to d61ff409cb4dda31386373d706ea0cfb1aaac5b7:
btt: make device/devno use PATH_MAX to avoid overflow (2018-05-02 10:24:17 -0600)
----------------------------------------------------------------
Jens Axboe (1):
btt: make device/devno use PATH_MAX to avoid overflow
btt/devmap.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
---
Diff of recent changes:
diff --git a/btt/devmap.c b/btt/devmap.c
index 0553a9e..5fc1cb2 100644
--- a/btt/devmap.c
+++ b/btt/devmap.c
@@ -23,7 +23,7 @@
struct devmap {
struct list_head head;
- char device[32], devno[32];
+ char device[PATH_MAX], devno[PATH_MAX];
};
LIST_HEAD(all_devmaps);
^ permalink raw reply related [flat|nested] 45+ messages in thread
* Recent changes (master)
2013-03-20 5:00 Jens Axboe
` (22 preceding siblings ...)
2018-05-03 12:00 ` Jens Axboe
@ 2018-05-17 12:00 ` Jens Axboe
2018-08-31 12:00 ` Jens Axboe
` (13 subsequent siblings)
37 siblings, 0 replies; 45+ messages in thread
From: Jens Axboe @ 2018-05-17 12:00 UTC (permalink / raw)
To: linux-btrace
The following changes since commit d61ff409cb4dda31386373d706ea0cfb1aaac5b7:
btt: make device/devno use PATH_MAX to avoid overflow (2018-05-02 10:24:17 -0600)
are available in the git repository at:
git://git.kernel.dk/blktrace.git master
for you to fetch changes up to 70d5ca2d5f3d6b97c11c641b7e0c5836983219a0:
make btt scripts python3-ready (2018-05-16 13:09:58 -0600)
----------------------------------------------------------------
Eric Sandeen (1):
make btt scripts python3-ready
btt/bno_plot.py | 28 +++++++++++++++-------------
btt/btt_plot.py | 22 +++++++++++++---------
2 files changed, 28 insertions(+), 22 deletions(-)
---
Diff of recent changes:
diff --git a/btt/bno_plot.py b/btt/bno_plot.py
index aa92480..f05cfdc 100644
--- a/btt/bno_plot.py
+++ b/btt/bno_plot.py
@@ -38,6 +38,8 @@ automatically push the keys under the graph.
To exit the plotter, enter 'quit' or ^D at the 'gnuplot> ' prompt.
"""
+from __future__ import absolute_import
+from __future__ import print_function
import getopt, glob, os, sys, tempfile
verbose = 0
@@ -60,14 +62,14 @@ def parse_args(in_args):
try:
(opts, args) = getopt.getopt(in_args, s_opts, l_opts)
- except getopt.error, msg:
- print >>sys.stderr, msg
- print >>sys.stderr, __doc__
+ except getopt.error as msg:
+ print(msg, file=sys.stderr)
+ print(__doc__, file=sys.stderr)
sys.exit(1)
for (o, a) in opts:
if o in ('-h', '--help'):
- print __doc__
+ print(__doc__)
sys.exit(0)
elif o in ('-v', '--verbose'):
verbose += 1
@@ -84,10 +86,10 @@ if __name__ = '__main__':
(bnos, keys_below) = parse_args(sys.argv[1:])
if verbose:
- print 'Using files:',
- for bno in bnos: print bno,
- if keys_below: print '\nKeys are to be placed below graph'
- else: print ''
+ print('Using files:', end=' ')
+ for bno in bnos: print(bno, end=' ')
+ if keys_below: print('\nKeys are to be placed below graph')
+ else: print('')
tmpdir = tempfile.mktemp()
os.mkdir(tmpdir)
@@ -99,7 +101,7 @@ if __name__ = '__main__':
fo = open(t, 'w')
for line in open(f, 'r'):
fld = line.split(None)
- print >>fo, fld[0], fld[1], int(fld[2])-int(fld[1])
+ print(fld[0], fld[1], int(fld[2])-int(fld[1]), file=fo)
fo.close()
t = t[t.rfind('/')+1:]
@@ -107,16 +109,16 @@ if __name__ = '__main__':
else: plot_cmd = "%s,'%s'" % (plot_cmd, t)
fo = open('%s/plot.cmds' % tmpdir, 'w')
- print >>fo, cmds
- if len(bnos) > 10 or keys_below: print >>fo, 'set key below'
- print >>fo, plot_cmd
+ print(cmds, file=fo)
+ if len(bnos) > 10 or keys_below: print('set key below', file=fo)
+ print(plot_cmd, file=fo)
fo.close()
pid = os.fork()
if pid = 0:
cmd = 'gnuplot %s/plot.cmds -' % tmpdir
- if verbose: print 'Executing %s' % cmd
+ if verbose: print('Executing %s' % cmd)
os.chdir(tmpdir)
os.system(cmd)
diff --git a/btt/btt_plot.py b/btt/btt_plot.py
index b81dad5..76fcca8 100755
--- a/btt/btt_plot.py
+++ b/btt/btt_plot.py
@@ -55,6 +55,10 @@ Arguments:
but the -o (--output) and -T (--title) options will be ignored.
"""
+from __future__ import absolute_import
+from __future__ import print_function
+import six
+from six.moves import range
__author__ = 'Alan D. Brunelle <alan.brunelle@hp.com>'
#------------------------------------------------------------------------------
@@ -82,7 +86,7 @@ get_base = lambda file: file[file.find('_')+1:file.rfind('_')]
def fatal(msg):
"""Generate fatal error message and exit"""
- print >>sys.stderr, 'FATAL: %s' % msg
+ print('FATAL: %s' % msg, file=sys.stderr)
sys.exit(1)
#------------------------------------------------------------------------------
@@ -163,7 +167,7 @@ def get_data(files):
if not os.path.exists(file):
fatal('%s not found' % file)
elif verbose:
- print 'Processing %s' % file
+ print('Processing %s' % file)
xs = []
ys = []
@@ -214,8 +218,8 @@ def parse_args(args):
try:
(opts, args) = getopt.getopt(args[1:], s_opts, l_opts)
- except getopt.error, msg:
- print >>sys.stderr, msg
+ except getopt.error as msg:
+ print(msg, file=sys.stderr)
fatal(__doc__)
for (o, a) in opts:
@@ -293,15 +297,15 @@ def generate_output(type, db):
def color(idx, style):
"""Returns a color/symbol type based upon the index passed."""
- colors = [ 'b', 'g', 'r', 'c', 'm', 'y', 'k' ]
+ colors = [ 'b', 'g', 'r', 'c', 'm', 'y', 'k' ]
l_styles = [ '-', ':', '--', '-.' ]
m_styles = [ 'o', '+', '.', ',', 's', 'v', 'x', '<', '>' ]
color = colors[idx % len(colors)]
if style = 'line':
- style = l_styles[(idx / len(l_styles)) % len(l_styles)]
+ style = l_styles[int((idx / len(l_styles)) % len(l_styles))]
elif style = 'marker':
- style = m_styles[(idx / len(m_styles)) % len(m_styles)]
+ style = m_styles[int((idx / len(m_styles)) % len(m_styles))]
return '%s%s' % (color, style)
@@ -314,7 +318,7 @@ def generate_output(type, db):
ofile = '%s.png' % type
if verbose:
- print 'Generating plot into %s' % ofile
+ print('Generating plot into %s' % ofile)
fig = plt.figure(figsize=plot_size)
ax = fig.add_subplot(111)
@@ -329,7 +333,7 @@ def generate_output(type, db):
legends = None
keys = []
- for file in db.iterkeys():
+ for file in six.iterkeys(db):
if not file in ['min_x', 'max_x', 'min_y', 'max_y']:
keys.append(file)
^ permalink raw reply related [flat|nested] 45+ messages in thread
* Recent changes (master)
2013-03-20 5:00 Jens Axboe
` (23 preceding siblings ...)
2018-05-17 12:00 ` Jens Axboe
@ 2018-08-31 12:00 ` Jens Axboe
2018-09-01 12:00 ` Jens Axboe
` (12 subsequent siblings)
37 siblings, 0 replies; 45+ messages in thread
From: Jens Axboe @ 2018-08-31 12:00 UTC (permalink / raw)
To: linux-btrace
The following changes since commit 70d5ca2d5f3d6b97c11c641b7e0c5836983219a0:
make btt scripts python3-ready (2018-05-16 13:09:58 -0600)
are available in the git repository at:
git://git.kernel.dk/blktrace.git master
for you to fetch changes up to f011d96f260a2be5dcc2ad9f4d1bf2d591946723:
iowatcher: don't add Q events to the io hash (2018-08-30 20:57:53 -0600)
----------------------------------------------------------------
Jeff Moyer (1):
iowatcher: don't add Q events to the io hash
iowatcher/blkparse.c | 32 ++++++++++++++++++++++----------
1 file changed, 22 insertions(+), 10 deletions(-)
---
Diff of recent changes:
diff --git a/iowatcher/blkparse.c b/iowatcher/blkparse.c
index c7d1d65..41e20f0 100644
--- a/iowatcher/blkparse.c
+++ b/iowatcher/blkparse.c
@@ -1099,16 +1099,28 @@ void add_pending_io(struct trace *trace, struct graph_line_data *gld)
if (action = __BLK_TA_QUEUE) {
if (io->sector = 0)
return;
- if (trace->found_issue || trace->found_completion) {
- pio = hash_queued_io(trace->io);
- /*
- * When there are no ISSUE events count depth and
- * latency at least from queue events
- */
- if (pio && !trace->found_issue) {
- pio->dispatch_time = io->time;
- goto account_io;
- }
+ /*
+ * If D (issue) events are available, use them for I/O
+ * accounting. Nothing needs to be done for Q.
+ */
+ if (trace->found_issue)
+ return;
+ /*
+ * If there are no D or C events, then all that can be
+ * done is to account the Q event (and make sure not to
+ * add the I/O to the hash, because it will never be
+ * removed).
+ */
+ if (!trace->found_completion)
+ goto account_io;
+ /*
+ * When there are no ISSUE events, count depth and
+ * latency from queue events.
+ */
+ pio = hash_queued_io(trace->io);
+ if (pio) {
+ pio->dispatch_time = io->time;
+ goto account_io;
}
return;
}
^ permalink raw reply related [flat|nested] 45+ messages in thread
* Recent changes (master)
2013-03-20 5:00 Jens Axboe
` (24 preceding siblings ...)
2018-08-31 12:00 ` Jens Axboe
@ 2018-09-01 12:00 ` Jens Axboe
2019-05-22 12:00 ` Jens Axboe
` (11 subsequent siblings)
37 siblings, 0 replies; 45+ messages in thread
From: Jens Axboe @ 2018-09-01 12:00 UTC (permalink / raw)
To: linux-btrace
The following changes since commit f011d96f260a2be5dcc2ad9f4d1bf2d591946723:
iowatcher: don't add Q events to the io hash (2018-08-30 20:57:53 -0600)
are available in the git repository at:
git://git.kernel.dk/blktrace.git master
for you to fetch changes up to 10df4b691a68dd440547e393b6d241fc54fd2fad:
iowatcher: spawn NPROCESSORS_ONLN for rsvg-convert-s (2018-08-31 14:57:57 -0600)
----------------------------------------------------------------
Jeff Moyer (1):
iowatcher: spawn NPROCESSORS_ONLN for rsvg-convert-s
iowatcher/main.c | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)
---
Diff of recent changes:
diff --git a/iowatcher/main.c b/iowatcher/main.c
index 54325fb..4b97013 100644
--- a/iowatcher/main.c
+++ b/iowatcher/main.c
@@ -1043,9 +1043,14 @@ static void system_check(const char *cmd)
static void convert_movie_files(char *movie_dir)
{
+ long nr_cpus = sysconf(_SC_NPROCESSORS_ONLN);
+
+ if (nr_cpus < 0)
+ nr_cpus = 8;
+
fprintf(stderr, "Converting svg files in %s\n", movie_dir);
- snprintf(line, line_len, "find %s -name \\*.svg | xargs -I{} -n 1 -P 8 rsvg-convert -o {}.png {}",
- movie_dir);
+ snprintf(line, line_len, "find %s -name \\*.svg | xargs -I{} -n 1 -P %ld rsvg-convert -o {}.png {}",
+ movie_dir, nr_cpus);
system_check(line);
}
^ permalink raw reply related [flat|nested] 45+ messages in thread
* Recent changes (master)
2013-03-20 5:00 Jens Axboe
` (25 preceding siblings ...)
2018-09-01 12:00 ` Jens Axboe
@ 2019-05-22 12:00 ` Jens Axboe
2019-09-17 12:00 ` Jens Axboe
` (10 subsequent siblings)
37 siblings, 0 replies; 45+ messages in thread
From: Jens Axboe @ 2019-05-22 12:00 UTC (permalink / raw)
To: linux-btrace
The following changes since commit 10df4b691a68dd440547e393b6d241fc54fd2fad:
iowatcher: spawn NPROCESSORS_ONLN for rsvg-convert-s (2018-08-31 14:57:57 -0600)
are available in the Git repository at:
git://git.kernel.dk/blktrace.git master
for you to fetch changes up to a7263b8fb22f07f4f1a3ec54f0c37193c5908b22:
blkparse: add support sort program by io event (2019-05-21 08:06:08 -0600)
----------------------------------------------------------------
Weiping Zhang (1):
blkparse: add support sort program by io event
blkparse.c | 156 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++-
doc/blkparse.1 | 15 ++++++
2 files changed, 169 insertions(+), 2 deletions(-)
---
Diff of recent changes:
diff --git a/blkparse.c b/blkparse.c
index 227cc44..3de2ebe 100644
--- a/blkparse.c
+++ b/blkparse.c
@@ -100,6 +100,19 @@ struct per_process_info {
#define PPI_HASH_SHIFT (8)
#define PPI_HASH_SIZE (1 << PPI_HASH_SHIFT)
#define PPI_HASH_MASK (PPI_HASH_SIZE - 1)
+
+enum {
+ SORT_PROG_EVENT_N, /* Program Name */
+ SORT_PROG_EVENT_QKB, /* KB: Queued read and write */
+ SORT_PROG_EVENT_RKB, /* KB: Queued Read */
+ SORT_PROG_EVENT_WKB, /* KB: Queued Write */
+ SORT_PROG_EVENT_CKB, /* KB: Complete */
+ SORT_PROG_EVENT_QIO, /* IO: Queued read and write */
+ SORT_PROG_EVENT_RIO, /* IO: Queued Read */
+ SORT_PROG_EVENT_WIO, /* IO: Queued Write */
+ SORT_PROG_EVENT_CIO, /* IO: Complete */
+};
+
static struct per_process_info *ppi_hash_table[PPI_HASH_SIZE];
static struct per_process_info *ppi_list;
static int ppi_list_entries;
@@ -189,6 +202,12 @@ static struct option l_opts[] = {
.flag = NULL,
.val = 's'
},
+ {
+ .name = "sort-program-stats",
+ .has_arg = required_argument,
+ .flag = NULL,
+ .val = 'S'
+ },
{
.name = "track-ios",
.has_arg = no_argument,
@@ -269,6 +288,7 @@ static unsigned long long stopwatch_end = -1ULL; /* "infinity" */
static unsigned long read_sequence;
static int per_process_stats;
+static int per_process_stats_event = SORT_PROG_EVENT_N;
static int per_device_and_cpu_stats = 1;
static int track_ios;
static int ppi_hash_by_pid = 1;
@@ -1758,6 +1778,88 @@ static int ppi_name_compare(const void *p1, const void *p2)
return res;
}
+static int ppi_event_compare(const void *p1, const void *p2)
+{
+ struct per_process_info *ppi1 = *((struct per_process_info **) p1);
+ struct per_process_info *ppi2 = *((struct per_process_info **) p2);
+ struct io_stats *ios1 = &ppi1->io_stats;
+ struct io_stats *ios2 = &ppi2->io_stats;
+ unsigned long io1, io2;
+ unsigned long long kb1,kb2;
+ int sort_by_kb = 1;
+
+ io1 = io2 = 0;
+ kb1 = kb2 = 0;
+
+ switch (per_process_stats_event) {
+ case SORT_PROG_EVENT_QKB: /* KB: Queued read and write */
+ kb1 = ios1->qwrite_kb + (ios1->qwrite_b>>10) +
+ ios1->qread_kb + (ios1->qread_b>>10);
+ kb2 = ios2->qwrite_kb + (ios2->qwrite_b>>10) +
+ ios2->qread_kb + (ios2->qread_b>>10);
+ break;
+ case SORT_PROG_EVENT_RKB: /* KB: Queued Read */
+ kb1 = ios1->qread_kb + (ios1->qread_b>>10);
+ kb2 = ios2->qread_kb + (ios2->qread_b>>10);
+ break;
+ case SORT_PROG_EVENT_WKB: /* KB: Queued Write */
+ kb1 = ios1->qwrite_kb + (ios1->qwrite_b>>10);
+ kb2 = ios2->qwrite_kb + (ios2->qwrite_b>>10);
+ break;
+ case SORT_PROG_EVENT_CKB: /* KB: Complete */
+ kb1 = ios1->cwrite_kb + (ios1->cwrite_b>>10) +
+ ios1->cread_kb + (ios1->cread_b>>10);
+ kb2 = ios2->cwrite_kb + (ios2->cwrite_b>>10) +
+ ios2->cread_kb + (ios2->cread_b>>10);
+ break;
+ case SORT_PROG_EVENT_QIO: /* IO: Queued read and write */
+ sort_by_kb = 0;
+ io1 = ios1->qreads + ios1->qwrites;
+ io2 = ios2->qreads + ios2->qwrites;
+ break;
+ case SORT_PROG_EVENT_RIO: /* IO: Queued Read */
+ sort_by_kb = 0;
+ io1 = ios1->qreads;
+ io2 = ios2->qreads;
+ break;
+ case SORT_PROG_EVENT_WIO: /* IO: Queued Write */
+ sort_by_kb = 0;
+ io1 = ios1->qwrites;
+ io2 = ios2->qwrites;
+ break;
+ case SORT_PROG_EVENT_CIO: /* IO: Complete */
+ sort_by_kb = 0;
+ io1 = ios1->creads + ios1->cwrites;
+ io2 = ios2->creads + ios2->cwrites;
+ break;
+ }
+
+
+ /* compare kb */
+ if (sort_by_kb) {
+ if (kb1 > kb2)
+ return 1;
+ else if (kb1 = kb2)
+ return 0;
+ return -1;
+ }
+
+ /* compare io */
+ if (io1 > io2)
+ return 1;
+ else if (io1 = io2)
+ return 0;
+ return -1;
+}
+
+static int ppi_compare(const void *p1, const void *p2)
+{
+ if (per_process_stats_event = SORT_PROG_EVENT_N)
+ return ppi_name_compare(p1, p2);
+
+ return ppi_event_compare(p1, p2);
+}
+
static void sort_process_list(void)
{
struct per_process_info **ppis;
@@ -1772,7 +1874,7 @@ static void sort_process_list(void)
ppi = ppi->list_next;
}
- qsort(ppis, ppi_list_entries, sizeof(ppi), ppi_name_compare);
+ qsort(ppis, ppi_list_entries, sizeof(ppi), ppi_compare);
i = ppi_list_entries - 1;
ppi_list = NULL;
@@ -2730,7 +2832,46 @@ static int is_pipe(const char *str)
return 0;
}
-#define S_OPTS "a:A:b:D:d:f:F:hi:o:Oqstw:vVM"
+static int get_program_sort_event(const char *str)
+{
+ char evt = str[0];
+
+ switch (evt) {
+ case 'N':
+ per_process_stats_event = SORT_PROG_EVENT_N;
+ break;
+ case 'Q':
+ per_process_stats_event = SORT_PROG_EVENT_QKB;
+ break;
+ case 'q':
+ per_process_stats_event = SORT_PROG_EVENT_QIO;
+ break;
+ case 'R':
+ per_process_stats_event = SORT_PROG_EVENT_RKB;
+ break;
+ case 'r':
+ per_process_stats_event = SORT_PROG_EVENT_RIO;
+ break;
+ case 'W':
+ per_process_stats_event = SORT_PROG_EVENT_WKB;
+ break;
+ case 'w':
+ per_process_stats_event = SORT_PROG_EVENT_WIO;
+ break;
+ case 'C':
+ per_process_stats_event = SORT_PROG_EVENT_CKB;
+ break;
+ case 'c':
+ per_process_stats_event = SORT_PROG_EVENT_CIO;
+ break;
+ default:
+ return 1;
+ }
+
+ return 0;
+}
+
+#define S_OPTS "a:A:b:D:d:f:F:hi:o:OqsS:tw:vVM"
static char usage_str[] = "\n\n" \
"-i <file> | --input=<file>\n" \
"[ -a <action field> | --act-mask=<action field> ]\n" \
@@ -2745,6 +2886,7 @@ static char usage_str[] = "\n\n" \
"[ -O | --no-text-output ]\n" \
"[ -q | --quiet ]\n" \
"[ -s | --per-program-stats ]\n" \
+ "[ -S <event> | --sort-program-stats=<event> ]\n" \
"[ -t | --track-ios ]\n" \
"[ -w <time> | --stopwatch=<time> ]\n" \
"[ -M | --no-msgs\n" \
@@ -2764,6 +2906,11 @@ static char usage_str[] = "\n\n" \
"\t-O Do NOT output text data\n" \
"\t-q Quiet. Don't display any stats at the end of the trace\n" \
"\t-s Show per-program io statistics\n" \
+ "\t-S Show per-program io statistics sorted by N/Q/q/R/r/W/w/C/c\n" \
+ "\t N:Name, Q/q:Queued(read & write), R/r:Queued Read, W/w:Queued Write, C/c:Complete.\n" \
+ "\t Sort programs by how much data(KB): Q,R,W,C.\n" \
+ "\t Sort programs by how many IO operations: q,r,w,c.\n" \
+ "\t if -S was used, the -s parameter will be ignored.\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-w Only parse data between the given time interval in seconds.\n" \
@@ -2830,6 +2977,11 @@ int main(int argc, char *argv[])
case 's':
per_process_stats = 1;
break;
+ case 'S':
+ per_process_stats = 1;
+ if (get_program_sort_event(optarg))
+ return 1;
+ break;
case 't':
track_ios = 1;
break;
diff --git a/doc/blkparse.1 b/doc/blkparse.1
index cb21fea..627b7b1 100644
--- a/doc/blkparse.1
+++ b/doc/blkparse.1
@@ -165,6 +165,21 @@ Quiet mode
Displays data sorted by program
.RE
+\-S \fIevent\fR
+.br
+\-\-sort\-program\-stats=\fIevent\fR
+.br
+.RS
+Displays each program's data sorted by program name or io event, like
+Queued, Read, Write and Complete. When \-S is specified the \-s will be ignored.
+The capital letters Q,R,W,C stand for KB, then q/r/w/c stand for IO.
+
+If you want to soct programs by how many data they queued, you can use:
+
+blkparse -i sda.blktrace. -q \-S Q \-o sda.parse
+.RE
+
+
\-t
.br
\-\-track\-ios
^ permalink raw reply related [flat|nested] 45+ messages in thread
* Recent changes (master)
2013-03-20 5:00 Jens Axboe
` (26 preceding siblings ...)
2019-05-22 12:00 ` Jens Axboe
@ 2019-09-17 12:00 ` Jens Axboe
2019-09-25 12:00 ` Jens Axboe
` (9 subsequent siblings)
37 siblings, 0 replies; 45+ messages in thread
From: Jens Axboe @ 2019-09-17 12:00 UTC (permalink / raw)
To: linux-btrace
The following changes since commit a7263b8fb22f07f4f1a3ec54f0c37193c5908b22:
blkparse: add support sort program by io event (2019-05-21 08:06:08 -0600)
are available in the Git repository at:
git://git.kernel.dk/blktrace.git master
for you to fetch changes up to 667ac92a1a72b6038f0fae4acfc6a280fd69697b:
btreplay: fix device IO remap functionality (2019-09-16 10:30:23 -0600)
----------------------------------------------------------------
Ignat Korchagin (1):
btreplay: fix device IO remap functionality
btreplay/btreplay.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
---
Diff of recent changes:
diff --git a/btreplay/btreplay.c b/btreplay/btreplay.c
index edaf81f..23cc2a9 100644
--- a/btreplay/btreplay.c
+++ b/btreplay/btreplay.c
@@ -645,7 +645,7 @@ static void find_input_devs(char *idir)
static void read_map_devs(char *file_name)
{
FILE *fp;
- char from_dev[256], to_dev[256];
+ char *from_dev, *to_dev;
fp = fopen(file_name, "r");
if (!fp) {
@@ -653,7 +653,7 @@ static void read_map_devs(char *file_name)
/*NOTREACHED*/
}
- while (fscanf(fp, "%s %s", from_dev, to_dev) = 2) {
+ while (fscanf(fp, "%ms %ms", &from_dev, &to_dev) = 2) {
struct map_dev *mdp = malloc(sizeof(*mdp));
mdp->from_dev = from_dev;
^ permalink raw reply related [flat|nested] 45+ messages in thread
* Recent changes (master)
2013-03-20 5:00 Jens Axboe
` (27 preceding siblings ...)
2019-09-17 12:00 ` Jens Axboe
@ 2019-09-25 12:00 ` Jens Axboe
2020-01-17 13:00 ` Jens Axboe
` (8 subsequent siblings)
37 siblings, 0 replies; 45+ messages in thread
From: Jens Axboe @ 2019-09-25 12:00 UTC (permalink / raw)
To: linux-btrace
The following changes since commit 667ac92a1a72b6038f0fae4acfc6a280fd69697b:
btreplay: fix device IO remap functionality (2019-09-16 10:30:23 -0600)
are available in the Git repository at:
git://git.kernel.dk/blktrace.git master
for you to fetch changes up to 9c73da91540b27adaaf56065629e831cc50c5a3d:
doc: tex: add absolute timestamp printing option (2019-09-25 00:22:13 -0600)
----------------------------------------------------------------
Hiroaki Mihara (4):
blkparse: man: add absolute timestamp printing option
blkparse: split off the timestamp correction code in to a separate function
blkparse: fix absolute timestamp when reading from file
doc: tex: add absolute timestamp printing option
blkparse.c | 37 +++++++++++++++++++++++++------------
doc/blkparse.1 | 3 +++
doc/blktrace.tex | 1 +
3 files changed, 29 insertions(+), 12 deletions(-)
---
Diff of recent changes:
diff --git a/blkparse.c b/blkparse.c
index 3de2ebe..28bdf15 100644
--- a/blkparse.c
+++ b/blkparse.c
@@ -2022,6 +2022,22 @@ static void show_device_and_cpu_stats(void)
}
}
+static void correct_abs_start_time(void)
+{
+ long delta = genesis_time - start_timestamp;
+
+ abs_start_time.tv_sec += SECONDS(delta);
+ abs_start_time.tv_nsec += NANO_SECONDS(delta);
+ if (abs_start_time.tv_nsec < 0) {
+ abs_start_time.tv_nsec += 1000000000;
+ abs_start_time.tv_sec -= 1;
+ } else
+ if (abs_start_time.tv_nsec > 1000000000) {
+ abs_start_time.tv_nsec -= 1000000000;
+ abs_start_time.tv_sec += 1;
+ }
+}
+
static void find_genesis(void)
{
struct trace *t = trace_list;
@@ -2039,18 +2055,7 @@ static void find_genesis(void)
*/
if (start_timestamp
&& start_timestamp != genesis_time) {
- long delta = genesis_time - start_timestamp;
-
- abs_start_time.tv_sec += SECONDS(delta);
- abs_start_time.tv_nsec += NANO_SECONDS(delta);
- if (abs_start_time.tv_nsec < 0) {
- abs_start_time.tv_nsec += 1000000000;
- abs_start_time.tv_sec -= 1;
- } else
- if (abs_start_time.tv_nsec > 1000000000) {
- abs_start_time.tv_nsec -= 1000000000;
- abs_start_time.tv_sec += 1;
- }
+ correct_abs_start_time();
}
}
@@ -2704,6 +2709,14 @@ static int do_file(void)
if (ms_head)
genesis_time = ms_peek_time(ms_head);
+ /*
+ * Correct abs_start_time if necessary
+ */
+ if (start_timestamp
+ && start_timestamp != genesis_time) {
+ correct_abs_start_time();
+ }
+
/*
* Keep processing traces while any are left
*/
diff --git a/doc/blkparse.1 b/doc/blkparse.1
index 627b7b1..e494b6e 100644
--- a/doc/blkparse.1
+++ b/doc/blkparse.1
@@ -368,6 +368,9 @@ Elapsed value in microseconds (\fI\-t\fR command line option)
.IP \fBU\fR 4
Payload unsigned integer
+.IP \fBz\fR 4
+The absolute time, as local time in your time zone, with no date displayed
+
.PP
Note that the user can optionally specify field display width, and optionally a
left-aligned specifier. These precede field specifiers, with a '%' character,
diff --git a/doc/blktrace.tex b/doc/blktrace.tex
index 4d8278e..3647c75 100644
--- a/doc/blktrace.tex
+++ b/doc/blktrace.tex
@@ -613,6 +613,7 @@ the event's device \\
\emph{T} & Time stamp (seconds) \\ \hline
\emph{u} & Elapsed value in microseconds (\emph{-t} command line option) \\ \hline
\emph{U} & Payload unsigned integer \\ \hline
+\emph{z} & Absolute time stamp \\ \hline
\end{tabular}
Note that the user can optionally specify field display width, and
^ permalink raw reply related [flat|nested] 45+ messages in thread
* Recent changes (master)
2013-03-20 5:00 Jens Axboe
` (28 preceding siblings ...)
2019-09-25 12:00 ` Jens Axboe
@ 2020-01-17 13:00 ` Jens Axboe
2020-03-21 12:00 ` Jens Axboe
` (7 subsequent siblings)
37 siblings, 0 replies; 45+ messages in thread
From: Jens Axboe @ 2020-01-17 13:00 UTC (permalink / raw)
To: linux-btrace
The following changes since commit 9c73da91540b27adaaf56065629e831cc50c5a3d:
doc: tex: add absolute timestamp printing option (2019-09-25 00:22:13 -0600)
are available in the Git repository at:
git://git.kernel.dk/blktrace.git master
for you to fetch changes up to f4f8ef7cdea138cfaa2f3ca0ee31fa23d3bcf1cc:
fix parallel build of btt and blkiomon (2020-01-16 13:33:59 -0700)
----------------------------------------------------------------
Gwendal Grignou (1):
fix parallel build of btt and blkiomon
Makefile | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
---
Diff of recent changes:
diff --git a/Makefile b/Makefile
index 5917814..eb3c6a1 100644
--- a/Makefile
+++ b/Makefile
@@ -14,7 +14,7 @@ all: $(ALL) $(SUBDIRS)
# We always descend into subdirs because they contain their own dependency
# information which we don't track in this top level Makefile.
-$(SUBDIRS):
+$(SUBDIRS): $(PROGS)
$(MAKE) -C $@
.PHONY: $(SUBDIRS)
^ permalink raw reply related [flat|nested] 45+ messages in thread
* Recent changes (master)
2013-03-20 5:00 Jens Axboe
` (29 preceding siblings ...)
2020-01-17 13:00 ` Jens Axboe
@ 2020-03-21 12:00 ` Jens Axboe
2020-05-08 12:00 ` Jens Axboe
` (6 subsequent siblings)
37 siblings, 0 replies; 45+ messages in thread
From: Jens Axboe @ 2020-03-21 12:00 UTC (permalink / raw)
To: linux-btrace
The following changes since commit f4f8ef7cdea138cfaa2f3ca0ee31fa23d3bcf1cc:
fix parallel build of btt and blkiomon (2020-01-16 13:33:59 -0700)
are available in the Git repository at:
git://git.kernel.dk/blktrace.git master
for you to fetch changes up to db4f6340e04716285ea56fe26d76381c3adabe58:
btt_plot.py: Use `with open() as ...` context manager (2020-03-20 15:53:50 -0600)
----------------------------------------------------------------
Vincent Legoll (10):
btt_plot.py: Use sum() instead of open-coding it to compute list average
bno_plot.py: Use shutil.rmtree() instead of os.system('/bin/rm')
bno_plot.py: Use `with open() as ...` context manager to automatically handle close()
btt_plot.py: Fix pylint: wrong-import-order
btt_plot.py: Fix pylint: len-as-condition
btt_plot.py: Fix pylint: singleton-comparison
btt_plot.py: Fix pylint: no-else-return
bno_plot.py: Fix pylint: len-as-condition
bno_plot.py: Fix pylint: singleton-comparison
btt_plot.py: Use `with open() as ...` context manager
btt/bno_plot.py | 27 +++++++++++++-------------
btt/btt_plot.py | 60 ++++++++++++++++++++++++++++-----------------------------
2 files changed, 42 insertions(+), 45 deletions(-)
---
Diff of recent changes:
diff --git a/btt/bno_plot.py b/btt/bno_plot.py
index f05cfdc..3aa4e19 100644
--- a/btt/bno_plot.py
+++ b/btt/bno_plot.py
@@ -40,7 +40,7 @@ To exit the plotter, enter 'quit' or ^D at the 'gnuplot> ' prompt.
from __future__ import absolute_import
from __future__ import print_function
-import getopt, glob, os, sys, tempfile
+import getopt, glob, os, sys, tempfile, shutil
verbose = 0
cmds = """
@@ -76,7 +76,7 @@ def parse_args(in_args):
elif o in ('-K', '--keys-below'):
keys_below = True
- if len(args) > 0: bnos = args
+ if args: bnos = args
else: bnos = glob.glob('blknos*[rw].dat')
return (bnos, keys_below)
@@ -98,21 +98,20 @@ if __name__ = '__main__':
for f in bnos:
t = '%s/%s' % (tmpdir, f)
- fo = open(t, 'w')
- for line in open(f, 'r'):
- fld = line.split(None)
- print(fld[0], fld[1], int(fld[2])-int(fld[1]), file=fo)
- fo.close()
+ with open(t, 'w') as fo:
+ with open(f, 'r') as fi:
+ for line in fi:
+ fld = line.split(None)
+ print(fld[0], fld[1], int(fld[2])-int(fld[1]), file=fo)
t = t[t.rfind('/')+1:]
- if plot_cmd = None: plot_cmd = "splot '%s'" % t
+ if plot_cmd is None: plot_cmd = "splot '%s'" % t
else: plot_cmd = "%s,'%s'" % (plot_cmd, t)
- fo = open('%s/plot.cmds' % tmpdir, 'w')
- print(cmds, file=fo)
- if len(bnos) > 10 or keys_below: print('set key below', file=fo)
- print(plot_cmd, file=fo)
- fo.close()
+ with open('%s/plot.cmds' % tmpdir, 'w') as fo:
+ print(cmds, file=fo)
+ if len(bnos) > 10 or keys_below: print('set key below', file=fo)
+ print(plot_cmd, file=fo)
pid = os.fork()
if pid = 0:
@@ -125,4 +124,4 @@ if __name__ = '__main__':
sys.exit(1)
os.waitpid(pid, 0)
- os.system('/bin/rm -rf ' + tmpdir)
+ shutil.rmtree(tmpdir)
diff --git a/btt/btt_plot.py b/btt/btt_plot.py
index 76fcca8..40bc71f 100755
--- a/btt/btt_plot.py
+++ b/btt/btt_plot.py
@@ -57,6 +57,7 @@ Arguments:
from __future__ import absolute_import
from __future__ import print_function
+import getopt, glob, os, sys
import six
from six.moves import range
__author__ = 'Alan D. Brunelle <alan.brunelle@hp.com>'
@@ -65,7 +66,6 @@ __author__ = 'Alan D. Brunelle <alan.brunelle@hp.com>'
import matplotlib
matplotlib.use('Agg')
-import getopt, glob, os, sys
import matplotlib.pyplot as plt
plot_size = [10.9, 8.4] # inches...
@@ -113,8 +113,8 @@ def get_data(files):
"""Returns new min, max, and float value for those passed in"""
v = float(v)
- if mn = None or v < mn: mn = v
- if mx = None or v > mx: mx = v
+ if mn is None or v < mn: mn = v
+ if mx is None or v > mx: mx = v
return mn, mx, v
#--------------------------------------------------------------
@@ -125,10 +125,7 @@ def get_data(files):
def _avg(vals):
"""Computes average for array of values passed"""
- total = 0.0
- for val in vals:
- total += val
- return total / len(vals)
+ return sum(vals) / len(vals)
#------------------------------------------------------
if len(xs) < 1000:
@@ -171,14 +168,15 @@ def get_data(files):
xs = []
ys = []
- for line in open(file, 'r'):
- f = line.rstrip().split(None)
- if line.find('#') = 0 or len(f) < 2:
- continue
- (min_x, max_x, x) = check(min_x, max_x, f[0])
- (min_y, max_y, y) = check(min_y, max_y, f[1])
- xs.append(x)
- ys.append(y)
+ with open(file, 'r') as fi:
+ for line in fi:
+ f = line.rstrip().split(None)
+ if line.find('#') = 0 or len(f) < 2:
+ continue
+ (min_x, max_x, x) = check(min_x, max_x, f[0])
+ (min_y, max_y, y) = check(min_y, max_y, f[1])
+ xs.append(x)
+ ys.append(y)
db[file] = {'x':xs, 'y':ys}
if len(xs) > 10:
@@ -238,7 +236,7 @@ def parse_args(args):
elif o in ('-v', '--verbose'):
verbose = True
- if type = None and not generate_all:
+ if type is None and not generate_all:
fatal('Need type of data files to process - (-t <type>)')
return args
@@ -247,7 +245,7 @@ def parse_args(args):
def gen_title(fig, type, title_str):
"""Sets the title for the figure based upon the type /or/ user title"""
- if title_str != None:
+ if title_str is not None:
pass
elif type = 'aqd':
title_str = 'Average Queue Depth'
@@ -312,7 +310,7 @@ def generate_output(type, db):
#----------------------------------------------------------------------
global add_legend, output_file, title_str, verbose
- if output_file != None:
+ if output_file is not None:
ofile = output_file
else:
ofile = '%s.png' % type
@@ -343,7 +341,7 @@ def generate_output(type, db):
if type = 'bnos':
ax.plot(dat['x'], dat['y'], color(idx, 'marker'),
markersize=1)
- elif dat['ax'] = None:
+ elif dat['ax'] is None:
continue # Don't add legend
else:
ax.plot(dat['ax'], dat['ay'], color(idx, 'line'),
@@ -352,7 +350,7 @@ def generate_output(type, db):
legends.append(get_base(file))
idx += 1
- if add_legend and len(legends) > 0:
+ if add_legend and legends:
gen_legends(ax, legends)
plt.savefig(ofile)
@@ -388,23 +386,23 @@ def do_live(files):
def get_live_data(fn):
xs = []
ys = []
- for line in open(fn, 'r'):
- f = line.rstrip().split()
- if f[0] != '#' and len(f) = 2:
- xs.append(float(f[0]))
- ys.append(float(f[1]))
+ with open(fn, 'r') as fi:
+ for line in fi:
+ f = line.rstrip().split()
+ if f[0] != '#' and len(f) = 2:
+ xs.append(float(f[0]))
+ ys.append(float(f[1]))
return xs, ys
#----------------------------------------------------------------------
def live_sort(a, b):
if a[0] = 'sys' and b[0] = 'sys':
return 0
- elif a[0] = 'sys' or a[2][0] < b[2][0]:
+ if a[0] = 'sys' or a[2][0] < b[2][0]:
return -1
- elif b[0] = 'sys' or a[2][0] > b[2][0]:
+ if b[0] = 'sys' or a[2][0] > b[2][0]:
return 1
- else:
- return 0
+ return 0
#----------------------------------------------------------------------
def turn_off_ticks(ax):
@@ -453,7 +451,7 @@ if __name__ = '__main__':
output_file = title_str = type = None
for t in types:
files = get_files(t)
- if len(files) = 0:
+ if files = 0:
continue
elif t = 'bnos':
do_bnos(files)
@@ -463,7 +461,7 @@ if __name__ = '__main__':
generate_output(t, get_data(files))
continue
- elif len(files) < 1:
+ elif not files:
fatal('Need data files to process')
else:
generate_output(type, get_data(files))
^ permalink raw reply related [flat|nested] 45+ messages in thread
* Recent changes (master)
2013-03-20 5:00 Jens Axboe
` (30 preceding siblings ...)
2020-03-21 12:00 ` Jens Axboe
@ 2020-05-08 12:00 ` Jens Axboe
2020-05-21 12:00 ` Jens Axboe
` (5 subsequent siblings)
37 siblings, 0 replies; 45+ messages in thread
From: Jens Axboe @ 2020-05-08 12:00 UTC (permalink / raw)
To: linux-btrace
The following changes since commit db4f6340e04716285ea56fe26d76381c3adabe58:
btt_plot.py: Use `with open() as ...` context manager (2020-03-20 15:53:50 -0600)
are available in the Git repository at:
git://git.kernel.dk/blktrace.git master
for you to fetch changes up to e81829a565162d41e2f551dc5e0f74f22f319554:
blkparse: Fix up the sector and length of split completions (2020-05-07 12:22:37 -0600)
----------------------------------------------------------------
Andreas Gruenbacher (4):
blkparse: Fix device in event tracking error messages
blkparse: Allow request tracking on non md/dm devices
blkparse: Initialize and test for undefined request tracking timestamps
blkparse: Fix up the sector and length of split completions
blkparse.c | 169 +++++++++++++++++++++++++++++++++++++++++++++++--------------
1 file changed, 130 insertions(+), 39 deletions(-)
---
Diff of recent changes:
diff --git a/blkparse.c b/blkparse.c
index 28bdf15..796059b 100644
--- a/blkparse.c
+++ b/blkparse.c
@@ -25,6 +25,7 @@
#include <stdio.h>
#include <fcntl.h>
#include <stdlib.h>
+#include <stdarg.h>
#include <string.h>
#include <getopt.h>
#include <errno.h>
@@ -261,17 +262,21 @@ static struct trace *t_alloc_list;
/*
* for tracking individual ios
*/
-struct io_track {
- struct rb_node rb_node;
-
+struct io_track_req {
struct process_pid_map *ppm;
- __u64 sector;
unsigned long long allocation_time;
unsigned long long queue_time;
unsigned long long dispatch_time;
unsigned long long completion_time;
};
+struct io_track {
+ struct rb_node rb_node;
+ struct io_track_req *req;
+ struct io_track *next;
+ __u64 sector;
+};
+
static int ndevices;
static struct per_dev_info *devices;
static char *get_dev_name(struct per_dev_info *, char *, int);
@@ -326,6 +331,21 @@ static int have_drv_data = 0;
#define CPU_IDX(cpu) ((cpu) / CPUS_PER_LONG)
#define CPU_BIT(cpu) ((cpu) & (CPUS_PER_LONG - 1))
+static void io_warn_unless(struct blk_io_trace *t, int condition,
+ const char *fmt, ...)
+{
+ va_list ap;
+
+ if (condition)
+ return;
+ va_start(ap, fmt);
+ printf("(%d,%d) request %llu + %u: ",
+ MAJOR(t->device), MINOR(t->device),
+ t->sector, t->bytes);
+ vfprintf(stderr, fmt, ap);
+ va_end(ap);
+}
+
static void output_binary(void *buf, int len)
{
if (dump_binary) {
@@ -976,6 +996,11 @@ static struct io_track *__find_track(struct per_dev_info *pdi, __u64 sector)
return NULL;
}
+static inline struct io_track *first_iot(struct io_track_req *req)
+{
+ return (struct io_track *)(req + 1);
+}
+
static struct io_track *find_track(struct per_dev_info *pdi, pid_t pid,
__u64 sector)
{
@@ -983,10 +1008,19 @@ static struct io_track *find_track(struct per_dev_info *pdi, pid_t pid,
iot = __find_track(pdi, sector);
if (!iot) {
- iot = malloc(sizeof(*iot));
- iot->ppm = find_ppm(pid);
- if (!iot->ppm)
- iot->ppm = add_ppm_hash(pid, "unknown");
+ struct io_track_req *req;
+
+ req = malloc(sizeof(*req) + sizeof(*iot));
+ req->ppm = find_ppm(pid);
+ if (!req->ppm)
+ req->ppm = add_ppm_hash(pid, "unknown");
+ req->allocation_time = -1ULL;
+ req->queue_time = -1ULL;
+ req->dispatch_time = -1ULL;
+ req->completion_time = -1ULL;
+ iot = first_iot(req);
+ iot->req = req;
+ iot->next = NULL;
iot->sector = sector;
track_rb_insert(pdi, iot);
}
@@ -1006,7 +1040,7 @@ static void log_track_frontmerge(struct per_dev_info *pdi,
if (!iot) {
if (verbose)
fprintf(stderr, "merge not found for (%d,%d): %llu\n",
- MAJOR(pdi->dev), MINOR(pdi->dev),
+ MAJOR(t->device), MINOR(t->device),
(unsigned long long) t->sector + t_sec(t));
return;
}
@@ -1019,19 +1053,16 @@ static void log_track_frontmerge(struct per_dev_info *pdi,
static void log_track_getrq(struct per_dev_info *pdi, struct blk_io_trace *t)
{
struct io_track *iot;
+ struct io_track_req *req;
if (!track_ios)
return;
iot = find_track(pdi, t->pid, t->sector);
- iot->allocation_time = t->time;
-}
-
-static inline int is_remapper(struct per_dev_info *pdi)
-{
- int major = MAJOR(pdi->dev);
-
- return (major = 253 || major = 9);
+ req = iot->req;
+ io_warn_unless(t, req->allocation_time = -1ULL,
+ "confused about %s time", "allocation");
+ req->allocation_time = t->time;
}
/*
@@ -1041,14 +1072,34 @@ static inline int is_remapper(struct per_dev_info *pdi)
static void log_track_queue(struct per_dev_info *pdi, struct blk_io_trace *t)
{
struct io_track *iot;
+ struct io_track_req *req;
if (!track_ios)
return;
- if (!is_remapper(pdi))
- return;
iot = find_track(pdi, t->pid, t->sector);
- iot->dispatch_time = t->time;
+ req = iot->req;
+ io_warn_unless(t, req->dispatch_time = -1ULL,
+ "confused about %s time", "dispatch");
+ req->dispatch_time = t->time;
+}
+
+static void log_track_split(struct per_dev_info *pdi, struct blk_io_trace *t)
+{
+ struct io_track *iot, *split;
+
+ /*
+ * With a split request, the completion event will refer to the last
+ * part of the original request, but other events might refer to other
+ * parts.
+ */
+ iot = find_track(pdi, t->pid, t->sector);
+ split = malloc(sizeof(*iot));
+ split->req = iot->req;
+ split->next = iot->next;
+ iot->next = split;
+ split->sector = iot->sector + t_sec(t);
+ track_rb_insert(pdi, split);
}
/*
@@ -1059,20 +1110,24 @@ static unsigned long long log_track_insert(struct per_dev_info *pdi,
{
unsigned long long elapsed;
struct io_track *iot;
+ struct io_track_req *req;
if (!track_ios)
return -1;
iot = find_track(pdi, t->pid, t->sector);
- iot->queue_time = t->time;
+ req = iot->req;
+ io_warn_unless(t, req->queue_time = -1ULL,
+ "confused about %s time", "queue");
+ req->queue_time = t->time;
- if (!iot->allocation_time)
+ if (req->allocation_time = -1ULL)
return -1;
- elapsed = iot->queue_time - iot->allocation_time;
+ elapsed = req->queue_time - req->allocation_time;
if (per_process_stats) {
- struct per_process_info *ppi = find_ppi(iot->ppm->pid);
+ struct per_process_info *ppi = find_ppi(req->ppm->pid);
int w = (t->action & BLK_TC_ACT(BLK_TC_WRITE)) != 0;
if (ppi && elapsed > ppi->longest_allocation_wait[w])
@@ -1088,8 +1143,9 @@ static unsigned long long log_track_insert(struct per_dev_info *pdi,
static unsigned long long log_track_issue(struct per_dev_info *pdi,
struct blk_io_trace *t)
{
- unsigned long long elapsed;
+ unsigned long long elapsed = -1ULL;
struct io_track *iot;
+ struct io_track_req *req;
if (!track_ios)
return -1;
@@ -1100,16 +1156,20 @@ static unsigned long long log_track_issue(struct per_dev_info *pdi,
if (!iot) {
if (verbose)
fprintf(stderr, "issue not found for (%d,%d): %llu\n",
- MAJOR(pdi->dev), MINOR(pdi->dev),
+ MAJOR(t->device), MINOR(t->device),
(unsigned long long) t->sector);
return -1;
}
- iot->dispatch_time = t->time;
- elapsed = iot->dispatch_time - iot->queue_time;
+ req = iot->req;
+ io_warn_unless(t, req->dispatch_time = -1ULL,
+ "confused about %s time", "dispatch");
+ req->dispatch_time = t->time;
+ if (req->queue_time != -1ULL)
+ elapsed = req->dispatch_time - req->queue_time;
- if (per_process_stats) {
- struct per_process_info *ppi = find_ppi(iot->ppm->pid);
+ if (elapsed != -1ULL && per_process_stats) {
+ struct per_process_info *ppi = find_ppi(req->ppm->pid);
int w = (t->action & BLK_TC_ACT(BLK_TC_WRITE)) != 0;
if (ppi && elapsed > ppi->longest_dispatch_wait[w])
@@ -1119,14 +1179,34 @@ static unsigned long long log_track_issue(struct per_dev_info *pdi,
return elapsed;
}
+static void fixup_complete(struct per_dev_info *pdi, struct blk_io_trace *t)
+{
+ struct io_track *iot;
+ __u64 start_sector;
+
+ iot = __find_track(pdi, t->sector);
+ if (!iot)
+ return;
+
+ /*
+ * When a split io completes, the sector and length of the completion
+ * refer to the last part of the original request. Fix the sector and
+ * length of the complete event to match the original request.
+ */
+ start_sector = first_iot(iot->req)->sector;
+ t->bytes += (t->sector - start_sector) << 9;
+ t->sector = start_sector;
+}
+
/*
* return time between dispatch and complete
*/
static unsigned long long log_track_complete(struct per_dev_info *pdi,
struct blk_io_trace *t)
{
- unsigned long long elapsed;
- struct io_track *iot;
+ unsigned long long elapsed = -1ULL;
+ struct io_track *iot, *next;
+ struct io_track_req *req;
if (!track_ios)
return -1;
@@ -1135,16 +1215,20 @@ static unsigned long long log_track_complete(struct per_dev_info *pdi,
if (!iot) {
if (verbose)
fprintf(stderr,"complete not found for (%d,%d): %llu\n",
- MAJOR(pdi->dev), MINOR(pdi->dev),
+ MAJOR(t->device), MINOR(t->device),
(unsigned long long) t->sector);
return -1;
}
- iot->completion_time = t->time;
- elapsed = iot->completion_time - iot->dispatch_time;
+ req = iot->req;
+ io_warn_unless(t, req->completion_time = -1ULL,
+ "confused about %s time", "completion");
+ req->completion_time = t->time;
+ if (req->dispatch_time != -1ULL)
+ elapsed = req->completion_time - req->dispatch_time;
- if (per_process_stats) {
- struct per_process_info *ppi = find_ppi(iot->ppm->pid);
+ if (elapsed != -1ULL && per_process_stats) {
+ struct per_process_info *ppi = find_ppi(req->ppm->pid);
int w = (t->action & BLK_TC_ACT(BLK_TC_WRITE)) != 0;
if (ppi && elapsed > ppi->longest_completion_wait[w])
@@ -1154,8 +1238,13 @@ static unsigned long long log_track_complete(struct per_dev_info *pdi,
/*
* kill the trace, we don't need it after completion
*/
- rb_erase(&iot->rb_node, &pdi->rb_track);
- free(iot);
+ for (iot = first_iot(req); iot; iot = next) {
+ next = iot->next;
+ rb_erase(&iot->rb_node, &pdi->rb_track);
+ if (iot != first_iot(req))
+ free(iot);
+ }
+ free(req);
return elapsed;
}
@@ -1606,6 +1695,7 @@ static void dump_trace_fs(struct blk_io_trace *t, struct per_dev_info *pdi,
case __BLK_TA_COMPLETE:
if (pdi->cur_depth[w])
pdi->cur_depth[w]--;
+ fixup_complete(pdi, t);
account_c(t, pci, w, t->bytes);
log_complete(pdi, pci, t, "C");
break;
@@ -1621,6 +1711,7 @@ static void dump_trace_fs(struct blk_io_trace *t, struct per_dev_info *pdi,
log_unplug(pci, t, "UT");
break;
case __BLK_TA_SPLIT:
+ log_track_split(pdi, t);
log_split(pci, t, "X");
break;
case __BLK_TA_BOUNCE:
^ permalink raw reply related [flat|nested] 45+ messages in thread
* Recent changes (master)
2013-03-20 5:00 Jens Axboe
` (31 preceding siblings ...)
2020-05-08 12:00 ` Jens Axboe
@ 2020-05-21 12:00 ` Jens Axboe
2021-02-20 13:00 ` Jens Axboe
` (4 subsequent siblings)
37 siblings, 0 replies; 45+ messages in thread
From: Jens Axboe @ 2020-05-21 12:00 UTC (permalink / raw)
To: linux-btrace
The following changes since commit e81829a565162d41e2f551dc5e0f74f22f319554:
blkparse: Fix up the sector and length of split completions (2020-05-07 12:22:37 -0600)
are available in the Git repository at:
git://git.kernel.dk/blktrace.git master
for you to fetch changes up to a021a33b405b5101eec6c389e1dacd7934fdd35e:
blkparse: Print PID information for TN_MESSAGE events (2020-05-20 07:38:26 -0600)
----------------------------------------------------------------
Jan Kara (4):
blkparse: Handle cgroup information
iowatcher: Use blktrace_api.h
iowatcher: Handle cgroup information
blkparse: Print PID information for TN_MESSAGE events
blkparse.c | 41 ++++++++++------
blkparse_fmt.c | 15 ++++++
blktrace_api.h | 10 ++++
doc/blkparse.1 | 4 ++
doc/blktrace.tex | 3 ++
iowatcher/blkparse.c | 134 +++++++++------------------------------------------
6 files changed, 81 insertions(+), 126 deletions(-)
---
Diff of recent changes:
diff --git a/blkparse.c b/blkparse.c
index 796059b..33dd023 100644
--- a/blkparse.c
+++ b/blkparse.c
@@ -617,7 +617,7 @@ static void handle_notify(struct blk_io_trace *bit)
void *payload = (caddr_t) bit + sizeof(*bit);
__u32 two32[2];
- switch (bit->action) {
+ switch (bit->action & ~__BLK_TN_CGROUP) {
case BLK_TN_PROCESS:
add_ppm_hash(bit->pid, payload);
break;
@@ -643,16 +643,27 @@ static void handle_notify(struct blk_io_trace *bit)
case BLK_TN_MESSAGE:
if (bit->pdu_len > 0) {
char msg[bit->pdu_len+1];
+ int len = bit->pdu_len;
+ char cgidstr[24];
- memcpy(msg, (char *)payload, bit->pdu_len);
- msg[bit->pdu_len] = '\0';
+ cgidstr[0] = 0;
+ if (bit->action & __BLK_TN_CGROUP) {
+ struct blk_io_cgroup_payload *cgid = payload;
+
+ sprintf(cgidstr, "%x,%x ", cgid->ino,
+ cgid->gen);
+ payload += sizeof(struct blk_io_cgroup_payload);
+ len -= sizeof(struct blk_io_cgroup_payload);
+ }
+ memcpy(msg, (char *)payload, len);
+ msg[len] = '\0';
fprintf(ofp,
- "%3d,%-3d %2d %8s %5d.%09lu %5u %2s %3s %s\n",
+ "%3d,%-3d %2d %8s %5d.%09lu %5u %s%2s %3s %s\n",
MAJOR(bit->device), MINOR(bit->device),
- bit->cpu, "0", (int) SECONDS(bit->time),
- (unsigned long) NANO_SECONDS(bit->time),
- 0, "m", "N", msg);
+ bit->cpu, "0", (int)SECONDS(bit->time),
+ (unsigned long)NANO_SECONDS(bit->time),
+ bit->pid, cgidstr, "m", "N", msg);
}
break;
@@ -1600,7 +1611,7 @@ static void dump_trace_pc(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)) != 0;
- int act = t->action & 0xffff;
+ int act = (t->action & 0xffff) & ~__BLK_TA_CGROUP;
switch (act) {
case __BLK_TA_QUEUE:
@@ -1649,7 +1660,7 @@ 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)) != 0;
- int act = t->action & 0xffff;
+ int act = (t->action & 0xffff) & ~__BLK_TA_CGROUP;
switch (act) {
case __BLK_TA_QUEUE:
@@ -1734,7 +1745,7 @@ static void dump_trace(struct blk_io_trace *t, struct per_cpu_info *pci,
struct per_dev_info *pdi)
{
if (text_output) {
- if (t->action = BLK_TN_MESSAGE)
+ if ((t->action & ~__BLK_TN_CGROUP) = BLK_TN_MESSAGE)
handle_notify(t);
else if (t->action & BLK_TC_ACT(BLK_TC_PC))
dump_trace_pc(t, pdi, pci);
@@ -1749,7 +1760,7 @@ static void dump_trace(struct blk_io_trace *t, struct per_cpu_info *pci,
if (bin_output_msgs ||
!(t->action & BLK_TC_ACT(BLK_TC_NOTIFY) &&
- t->action = BLK_TN_MESSAGE))
+ (t->action & ~__BLK_TN_CGROUP) = BLK_TN_MESSAGE))
output_binary(t, sizeof(*t) + t->pdu_len);
}
@@ -2325,7 +2336,7 @@ static void show_entries_rb(int force)
break;
}
- if (!(bit->action = BLK_TN_MESSAGE) &&
+ if (!((bit->action & ~__BLK_TN_CGROUP) = BLK_TN_MESSAGE) &&
check_sequence(pdi, t, force))
break;
@@ -2337,7 +2348,7 @@ static void show_entries_rb(int force)
if (!pci || pci->cpu != bit->cpu)
pci = get_cpu_info(pdi, bit->cpu);
- if (!(bit->action = BLK_TN_MESSAGE))
+ if (!((bit->action & ~__BLK_TN_CGROUP) = BLK_TN_MESSAGE))
pci->last_sequence = bit->sequence;
pci->nelems++;
@@ -2471,7 +2482,7 @@ static int read_events(int fd, int always_block, int *fdblock)
/*
* not a real trace, so grab and handle it here
*/
- if (bit->action & BLK_TC_ACT(BLK_TC_NOTIFY) && bit->action != BLK_TN_MESSAGE) {
+ if (bit->action & BLK_TC_ACT(BLK_TC_NOTIFY) && (bit->action & ~__BLK_TN_CGROUP) != BLK_TN_MESSAGE) {
handle_notify(bit);
output_binary(bit, sizeof(*bit) + bit->pdu_len);
continue;
@@ -2620,7 +2631,7 @@ static int ms_prime(struct ms_stream *msp)
continue;
}
- if (bit->action & BLK_TC_ACT(BLK_TC_NOTIFY) && bit->action != BLK_TN_MESSAGE) {
+ if (bit->action & BLK_TC_ACT(BLK_TC_NOTIFY) && (bit->action & ~__BLK_TN_CGROUP) != BLK_TN_MESSAGE) {
handle_notify(bit);
output_binary(bit, sizeof(*bit) + bit->pdu_len);
bit_free(bit);
diff --git a/blkparse_fmt.c b/blkparse_fmt.c
index c42e6d7..df2f6ce 100644
--- a/blkparse_fmt.c
+++ b/blkparse_fmt.c
@@ -205,6 +205,21 @@ static void print_field(char *act, struct per_cpu_info *pci,
case 'e':
fprintf(ofp, strcat(format, "d"), t->error);
break;
+ case 'g': {
+ char cgidstr[24];
+ u32 ino = 0, gen = 0;
+
+ if (t->action & __BLK_TA_CGROUP) {
+ struct blk_io_cgroup_payload *cgid + (struct blk_io_cgroup_payload *)pdu_buf;
+
+ ino = cgid->ino;
+ gen = cgid->gen;
+ }
+ sprintf(cgidstr, "%x,%x", ino, gen);
+ fprintf(ofp, strcat(format, "s"), cgidstr);
+ break;
+ }
case 'M':
fprintf(ofp, strcat(format, "d"), MAJOR(t->device));
break;
diff --git a/blktrace_api.h b/blktrace_api.h
index b222218..8c760b8 100644
--- a/blktrace_api.h
+++ b/blktrace_api.h
@@ -51,6 +51,7 @@ enum {
__BLK_TA_REMAP, /* bio was remapped */
__BLK_TA_ABORT, /* request aborted */
__BLK_TA_DRV_DATA, /* binary driver data */
+ __BLK_TA_CGROUP = 1 << 8,
};
/*
@@ -60,6 +61,7 @@ enum blktrace_notify {
__BLK_TN_PROCESS = 0, /* establish pid/name mapping */
__BLK_TN_TIMESTAMP, /* include system clock */
__BLK_TN_MESSAGE, /* Character string message */
+ __BLK_TN_CGROUP = __BLK_TA_CGROUP,
};
/*
@@ -116,6 +118,14 @@ struct blk_io_trace_remap {
__u64 sector_from;
};
+/*
+ * Payload with originating cgroup info
+ */
+struct blk_io_cgroup_payload {
+ __u32 ino;
+ __u32 gen;
+};
+
/*
* User setup structure passed with BLKSTARTTRACE
*/
diff --git a/doc/blkparse.1 b/doc/blkparse.1
index e494b6e..4c26baf 100644
--- a/doc/blkparse.1
+++ b/doc/blkparse.1
@@ -332,6 +332,10 @@ the event's device (separated by a comma).
.IP \fBe\fR 4
Error value
+.IP \fBg\fR 4
+Cgroup identifier of the cgroup that generated the IO. Note that this requires
+appropriate kernel support (kernel version at least 4.14).
+
.IP \fBm\fR 4
Minor number of event's device.
diff --git a/doc/blktrace.tex b/doc/blktrace.tex
index 3647c75..836ac4a 100644
--- a/doc/blktrace.tex
+++ b/doc/blktrace.tex
@@ -601,6 +601,9 @@ Specifier & \\ \hline\hline
the event's device \\
& (separated by a comma). \\ \hline
\emph{e} & Error value \\ \hline
+\emph{g} & Cgroup identifier of the cgroup that generated the IO. Note that this requires
+appropriate \\
+ & kernel support (kernel version at least 4.14). \\ \hline
\emph{m} & Minor number of event's device. \\ \hline
\emph{M} & Major number of event's device. \\ \hline
\emph{n} & Number of blocks \\ \hline
diff --git a/iowatcher/blkparse.c b/iowatcher/blkparse.c
index 41e20f0..6203854 100644
--- a/iowatcher/blkparse.c
+++ b/iowatcher/blkparse.c
@@ -36,6 +36,7 @@
#include "blkparse.h"
#include "list.h"
#include "tracers.h"
+#include "../blktrace_api.h"
#define IO_HASH_TABLE_BITS 11
#define IO_HASH_TABLE_SIZE (1 << IO_HASH_TABLE_BITS)
@@ -49,111 +50,8 @@ static struct list_head process_hash_table[PROCESS_HASH_TABLE_SIZE];
extern int plot_io_action;
extern int io_per_process;
-/*
- * Trace categories
- */
-enum {
- BLK_TC_READ = 1 << 0, /* reads */
- BLK_TC_WRITE = 1 << 1, /* writes */
- BLK_TC_FLUSH = 1 << 2, /* flush */
- BLK_TC_SYNC = 1 << 3, /* sync */
- BLK_TC_QUEUE = 1 << 4, /* queueing/merging */
- BLK_TC_REQUEUE = 1 << 5, /* requeueing */
- BLK_TC_ISSUE = 1 << 6, /* issue */
- BLK_TC_COMPLETE = 1 << 7, /* completions */
- BLK_TC_FS = 1 << 8, /* fs requests */
- BLK_TC_PC = 1 << 9, /* pc requests */
- BLK_TC_NOTIFY = 1 << 10, /* special message */
- BLK_TC_AHEAD = 1 << 11, /* readahead */
- BLK_TC_META = 1 << 12, /* metadata */
- BLK_TC_DISCARD = 1 << 13, /* discard requests */
- BLK_TC_DRV_DATA = 1 << 14, /* binary driver data */
- BLK_TC_FUA = 1 << 15, /* fua requests */
-
- BLK_TC_END = 1 << 15, /* we've run out of bits! */
-};
-
-#define BLK_TC_SHIFT (16)
-#define BLK_TC_ACT(act) ((act) << BLK_TC_SHIFT)
#define BLK_DATADIR(a) (((a) >> BLK_TC_SHIFT) & (BLK_TC_READ | BLK_TC_WRITE))
-
-/*
- * Basic trace actions
- */
-enum {
- __BLK_TA_QUEUE = 1, /* queued */
- __BLK_TA_BACKMERGE, /* back merged to existing rq */
- __BLK_TA_FRONTMERGE, /* front merge to existing rq */
- __BLK_TA_GETRQ, /* allocated new request */
- __BLK_TA_SLEEPRQ, /* sleeping on rq allocation */
- __BLK_TA_REQUEUE, /* request requeued */
- __BLK_TA_ISSUE, /* sent to driver */
- __BLK_TA_COMPLETE, /* completed by driver */
- __BLK_TA_PLUG, /* queue was plugged */
- __BLK_TA_UNPLUG_IO, /* queue was unplugged by io */
- __BLK_TA_UNPLUG_TIMER, /* queue was unplugged by timer */
- __BLK_TA_INSERT, /* insert request */
- __BLK_TA_SPLIT, /* bio was split */
- __BLK_TA_BOUNCE, /* bio was bounced */
- __BLK_TA_REMAP, /* bio was remapped */
- __BLK_TA_ABORT, /* request aborted */
- __BLK_TA_DRV_DATA, /* binary driver data */
-};
-
-#define BLK_TA_MASK ((1 << BLK_TC_SHIFT) - 1)
-
-/*
- * Notify events.
- */
-enum blktrace_notify {
- __BLK_TN_PROCESS = 0, /* establish pid/name mapping */
- __BLK_TN_TIMESTAMP, /* include system clock */
- __BLK_TN_MESSAGE, /* Character string message */
-};
-
-/*
- * Trace actions in full. Additionally, read or write is masked
- */
-#define BLK_TA_QUEUE (__BLK_TA_QUEUE | BLK_TC_ACT(BLK_TC_QUEUE))
-#define BLK_TA_BACKMERGE (__BLK_TA_BACKMERGE | BLK_TC_ACT(BLK_TC_QUEUE))
-#define BLK_TA_FRONTMERGE (__BLK_TA_FRONTMERGE | BLK_TC_ACT(BLK_TC_QUEUE))
-#define BLK_TA_GETRQ (__BLK_TA_GETRQ | BLK_TC_ACT(BLK_TC_QUEUE))
-#define BLK_TA_SLEEPRQ (__BLK_TA_SLEEPRQ | BLK_TC_ACT(BLK_TC_QUEUE))
-#define BLK_TA_REQUEUE (__BLK_TA_REQUEUE | BLK_TC_ACT(BLK_TC_REQUEUE))
-#define BLK_TA_ISSUE (__BLK_TA_ISSUE | BLK_TC_ACT(BLK_TC_ISSUE))
-#define BLK_TA_COMPLETE (__BLK_TA_COMPLETE| BLK_TC_ACT(BLK_TC_COMPLETE))
-#define BLK_TA_PLUG (__BLK_TA_PLUG | BLK_TC_ACT(BLK_TC_QUEUE))
-#define BLK_TA_UNPLUG_IO (__BLK_TA_UNPLUG_IO | BLK_TC_ACT(BLK_TC_QUEUE))
-#define BLK_TA_UNPLUG_TIMER (__BLK_TA_UNPLUG_TIMER | BLK_TC_ACT(BLK_TC_QUEUE))
-#define BLK_TA_INSERT (__BLK_TA_INSERT | BLK_TC_ACT(BLK_TC_QUEUE))
-#define BLK_TA_SPLIT (__BLK_TA_SPLIT)
-#define BLK_TA_BOUNCE (__BLK_TA_BOUNCE)
-#define BLK_TA_REMAP (__BLK_TA_REMAP | BLK_TC_ACT(BLK_TC_QUEUE))
-#define BLK_TA_ABORT (__BLK_TA_ABORT | BLK_TC_ACT(BLK_TC_QUEUE))
-#define BLK_TA_DRV_DATA (__BLK_TA_DRV_DATA | BLK_TC_ACT(BLK_TC_DRV_DATA))
-
-#define BLK_TN_PROCESS (__BLK_TN_PROCESS | BLK_TC_ACT(BLK_TC_NOTIFY))
-#define BLK_TN_TIMESTAMP (__BLK_TN_TIMESTAMP | BLK_TC_ACT(BLK_TC_NOTIFY))
-#define BLK_TN_MESSAGE (__BLK_TN_MESSAGE | BLK_TC_ACT(BLK_TC_NOTIFY))
-
-#define BLK_IO_TRACE_MAGIC 0x65617400
-#define BLK_IO_TRACE_VERSION 0x07
-/*
- * The trace itself
- */
-struct blk_io_trace {
- __u32 magic; /* MAGIC << 8 | version */
- __u32 sequence; /* event number */
- __u64 time; /* in nanoseconds */
- __u64 sector; /* disk offset */
- __u32 bytes; /* transfer length */
- __u32 action; /* what happened */
- __u32 pid; /* who did it */
- __u32 device; /* device identifier (dev_t) */
- __u32 cpu; /* on what cpu did it happen */
- __u16 error; /* completion error */
- __u16 pdu_len; /* length of data after this trace */
-};
+#define BLK_TA_MASK (((1 << BLK_TC_SHIFT) - 1) & ~__BLK_TA_CGROUP)
struct pending_io {
/* sector offset of this IO */
@@ -362,18 +260,23 @@ static void handle_notify(struct trace *trace)
{
struct blk_io_trace *io = trace->io;
void *payload = (char *)io + sizeof(*io);
+ int pdu_len = io->pdu_len;
u32 two32[2];
- if (io->action = BLK_TN_PROCESS) {
+ if (io->action & __BLK_TN_CGROUP) {
+ payload += sizeof(struct blk_io_cgroup_payload);
+ pdu_len -= sizeof(struct blk_io_cgroup_payload);
+ }
+ if ((io->action & ~__BLK_TN_CGROUP) = BLK_TN_PROCESS) {
if (io_per_process)
process_hash_insert(io->pid, payload);
return;
}
- if (io->action != BLK_TN_TIMESTAMP)
+ if ((io->action & ~__BLK_TN_CGROUP) != BLK_TN_TIMESTAMP)
return;
- if (io->pdu_len != sizeof(two32))
+ if (pdu_len != sizeof(two32))
return;
memcpy(two32, payload, sizeof(two32));
@@ -411,11 +314,16 @@ static int is_io_event(struct blk_io_trace *test)
char *message;
if (!(test->action & BLK_TC_ACT(BLK_TC_NOTIFY)))
return 1;
- if (test->action = BLK_TN_MESSAGE) {
+ if ((test->action & ~__BLK_TN_CGROUP) = BLK_TN_MESSAGE) {
int len = test->pdu_len;
+
+ message = (char *)(test + 1);
+ if (test->action & __BLK_TN_CGROUP) {
+ len -= sizeof(struct blk_io_cgroup_payload);
+ message += sizeof(struct blk_io_cgroup_payload);
+ }
if (len < 3)
return 0;
- message = (char *)(test + 1);
if (strncmp(message, "fio ", 4) = 0) {
return 1;
}
@@ -474,13 +382,17 @@ static int parse_fio_bank_message(struct trace *trace, u64 *bank_ret, u64 *offse
if (!(test->action & BLK_TC_ACT(BLK_TC_NOTIFY)))
return -1;
- if (test->action != BLK_TN_MESSAGE)
+ if ((test->action & ~__BLK_TN_CGROUP) != BLK_TN_MESSAGE)
return -1;
+ message = (char *)(test + 1);
+ if (test->action & __BLK_TN_CGROUP) {
+ len -= sizeof(struct blk_io_cgroup_payload);
+ message += sizeof(struct blk_io_cgroup_payload);
+ }
/* the message is fio rw bank offset num_banks */
if (len < 3)
return -1;
- message = (char *)(test + 1);
if (strncmp(message, "fio r ", 6) != 0)
return -1;
^ permalink raw reply related [flat|nested] 45+ messages in thread
* Recent changes (master)
2013-03-20 5:00 Jens Axboe
` (32 preceding siblings ...)
2020-05-21 12:00 ` Jens Axboe
@ 2021-02-20 13:00 ` Jens Axboe
2021-04-20 12:00 ` Jens Axboe
` (3 subsequent siblings)
37 siblings, 0 replies; 45+ messages in thread
From: Jens Axboe @ 2021-02-20 13:00 UTC (permalink / raw)
To: linux-btrace
The following changes since commit a021a33b405b5101eec6c389e1dacd7934fdd35e:
blkparse: Print PID information for TN_MESSAGE events (2020-05-20 07:38:26 -0600)
are available in the Git repository at:
git://git.kernel.dk/blktrace.git master
for you to fetch changes up to 2ec0bb0b725305025dcc3e3f195894040e2dab90:
blktrace: inclusive terminology (2021-02-19 09:42:41 -0700)
----------------------------------------------------------------
Eric Sandeen (1):
blktrace: inclusive terminology
blkparse_fmt.c | 4 ++--
blktrace.c | 2 +-
2 files changed, 3 insertions(+), 3 deletions(-)
---
Diff of recent changes:
diff --git a/blkparse_fmt.c b/blkparse_fmt.c
index df2f6ce..9b83d1d 100644
--- a/blkparse_fmt.c
+++ b/blkparse_fmt.c
@@ -276,12 +276,12 @@ static void print_field(char *act, struct per_cpu_info *pci,
static char *parse_field(char *act, struct per_cpu_info *pci,
struct blk_io_trace *t, unsigned long long elapsed,
int pdu_len, unsigned char *pdu_buf,
- char *master_format)
+ char *primary_format)
{
int minus = 0;
int has_w = 0;
int width = 0;
- char *p = master_format;
+ char *p = primary_format;
if (*p = '-') {
minus = 1;
diff --git a/blktrace.c b/blktrace.c
index d0d271f..82a6aad 100644
--- a/blktrace.c
+++ b/blktrace.c
@@ -307,7 +307,7 @@ static pthread_mutex_t dp_mutex = PTHREAD_MUTEX_INITIALIZER;
static volatile int dp_entries;
/*
- * These synchronize master / thread interactions.
+ * These synchronize main / thread interactions.
*/
static pthread_cond_t mt_cond = PTHREAD_COND_INITIALIZER;
static pthread_mutex_t mt_mutex = PTHREAD_MUTEX_INITIALIZER;
^ permalink raw reply related [flat|nested] 45+ messages in thread
* Recent changes (master)
2013-03-20 5:00 Jens Axboe
` (33 preceding siblings ...)
2021-02-20 13:00 ` Jens Axboe
@ 2021-04-20 12:00 ` Jens Axboe
2021-06-15 11:59 ` Jens Axboe
` (2 subsequent siblings)
37 siblings, 0 replies; 45+ messages in thread
From: Jens Axboe @ 2021-04-20 12:00 UTC (permalink / raw)
To: linux-btrace
The following changes since commit 2ec0bb0b725305025dcc3e3f195894040e2dab90:
blktrace: inclusive terminology (2021-02-19 09:42:41 -0700)
are available in the Git repository at:
git://git.kernel.dk/blktrace.git master
for you to fetch changes up to dc24c67dfbbd11a3221034557548061e7d2c602f:
blkparse: Print time when trace was started (2021-04-19 11:55:04 -0600)
----------------------------------------------------------------
Jan Kara (1):
blkparse: Print time when trace was started
blkparse.c | 2 ++
1 file changed, 2 insertions(+)
---
Diff of recent changes:
diff --git a/blkparse.c b/blkparse.c
index 33dd023..1d7ae95 100644
--- a/blkparse.c
+++ b/blkparse.c
@@ -32,6 +32,7 @@
#include <signal.h>
#include <locale.h>
#include <libgen.h>
+#include <time.h>
#include "blktrace.h"
#include "rbtree.h"
@@ -2888,6 +2889,7 @@ static void show_stats(void)
if (per_device_and_cpu_stats)
show_device_and_cpu_stats();
+ fprintf(ofp, "Trace started at %s\n", ctime(&abs_start_time.tv_sec));
fflush(ofp);
}
^ permalink raw reply related [flat|nested] 45+ messages in thread
* Recent changes (master)
2013-03-20 5:00 Jens Axboe
` (34 preceding siblings ...)
2021-04-20 12:00 ` Jens Axboe
@ 2021-06-15 11:59 ` Jens Axboe
2021-06-29 12:00 ` Jens Axboe
2021-10-22 12:00 ` Jens Axboe
37 siblings, 0 replies; 45+ messages in thread
From: Jens Axboe @ 2021-06-15 11:59 UTC (permalink / raw)
To: linux-btrace
The following changes since commit dc24c67dfbbd11a3221034557548061e7d2c602f:
blkparse: Print time when trace was started (2021-04-19 11:55:04 -0600)
are available in the Git repository at:
git://git.kernel.dk/blktrace.git master
for you to fetch changes up to 366d30b9cdb20345c5d064af850d686da79b89eb:
blktrace 1.3.0 (2021-06-14 08:55:52 -0600)
----------------------------------------------------------------
Jens Axboe (1):
blktrace 1.3.0
blkparse.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
---
Diff of recent changes:
diff --git a/blkparse.c b/blkparse.c
index 1d7ae95..f88204a 100644
--- a/blkparse.c
+++ b/blkparse.c
@@ -38,7 +38,7 @@
#include "rbtree.h"
#include "jhash.h"
-static char blkparse_version[] = "1.2.0";
+static char blkparse_version[] = "1.3.0";
struct skip_info {
unsigned long start, end;
^ permalink raw reply related [flat|nested] 45+ messages in thread
* Recent changes (master)
2013-03-20 5:00 Jens Axboe
` (35 preceding siblings ...)
2021-06-15 11:59 ` Jens Axboe
@ 2021-06-29 12:00 ` Jens Axboe
2021-10-22 12:00 ` Jens Axboe
37 siblings, 0 replies; 45+ messages in thread
From: Jens Axboe @ 2021-06-29 12:00 UTC (permalink / raw)
To: linux-btrace
The following changes since commit 366d30b9cdb20345c5d064af850d686da79b89eb:
blktrace 1.3.0 (2021-06-14 08:55:52 -0600)
are available in the Git repository at:
git://git.kernel.dk/blktrace.git master
for you to fetch changes up to 3a1b1366d30375cdb0f5b299df4edda0c8ba3bcc:
blktrace: exit directly when nthreads_running != ncpus in run_tracers() (2021-06-28 13:41:32 -0600)
----------------------------------------------------------------
lijinlin (1):
blktrace: exit directly when nthreads_running != ncpus in run_tracers()
blktrace.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
---
Diff of recent changes:
diff --git a/blktrace.c b/blktrace.c
index 82a6aad..3444fbb 100644
--- a/blktrace.c
+++ b/blktrace.c
@@ -2705,8 +2705,10 @@ static int run_tracers(void)
printf("blktrace: connected!\n");
if (stop_watch)
alarm(stop_watch);
- } else
+ } else {
stop_tracers();
+ done = 1;
+ }
wait_tracers();
if (nthreads_running = ncpus)
^ permalink raw reply related [flat|nested] 45+ messages in thread
* Recent changes (master)
2013-03-20 5:00 Jens Axboe
` (36 preceding siblings ...)
2021-06-29 12:00 ` Jens Axboe
@ 2021-10-22 12:00 ` Jens Axboe
37 siblings, 0 replies; 45+ messages in thread
From: Jens Axboe @ 2021-10-22 12:00 UTC (permalink / raw)
To: linux-btrace
The following changes since commit 3a1b1366d30375cdb0f5b299df4edda0c8ba3bcc:
blktrace: exit directly when nthreads_running != ncpus in run_tracers() (2021-06-28 13:41:32 -0600)
are available in the Git repository at:
git://git.kernel.dk/blktrace.git master
for you to fetch changes up to 7f5d2c5173d72018aa29c583c9291ef10abaf8df:
blkparse: fix incorrectly sized memset in check_cpu_map (2021-10-21 08:45:17 -0600)
----------------------------------------------------------------
Jeff Mahoney (2):
blkparse: skip check_cpu_map with pipe input
blkparse: fix incorrectly sized memset in check_cpu_map
blkparse.c | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
---
Diff of recent changes:
diff --git a/blkparse.c b/blkparse.c
index f88204a..9d2029a 100644
--- a/blkparse.c
+++ b/blkparse.c
@@ -2229,11 +2229,14 @@ static int check_cpu_map(struct per_dev_info *pdi)
unsigned int i;
int ret, cpu;
+ /* Pipe input doesn't do CPU online tracking. */
+ if (!pdi->cpu_map_max)
+ return 0;
+
/*
* create a map of the cpus we have traces for
*/
- cpu_map = malloc(pdi->cpu_map_max / sizeof(long));
- memset(cpu_map, 0, sizeof(*cpu_map));
+ cpu_map = calloc(1, pdi->cpu_map_max / sizeof(long));
n = rb_first(&rb_sort_root);
while (n) {
__t = rb_entry(n, struct trace, rb_node);
^ permalink raw reply related [flat|nested] 45+ messages in thread
* Recent changes (master)
@ 2024-01-18 13:00 Jens Axboe
0 siblings, 0 replies; 45+ messages in thread
From: Jens Axboe @ 2024-01-18 13:00 UTC (permalink / raw)
To: linux-btrace
The following changes since commit 7f5d2c5173d72018aa29c583c9291ef10abaf8df:
blkparse: fix incorrectly sized memset in check_cpu_map (2021-10-21 08:45:17 -0600)
are available in the Git repository at:
git://git.kernel.dk/blktrace.git master
for you to fetch changes up to b9ea6e507e8849f01d06aa48c0c59c5cee4820be:
doc: btrace: fix wrong format on doc (2024-01-17 16:02:23 -0700)
----------------------------------------------------------------
Fukui Daichi (1):
doc: btrace: fix wrong format on doc
doc/btrace.8 | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
---
Diff of recent changes:
diff --git a/doc/btrace.8 b/doc/btrace.8
index a1f34c2..2080e6e 100644
--- a/doc/btrace.8
+++ b/doc/btrace.8
@@ -6,7 +6,7 @@ btrace \- perform live tracing for block devices
.SH SYNOPSIS
-.B btrace [\-s] [\-t] [\-w \fIN\fN] [\-n \fIN\fR] [\-b \fIN\fR] [\-r \fI<dbg mnt>\fR] [\-a <\fItrace\fR>...] <\fIdev\fR>...
+.B btrace [\-s] [\-t] [\-w \fIN\fR] [\-n \fIN\fR] [\-b \fIN\fR] [\-r \fI<dbg mnt>\fR] [\-a <\fItrace\fR>...] <\fIdev\fR>...
.br
^ permalink raw reply related [flat|nested] 45+ messages in thread
* Recent changes (master)
@ 2024-06-13 12:00 Jens Axboe
0 siblings, 0 replies; 45+ messages in thread
From: Jens Axboe @ 2024-06-13 12:00 UTC (permalink / raw)
To: linux-btrace
The following changes since commit b9ea6e507e8849f01d06aa48c0c59c5cee4820be:
doc: btrace: fix wrong format on doc (2024-01-17 16:02:23 -0700)
are available in the Git repository at:
git://git.kernel.dk/blktrace.git master
for you to fetch changes up to 1836be5d99c9362f1e2b39206c95270f19cb7faa:
fix hang when BLKTRACESETUP fails and "-o -" is used (2024-06-12 14:45:58 -0600)
----------------------------------------------------------------
Eric Sandeen (1):
fix hang when BLKTRACESETUP fails and "-o -" is used
blktrace.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
---
Diff of recent changes:
diff --git a/blktrace.c b/blktrace.c
index 3444fbb..038b2cb 100644
--- a/blktrace.c
+++ b/blktrace.c
@@ -2684,8 +2684,10 @@ static int run_tracers(void)
if (net_mode == Net_client)
printf("blktrace: connecting to %s\n", hostname);
- if (setup_buts())
+ if (setup_buts()) {
+ done = 1;
return 1;
+ }
if (use_tracer_devpaths()) {
if (setup_tracer_devpaths())
^ permalink raw reply related [flat|nested] 45+ messages in thread
* Recent changes (master)
@ 2024-10-09 12:00 Jens Axboe
0 siblings, 0 replies; 45+ messages in thread
From: Jens Axboe @ 2024-10-09 12:00 UTC (permalink / raw)
To: linux-btrace
The following changes since commit 1836be5d99c9362f1e2b39206c95270f19cb7faa:
fix hang when BLKTRACESETUP fails and "-o -" is used (2024-06-12 14:45:58 -0600)
are available in the Git repository at:
git://git.kernel.dk/blktrace.git master
for you to fetch changes up to f49e7ded6405bcecd10846a614f40061ca6301c8:
iowatcher: Calculate ios_in_flight per trace (2024-10-08 07:40:39 -0600)
----------------------------------------------------------------
Igor Pylypiv (1):
iowatcher: Calculate ios_in_flight per trace
iowatcher/blkparse.c | 13 ++++++-------
iowatcher/blkparse.h | 1 +
2 files changed, 7 insertions(+), 7 deletions(-)
---
Diff of recent changes:
diff --git a/iowatcher/blkparse.c b/iowatcher/blkparse.c
index 6203854..0518083 100644
--- a/iowatcher/blkparse.c
+++ b/iowatcher/blkparse.c
@@ -41,7 +41,6 @@
#define IO_HASH_TABLE_BITS 11
#define IO_HASH_TABLE_SIZE (1 << IO_HASH_TABLE_BITS)
static struct list_head io_hash_table[IO_HASH_TABLE_SIZE];
-static u64 ios_in_flight = 0;
#define PROCESS_HASH_TABLE_BITS 7
#define PROCESS_HASH_TABLE_SIZE (1 << PROCESS_HASH_TABLE_BITS)
@@ -1037,8 +1036,8 @@ void add_pending_io(struct trace *trace, struct graph_line_data *gld)
return;
}
if (action == __BLK_TA_REQUEUE) {
- if (ios_in_flight > 0)
- ios_in_flight--;
+ if (trace->ios_in_flight > 0)
+ trace->ios_in_flight--;
return;
}
if (action != __BLK_TA_ISSUE)
@@ -1054,10 +1053,10 @@ void add_pending_io(struct trace *trace, struct graph_line_data *gld)
}
account_io:
- ios_in_flight++;
+ trace->ios_in_flight++;
seconds = SECONDS(io->time);
- gld->data[seconds].sum += ios_in_flight;
+ gld->data[seconds].sum += trace->ios_in_flight;
gld->data[seconds].count++;
avg = (double)gld->data[seconds].sum / gld->data[seconds].count;
@@ -1088,8 +1087,8 @@ void add_completed_io(struct trace *trace,
if (!pio)
return;
- if (ios_in_flight > 0)
- ios_in_flight--;
+ if (trace->ios_in_flight > 0)
+ trace->ios_in_flight--;
if (io->time >= pio->dispatch_time) {
latency = io->time - pio->dispatch_time;
latency_gld->data[seconds].sum += latency;
diff --git a/iowatcher/blkparse.h b/iowatcher/blkparse.h
index fce9d01..f828763 100644
--- a/iowatcher/blkparse.h
+++ b/iowatcher/blkparse.h
@@ -57,6 +57,7 @@ struct trace {
int mpstat_fd;
int mpstat_seconds;
int mpstat_num_cpus;
+ u64 ios_in_flight;
char *fio_start;
char *fio_cur;
^ permalink raw reply related [flat|nested] 45+ messages in thread
* Recent changes (master)
@ 2025-01-31 13:00 Jens Axboe
0 siblings, 0 replies; 45+ messages in thread
From: Jens Axboe @ 2025-01-31 13:00 UTC (permalink / raw)
To: linux-btrace
The following changes since commit f49e7ded6405bcecd10846a614f40061ca6301c8:
iowatcher: Calculate ios_in_flight per trace (2024-10-08 07:40:39 -0600)
are available in the Git repository at:
git://git.kernel.dk/blktrace.git master
for you to fetch changes up to 16b952f4ea2db052f7cc613474d15a76c91c93d2:
doc: update RWBS descriptions (2025-01-30 09:54:59 -0700)
----------------------------------------------------------------
Stefan Hajnoczi (1):
doc: update RWBS descriptions
doc/blkparse.1 | 37 ++++++++++++++++++++++++++++++++++---
doc/blktrace.tex | 21 ++++++++++++++++++---
2 files changed, 52 insertions(+), 6 deletions(-)
---
Diff of recent changes:
diff --git a/doc/blkparse.1 b/doc/blkparse.1
index 4c26baf..93aa449 100644
--- a/doc/blkparse.1
+++ b/doc/blkparse.1
@@ -435,10 +435,41 @@ Split
.SH "RWBS DESCRIPTION"
-This is a small string containing at least one character ('R' for read, 'W'
-for write, or 'D' for block discard operation), and optionally either
-a 'B' (for barrier operations) or 'S' (for synchronous operations).
+This is a small string containing characters in the following order:
+.IP F
+Flush
+
+.IP R
+Read
+
+.IP W
+Write
+
+.IP D
+Discard
+
+.IP B
+Barrier
+
+.IP N
+Other operation
+
+.IP F
+Force Unit Access (FUA)
+
+.IP A
+Readahead
+
+.IP S
+Synchronous
+
+.IP M
+Meta
+
+.PP
+One of 'R', 'W', 'D', or 'N' is always present. The other characters are
+optional. Note that 'F' has two meanings, depending on its position.
.SH "DEFAULT OUTPUT"
diff --git a/doc/blktrace.tex b/doc/blktrace.tex
index 836ac4a..d747de7 100644
--- a/doc/blktrace.tex
+++ b/doc/blktrace.tex
@@ -653,9 +653,24 @@ X & Split \\ \hline
\end{tabular}
\subsubsection{\label{sec:act-table}RWBS Description}
-This is a small string containing at least one character ('R' for read,
-'W' for write, or 'D' for block discard operation), and optionally either
-a 'B' (for barrier operations) or 'S' (for synchronous operations).
+This is a small string containing characters in the following order:
+
+\begin{tabular}{|l|l|}\hline
+Character & Description \\ \hline\hline
+F & Flush \\ \hline
+R & Read \\ \hline
+W & Write \\ \hline
+D & Discard \\ \hline
+B & Barrier \\ \hline
+N & Other operation \\ \hline
+F & Force Unit Access (FUA) \\ \hline
+A & Readahead \\ \hline
+S & Synchronous \\ \hline
+M & Meta \\ \hline
+\end{tabular}
+
+One of 'R', 'W', 'D', or 'N' is always present. The other characters are
+optional. Note that 'F' has two meanings, depending on its position.
\subsubsection{\label{sec:default-output}Default output}
^ permalink raw reply related [flat|nested] 45+ messages in thread
* Recent changes (master)
@ 2025-03-20 12:00 Jens Axboe
0 siblings, 0 replies; 45+ messages in thread
From: Jens Axboe @ 2025-03-20 12:00 UTC (permalink / raw)
To: linux-btrace
The following changes since commit 16b952f4ea2db052f7cc613474d15a76c91c93d2:
doc: update RWBS descriptions (2025-01-30 09:54:59 -0700)
are available in the Git repository at:
git://git.kernel.dk/blktrace.git master
for you to fetch changes up to f9bd00dfbd67ce62ca6df6f55d6275b523cd0b39:
blkparse: Fix a potential coredump issue (2025-03-20 05:06:40 -0600)
----------------------------------------------------------------
Kou Wenqi (1):
blkparse: Fix a potential coredump issue
blkparse.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
---
Diff of recent changes:
diff --git a/blkparse.c b/blkparse.c
index 9d2029a..d6aaa8b 100644
--- a/blkparse.c
+++ b/blkparse.c
@@ -1022,7 +1022,7 @@ static struct io_track *find_track(struct per_dev_info *pdi, pid_t pid,
if (!iot) {
struct io_track_req *req;
- req = malloc(sizeof(*req) + sizeof(*iot));
+ req = calloc(1, sizeof(*req) + sizeof(*iot));
req->ppm = find_ppm(pid);
if (!req->ppm)
req->ppm = add_ppm_hash(pid, "unknown");
@@ -1106,7 +1106,7 @@ static void log_track_split(struct per_dev_info *pdi, struct blk_io_trace *t)
* parts.
*/
iot = find_track(pdi, t->pid, t->sector);
- split = malloc(sizeof(*iot));
+ split = calloc(1, sizeof(*iot));
split->req = iot->req;
split->next = iot->next;
iot->next = split;
^ permalink raw reply related [flat|nested] 45+ messages in thread
* Recent changes (master)
@ 2025-12-11 13:00 Jens Axboe
0 siblings, 0 replies; 45+ messages in thread
From: Jens Axboe @ 2025-12-11 13:00 UTC (permalink / raw)
To: linux-btrace
The following changes since commit f9bd00dfbd67ce62ca6df6f55d6275b523cd0b39:
blkparse: Fix a potential coredump issue (2025-03-20 05:06:40 -0600)
are available in the Git repository at:
git://git.kernel.dk/blktrace.git master
for you to fetch changes up to 9b24b42ef59d2e8015957db3dd70ffedb7ebcfe8:
Update git tree references (2025-12-10 23:53:45 -0700)
----------------------------------------------------------------
Jens Axboe (1):
Update git tree references
Johannes Thumshirn (20):
blktrace: fix comment for struct blk_trace_setup:
blkparse: fix compiler warning
blktrace: add definitions for BLKTRACESETUP2
blktrace: change size of action to 64 bits
blktrace: add definitions for blk_io_trace2
blkparse: pass magic to get_magic
blkparse: read 'magic' first
blkparse: factor out reading of a singe blk_io_trace event
blkparse: skip unsupported protocol versions
blkparse: make get_pdulen() take the pdu_len
blkiomon: read 'magic' first
blktrace: pass magic to CHECK_MAGIC macro
blktrace: pass magic to verify_trace
blktrace: rename trace_to_cpu to bit_trace_to_cpu
blkparse: use blk_io_trace2 internally
blkparse: natively parse blk_io_trace2
blkparse: parse zone (un)plug actions
blkparse: add zoned commands to fill_rwbs()
blktrace: call BLKTRACESETUP2 ioctl per default to setup a trace
blktrace: support protocol version 8
README | 6 +-
act_mask.c | 4 +-
blkiomon.c | 15 +-
blkparse.c | 446 +++++++++++++++++++++++++++++++---------------
blkparse_fmt.c | 83 +++++++--
blkrawverify.c | 14 +-
blktrace.c | 40 ++++-
blktrace.h | 64 +++++--
blktrace_api.h | 58 +++++-
btreplay/doc/btreplay.tex | 2 +-
10 files changed, 539 insertions(+), 193 deletions(-)
---
Diff of recent changes:
diff --git a/README b/README
index d7d1fbf..7999d21 100644
--- a/README
+++ b/README
@@ -14,7 +14,7 @@ Requirements
blktrace was integrated into the mainline kernel between 2.6.16 and 2.6.17-rc1.
The target trace needs to run on a kernel at least that new.
-git://git.kernel.dk/blktrace.git
+git://git.kernel.org/pub/scm/linux/kernel/git/axboe/blktrace.git
If you don't have git, you can get hourly snapshots from:
@@ -24,12 +24,12 @@ The snapshots include the full git object database as well. kernel.org has
excessively long mirror times, so if you have git installed, you can pull
the master tree from:
-git://git.kernel.dk/blktrace.git
+git://git.kernel.org/pub/scm/linux/kernel/git/axboe/blktrace.git
For browsing the repo over http and viewing history etc, you can direct
your browser to:
-http://git.kernel.dk/
+https://git.kernel.org/pub/scm/linux/kernel/git/axboe/blktrace.git
A blktrace visualization tool, iowatcher, was added to blktrace in version
1.1.0. It requires librsvg and either png2theora or ffmpeg to generate movies.
diff --git a/act_mask.c b/act_mask.c
index 8f1b8d7..510c7e0 100644
--- a/act_mask.c
+++ b/act_mask.c
@@ -42,7 +42,7 @@ int find_mask_map(char *string)
return -1;
}
-int valid_act_opt(int x)
+unsigned long long valid_act_opt(unsigned long long x)
{
- return (1 <= x) && (x < (1 << BLK_TC_SHIFT));
+ return (1ull <= x) && (x < (1ull << BLK_TC_SHIFT));
}
diff --git a/blkiomon.c b/blkiomon.c
index f8b0c9d..9defa2c 100644
--- a/blkiomon.c
+++ b/blkiomon.c
@@ -460,26 +460,35 @@ static int blkiomon_do_fifo(void)
bit = &t->bit;
while (up) {
+ __u32 magic;
+
+ if (fread(&magic, sizeof(magic), 1, ifp) != 1) {
+ if (!feof(ifp))
+ fprintf(stderr,
+ "blkiomon: could not read trace");
+ break;
+ }
if (fread(bit, sizeof(*bit), 1, ifp) != 1) {
if (!feof(ifp))
fprintf(stderr,
"blkiomon: could not read trace");
break;
}
+ bit->magic = magic;
if (ferror(ifp)) {
clearerr(ifp);
fprintf(stderr, "blkiomon: error while reading trace");
break;
}
- if (data_is_native == -1 && check_data_endianness(bit->magic)) {
+ if (data_is_native == -1 && check_data_endianness(magic)) {
fprintf(stderr, "blkiomon: endianess problem\n");
break;
}
/* endianess */
- trace_to_cpu(bit);
- if (verify_trace(bit)) {
+ bit_trace_to_cpu(bit);
+ if (verify_trace(bit->magic)) {
fprintf(stderr, "blkiomon: bad trace\n");
break;
}
diff --git a/blkparse.c b/blkparse.c
index d6aaa8b..76c775b 100644
--- a/blkparse.c
+++ b/blkparse.c
@@ -243,7 +243,7 @@ static struct option l_opts[] = {
* for sorting the displayed output
*/
struct trace {
- struct blk_io_trace *bit;
+ struct blk_io_trace2 *bit;
struct rb_node rb_node;
struct trace *next;
unsigned long read_sequence;
@@ -257,7 +257,7 @@ static struct trace *trace_list;
/*
* allocation cache
*/
-static struct blk_io_trace *bit_alloc_list;
+static struct blk_io_trace2 *bit_alloc_list;
static struct trace *t_alloc_list;
/*
@@ -299,7 +299,7 @@ static int per_device_and_cpu_stats = 1;
static int track_ios;
static int ppi_hash_by_pid = 1;
static int verbose;
-static unsigned int act_mask = -1U;
+static unsigned long long act_mask = -1U;
static int stats_printed;
static int bin_output_msgs = 1;
int data_is_native = -1;
@@ -332,7 +332,7 @@ static int have_drv_data = 0;
#define CPU_IDX(cpu) ((cpu) / CPUS_PER_LONG)
#define CPU_BIT(cpu) ((cpu) & (CPUS_PER_LONG - 1))
-static void io_warn_unless(struct blk_io_trace *t, int condition,
+static void io_warn_unless(struct blk_io_trace2 *t, int condition,
const char *fmt, ...)
{
va_list ap;
@@ -613,7 +613,7 @@ static struct process_pid_map *add_ppm_hash(pid_t pid, const char *name)
return ppm;
}
-static void handle_notify(struct blk_io_trace *bit)
+static void handle_notify(struct blk_io_trace2 *bit)
{
void *payload = (caddr_t) bit + sizeof(*bit);
__u32 two32[2];
@@ -802,25 +802,25 @@ static inline struct trace *t_alloc(void)
return malloc(sizeof(*t));
}
-static inline void bit_free(struct blk_io_trace *bit)
+static inline void bit_free(struct blk_io_trace2 *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_list = (struct blk_io_trace2 *) bit;
bit_alloc_cache++;
} else
free(bit);
}
-static inline struct blk_io_trace *bit_alloc(void)
+static inline struct blk_io_trace2 *bit_alloc(void)
{
- struct blk_io_trace *bit = bit_alloc_list;
+ struct blk_io_trace2 *bit = bit_alloc_list;
if (bit) {
- bit_alloc_list = (struct blk_io_trace *) (unsigned long) \
+ bit_alloc_list = (struct blk_io_trace2 *) (unsigned long) \
bit->time;
bit_alloc_cache--;
return bit;
@@ -1041,7 +1041,7 @@ static struct io_track *find_track(struct per_dev_info *pdi, pid_t pid,
}
static void log_track_frontmerge(struct per_dev_info *pdi,
- struct blk_io_trace *t)
+ struct blk_io_trace2 *t)
{
struct io_track *iot;
@@ -1062,7 +1062,7 @@ static void log_track_frontmerge(struct per_dev_info *pdi,
track_rb_insert(pdi, iot);
}
-static void log_track_getrq(struct per_dev_info *pdi, struct blk_io_trace *t)
+static void log_track_getrq(struct per_dev_info *pdi, struct blk_io_trace2 *t)
{
struct io_track *iot;
struct io_track_req *req;
@@ -1081,7 +1081,7 @@ static void log_track_getrq(struct per_dev_info *pdi, struct blk_io_trace *t)
* for md/dm setups, the interesting cycle is Q -> C. So track queueing
* time here, as dispatch time
*/
-static void log_track_queue(struct per_dev_info *pdi, struct blk_io_trace *t)
+static void log_track_queue(struct per_dev_info *pdi, struct blk_io_trace2 *t)
{
struct io_track *iot;
struct io_track_req *req;
@@ -1096,7 +1096,7 @@ static void log_track_queue(struct per_dev_info *pdi, struct blk_io_trace *t)
req->dispatch_time = t->time;
}
-static void log_track_split(struct per_dev_info *pdi, struct blk_io_trace *t)
+static void log_track_split(struct per_dev_info *pdi, struct blk_io_trace2 *t)
{
struct io_track *iot, *split;
@@ -1118,7 +1118,7 @@ static void log_track_split(struct per_dev_info *pdi, struct blk_io_trace *t)
* return time between rq allocation and insertion
*/
static unsigned long long log_track_insert(struct per_dev_info *pdi,
- struct blk_io_trace *t)
+ struct blk_io_trace2 *t)
{
unsigned long long elapsed;
struct io_track *iot;
@@ -1153,7 +1153,7 @@ static unsigned long long log_track_insert(struct per_dev_info *pdi,
* return time between queue and issue
*/
static unsigned long long log_track_issue(struct per_dev_info *pdi,
- struct blk_io_trace *t)
+ struct blk_io_trace2 *t)
{
unsigned long long elapsed = -1ULL;
struct io_track *iot;
@@ -1191,7 +1191,7 @@ static unsigned long long log_track_issue(struct per_dev_info *pdi,
return elapsed;
}
-static void fixup_complete(struct per_dev_info *pdi, struct blk_io_trace *t)
+static void fixup_complete(struct per_dev_info *pdi, struct blk_io_trace2 *t)
{
struct io_track *iot;
__u64 start_sector;
@@ -1214,7 +1214,7 @@ static void fixup_complete(struct per_dev_info *pdi, struct blk_io_trace *t)
* return time between dispatch and complete
*/
static unsigned long long log_track_complete(struct per_dev_info *pdi,
- struct blk_io_trace *t)
+ struct blk_io_trace2 *t)
{
unsigned long long elapsed = -1ULL;
struct io_track *iot, *next;
@@ -1288,7 +1288,7 @@ static char *get_dev_name(struct per_dev_info *pdi, char *buffer, int size)
return buffer;
}
-static void check_time(struct per_dev_info *pdi, struct blk_io_trace *bit)
+static void check_time(struct per_dev_info *pdi, struct blk_io_trace2 *bit)
{
unsigned long long this = bit->time;
unsigned long long last = pdi->last_reported_time;
@@ -1297,7 +1297,7 @@ static void check_time(struct per_dev_info *pdi, struct blk_io_trace *bit)
pdi->last_reported_time = this;
}
-static inline void __account_m(struct io_stats *ios, struct blk_io_trace *t,
+static inline void __account_m(struct io_stats *ios, struct blk_io_trace2 *t,
int rw)
{
if (rw) {
@@ -1311,7 +1311,7 @@ static inline void __account_m(struct io_stats *ios, struct blk_io_trace *t,
}
}
-static inline void account_m(struct blk_io_trace *t, struct per_cpu_info *pci,
+static inline void account_m(struct blk_io_trace2 *t, struct per_cpu_info *pci,
int rw)
{
__account_m(&pci->io_stats, t, rw);
@@ -1324,7 +1324,7 @@ static inline void account_m(struct blk_io_trace *t, struct per_cpu_info *pci,
}
static inline void __account_pc_queue(struct io_stats *ios,
- struct blk_io_trace *t, int rw)
+ struct blk_io_trace2 *t, int rw)
{
if (rw) {
ios->qwrites_pc++;
@@ -1337,7 +1337,7 @@ static inline void __account_pc_queue(struct io_stats *ios,
}
}
-static inline void account_pc_queue(struct blk_io_trace *t,
+static inline void account_pc_queue(struct blk_io_trace2 *t,
struct per_cpu_info *pci, int rw)
{
__account_pc_queue(&pci->io_stats, t, rw);
@@ -1363,7 +1363,7 @@ static inline void __account_pc_issue(struct io_stats *ios, int rw,
}
}
-static inline void account_pc_issue(struct blk_io_trace *t,
+static inline void account_pc_issue(struct blk_io_trace2 *t,
struct per_cpu_info *pci, int rw)
{
__account_pc_issue(&pci->io_stats, rw, t->bytes);
@@ -1376,7 +1376,7 @@ static inline void account_pc_issue(struct blk_io_trace *t,
}
static inline void __account_pc_requeue(struct io_stats *ios,
- struct blk_io_trace *t, int rw)
+ struct blk_io_trace2 *t, int rw)
{
if (rw) {
ios->wrqueue_pc++;
@@ -1389,7 +1389,7 @@ static inline void __account_pc_requeue(struct io_stats *ios,
}
}
-static inline void account_pc_requeue(struct blk_io_trace *t,
+static inline void account_pc_requeue(struct blk_io_trace2 *t,
struct per_cpu_info *pci, int rw)
{
__account_pc_requeue(&pci->io_stats, t, rw);
@@ -1409,7 +1409,7 @@ static inline void __account_pc_c(struct io_stats *ios, int rw)
ios->creads_pc++;
}
-static inline void account_pc_c(struct blk_io_trace *t,
+static inline void account_pc_c(struct blk_io_trace2 *t,
struct per_cpu_info *pci, int rw)
{
__account_pc_c(&pci->io_stats, rw);
@@ -1421,7 +1421,7 @@ static inline void account_pc_c(struct blk_io_trace *t,
}
}
-static inline void __account_queue(struct io_stats *ios, struct blk_io_trace *t,
+static inline void __account_queue(struct io_stats *ios, struct blk_io_trace2 *t,
int rw)
{
if (rw) {
@@ -1435,7 +1435,7 @@ static inline void __account_queue(struct io_stats *ios, struct blk_io_trace *t,
}
}
-static inline void account_queue(struct blk_io_trace *t,
+static inline void account_queue(struct blk_io_trace2 *t,
struct per_cpu_info *pci, int rw)
{
__account_queue(&pci->io_stats, t, rw);
@@ -1460,7 +1460,7 @@ static inline void __account_c(struct io_stats *ios, int rw, int bytes)
}
}
-static inline void account_c(struct blk_io_trace *t, struct per_cpu_info *pci,
+static inline void account_c(struct blk_io_trace2 *t, struct per_cpu_info *pci,
int rw, int bytes)
{
__account_c(&pci->io_stats, rw, bytes);
@@ -1486,7 +1486,7 @@ static inline void __account_issue(struct io_stats *ios, int rw,
}
}
-static inline void account_issue(struct blk_io_trace *t,
+static inline void account_issue(struct blk_io_trace2 *t,
struct per_cpu_info *pci, int rw)
{
__account_issue(&pci->io_stats, rw, t->bytes);
@@ -1506,7 +1506,7 @@ static inline void __account_unplug(struct io_stats *ios, int timer)
ios->io_unplugs++;
}
-static inline void account_unplug(struct blk_io_trace *t,
+static inline void account_unplug(struct blk_io_trace2 *t,
struct per_cpu_info *pci, int timer)
{
__account_unplug(&pci->io_stats, timer);
@@ -1519,7 +1519,7 @@ static inline void account_unplug(struct blk_io_trace *t,
}
static inline void __account_requeue(struct io_stats *ios,
- struct blk_io_trace *t, int rw)
+ struct blk_io_trace2 *t, int rw)
{
if (rw) {
ios->wrqueue++;
@@ -1532,7 +1532,7 @@ static inline void __account_requeue(struct io_stats *ios,
}
}
-static inline void account_requeue(struct blk_io_trace *t,
+static inline void account_requeue(struct blk_io_trace2 *t,
struct per_cpu_info *pci, int rw)
{
__account_requeue(&pci->io_stats, t, rw);
@@ -1545,31 +1545,31 @@ static inline void account_requeue(struct blk_io_trace *t,
}
static void log_complete(struct per_dev_info *pdi, struct per_cpu_info *pci,
- struct blk_io_trace *t, char *act)
+ struct blk_io_trace2 *t, char *act)
{
process_fmt(act, pci, t, log_track_complete(pdi, t), 0, NULL);
}
static void log_insert(struct per_dev_info *pdi, struct per_cpu_info *pci,
- struct blk_io_trace *t, char *act)
+ struct blk_io_trace2 *t, char *act)
{
process_fmt(act, pci, t, log_track_insert(pdi, t), 0, NULL);
}
-static void log_queue(struct per_cpu_info *pci, struct blk_io_trace *t,
+static void log_queue(struct per_cpu_info *pci, struct blk_io_trace2 *t,
char *act)
{
process_fmt(act, pci, t, -1, 0, NULL);
}
static void log_issue(struct per_dev_info *pdi, struct per_cpu_info *pci,
- struct blk_io_trace *t, char *act)
+ struct blk_io_trace2 *t, char *act)
{
process_fmt(act, pci, t, log_track_issue(pdi, t), 0, NULL);
}
static void log_merge(struct per_dev_info *pdi, struct per_cpu_info *pci,
- struct blk_io_trace *t, char *act)
+ struct blk_io_trace2 *t, char *act)
{
if (act[0] == 'F')
log_track_frontmerge(pdi, t);
@@ -1577,38 +1577,38 @@ static void log_merge(struct per_dev_info *pdi, struct per_cpu_info *pci,
process_fmt(act, pci, t, -1ULL, 0, NULL);
}
-static void log_action(struct per_cpu_info *pci, struct blk_io_trace *t,
+static void log_action(struct per_cpu_info *pci, struct blk_io_trace2 *t,
char *act)
{
process_fmt(act, pci, t, -1ULL, 0, NULL);
}
-static void log_generic(struct per_cpu_info *pci, struct blk_io_trace *t,
+static void log_generic(struct per_cpu_info *pci, struct blk_io_trace2 *t,
char *act)
{
process_fmt(act, pci, t, -1ULL, 0, NULL);
}
-static void log_unplug(struct per_cpu_info *pci, struct blk_io_trace *t,
+static void log_unplug(struct per_cpu_info *pci, struct blk_io_trace2 *t,
char *act)
{
process_fmt(act, pci, t, -1ULL, 0, NULL);
}
-static void log_split(struct per_cpu_info *pci, struct blk_io_trace *t,
+static void log_split(struct per_cpu_info *pci, struct blk_io_trace2 *t,
char *act)
{
process_fmt(act, pci, t, -1ULL, 0, NULL);
}
-static void log_pc(struct per_cpu_info *pci, struct blk_io_trace *t, char *act)
+static void log_pc(struct per_cpu_info *pci, struct blk_io_trace2 *t, char *act)
{
unsigned char *buf = (unsigned char *) t + sizeof(*t);
process_fmt(act, pci, t, -1ULL, t->pdu_len, buf);
}
-static void dump_trace_pc(struct blk_io_trace *t, struct per_dev_info *pdi,
+static void dump_trace_pc(struct blk_io_trace2 *t, struct per_dev_info *pdi,
struct per_cpu_info *pci)
{
int w = (t->action & BLK_TC_ACT(BLK_TC_WRITE)) != 0;
@@ -1657,7 +1657,7 @@ static void dump_trace_pc(struct blk_io_trace *t, struct per_dev_info *pdi,
}
}
-static void dump_trace_fs(struct blk_io_trace *t, struct per_dev_info *pdi,
+static void dump_trace_fs(struct blk_io_trace2 *t, struct per_dev_info *pdi,
struct per_cpu_info *pci)
{
int w = (t->action & BLK_TC_ACT(BLK_TC_WRITE)) != 0;
@@ -1722,6 +1722,13 @@ static void dump_trace_fs(struct blk_io_trace *t, struct per_dev_info *pdi,
account_unplug(t, pci, 1);
log_unplug(pci, t, "UT");
break;
+ case __BLK_TA_ZONE_PLUG:
+ log_action(pci, t, "ZP");
+ break;
+ case __BLK_TA_ZONE_UNPLUG:
+ account_unplug(t, pci, 0);
+ log_unplug(pci, t, "ZU");
+ break;
case __BLK_TA_SPLIT:
log_track_split(pdi, t);
log_split(pci, t, "X");
@@ -1737,12 +1744,12 @@ static void dump_trace_fs(struct blk_io_trace *t, struct per_dev_info *pdi,
/* dump to binary file only */
break;
default:
- fprintf(stderr, "Bad fs action %x\n", t->action);
+ fprintf(stderr, "Bad fs action %llx\n", t->action);
break;
}
}
-static void dump_trace(struct blk_io_trace *t, struct per_cpu_info *pci,
+static void dump_trace(struct blk_io_trace2 *t, struct per_cpu_info *pci,
struct per_dev_info *pdi)
{
if (text_output) {
@@ -2023,7 +2030,7 @@ static void show_device_and_cpu_stats(void)
struct io_stats total, *ios;
unsigned long long rrate, wrate, msec;
int i, j, pci_events;
- char line[3 + 8/*cpu*/ + 2 + 32/*dev*/ + 3];
+ char line[3 + 8/*cpu*/ + 2 + 32/*dev*/ + 3 + 2];
char name[32];
double ratio;
@@ -2162,7 +2169,7 @@ static void find_genesis(void)
}
}
-static inline int check_stopwatch(struct blk_io_trace *bit)
+static inline int check_stopwatch(struct blk_io_trace2 *bit)
{
if (bit->time < stopwatch_end &&
bit->time >= stopwatch_start)
@@ -2185,7 +2192,7 @@ static int sort_entries(unsigned long long *youngest)
*youngest = 0;
while ((t = trace_list) != NULL) {
- struct blk_io_trace *bit = t->bit;
+ struct blk_io_trace2 *bit = t->bit;
trace_list = t->next;
@@ -2264,7 +2271,7 @@ static int check_cpu_map(struct per_dev_info *pdi)
static int check_sequence(struct per_dev_info *pdi, struct trace *t, int force)
{
- struct blk_io_trace *bit = t->bit;
+ struct blk_io_trace2 *bit = t->bit;
unsigned long expected_sequence;
struct per_cpu_info *pci;
struct trace *__t;
@@ -2315,7 +2322,7 @@ static void show_entries_rb(int force)
{
struct per_dev_info *pdi = NULL;
struct per_cpu_info *pci = NULL;
- struct blk_io_trace *bit;
+ struct blk_io_trace2 *bit;
struct rb_node *n;
struct trace *t;
@@ -2412,40 +2419,112 @@ static int read_data(int fd, void *buffer, int bytes, int block, int *fdblock)
return 0;
}
-static inline __u16 get_pdulen(struct blk_io_trace *bit)
+static inline __u16 get_pdulen(__u16 pdu_len)
{
if (data_is_native)
- return bit->pdu_len;
+ return pdu_len;
- return __bswap_16(bit->pdu_len);
+ return __bswap_16(pdu_len);
}
-static inline __u32 get_magic(struct blk_io_trace *bit)
+static inline __u32 get_magic(__u32 magic)
{
if (data_is_native)
- return bit->magic;
+ return magic;
- return __bswap_32(bit->magic);
+ return __bswap_32(magic);
}
+static int read_one_bit(int fd, struct blk_io_trace2 **bit2, int block,
+ int *fdblock)
+{
+ struct blk_io_trace2 *new = *bit2;
+ struct blk_io_trace *bit;
+ int ret;
+ int pdu_len;
+ void *p;
+
+ bit = malloc(sizeof(*bit));
+ if (!bit)
+ return -1;
+
+ bit->magic = new->magic;
+
+ p = (void *) ((u8 *)bit + sizeof(__u32));
+
+ ret = read_data(fd, p, sizeof(*bit) - sizeof(__u32), block, fdblock);
+ if (ret)
+ return ret;
+
+ pdu_len = get_pdulen(bit->pdu_len);
+ if (pdu_len) {
+ void *ptr = realloc(bit, sizeof(*bit) + pdu_len);
+
+ ret = read_data(fd, ptr + sizeof(*bit), pdu_len, 1, fdblock);
+ if (ret) {
+ free(ptr);
+ return ret;
+ }
+ bit = ptr;
+
+ new = realloc(*bit2, sizeof(struct blk_io_trace2) + pdu_len);
+ }
+
+ bit_trace_to_cpu(bit);
+ bit_to_bit2(bit, new);
+ free(bit);
+ *bit2 = new;
+
+ return 0;
+}
+
+static int read_one_bit2(int fd, struct blk_io_trace2 **bit2, int block,
+ int *fdblock)
+{
+ struct blk_io_trace2 *new = *bit2;
+ int ret;
+ int pdu_len;
+ void *p;
+
+ p = (void *) ((u8 *)new + sizeof(__u32));
+
+ ret = read_data(fd, p, sizeof(*new) - sizeof(__u32), block, fdblock);
+ if (ret)
+ return ret;
+
+ pdu_len = get_pdulen(new->pdu_len);
+ if (pdu_len) {
+ void *ptr = realloc(new, sizeof(*new) + pdu_len);
+
+ ret = read_data(fd, ptr + sizeof(*new), pdu_len, 1, fdblock);
+ if (ret) {
+ free(ptr);
+ return ret;
+ }
+ new = ptr;
+ }
+
+ bit2_trace_to_cpu(new);
+ *bit2 = new;
+
+ return 0;
+}
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, should_block, ret;
+ int should_block, ret;
__u32 magic;
-
- bit = bit_alloc();
+ u8 version;
should_block = !events || always_block;
- ret = read_data(fd, bit, sizeof(*bit), should_block, fdblock);
+ ret = read_data(fd, &magic, sizeof(magic), should_block,
+ fdblock);
if (ret) {
- bit_free(bit);
if (!events && ret < 0)
events = ret;
break;
@@ -2455,56 +2534,96 @@ static int read_events(int fd, int always_block, int *fdblock)
* look at first trace to check whether we need to convert
* data in the future
*/
- if (data_is_native == -1 && check_data_endianness(bit->magic))
+ if (data_is_native == -1 && check_data_endianness(magic))
break;
- magic = get_magic(bit);
+ magic = get_magic(magic);
if ((magic & 0xffffff00) != BLK_IO_TRACE_MAGIC) {
fprintf(stderr, "Bad magic %x\n", magic);
break;
}
+ version = magic & 0xff;
+ if (version == SUPPORTED_VERSION) {
+ struct blk_io_trace2 *bit;
+ bit = bit_alloc();
+ bit->magic = magic;
+
+ ret = read_one_bit(fd, &bit, 1, fdblock);
+ if (ret)
+ break;
- pdu_len = get_pdulen(bit);
- if (pdu_len) {
- void *ptr = realloc(bit, sizeof(*bit) + pdu_len);
+ /*
+ * not a real trace, so grab and handle it here
+ */
+ if (bit->action & BLK_TC_ACT(BLK_TC_NOTIFY) &&
+ (bit->action & ~__BLK_TN_CGROUP) != BLK_TN_MESSAGE) {
+ handle_notify(bit);
+ output_binary(bit, sizeof(*bit) + bit->pdu_len);
+ continue;
+ }
- if (read_data(fd, ptr + sizeof(*bit), pdu_len, 1, fdblock)) {
- bit_free(ptr);
- break;
+ if (verify_trace(bit->magic)) {
+ bit_free(bit);
+ bit = NULL;
+ continue;
}
- bit = ptr;
- }
+ t = t_alloc();
+ memset(t, 0, sizeof(*t));
+ t->bit = bit;
+ t->read_sequence = read_sequence;
- trace_to_cpu(bit);
+ t->next = trace_list;
+ trace_list = t;
- if (verify_trace(bit)) {
- bit_free(bit);
- continue;
- }
+ if (!pdi || pdi->dev != bit->device)
+ pdi = get_dev_info(bit->device);
- /*
- * not a real trace, so grab and handle it here
- */
- if (bit->action & BLK_TC_ACT(BLK_TC_NOTIFY) && (bit->action & ~__BLK_TN_CGROUP) != BLK_TN_MESSAGE) {
- handle_notify(bit);
- output_binary(bit, sizeof(*bit) + bit->pdu_len);
- continue;
- }
+ if (bit->time > pdi->last_read_time)
+ pdi->last_read_time = bit->time;
+ } else if (version == SUPPORTED_VERSION2) {
+ struct blk_io_trace2 *bit;
+ bit = bit_alloc();
+ bit->magic = magic;
- t = t_alloc();
- memset(t, 0, sizeof(*t));
- t->bit = bit;
- t->read_sequence = read_sequence;
+ ret = read_one_bit2(fd, &bit, 1, fdblock);
+ if (ret)
+ break;
- t->next = trace_list;
- trace_list = t;
+ /*
+ * not a real trace, so grab and handle it here
+ */
+ if (bit->action & BLK_TC_ACT(BLK_TC_NOTIFY) &&
+ (bit->action & ~__BLK_TN_CGROUP) != BLK_TN_MESSAGE) {
+ handle_notify(bit);
+ output_binary(bit, sizeof(*bit) + bit->pdu_len);
+ continue;
+ }
- if (!pdi || pdi->dev != bit->device)
- pdi = get_dev_info(bit->device);
+ if (verify_trace(bit->magic)) {
+ bit_free(bit);
+ bit = NULL;
+ continue;
+ }
+
+ t = t_alloc();
+ memset(t, 0, sizeof(*t));
+ t->bit = bit;
+ t->read_sequence = read_sequence;
+
+ t->next = trace_list;
+ trace_list = t;
+
+ if (!pdi || pdi->dev != bit->device)
+ pdi = get_dev_info(bit->device);
+
+ if (bit->time > pdi->last_read_time)
+ pdi->last_read_time = bit->time;
+ } else {
+ fprintf(stderr, "unsupported version %d\n", version);
+ continue;
+ }
- if (bit->time > pdi->last_read_time)
- pdi->last_read_time = bit->time;
events++;
}
@@ -2592,73 +2711,118 @@ static int ms_prime(struct ms_stream *msp)
struct trace *t;
struct per_dev_info *pdi = msp->pdi;
struct per_cpu_info *pci = get_cpu_info(pdi, msp->cpu);
- struct blk_io_trace *bit = NULL;
- int ret, pdu_len, ndone = 0;
+ struct blk_io_trace2 *bit = NULL;
+ int ret, ndone = 0;
for (i = 0; !is_done() && pci->fd >= 0 && i < rb_batch; i++) {
- bit = bit_alloc();
- ret = read_data(pci->fd, bit, sizeof(*bit), 1, &pci->fdblock);
+ u8 version;
+
+ ret = read_data(pci->fd, &magic, sizeof(magic), 1,
+ &pci->fdblock);
if (ret)
goto err;
- if (data_is_native == -1 && check_data_endianness(bit->magic))
+ if (data_is_native == -1 && check_data_endianness(magic))
goto err;
- magic = get_magic(bit);
+ magic = get_magic(magic);
if ((magic & 0xffffff00) != BLK_IO_TRACE_MAGIC) {
fprintf(stderr, "Bad magic %x\n", magic);
goto err;
}
+ version = magic & 0xff;
+ if (version == SUPPORTED_VERSION) {
+ bit = bit_alloc();
+ bit->magic = magic;
- pdu_len = get_pdulen(bit);
- if (pdu_len) {
- void *ptr = realloc(bit, sizeof(*bit) + pdu_len);
- ret = read_data(pci->fd, ptr + sizeof(*bit), pdu_len,
- 1, &pci->fdblock);
- if (ret) {
- free(ptr);
- bit = NULL;
+ ret = read_one_bit(pci->fd, &bit, 1, &pci->fdblock);
+ if (ret)
goto err;
+
+ if (verify_trace(bit->magic))
+ goto err;
+
+ if (bit->cpu != pci->cpu) {
+ fprintf(stderr,
+ "cpu %d trace info has error cpu %d\n",
+ pci->cpu, bit->cpu);
+ continue;
}
- bit = ptr;
- }
+ if (bit->action & BLK_TC_ACT(BLK_TC_NOTIFY) &&
+ (bit->action & ~__BLK_TN_CGROUP) != BLK_TN_MESSAGE) {
+ handle_notify(bit);
+ output_binary(bit, sizeof(*bit) + bit->pdu_len);
+ bit_free(bit);
+ bit = NULL;
- trace_to_cpu(bit);
- if (verify_trace(bit))
- goto err;
+ i -= 1;
+ continue;
+ }
- if (bit->cpu != pci->cpu) {
- fprintf(stderr, "cpu %d trace info has error cpu %d\n",
- pci->cpu, bit->cpu);
- continue;
- }
+ if (bit->time > pdi->last_read_time)
+ pdi->last_read_time = bit->time;
- if (bit->action & BLK_TC_ACT(BLK_TC_NOTIFY) && (bit->action & ~__BLK_TN_CGROUP) != BLK_TN_MESSAGE) {
- handle_notify(bit);
- output_binary(bit, sizeof(*bit) + bit->pdu_len);
- bit_free(bit);
+ t = t_alloc();
+ memset(t, 0, sizeof(*t));
+ t->bit = bit;
- i -= 1;
- continue;
- }
+ if (msp->first == NULL)
+ msp->first = msp->last = t;
+ else {
+ msp->last->next = t;
+ msp->last = t;
+ }
+ } else if (version == SUPPORTED_VERSION2) {
+ bit = bit_alloc();
+ bit->magic = magic;
- if (bit->time > pdi->last_read_time)
- pdi->last_read_time = bit->time;
+ ret = read_one_bit2(pci->fd, &bit, 1, &pci->fdblock);
+ if (ret)
+ goto err;
- t = t_alloc();
- memset(t, 0, sizeof(*t));
- t->bit = bit;
+ if (verify_trace(bit->magic))
+ goto err;
- if (msp->first == NULL)
- msp->first = msp->last = t;
- else {
- msp->last->next = t;
- msp->last = t;
- }
+ if (bit->cpu != pci->cpu) {
+ fprintf(stderr,
+ "cpu %d trace info has error cpu %d\n",
+ pci->cpu, bit->cpu);
+ continue;
+ }
+ if (bit->action & BLK_TC_ACT(BLK_TC_NOTIFY) &&
+ (bit->action & ~__BLK_TN_CGROUP) != BLK_TN_MESSAGE) {
+ handle_notify(bit);
+ output_binary(bit, sizeof(*bit) + bit->pdu_len);
+ bit_free(bit);
+ bit = NULL;
+
+ i -= 1;
+ continue;
+ }
+
+ if (bit->time > pdi->last_read_time)
+ pdi->last_read_time = bit->time;
+
+ t = t_alloc();
+ memset(t, 0, sizeof(*t));
+ t->bit = bit;
+
+ if (msp->first == NULL)
+ msp->first = msp->last = t;
+ else {
+ msp->last->next = t;
+ msp->last = t;
+ }
+
+ } else {
+ fprintf(stderr, "unsupported version %d\n", version);
+ continue;
+ }
ndone++;
+ bit = NULL;
}
return ndone;
@@ -2737,7 +2901,7 @@ static int handle(struct ms_stream *msp)
struct trace *t;
struct per_dev_info *pdi;
struct per_cpu_info *pci;
- struct blk_io_trace *bit;
+ struct blk_io_trace2 *bit;
t = ms_peek(msp);
diff --git a/blkparse_fmt.c b/blkparse_fmt.c
index 9b83d1d..06b055b 100644
--- a/blkparse_fmt.c
+++ b/blkparse_fmt.c
@@ -8,6 +8,7 @@
#include <unistd.h>
#include <ctype.h>
#include <time.h>
+#include <stdbool.h>
#include "blktrace.h"
@@ -50,28 +51,54 @@ int add_format_spec(char *option)
return 0;
}
-static inline void fill_rwbs(char *rwbs, struct blk_io_trace *t)
+static inline void fill_rwbs(char *rwbs, struct blk_io_trace2 *t)
{
- int w = t->action & BLK_TC_ACT(BLK_TC_WRITE);
- int a = t->action & BLK_TC_ACT(BLK_TC_AHEAD);
- int s = t->action & BLK_TC_ACT(BLK_TC_SYNC);
- int m = t->action & BLK_TC_ACT(BLK_TC_META);
- int d = t->action & BLK_TC_ACT(BLK_TC_DISCARD);
- int f = t->action & BLK_TC_ACT(BLK_TC_FLUSH);
- int u = t->action & BLK_TC_ACT(BLK_TC_FUA);
+ bool w = !!(t->action & BLK_TC_ACT(BLK_TC_WRITE));
+ bool a = !!(t->action & BLK_TC_ACT(BLK_TC_AHEAD));
+ bool s = !!(t->action & BLK_TC_ACT(BLK_TC_SYNC));
+ bool m = !!(t->action & BLK_TC_ACT(BLK_TC_META));
+ bool d = !!(t->action & BLK_TC_ACT(BLK_TC_DISCARD));
+ bool f = !!(t->action & BLK_TC_ACT(BLK_TC_FLUSH));
+ bool u = !!(t->action & BLK_TC_ACT(BLK_TC_FUA));
+ bool za = !!(t->action & BLK_TC_ACT(BLK_TC_ZONE_APPEND));
+ bool zr = !!(t->action & BLK_TC_ACT(BLK_TC_ZONE_RESET));
+ bool zra = !!(t->action & BLK_TC_ACT(BLK_TC_ZONE_RESET_ALL));
+ bool zf = !!(t->action & BLK_TC_ACT(BLK_TC_ZONE_FINISH));
+ bool zo = !!(t->action & BLK_TC_ACT(BLK_TC_ZONE_OPEN));
+ bool zc = !!(t->action & BLK_TC_ACT(BLK_TC_ZONE_CLOSE));
int i = 0;
if (f)
rwbs[i++] = 'F'; /* flush */
- if (d)
+ if (d) {
rwbs[i++] = 'D';
- else if (w)
+ } else if (za) {
+ rwbs[i++] = 'Z';
+ rwbs[i++] = 'A';
+ } else if (zr) {
+ rwbs[i++] = 'Z';
+ rwbs[i++] = 'R';
+ } else if (zra) {
+ rwbs[i++] = 'Z';
+ rwbs[i++] = 'R';
+ rwbs[i++] = 'A';
+ } else if (zf) {
+ rwbs[i++] = 'Z';
+ rwbs[i++] = 'F';
+ } else if (zo) {
+ rwbs[i++] = 'Z';
+ rwbs[i++] = 'O';
+ } else if (zc) {
+ rwbs[i++] = 'Z';
+ rwbs[i++] = 'C';
+ } else if (w) {
rwbs[i++] = 'W';
- else if (t->bytes)
+ } else if (t->bytes) {
rwbs[i++] = 'R';
- else
+ } else {
rwbs[i++] = 'N';
+ }
if (u)
rwbs[i++] = 'F'; /* fua */
@@ -145,16 +172,16 @@ static char *dump_pdu(unsigned char *pdu_buf, int pdu_len)
return p;
}
-#define pdu_start(t) (((void *) (t) + sizeof(struct blk_io_trace)))
+#define pdu_start(t) (((void *) (t) + sizeof(struct blk_io_trace2)))
-static unsigned int get_pdu_int(struct blk_io_trace *t)
+static unsigned int get_pdu_int(struct blk_io_trace2 *t)
{
__u64 *val = pdu_start(t);
return be64_to_cpu(*val);
}
-static void get_pdu_remap(struct blk_io_trace *t, struct blk_io_trace_remap *r)
+static void get_pdu_remap(struct blk_io_trace2 *t, struct blk_io_trace_remap *r)
{
struct blk_io_trace_remap *__r = pdu_start(t);
__u64 sector_from = __r->sector_from;
@@ -165,7 +192,7 @@ static void get_pdu_remap(struct blk_io_trace *t, struct blk_io_trace_remap *r)
}
static void print_field(char *act, struct per_cpu_info *pci,
- struct blk_io_trace *t, unsigned long long elapsed,
+ struct blk_io_trace2 *t, unsigned long long elapsed,
int pdu_len, unsigned char *pdu_buf, char field,
int minus, int has_w, int width)
{
@@ -274,7 +301,7 @@ static void print_field(char *act, struct per_cpu_info *pci,
}
static char *parse_field(char *act, struct per_cpu_info *pci,
- struct blk_io_trace *t, unsigned long long elapsed,
+ struct blk_io_trace2 *t, unsigned long long elapsed,
int pdu_len, unsigned char *pdu_buf,
char *primary_format)
{
@@ -300,8 +327,23 @@ static char *parse_field(char *act, struct per_cpu_info *pci,
return p;
}
+static void process_zoned(char *act, struct blk_io_trace2 *t, char *name)
+{
+ switch (act[1]) {
+ case 'P': /* Zone Plug */
+ fprintf(ofp, "[%s]\n", name);
+ break;
+ case 'U': /* Zone Unplug */
+ fprintf(ofp, "[%s] %u\n", name, get_pdu_int(t));
+ break;
+ default:
+ fprintf(stderr, "Unknown zoned action %c\n", act[1]);
+ break;
+ }
+}
+
static void process_default(char *act, struct per_cpu_info *pci,
- struct blk_io_trace *t, unsigned long long elapsed,
+ struct blk_io_trace2 *t, unsigned long long elapsed,
int pdu_len, unsigned char *pdu_buf)
{
struct blk_io_trace_remap r = { .device_from = 0, };
@@ -428,6 +470,9 @@ static void process_default(char *act, struct per_cpu_info *pci,
fprintf(ofp, "%*s\n", pdu_len, pdu_buf);
break;
+ case 'Z': /* Zoned command */
+ process_zoned(act, t, name);
+ break;
default:
fprintf(stderr, "Unknown action %c\n", act[0]);
break;
@@ -435,7 +480,7 @@ static void process_default(char *act, struct per_cpu_info *pci,
}
-void process_fmt(char *act, struct per_cpu_info *pci, struct blk_io_trace *t,
+void process_fmt(char *act, struct per_cpu_info *pci, struct blk_io_trace2 *t,
unsigned long long elapsed, int pdu_len,
unsigned char *pdu_buf)
{
diff --git a/blkrawverify.c b/blkrawverify.c
index ed5d258..8e863cb 100644
--- a/blkrawverify.c
+++ b/blkrawverify.c
@@ -55,7 +55,7 @@ static struct trace_info traces[] = {
#define N_TRACES (sizeof(traces) / sizeof(struct trace_info))
struct act_info {
- __u32 val;
+ __u64 val;
char *string;
};
@@ -80,12 +80,12 @@ static struct act_info acts[] = {
};
#define N_ACTS (sizeof(acts) / sizeof(struct act_info))
-static char *act_to_str(__u32 action)
+static char *act_to_str(__u64 action)
{
static char buf[1024];
unsigned int i;
- unsigned int act = action & 0xffff;
- unsigned int trace = (action >> BLK_TC_SHIFT) & 0xffff;
+ unsigned long long act = action & 0xffffffff;
+ unsigned long long trace = (action >> BLK_TC_SHIFT) & 0xffffffff;
if (act < N_ACTS) {
sprintf(buf, "%s ", acts[act].string);
@@ -97,7 +97,7 @@ static char *act_to_str(__u32 action)
}
}
else
- sprintf(buf, "Invalid action=%08x", action);
+ sprintf(buf, "Invalid action=%016llx", action);
return buf;
}
@@ -181,9 +181,9 @@ static int process(FILE **fp, char *devname, char *file, unsigned int cpu)
if (data_is_native == -1)
check_data_endianness(bit->magic);
- trace_to_cpu(bit);
+ bit_trace_to_cpu(bit);
- if (!CHECK_MAGIC(bit)) {
+ if (!CHECK_MAGIC(bit->magic)) {
INC_BAD("bad trace");
continue;
}
diff --git a/blktrace.c b/blktrace.c
index 038b2cb..72562fd 100644
--- a/blktrace.c
+++ b/blktrace.c
@@ -279,7 +279,7 @@ static int max_cpus;
static int ncpus;
static cpu_set_t *online_cpus;
static int pagesize;
-static int act_mask = ~0U;
+static unsigned long long act_mask = ~0U;
static int kill_running_trace;
static int stop_watch;
static int piped_output;
@@ -1067,6 +1067,36 @@ static void close_client_connections(void)
}
}
+static int setup_buts2(void)
+{
+ struct list_head *p;
+ int ret = 0;
+
+ __list_for_each(p, &devpaths) {
+ struct blk_user_trace_setup2 buts2;
+ struct devpath *dpp = list_entry(p, struct devpath, head);
+
+ memset(&buts2, 0, sizeof(buts2));
+ buts2.buf_size = buf_size;
+ buts2.buf_nr = buf_nr;
+ buts2.act_mask = act_mask;
+
+ if (ioctl(dpp->fd, BLKTRACESETUP2, &buts2) >= 0) {
+ dpp->ncpus = max_cpus;
+ dpp->buts_name = strdup(buts2.name);
+ dpp->setup_done = 1;
+ if (dpp->stats)
+ free(dpp->stats);
+ dpp->stats = calloc(dpp->ncpus, sizeof(*dpp->stats));
+ memset(dpp->stats, 0, dpp->ncpus * sizeof(*dpp->stats));
+ } else {
+ ret++;
+ }
+ }
+
+ return ret;
+}
+
static int setup_buts(void)
{
struct list_head *p;
@@ -2684,9 +2714,11 @@ static int run_tracers(void)
if (net_mode == Net_client)
printf("blktrace: connecting to %s\n", hostname);
- if (setup_buts()) {
- done = 1;
- return 1;
+ if (setup_buts2()) {
+ if (setup_buts()) {
+ done = 1;
+ return 1;
+ }
}
if (use_tracer_devpaths()) {
diff --git a/blktrace.h b/blktrace.h
index 944fc08..ba06237 100644
--- a/blktrace.h
+++ b/blktrace.h
@@ -6,6 +6,7 @@
#include <byteswap.h>
#include <endian.h>
#include <sys/types.h>
+#include <string.h>
#include "blktrace_api.h"
#include "rbtree.h"
@@ -67,8 +68,9 @@ 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 CHECK_MAGIC(magic) (((magic) & 0xffffff00) == BLK_IO_TRACE_MAGIC)
#define SUPPORTED_VERSION (0x07)
+#define SUPPORTED_VERSION2 (0x08)
#if __BYTE_ORDER == __LITTLE_ENDIAN
#define be16_to_cpu(x) __bswap_16(x)
@@ -88,22 +90,64 @@ extern struct timespec abs_start_time;
#error "Bad arch"
#endif
-static inline int verify_trace(struct blk_io_trace *t)
+static inline int verify_trace(__u32 magic)
{
- if (!CHECK_MAGIC(t)) {
- fprintf(stderr, "bad trace magic %x\n", t->magic);
+ u8 version;
+
+ if (!CHECK_MAGIC(magic)) {
+ fprintf(stderr, "bad trace magic %x\n", magic);
return 1;
}
- if ((t->magic & 0xff) != SUPPORTED_VERSION) {
- fprintf(stderr, "unsupported trace version %x\n",
- t->magic & 0xff);
+
+ version = magic & 0xff;
+ if (version != SUPPORTED_VERSION &&
+ version != SUPPORTED_VERSION2) {
+ fprintf(stderr, "unsupported trace version %x\n", version);
return 1;
}
return 0;
}
-static inline void trace_to_cpu(struct blk_io_trace *t)
+static inline void bit_to_bit2(struct blk_io_trace *old,
+ struct blk_io_trace2 *new)
+{
+ new->magic = old->magic;
+ new->sequence = old->sequence;
+ new->time = old->time;
+ new->sector = old->sector;
+ new->bytes = old->bytes;
+ new->action = 0 | old->action;
+ new->pid = old->pid;
+ new->device = old->device;
+ new->cpu = old->cpu;
+ new->error = old->error;
+ new->pdu_len = old->pdu_len;
+
+ if (new->pdu_len)
+ memcpy(((u8 *) new + sizeof(*new)), ((u8 *)old + sizeof(*old)),
+ old->pdu_len);
+}
+
+static inline void bit2_trace_to_cpu(struct blk_io_trace2 *t)
+{
+ if (data_is_native)
+ return;
+
+ t->magic = be32_to_cpu(t->magic);
+ t->sequence = be32_to_cpu(t->sequence);
+ t->time = be64_to_cpu(t->time);
+ t->sector = be64_to_cpu(t->sector);
+ t->bytes = be32_to_cpu(t->bytes);
+ t->action = be64_to_cpu(t->action);
+ t->pid = be32_to_cpu(t->pid);
+ t->device = be32_to_cpu(t->device);
+ t->cpu = be32_to_cpu(t->cpu);
+ t->error = be16_to_cpu(t->error);
+ t->pdu_len = be16_to_cpu(t->pdu_len);
+}
+
+static inline void bit_trace_to_cpu(struct blk_io_trace *t)
{
if (data_is_native)
return;
@@ -142,9 +186,9 @@ static inline int check_data_endianness(u32 magic)
extern void set_all_format_specs(char *);
extern int add_format_spec(char *);
-extern void process_fmt(char *, struct per_cpu_info *, struct blk_io_trace *,
+extern void process_fmt(char *, struct per_cpu_info *, struct blk_io_trace2 *,
unsigned long long, int, unsigned char *);
-extern int valid_act_opt(int);
+extern unsigned long long valid_act_opt(unsigned long long);
extern int find_mask_map(char *);
extern char *find_process_name(pid_t);
diff --git a/blktrace_api.h b/blktrace_api.h
index 8c760b8..8db24fc 100644
--- a/blktrace_api.h
+++ b/blktrace_api.h
@@ -24,11 +24,20 @@ enum {
BLK_TC_DRV_DATA = 1 << 14, /* binary driver data */
BLK_TC_FUA = 1 << 15, /* fua requests */
- BLK_TC_END = 1 << 15, /* we've run out of bits! */
+ BLK_TC_END_V1 = 1 << 15, /* we've run out of bits! */
+
+ BLK_TC_ZONE_APPEND = 1ull << 16, /* zone append */
+ BLK_TC_ZONE_RESET = 1ull << 17, /* zone reset */
+ BLK_TC_ZONE_RESET_ALL = 1ull << 18, /* zone reset all */
+ BLK_TC_ZONE_FINISH = 1ull << 19, /* zone finish */
+ BLK_TC_ZONE_OPEN = 1ull << 20, /* zone open */
+ BLK_TC_ZONE_CLOSE = 1ull << 21, /* zone close */
+
+ BLK_TC_END_V2 = 1ull << 21,
};
#define BLK_TC_SHIFT (16)
-#define BLK_TC_ACT(act) ((act) << BLK_TC_SHIFT)
+#define BLK_TC_ACT(act) ((__u64)(act) << BLK_TC_SHIFT)
/*
* Basic trace actions
@@ -51,6 +60,9 @@ enum {
__BLK_TA_REMAP, /* bio was remapped */
__BLK_TA_ABORT, /* request aborted */
__BLK_TA_DRV_DATA, /* binary driver data */
+ __BLK_TA_ZONE_PLUG, /* zone write plug was plugged */
+ __BLK_TA_ZONE_UNPLUG, /* zone write plug was unplugged */
+ __BLK_TA_ZONE_MGMT, /* zone management command was issued */
__BLK_TA_CGROUP = 1 << 8,
};
@@ -85,12 +97,20 @@ enum blktrace_notify {
#define BLK_TA_ABORT (__BLK_TA_ABORT | BLK_TC_ACT(BLK_TC_QUEUE))
#define BLK_TA_DRV_DATA (__BLK_TA_DRV_DATA | BLK_TC_ACT(BLK_TC_DRV_DATA))
+#define BLK_TA_ZONE_APPEND (__BLK_TA_COMPLETE |\
+ BLK_TC_ACT2(BLK_TC_ZONE_APPEND))
+#define BLK_TA_ZONE_MGMT __BLK_TA_ZONE_MGMT
+#define BLK_TA_ZONE_PLUG (__BLK_TA_ZONE_PLUG | BLK_TC_ACT(BLK_TC_QUEUE))
+#define BLK_TA_ZONE_UNPLUG (__BLK_TA_ZONE_UNPLUG |\
+ BLK_TC_ACT(BLK_TC_QUEUE))
+
#define BLK_TN_PROCESS (__BLK_TN_PROCESS | BLK_TC_ACT(BLK_TC_NOTIFY))
#define BLK_TN_TIMESTAMP (__BLK_TN_TIMESTAMP | BLK_TC_ACT(BLK_TC_NOTIFY))
#define BLK_TN_MESSAGE (__BLK_TN_MESSAGE | BLK_TC_ACT(BLK_TC_NOTIFY))
#define BLK_IO_TRACE_MAGIC 0x65617400
#define BLK_IO_TRACE_VERSION 0x07
+#define BLK_IO_TRACE2_VERSION 0x08
/*
* The trace itself
@@ -118,6 +138,22 @@ struct blk_io_trace_remap {
__u64 sector_from;
};
+struct blk_io_trace2 {
+ __u32 magic; /* MAGIC << 8 | BLK_IO_TRACE2_VERSION */
+ __u32 sequence; /* event number */
+ __u64 time; /* in nanoseconds */
+ __u64 sector; /* disk offset */
+ __u32 bytes; /* transfer length */
+ __u32 pid; /* who did it */
+ __u64 action; /* what happened */
+ __u32 device; /* device number */
+ __u32 cpu; /* on what cpu did it happen */
+ __u16 error; /* completion error */
+ __u16 pdu_len; /* length of data after this trace */
+ __u8 pad[12];
+ /* cgroup id will be stored here if exists */
+};
+
/*
* Payload with originating cgroup info
*/
@@ -127,7 +163,7 @@ struct blk_io_cgroup_payload {
};
/*
- * User setup structure passed with BLKSTARTTRACE
+ * User setup structure passed with BLKTRACESETUP
*/
struct blk_user_trace_setup {
char name[32]; /* output */
@@ -139,9 +175,25 @@ struct blk_user_trace_setup {
__u32 pid;
};
+/*
+ * User setup structure passed with BLKTRACESETUP2
+ */
+struct blk_user_trace_setup2 {
+ char name[64]; /* output */
+ __u64 act_mask; /* input */
+ __u32 buf_size; /* input */
+ __u32 buf_nr; /* input */
+ __u64 start_lba;
+ __u64 end_lba;
+ __u32 pid;
+ __u32 flags; /* currently unused */
+ __u64 reserved[11];
+};
+
#define BLKTRACESETUP _IOWR(0x12,115,struct blk_user_trace_setup)
#define BLKTRACESTART _IO(0x12,116)
#define BLKTRACESTOP _IO(0x12,117)
#define BLKTRACETEARDOWN _IO(0x12,118)
+#define BLKTRACESETUP2 _IOWR(0x12, 142, struct blk_user_trace_setup2)
#endif
diff --git a/btreplay/doc/btreplay.tex b/btreplay/doc/btreplay.tex
index 8b0ecf7..98509bb 100644
--- a/btreplay/doc/btreplay.tex
+++ b/btreplay/doc/btreplay.tex
@@ -46,7 +46,7 @@ Performance Group.
To build these tools, one needs to
place the source directory next to a valid
-\texttt{blktrace}\footnote{\texttt{git://git.kernel.dk/blktrace.git}}
+\texttt{blktrace}\footnote{\texttt{git://git.kernel.org/pub/scm/linux/kernel/git/axboe/blktrace.git}}
directory, as it includes \texttt{../blktrace} in the \texttt{Makefile}.
^ permalink raw reply related [flat|nested] 45+ messages in thread
end of thread, other threads:[~2025-12-11 13:00 UTC | newest]
Thread overview: 45+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-10-09 12:00 Recent changes (master) Jens Axboe
-- strict thread matches above, loose matches on Subject: below --
2025-12-11 13:00 Jens Axboe
2025-03-20 12:00 Jens Axboe
2025-01-31 13:00 Jens Axboe
2024-06-13 12:00 Jens Axboe
2024-01-18 13:00 Jens Axboe
2013-03-20 5:00 Jens Axboe
2013-08-02 4:00 ` Jens Axboe
2013-12-04 4:56 ` Jens Axboe
2014-04-12 12:00 ` Jens Axboe
2014-09-09 12:00 ` Jens Axboe
2014-09-26 12:00 ` Jens Axboe
2015-02-19 13:00 ` Jens Axboe
2015-08-21 12:00 ` Jens Axboe
2015-09-16 12:00 ` Jens Axboe
2016-01-09 13:00 ` Jens Axboe
2016-02-10 13:00 ` Jens Axboe
2016-04-26 12:00 ` Jens Axboe
2016-05-04 12:00 ` Jens Axboe
2016-05-06 12:00 ` Jens Axboe
2016-05-20 12:00 ` Jens Axboe
2016-08-24 12:00 ` Jens Axboe
2017-01-27 13:00 ` Jens Axboe
2017-11-05 13:00 ` Jens Axboe
2017-11-06 13:00 ` Jens Axboe
2017-11-08 13:00 ` Jens Axboe
2018-01-24 13:00 ` Jens Axboe
2018-01-25 13:00 ` Jens Axboe
2018-04-10 12:00 ` Jens Axboe
2018-05-03 12:00 ` Jens Axboe
2018-05-17 12:00 ` Jens Axboe
2018-08-31 12:00 ` Jens Axboe
2018-09-01 12:00 ` Jens Axboe
2019-05-22 12:00 ` Jens Axboe
2019-09-17 12:00 ` Jens Axboe
2019-09-25 12:00 ` Jens Axboe
2020-01-17 13:00 ` Jens Axboe
2020-03-21 12:00 ` Jens Axboe
2020-05-08 12:00 ` Jens Axboe
2020-05-21 12:00 ` Jens Axboe
2021-02-20 13:00 ` Jens Axboe
2021-04-20 12:00 ` Jens Axboe
2021-06-15 11:59 ` Jens Axboe
2021-06-29 12:00 ` Jens Axboe
2021-10-22 12:00 ` Jens Axboe
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).