---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
 
        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)
 
        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);
 
 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)
 
        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;
                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
        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);