blkio: Some debugging aids for CFQ
authorVivek Goyal <vgoyal@redhat.com>
Thu, 3 Dec 2009 17:59:48 +0000 (12:59 -0500)
committerJens Axboe <jens.axboe@oracle.com>
Thu, 3 Dec 2009 18:28:52 +0000 (19:28 +0100)
o Some debugging aids for CFQ.

Signed-off-by: Vivek Goyal <vgoyal@redhat.com>
Signed-off-by: Jens Axboe <jens.axboe@oracle.com>
block/Kconfig
block/Kconfig.iosched
block/blk-cgroup.c
block/blk-cgroup.h
block/cfq-iosched.c

index 6ba1a8e3388bbc3f0528bfbe461d511200facf59..e20fbde0875c6154fc8deaa96df64844f67c4bfc 100644 (file)
@@ -90,6 +90,15 @@ config BLK_CGROUP
        control disk bandwidth allocation (proportional time slice allocation)
        to such task groups.
 
+config DEBUG_BLK_CGROUP
+       bool
+       depends on BLK_CGROUP
+       default n
+       ---help---
+       Enable some debugging help. Currently it stores the cgroup path
+       in the blk group which can be used by cfq for tracing various
+       group related activity.
+
 endif # BLOCK
 
 config BLOCK_COMPAT
index fa95fa77057071687af031435be6cf0864bf723a..b71abfb0d7269eed44b65b3e75b8c6aa3b1ebbe5 100644 (file)
@@ -40,6 +40,15 @@ config CFQ_GROUP_IOSCHED
        ---help---
          Enable group IO scheduling in CFQ.
 
+config DEBUG_CFQ_IOSCHED
+       bool "Debug CFQ Scheduling"
+       depends on CFQ_GROUP_IOSCHED
+       select DEBUG_BLK_CGROUP
+       default n
+       ---help---
+         Enable CFQ IO scheduling debugging in CFQ. Currently it makes
+         blktrace output more verbose.
+
 choice
        prompt "Default I/O scheduler"
        default DEFAULT_CFQ
index 0426ab692fd5b8d283a65794377bb184fe89d03f..6bc99a3865b0fa0e37f55529d978615439d5b67b 100644 (file)
@@ -33,6 +33,10 @@ void blkiocg_add_blkio_group(struct blkio_cgroup *blkcg,
        blkg->blkcg_id = css_id(&blkcg->css);
        hlist_add_head_rcu(&blkg->blkcg_node, &blkcg->blkg_list);
        spin_unlock_irqrestore(&blkcg->lock, flags);
+#ifdef CONFIG_DEBUG_BLK_CGROUP
+       /* Need to take css reference ? */
+       cgroup_path(blkcg->css.cgroup, blkg->path, sizeof(blkg->path));
+#endif
 }
 
 static void __blkiocg_del_blkio_group(struct blkio_group *blkg)
index cd50a2f8733e5daa6f4e127fa8a9fa1dea5ae668..3573199b298bc8fe7d5f1724917af8997d269d34 100644 (file)
@@ -27,12 +27,25 @@ struct blkio_group {
        void *key;
        struct hlist_node blkcg_node;
        unsigned short blkcg_id;
+#ifdef CONFIG_DEBUG_BLK_CGROUP
+       /* Store cgroup path */
+       char path[128];
+#endif
 };
 
 #define BLKIO_WEIGHT_MIN       100
 #define BLKIO_WEIGHT_MAX       1000
 #define BLKIO_WEIGHT_DEFAULT   500
 
+#ifdef CONFIG_DEBUG_BLK_CGROUP
+static inline char *blkg_path(struct blkio_group *blkg)
+{
+       return blkg->path;
+}
+#else
+static inline char *blkg_path(struct blkio_group *blkg) { return NULL; }
+#endif
+
 #ifdef CONFIG_BLK_CGROUP
 extern struct blkio_cgroup blkio_root_cgroup;
 extern struct blkio_cgroup *cgroup_to_blkio_cgroup(struct cgroup *cgroup);
index 8bc31a50a57f77ec274d4ff78fc443f0977ba225..662d4e55b3c2c683f8ece4419282ad8925bedb90 100644 (file)
@@ -341,8 +341,21 @@ CFQ_CFQQ_FNS(coop);
 CFQ_CFQQ_FNS(deep);
 #undef CFQ_CFQQ_FNS
 
+#ifdef CONFIG_DEBUG_CFQ_IOSCHED
+#define cfq_log_cfqq(cfqd, cfqq, fmt, args...) \
+       blk_add_trace_msg((cfqd)->queue, "cfq%d%c %s " fmt, (cfqq)->pid, \
+                       cfq_cfqq_sync((cfqq)) ? 'S' : 'A', \
+                       blkg_path(&(cfqq)->cfqg->blkg), ##args);
+
+#define cfq_log_cfqg(cfqd, cfqg, fmt, args...)                         \
+       blk_add_trace_msg((cfqd)->queue, "%s " fmt,                     \
+                               blkg_path(&(cfqg)->blkg), ##args);      \
+
+#else
 #define cfq_log_cfqq(cfqd, cfqq, fmt, args...) \
        blk_add_trace_msg((cfqd)->queue, "cfq%d " fmt, (cfqq)->pid, ##args)
+#define cfq_log_cfqg(cfqd, cfqg, fmt, args...)         do {} while (0);
+#endif
 #define cfq_log(cfqd, fmt, args...)    \
        blk_add_trace_msg((cfqd)->queue, "cfq " fmt, ##args)
 
@@ -832,6 +845,7 @@ cfq_group_service_tree_del(struct cfq_data *cfqd, struct cfq_group *cfqg)
        if (cfqg->nr_cfqq)
                return;
 
+       cfq_log_cfqg(cfqd, cfqg, "del_from_rr group");
        cfqg->on_st = false;
        cfqd->nr_groups--;
        st->total_weight -= cfqg->weight;
@@ -889,6 +903,9 @@ static void cfq_group_served(struct cfq_data *cfqd, struct cfq_group *cfqg,
                cfqg->saved_serving_prio = cfqd->serving_prio;
        } else
                cfqg->saved_workload_slice = 0;
+
+       cfq_log_cfqg(cfqd, cfqg, "served: vt=%llu min_vt=%llu", cfqg->vdisktime,
+                                       st->min_vdisktime);
 }
 
 #ifdef CONFIG_CFQ_GROUP_IOSCHED
@@ -3102,7 +3119,7 @@ static void cfq_completed_request(struct request_queue *q, struct request *rq)
        unsigned long now;
 
        now = jiffies;
-       cfq_log_cfqq(cfqd, cfqq, "complete");
+       cfq_log_cfqq(cfqd, cfqq, "complete rqnoidle %d", !!rq_noidle(rq));
 
        cfq_update_hw_tag(cfqd);