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
--- /dev/null
+#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));
+}
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,
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;
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);
}
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;
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);
#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[] = {
{
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;
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);
#ifndef BLKTRACE_H
#define BLKTRACE_H
+#include <stdio.h>
#include <byteswap.h>
#include <asm/types.h>
#include <asm/byteorder.h>
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