1
0
Fork 0

block: use standard blktrace API to output cgroup info for debug notes

Currently cfq/bfq/blk-throttle output cgroup info in trace in their own
way. Now we have standard blktrace API for this, so convert them to use
it.

Note, this changes the behavior a little bit. cgroup info isn't output
by default, we only do this with 'blk_cgroup' option enabled. cgroup
info isn't output as a string by default too, we only do this with
'blk_cgname' option enabled. Also cgroup info is output in different
position of the note string. I think these behavior changes aren't a big
issue (actually we make trace data shorter which is good), since the
blktrace note is solely for debugging.

Signed-off-by: Shaohua Li <shli@fb.com>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
hifive-unleashed-5.1
Shaohua Li 2017-07-12 11:49:56 -07:00 committed by Jens Axboe
parent 69fd5c3917
commit 35fe6d7632
5 changed files with 35 additions and 24 deletions

View File

@ -917,13 +917,16 @@ void bfq_add_bfqq_busy(struct bfq_data *bfqd, struct bfq_queue *bfqq);
struct bfq_group *bfqq_group(struct bfq_queue *bfqq); struct bfq_group *bfqq_group(struct bfq_queue *bfqq);
#define bfq_log_bfqq(bfqd, bfqq, fmt, args...) do { \ #define bfq_log_bfqq(bfqd, bfqq, fmt, args...) do { \
blk_add_trace_msg((bfqd)->queue, "bfq%d%c %s " fmt, (bfqq)->pid,\ blk_add_cgroup_trace_msg((bfqd)->queue, \
bfq_bfqq_sync((bfqq)) ? 'S' : 'A', \ bfqg_to_blkg(bfqq_group(bfqq))->blkcg, \
bfqq_group(bfqq)->blkg_path, ##args); \ "bfq%d%c " fmt, (bfqq)->pid, \
bfq_bfqq_sync((bfqq)) ? 'S' : 'A', ##args); \
} while (0) } while (0)
#define bfq_log_bfqg(bfqd, bfqg, fmt, args...) \ #define bfq_log_bfqg(bfqd, bfqg, fmt, args...) do { \
blk_add_trace_msg((bfqd)->queue, "%s " fmt, (bfqg)->blkg_path, ##args) blk_add_cgroup_trace_msg((bfqd)->queue, \
bfqg_to_blkg(bfqg)->blkcg, fmt, ##args); \
} while (0)
#else /* CONFIG_BFQ_GROUP_IOSCHED */ #else /* CONFIG_BFQ_GROUP_IOSCHED */

View File

