aboutsummaryrefslogtreecommitdiffstats
path: root/kernel/trace/trace.c
diff options
context:
space:
mode:
authorEduard - Gabriel Munteanu <eduard.munteanu@linux360.ro>2009-02-09 01:15:55 -0500
committerSteven Rostedt <srostedt@redhat.com>2009-02-09 12:24:51 -0500
commitff98781bab2735e6c89793034173e0cb5007a7e5 (patch)
treee79e4c329896018cd9ca97192292632ad7c43007 /kernel/trace/trace.c
parent3c56819b14b00dd449bd776303e61f8532fad09f (diff)
tracing: Move pipe waiting code out of tracing_read_pipe().
This moves the pipe waiting code from tracing_read_pipe() into tracing_wait_pipe(), which is useful to implement other fops, like splice_read. Signed-off-by: Eduard - Gabriel Munteanu <eduard.munteanu@linux360.ro> Signed-off-by: Steven Rostedt <srostedt@redhat.com>
Diffstat (limited to 'kernel/trace/trace.c')
-rw-r--r--kernel/trace/trace.c69
1 files changed, 40 insertions, 29 deletions
diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c
index 9e29fdb0dfe5..11fde0ad9cb6 100644
--- a/kernel/trace/trace.c
+++ b/kernel/trace/trace.c
@@ -2388,37 +2388,15 @@ tracing_poll_pipe(struct file *filp, poll_table *poll_table)
2388 } 2388 }
2389} 2389}
2390 2390
2391/* 2391/* Must be called with trace_types_lock mutex held. */
2392 * Consumer reader. 2392static int tracing_wait_pipe(struct file *filp)
2393 */
2394static ssize_t
2395tracing_read_pipe(struct file *filp, char __user *ubuf,
2396 size_t cnt, loff_t *ppos)
2397{ 2393{
2398 struct trace_iterator *iter = filp->private_data; 2394 struct trace_iterator *iter = filp->private_data;
2399 ssize_t sret;
2400
2401 /* return any leftover data */
2402 sret = trace_seq_to_user(&iter->seq, ubuf, cnt);
2403 if (sret != -EBUSY)
2404 return sret;
2405
2406 trace_seq_reset(&iter->seq);
2407 2395
2408 mutex_lock(&trace_types_lock);
2409 if (iter->trace->read) {
2410 sret = iter->trace->read(iter, filp, ubuf, cnt, ppos);
2411 if (sret)
2412 goto out;
2413 }
2414
2415waitagain:
2416 sret = 0;
2417 while (trace_empty(iter)) { 2396 while (trace_empty(iter)) {
2418 2397
2419 if ((filp->f_flags & O_NONBLOCK)) { 2398 if ((filp->f_flags & O_NONBLOCK)) {
2420 sret = -EAGAIN; 2399 return -EAGAIN;
2421 goto out;
2422 } 2400 }
2423 2401
2424 /* 2402 /*
@@ -2443,12 +2421,11 @@ waitagain:
2443 iter->tr->waiter = NULL; 2421 iter->tr->waiter = NULL;
2444 2422
2445 if (signal_pending(current)) { 2423 if (signal_pending(current)) {
2446 sret = -EINTR; 2424 return -EINTR;
2447 goto out;
2448 } 2425 }
2449 2426
2450 if (iter->trace != current_trace) 2427 if (iter->trace != current_trace)
2451 goto out; 2428 return 0;
2452 2429
2453 /* 2430 /*
2454 * We block until we read something and tracing is disabled. 2431 * We block until we read something and tracing is disabled.
@@ -2465,9 +2442,43 @@ waitagain:
2465 continue; 2442 continue;
2466 } 2443 }
2467 2444
2445 return 1;
2446}
2447
2448/*
2449 * Consumer reader.
2450 */
2451static ssize_t
2452tracing_read_pipe(struct file *filp, char __user *ubuf,
2453 size_t cnt, loff_t *ppos)
2454{
2455 struct trace_iterator *iter = filp->private_data;
2456 ssize_t sret;
2457
2458 /* return any leftover data */
2459 sret = trace_seq_to_user(&iter->seq, ubuf, cnt);
2460 if (sret != -EBUSY)
2461 return sret;
2462
2463 trace_seq_reset(&iter->seq);
2464
2465 mutex_lock(&trace_types_lock);
2466 if (iter->trace->read) {
2467 sret = iter->trace->read(iter, filp, ubuf, cnt, ppos);
2468 if (sret)
2469 goto out;
2470 }
2471
2472waitagain:
2473 sret = tracing_wait_pipe(filp);
2474 if (sret <= 0)
2475 goto out;
2476
2468 /* stop when tracing is finished */ 2477 /* stop when tracing is finished */
2469 if (trace_empty(iter)) 2478 if (trace_empty(iter)) {
2479 sret = 0;
2470 goto out; 2480 goto out;
2481 }
2471 2482
2472 if (cnt >= PAGE_SIZE) 2483 if (cnt >= PAGE_SIZE)
2473 cnt = PAGE_SIZE - 1; 2484 cnt = PAGE_SIZE - 1;