aboutsummaryrefslogtreecommitdiffstats
path: root/kernel/trace/trace.c
diff options
context:
space:
mode:
authorSteven Rostedt (Red Hat) <rostedt@goodmis.org>2014-06-25 15:54:42 -0400
committerSteven Rostedt <rostedt@goodmis.org>2014-11-19 22:01:09 -0500
commit3a161d99c43ce74c76aecff309be4c3ba455e823 (patch)
treecc3aa5d746203cd17e8d9b92c78bef04f6f0ccdb /kernel/trace/trace.c
parent16a8ef2751801346f1f76a18685b2beb63cd170f (diff)
tracing: Create seq_buf layer in trace_seq
Create a seq_buf layer that trace_seq sits on. The seq_buf will not be limited to page size. This will allow other usages of seq_buf instead of a hard set PAGE_SIZE one that trace_seq has. Link: http://lkml.kernel.org/r/20141104160221.864997179@goodmis.org Link: http://lkml.kernel.org/r/20141114011412.170377300@goodmis.org Tested-by: Jiri Kosina <jkosina@suse.cz> Acked-by: Jiri Kosina <jkosina@suse.cz> Reviewed-by: Petr Mladek <pmladek@suse.cz> Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
Diffstat (limited to 'kernel/trace/trace.c')
-rw-r--r--kernel/trace/trace.c39
1 files changed, 21 insertions, 18 deletions
diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c
index 3ce3c4ccfc94..7d7a07e9b9e9 100644
--- a/kernel/trace/trace.c
+++ b/kernel/trace/trace.c
@@ -939,19 +939,20 @@ out:
939 return ret; 939 return ret;
940} 940}
941 941
942/* TODO add a seq_buf_to_buffer() */
942static ssize_t trace_seq_to_buffer(struct trace_seq *s, void *buf, size_t cnt) 943static ssize_t trace_seq_to_buffer(struct trace_seq *s, void *buf, size_t cnt)
943{ 944{
944 int len; 945 int len;
945 946
946 if (s->len <= s->readpos) 947 if (s->seq.len <= s->seq.readpos)
947 return -EBUSY; 948 return -EBUSY;
948 949
949 len = s->len - s->readpos; 950 len = s->seq.len - s->seq.readpos;
950 if (cnt > len) 951 if (cnt > len)
951 cnt = len; 952 cnt = len;
952 memcpy(buf, s->buffer + s->readpos, cnt); 953 memcpy(buf, s->buffer + s->seq.readpos, cnt);
953 954
954 s->readpos += cnt; 955 s->seq.readpos += cnt;
955 return cnt; 956 return cnt;
956} 957}
957 958
@@ -4315,6 +4316,8 @@ static int tracing_open_pipe(struct inode *inode, struct file *filp)
4315 goto out; 4316 goto out;
4316 } 4317 }
4317 4318
4319 trace_seq_init(&iter->seq);
4320
4318 /* 4321 /*
4319 * We make a copy of the current tracer to avoid concurrent 4322 * We make a copy of the current tracer to avoid concurrent
4320 * changes on it while we are reading. 4323 * changes on it while we are reading.
@@ -4511,18 +4514,18 @@ waitagain:
4511 trace_access_lock(iter->cpu_file); 4514 trace_access_lock(iter->cpu_file);
4512 while (trace_find_next_entry_inc(iter) != NULL) { 4515 while (trace_find_next_entry_inc(iter) != NULL) {
4513 enum print_line_t ret; 4516 enum print_line_t ret;
4514 int len = iter->seq.len; 4517 int len = iter->seq.seq.len;
4515 4518
4516 ret = print_trace_line(iter); 4519 ret = print_trace_line(iter);
4517 if (ret == TRACE_TYPE_PARTIAL_LINE) { 4520 if (ret == TRACE_TYPE_PARTIAL_LINE) {
4518 /* don't print partial lines */ 4521 /* don't print partial lines */
4519 iter->seq.len = len; 4522 iter->seq.seq.len = len;
4520 break; 4523 break;
4521 } 4524 }
4522 if (ret != TRACE_TYPE_NO_CONSUME) 4525 if (ret != TRACE_TYPE_NO_CONSUME)
4523 trace_consume(iter); 4526 trace_consume(iter);
4524 4527
4525 if (iter->seq.len >= cnt) 4528 if (iter->seq.seq.len >= cnt)
4526 break; 4529 break;
4527 4530
4528 /* 4531 /*
@@ -4538,7 +4541,7 @@ waitagain:
4538 4541
4539 /* Now copy what we have to the user */ 4542 /* Now copy what we have to the user */
4540 sret = trace_seq_to_user(&iter->seq, ubuf, cnt); 4543 sret = trace_seq_to_user(&iter->seq, ubuf, cnt);
4541 if (iter->seq.readpos >= iter->seq.len) 4544 if (iter->seq.seq.readpos >= iter->seq.seq.len)
4542 trace_seq_init(&iter->seq); 4545 trace_seq_init(&iter->seq);
4543 4546
4544 /* 4547 /*
@@ -4576,16 +4579,16 @@ tracing_fill_pipe_page(size_t rem, struct trace_iterator *iter)
4576 4579
4577 /* Seq buffer is page-sized, exactly what we need. */ 4580 /* Seq buffer is page-sized, exactly what we need. */
4578 for (;;) { 4581 for (;;) {
4579 count = iter->seq.len; 4582 count = iter->seq.seq.len;
4580 ret = print_trace_line(iter); 4583 ret = print_trace_line(iter);
4581 count = iter->seq.len - count; 4584 count = iter->seq.seq.len - count;
4582 if (rem < count) { 4585 if (rem < count) {
4583 rem = 0; 4586 rem = 0;
4584 iter->seq.len -= count; 4587 iter->seq.seq.len -= count;
4585 break; 4588 break;
4586 } 4589 }
4587 if (ret == TRACE_TYPE_PARTIAL_LINE) { 4590 if (ret == TRACE_TYPE_PARTIAL_LINE) {
4588 iter->seq.len -= count; 4591 iter->seq.seq.len -= count;
4589 break; 4592 break;
4590 } 4593 }
4591 4594
@@ -4666,13 +4669,13 @@ static ssize_t tracing_splice_read_pipe(struct file *filp,
4666 /* Copy the data into the page, so we can start over. */ 4669 /* Copy the data into the page, so we can start over. */
4667 ret = trace_seq_to_buffer(&iter->seq, 4670 ret = trace_seq_to_buffer(&iter->seq,
4668 page_address(spd.pages[i]), 4671 page_address(spd.pages[i]),
4669 iter->seq.len); 4672 iter->seq.seq.len);
4670 if (ret < 0) { 4673 if (ret < 0) {
4671 __free_page(spd.pages[i]); 4674 __free_page(spd.pages[i]);
4672 break; 4675 break;
4673 } 4676 }
4674 spd.partial[i].offset = 0; 4677 spd.partial[i].offset = 0;
4675 spd.partial[i].len = iter->seq.len; 4678 spd.partial[i].len = iter->seq.seq.len;
4676 4679
4677 trace_seq_init(&iter->seq); 4680 trace_seq_init(&iter->seq);
4678 } 4681 }
@@ -5673,7 +5676,7 @@ tracing_stats_read(struct file *filp, char __user *ubuf,
5673 cnt = ring_buffer_read_events_cpu(trace_buf->buffer, cpu); 5676 cnt = ring_buffer_read_events_cpu(trace_buf->buffer, cpu);
5674 trace_seq_printf(s, "read events: %ld\n", cnt); 5677 trace_seq_printf(s, "read events: %ld\n", cnt);
5675 5678
5676 count = simple_read_from_buffer(ubuf, count, ppos, s->buffer, s->len); 5679 count = simple_read_from_buffer(ubuf, count, ppos, s->buffer, s->seq.len);
5677 5680
5678 kfree(s); 5681 kfree(s);
5679 5682
@@ -6636,11 +6639,11 @@ void
6636trace_printk_seq(struct trace_seq *s) 6639trace_printk_seq(struct trace_seq *s)
6637{ 6640{
6638 /* Probably should print a warning here. */ 6641 /* Probably should print a warning here. */
6639 if (s->len >= TRACE_MAX_PRINT) 6642 if (s->seq.len >= TRACE_MAX_PRINT)
6640 s->len = TRACE_MAX_PRINT; 6643 s->seq.len = TRACE_MAX_PRINT;
6641 6644
6642 /* should be zero ended, but we are paranoid. */ 6645 /* should be zero ended, but we are paranoid. */
6643 s->buffer[s->len] = 0; 6646 s->buffer[s->seq.len] = 0;
6644 6647
6645 printk(KERN_TRACE "%s", s->buffer); 6648 printk(KERN_TRACE "%s", s->buffer);
6646 6649