diff options
author | Shaohua Li <shli@fb.com> | 2016-05-09 20:22:15 -0400 |
---|---|---|
committer | Jens Axboe <axboe@fb.com> | 2016-05-10 10:41:37 -0400 |
commit | 59fa0224cfea31dde596e29555de94c961b139f9 (patch) | |
tree | 4d0812a3b897bc9f1ad1ca45bd156141b5c8b946 | |
parent | 8d1547e08dda8848f01185b3fd6bb946b68de99f (diff) |
blk-throttle: don't parse cgroup path if trace isn't enabled
if trace isn't enabled, parsing cgroup path just wastes cpu
Signed-off-by: Shaohua Li <shli@fb.com>
Signed-off-by: Jens Axboe <axboe@fb.com>
-rw-r--r-- | block/blk-throttle.c | 5 | ||||
-rw-r--r-- | include/linux/blktrace_api.h | 9 |
2 files changed, 11 insertions, 3 deletions
diff --git a/block/blk-throttle.c b/block/blk-throttle.c index 2149a1ddbacf..47a3e540631a 100644 --- a/block/blk-throttle.c +++ b/block/blk-throttle.c | |||
@@ -211,15 +211,14 @@ static struct throtl_data *sq_to_td(struct throtl_service_queue *sq) | |||
211 | * | 211 | * |
212 | * The messages are prefixed with "throtl BLKG_NAME" if @sq belongs to a | 212 | * The messages are prefixed with "throtl BLKG_NAME" if @sq belongs to a |
213 | * throtl_grp; otherwise, just "throtl". | 213 | * throtl_grp; otherwise, just "throtl". |
214 | * | ||
215 | * TODO: this should be made a function and name formatting should happen | ||
216 | * after testing whether blktrace is enabled. | ||
217 | */ | 214 | */ |
218 | #define throtl_log(sq, fmt, args...) do { \ | 215 | #define throtl_log(sq, fmt, args...) do { \ |
219 | struct throtl_grp *__tg = sq_to_tg((sq)); \ | 216 | struct throtl_grp *__tg = sq_to_tg((sq)); \ |
220 | struct throtl_data *__td = sq_to_td((sq)); \ | 217 | struct throtl_data *__td = sq_to_td((sq)); \ |
221 | \ | 218 | \ |
222 | (void)__td; \ | 219 | (void)__td; \ |
220 | if (likely(!blk_trace_note_message_enabled(__td->queue))) \ | ||
221 | break; \ | ||
223 | if ((__tg)) { \ | 222 | if ((__tg)) { \ |
224 | char __pbuf[128]; \ | 223 | char __pbuf[128]; \ |
225 | \ | 224 | \ |
diff --git a/include/linux/blktrace_api.h b/include/linux/blktrace_api.h index afc1343df3c7..0f3172b8b225 100644 --- a/include/linux/blktrace_api.h +++ b/include/linux/blktrace_api.h | |||
@@ -57,6 +57,14 @@ void __trace_note_message(struct blk_trace *, const char *fmt, ...); | |||
57 | } while (0) | 57 | } while (0) |
58 | #define BLK_TN_MAX_MSG 128 | 58 | #define BLK_TN_MAX_MSG 128 |
59 | 59 | ||
60 | static inline bool blk_trace_note_message_enabled(struct request_queue *q) | ||
61 | { | ||
62 | struct blk_trace *bt = q->blk_trace; | ||
63 | if (likely(!bt)) | ||
64 | return false; | ||
65 | return bt->act_mask & BLK_TC_NOTIFY; | ||
66 | } | ||
67 | |||
60 | extern void blk_add_driver_data(struct request_queue *q, struct request *rq, | 68 | extern void blk_add_driver_data(struct request_queue *q, struct request *rq, |
61 | void *data, size_t len); | 69 | void *data, size_t len); |
62 | extern int blk_trace_setup(struct request_queue *q, char *name, dev_t dev, | 70 | extern int blk_trace_setup(struct request_queue *q, char *name, dev_t dev, |
@@ -79,6 +87,7 @@ extern struct attribute_group blk_trace_attr_group; | |||
79 | # define blk_trace_remove(q) (-ENOTTY) | 87 | # define blk_trace_remove(q) (-ENOTTY) |
80 | # define blk_add_trace_msg(q, fmt, ...) do { } while (0) | 88 | # define blk_add_trace_msg(q, fmt, ...) do { } while (0) |
81 | # define blk_trace_remove_sysfs(dev) do { } while (0) | 89 | # define blk_trace_remove_sysfs(dev) do { } while (0) |
90 | # define blk_trace_note_message_enabled(q) (false) | ||
82 | static inline int blk_trace_init_sysfs(struct device *dev) | 91 | static inline int blk_trace_init_sysfs(struct device *dev) |
83 | { | 92 | { |
84 | return 0; | 93 | return 0; |