aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--block/blktrace.c15
-rw-r--r--include/linux/blktrace_api.h3
2 files changed, 14 insertions, 4 deletions
diff --git a/block/blktrace.c b/block/blktrace.c
index 20e11f354f11..7ae87cc4a163 100644
--- a/block/blktrace.c
+++ b/block/blktrace.c
@@ -79,13 +79,16 @@ void __trace_note_message(struct blk_trace *bt, const char *fmt, ...)
79{ 79{
80 int n; 80 int n;
81 va_list args; 81 va_list args;
82 static char bt_msg_buf[BLK_TN_MAX_MSG]; 82 char *buf;
83 83
84 preempt_disable();
85 buf = per_cpu_ptr(bt->msg_data, smp_processor_id());
84 va_start(args, fmt); 86 va_start(args, fmt);
85 n = vscnprintf(bt_msg_buf, BLK_TN_MAX_MSG, fmt, args); 87 n = vscnprintf(buf, BLK_TN_MAX_MSG, fmt, args);
86 va_end(args); 88 va_end(args);
87 89
88 trace_note(bt, 0, BLK_TN_MESSAGE, bt_msg_buf, n); 90 trace_note(bt, 0, BLK_TN_MESSAGE, buf, n);
91 preempt_enable();
89} 92}
90EXPORT_SYMBOL_GPL(__trace_note_message); 93EXPORT_SYMBOL_GPL(__trace_note_message);
91 94
@@ -246,6 +249,7 @@ static void blk_trace_cleanup(struct blk_trace *bt)
246 debugfs_remove(bt->dropped_file); 249 debugfs_remove(bt->dropped_file);
247 blk_remove_tree(bt->dir); 250 blk_remove_tree(bt->dir);
248 free_percpu(bt->sequence); 251 free_percpu(bt->sequence);
252 free_percpu(bt->msg_data);
249 kfree(bt); 253 kfree(bt);
250} 254}
251 255
@@ -360,6 +364,10 @@ int do_blk_trace_setup(struct request_queue *q, char *name, dev_t dev,
360 if (!bt->sequence) 364 if (!bt->sequence)
361 goto err; 365 goto err;
362 366
367 bt->msg_data = __alloc_percpu(BLK_TN_MAX_MSG);
368 if (!bt->msg_data)
369 goto err;
370
363 ret = -ENOENT; 371 ret = -ENOENT;
364 dir = blk_create_tree(buts->name); 372 dir = blk_create_tree(buts->name);
365 if (!dir) 373 if (!dir)
@@ -406,6 +414,7 @@ err:
406 if (bt->dropped_file) 414 if (bt->dropped_file)
407 debugfs_remove(bt->dropped_file); 415 debugfs_remove(bt->dropped_file);
408 free_percpu(bt->sequence); 416 free_percpu(bt->sequence);
417 free_percpu(bt->msg_data);
409 if (bt->rchan) 418 if (bt->rchan)
410 relay_close(bt->rchan); 419 relay_close(bt->rchan);
411 kfree(bt); 420 kfree(bt);
diff --git a/include/linux/blktrace_api.h b/include/linux/blktrace_api.h
index b7cd8f1eedbe..e3ef903aae88 100644
--- a/include/linux/blktrace_api.h
+++ b/include/linux/blktrace_api.h
@@ -121,6 +121,7 @@ struct blk_trace {
121 int trace_state; 121 int trace_state;
122 struct rchan *rchan; 122 struct rchan *rchan;
123 unsigned long *sequence; 123 unsigned long *sequence;
124 unsigned char *msg_data;
124 u16 act_mask; 125 u16 act_mask;
125 u64 start_lba; 126 u64 start_lba;
126 u64 end_lba; 127 u64 end_lba;
@@ -172,7 +173,7 @@ extern void __trace_note_message(struct blk_trace *, const char *fmt, ...);
172 if (unlikely(bt)) \ 173 if (unlikely(bt)) \
173 __trace_note_message(bt, fmt, ##__VA_ARGS__); \ 174 __trace_note_message(bt, fmt, ##__VA_ARGS__); \
174 } while (0) 175 } while (0)
175#define BLK_TN_MAX_MSG 1024 176#define BLK_TN_MAX_MSG 128
176 177
177/** 178/**
178 * blk_add_trace_rq - Add a trace for a request oriented action 179 * blk_add_trace_rq - Add a trace for a request oriented action