@ -373,10 +373,8 @@ static unsigned int tg_iops_limit(struct throtl_grp *tg, int rw)
if (likely(!blk_trace_note_message_enabled(__td->queue))) \ if (likely(!blk_trace_note_message_enabled(__td->queue))) \
break; \ break; \
if ((__tg)) { \ if ((__tg)) { \
char __pbuf[128]; \ blk_add_cgroup_trace_msg(__td->queue, \
\ tg_to_blkg(__tg)->blkcg, "throtl " fmt, ##args);\
blkg_path(tg_to_blkg(__tg), __pbuf, sizeof(__pbuf)); \
blk_add_trace_msg(__td->queue, "throtl %s " fmt, __pbuf, ##args); \
} else { \ } else { \
blk_add_trace_msg(__td->queue, "throtl " fmt, ##args); \ blk_add_trace_msg(__td->queue, "throtl " fmt, ##args); \
} \ } \

View File

@ -656,20 +656,17 @@ static inline void cfqg_put(struct cfq_group *cfqg)
} }
#define cfq_log_cfqq(cfqd, cfqq, fmt, args...) do { \ #define cfq_log_cfqq(cfqd, cfqq, fmt, args...) do { \
char __pbuf[128]; \ blk_add_cgroup_trace_msg((cfqd)->queue, \
\ cfqg_to_blkg((cfqq)->cfqg)->blkcg, \
blkg_path(cfqg_to_blkg((cfqq)->cfqg), __pbuf, sizeof(__pbuf)); \ "cfq%d%c%c " fmt, (cfqq)->pid, \
blk_add_trace_msg((cfqd)->queue, "cfq%d%c%c %s " fmt, (cfqq)->pid, \
cfq_cfqq_sync((cfqq)) ? 'S' : 'A', \ cfq_cfqq_sync((cfqq)) ? 'S' : 'A', \
cfqq_type((cfqq)) == SYNC_NOIDLE_WORKLOAD ? 'N' : ' ',\ cfqq_type((cfqq)) == SYNC_NOIDLE_WORKLOAD ? 'N' : ' ',\
__pbuf, ##args); \ ##args); \
} while (0) } while (0)
#define cfq_log_cfqg(cfqd, cfqg, fmt, args...) do { \ #define cfq_log_cfqg(cfqd, cfqg, fmt, args...) do { \
char __pbuf[128]; \ blk_add_cgroup_trace_msg((cfqd)->queue, \
\ cfqg_to_blkg(cfqg)->blkcg, fmt, ##args); \
blkg_path(cfqg_to_blkg(cfqg), __pbuf, sizeof(__pbuf)); \
blk_add_trace_msg((cfqd)->queue, "%s " fmt, __pbuf, ##args); \
} while (0) } while (0)
static inline void cfqg_stats_update_io_add(struct cfq_group *cfqg, static inline void cfqg_stats_update_io_add(struct cfq_group *cfqg,

View File

@ -28,10 +28,12 @@ struct blk_trace {
atomic_t dropped; atomic_t dropped;
}; };
struct blkcg;
extern int blk_trace_ioctl(struct block_device *, unsigned, char __user *); extern int blk_trace_ioctl(struct block_device *, unsigned, char __user *);
extern void blk_trace_shutdown(struct request_queue *); extern void blk_trace_shutdown(struct request_queue *);
extern __printf(2, 3) extern __printf(3, 4)
void __trace_note_message(struct blk_trace *, const char *fmt, ...); void __trace_note_message(struct blk_trace *, struct blkcg *blkcg, const char *fmt, ...);
/** /**
* blk_add_trace_msg - Add a (simple) message to the blktrace stream * blk_add_trace_msg - Add a (simple) message to the blktrace stream
@ -46,12 +48,14 @@ void __trace_note_message(struct blk_trace *, const char *fmt, ...);
* NOTE: Can not use 'static inline' due to presence of var args... * NOTE: Can not use 'static inline' due to presence of var args...
* *
**/ **/
#define blk_add_trace_msg(q, fmt, ...) \ #define blk_add_cgroup_trace_msg(q, cg, fmt, ...) \
do { \ do { \
struct blk_trace *bt = (q)->blk_trace; \ struct blk_trace *bt = (q)->blk_trace; \
if (unlikely(bt)) \ if (unlikely(bt)) \
__trace_note_message(bt, fmt, ##__VA_ARGS__); \ __trace_note_message(bt, cg, fmt, ##__VA_ARGS__);\
} while (0) } while (0)
#define blk_add_trace_msg(q, fmt, ...) \
blk_add_cgroup_trace_msg(q, NULL, fmt, ##__VA_ARGS__)
#define BLK_TN_MAX_MSG 128 #define BLK_TN_MAX_MSG 128
static inline bool blk_trace_note_message_enabled(struct request_queue *q) static inline bool blk_trace_note_message_enabled(struct request_queue *q)
@ -82,6 +86,7 @@ extern struct attribute_group blk_trace_attr_group;
# define blk_trace_startstop(q, start) (-ENOTTY) # define blk_trace_startstop(q, start) (-ENOTTY)
# define blk_trace_remove(q) (-ENOTTY) # define blk_trace_remove(q) (-ENOTTY)
# define blk_add_trace_msg(q, fmt, ...) do { } while (0) # define blk_add_trace_msg(q, fmt, ...) do { } while (0)
# define blk_add_cgroup_trace_msg(q, cg, fmt, ...) do { } while (0)
# define blk_trace_remove_sysfs(dev) do { } while (0) # define blk_trace_remove_sysfs(dev) do { } while (0)
# define blk_trace_note_message_enabled(q) (false) # define blk_trace_note_message_enabled(q) (false)
static inline int blk_trace_init_sysfs(struct device *dev) static inline int blk_trace_init_sysfs(struct device *dev)

View File

@ -154,7 +154,8 @@ static void trace_note_time(struct blk_trace *bt)
local_irq_restore(flags); local_irq_restore(flags);
} }
void __trace_note_message(struct blk_trace *bt, const char *fmt, ...) void __trace_note_message(struct blk_trace *bt, struct blkcg *blkcg,
const char *fmt, ...)
{ {
int n; int n;
va_list args; va_list args;
@ -178,7 +179,14 @@ void __trace_note_message(struct blk_trace *bt, const char *fmt, ...)
n = vscnprintf(buf, BLK_TN_MAX_MSG, fmt, args); n = vscnprintf(buf, BLK_TN_MAX_MSG, fmt, args);
va_end(args); va_end(args);
if (!(blk_tracer_flags.val & TRACE_BLK_OPT_CGROUP))
blkcg = NULL;
#ifdef CONFIG_BLK_CGROUP
trace_note(bt, 0, BLK_TN_MESSAGE, buf, n,
blkcg ? cgroup_get_kernfs_id(blkcg->css.cgroup) : NULL);
#else
trace_note(bt, 0, BLK_TN_MESSAGE, buf, n, NULL); trace_note(bt, 0, BLK_TN_MESSAGE, buf, n, NULL);
#endif
local_irq_restore(flags); local_irq_restore(flags);
} }
EXPORT_SYMBOL_GPL(__trace_note_message); EXPORT_SYMBOL_GPL(__trace_note_message);
@ -375,7 +383,7 @@ static ssize_t blk_msg_write(struct file *filp, const char __user *buffer,
return PTR_ERR(msg); return PTR_ERR(msg);
bt = filp->private_data; bt = filp->private_data;
__trace_note_message(bt, "%s", msg); __trace_note_message(bt, NULL, "%s", msg);
kfree(msg); kfree(msg);
return count; return count;