summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Makefile4
-rw-r--r--act_mask.c42
-rw-r--r--blkparse.c44
-rw-r--r--blktrace.c40
-rw-r--r--blktrace.h3
5 files changed, 90 insertions, 43 deletions
diff --git a/Makefile b/Makefile
index 96edc55..16baa9e 100644
--- a/Makefile
+++ b/Makefile
@@ -6,10 +6,10 @@ SCRIPTS = btrace
all: $(PROGS) $(SCRIPTS)
-blkparse: blkparse.o blkparse_fmt.o rbtree.o
+blkparse: blkparse.o blkparse_fmt.o rbtree.o act_mask.o
$(CC) $(CFLAGS) -o $@ $(filter %.o,$^)
-blktrace: blktrace.o $(LIBS)
+blktrace: blktrace.o act_mask.o $(LIBS)
$(CC) $(CFLAGS) -o $@ $(filter %.o,$^) $(LIBS)
verify_blkparse: verify_blkparse.o
diff --git a/act_mask.c b/act_mask.c
new file mode 100644
index 0000000..f2767bd
--- /dev/null
+++ b/act_mask.c
@@ -0,0 +1,42 @@
+#include <strings.h>
+#include "blktrace.h"
+
+#define DECLARE_MASK_MAP(mask) { BLK_TC_##mask, #mask, "BLK_TC_"#mask }
+#define COMPARE_MASK_MAP(mmp, str) \
+ (!strcasecmp((mmp)->short_form, (str)) || \
+ !strcasecmp((mmp)->long_form, (str)))
+
+struct mask_map {
+ int mask;
+ char *short_form;
+ char *long_form;
+};
+
+static struct mask_map mask_maps[] = {
+ DECLARE_MASK_MAP(READ),
+ DECLARE_MASK_MAP(WRITE),
+ DECLARE_MASK_MAP(BARRIER),
+ DECLARE_MASK_MAP(SYNC),
+ DECLARE_MASK_MAP(QUEUE),
+ DECLARE_MASK_MAP(REQUEUE),
+ DECLARE_MASK_MAP(ISSUE),
+ DECLARE_MASK_MAP(COMPLETE),
+ DECLARE_MASK_MAP(FS),
+ DECLARE_MASK_MAP(PC),
+};
+
+int find_mask_map(char *string)
+{
+ unsigned int i;
+
+ for (i = 0; i < sizeof(mask_maps)/sizeof(mask_maps[0]); i++)
+ if (COMPARE_MASK_MAP(&mask_maps[i], string))
+ return mask_maps[i].mask;
+
+ return -1;
+}
+
+int valid_act_opt(int x)
+{
+ return (1 <= x) && (x < (1 << BLK_TC_SHIFT));
+}
diff --git a/blkparse.c b/blkparse.c
index 11354a7..9d67dab 100644
--- a/blkparse.c
+++ b/blkparse.c
@@ -81,8 +81,20 @@ static struct per_process_info *ppi_hash_table[PPI_HASH_SIZE];
static struct per_process_info *ppi_list;
static int ppi_list_entries;
-#define S_OPTS "i:o:b:stqw:f:F:vnmD:"
+#define S_OPTS "a:A:i:o:b:stqw:f:F:vnmD:"
static struct option l_opts[] = {
+ {
+ .name = "act-mask",
+ .has_arg = required_argument,
+ .flag = NULL,
+ .val = 'a'
+ },
+ {
+ .name = "set-mask",
+ .has_arg = required_argument,
+ .flag = NULL,
+ .val = 'A'
+ },
{
.name = "input",
.has_arg = required_argument,
@@ -216,6 +228,7 @@ static int per_process_stats;
static int track_ios;
static int ppi_hash_by_pid = 1;
static int print_missing;
+static unsigned int act_mask = -1U;
static unsigned int t_alloc_cache;
static unsigned int bit_alloc_cache;
@@ -1397,7 +1410,8 @@ static void show_entries_rb(int force)
if (!pci || pci->cpu != bit->cpu)
pci = get_cpu_info(pdi, bit->cpu);
- dump_trace(bit, pci, pdi);
+ if (bit->action & (act_mask << BLK_TC_SHIFT))
+ dump_trace(bit, pci, pdi);
put_trace(pdi, t);
}
@@ -1696,11 +1710,32 @@ static void usage(char *prog)
int main(int argc, char *argv[])
{
char *ofp_buffer;
- int c, ret, mode;
+ int i, c, ret, mode;
int per_device_and_cpu_stats = 1;
+ int act_mask_tmp = 0;
while ((c = getopt_long(argc, argv, S_OPTS, l_opts, NULL)) != -1) {
switch (c) {
+ case 'a':
+ i = find_mask_map(optarg);
+ if (i < 0) {
+ fprintf(stderr,"Invalid action mask %s\n",
+ optarg);
+ return 1;
+ }
+ act_mask_tmp |= i;
+ break;
+
+ case 'A':
+ if ((sscanf(optarg, "%x", &i) != 1) ||
+ !valid_act_opt(i)) {
+ fprintf(stderr,
+ "Invalid set action mask %s/0x%x\n",
+ optarg, i);
+ return 1;
+ }
+ act_mask_tmp = i;
+ break;
case 'i':
if (!strcmp(optarg, "-") && !pipeline)
pipeline = 1;
@@ -1766,6 +1801,9 @@ int main(int argc, char *argv[])
return 1;
}
+ if (act_mask_tmp != 0)
+ act_mask = act_mask_tmp;
+
memset(&rb_sort_root, 0, sizeof(rb_sort_root));
signal(SIGINT, handle_sigint);
diff --git a/blktrace.c b/blktrace.c
index 7394a92..b945e0e 100644
--- a/blktrace.c
+++ b/blktrace.c
@@ -44,32 +44,6 @@ static char blktrace_version[] = "0.90";
#define RELAYFS_TYPE 0xF0B4A981
-#define DECLARE_MASK_MAP(mask) { BLK_TC_##mask, #mask, "BLK_TC_"#mask }
-#define COMPARE_MASK_MAP(mmp, str) \
- (!strcasecmp((mmp)->short_form, (str)) || \
- !strcasecmp((mmp)->long_form, (str)))
-
-#define VALID_SET(x) ((1 <= (x)) && ((x) < (1 << BLK_TC_SHIFT)))
-
-struct mask_map {
- int mask;
- char *short_form;
- char *long_form;
-};
-
-static struct mask_map mask_maps[] = {
- DECLARE_MASK_MAP(READ),
- DECLARE_MASK_MAP(WRITE),
- DECLARE_MASK_MAP(BARRIER),
- DECLARE_MASK_MAP(SYNC),
- DECLARE_MASK_MAP(QUEUE),
- DECLARE_MASK_MAP(REQUEUE),
- DECLARE_MASK_MAP(ISSUE),
- DECLARE_MASK_MAP(COMPLETE),
- DECLARE_MASK_MAP(FS),
- DECLARE_MASK_MAP(PC),
-};
-
#define S_OPTS "d:a:A:r:o:kw:vb:n:D:"
static struct option l_opts[] = {
{
@@ -187,17 +161,6 @@ static pthread_mutex_t stdout_mutex = PTHREAD_MUTEX_INITIALIZER;
static void exit_trace(int status);
-static int find_mask_map(char *string)
-{
- unsigned int i;
-
- for (i = 0; i < sizeof(mask_maps)/sizeof(mask_maps[0]); i++)
- if (COMPARE_MASK_MAP(&mask_maps[i], string))
- return mask_maps[i].mask;
-
- return -1;
-}
-
static int start_trace(struct device_information *dip)
{
struct blk_user_trace_setup buts;
@@ -705,7 +668,8 @@ int main(int argc, char *argv[])
break;
case 'A':
- if ((sscanf(optarg, "%x", &i) != 1) || !VALID_SET(i)) {
+ if ((sscanf(optarg, "%x", &i) != 1) ||
+ !valid_act_opt(i)) {
fprintf(stderr,
"Invalid set action mask %s/0x%x\n",
optarg, i);
diff --git a/blktrace.h b/blktrace.h
index 799acf8..c1e5df1 100644
--- a/blktrace.h
+++ b/blktrace.h
@@ -1,6 +1,7 @@
#ifndef BLKTRACE_H
#define BLKTRACE_H
+#include <stdio.h>
#include <byteswap.h>
#include <asm/types.h>
#include <asm/byteorder.h>
@@ -112,5 +113,7 @@ 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 *,
unsigned long long, int, unsigned char *);
+extern int valid_act_opt(int);
+extern int find_mask_map(char *);
#endif