aboutsummaryrefslogtreecommitdiffstats
path: root/kernel/trace/trace.c
diff options
context:
space:
mode:
authorArnaldo Carvalho de Melo <acme@redhat.com>2009-02-03 17:20:41 -0500
committerIngo Molnar <mingo@elte.hu>2009-02-04 14:48:30 -0500
commitd9793bd8018f835c64b10f44e278c86cecb8e932 (patch)
treeda5ad9bc8f3fc7b4eb4ecd398f7c52a6f112d544 /kernel/trace/trace.c
parentce70a0b472e06feae3a580ecb3fbef1e1e020a9b (diff)
trace: judicious error checking of trace_seq results
Impact: bugfix and cleanup Some callsites were returning either TRACE_ITER_PARTIAL_LINE if the trace_seq routines (trace_seq_printf, etc) returned 0 meaning its buffer was full, or zero otherwise. But... /* Return values for print_line callback */ enum print_line_t { TRACE_TYPE_PARTIAL_LINE = 0, /* Retry after flushing the seq */ TRACE_TYPE_HANDLED = 1, TRACE_TYPE_UNHANDLED = 2 /* Relay to other output functions */ }; In other cases the return value was not being relayed at all. Most of the time it didn't hurt because the page wasn't get filled, but for correctness sake, handle the return values everywhere. Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com> Acked-by: Frederic Weisbecker <fweisbec@gmail.com> Signed-off-by: Ingo Molnar <mingo@elte.hu>
Diffstat (limited to 'kernel/trace/trace.c')
-rw-r--r--kernel/trace/trace.c75
1 files changed, 34 insertions, 41 deletions
diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c
index bbdfaa2cbdb9..5822ff4e5a3e 100644
--- a/kernel/trace/trace.c
+++ b/kernel/trace/trace.c
@@ -1402,27 +1402,25 @@ static enum print_line_t print_lat_fmt(struct trace_iterator *iter)
1402 unsigned long sym_flags = (trace_flags & TRACE_ITER_SYM_MASK); 1402 unsigned long sym_flags = (trace_flags & TRACE_ITER_SYM_MASK);
1403 struct trace_event *event; 1403 struct trace_event *event;
1404 struct trace_entry *entry = iter->ent; 1404 struct trace_entry *entry = iter->ent;
1405 int ret;
1406 1405
1407 test_cpu_buff_start(iter); 1406 test_cpu_buff_start(iter);
1408 1407
1409 event = ftrace_find_event(entry->type); 1408 event = ftrace_find_event(entry->type);
1410 1409
1411 if (trace_flags & TRACE_ITER_CONTEXT_INFO) { 1410 if (trace_flags & TRACE_ITER_CONTEXT_INFO) {
1412 ret = trace_print_lat_context(iter); 1411 if (!trace_print_lat_context(iter))
1413 if (ret) 1412 goto partial;
1414 return ret;
1415 } 1413 }
1416 1414
1417 if (event && event->latency_trace) { 1415 if (event && event->latency_trace)
1418 ret = event->latency_trace(iter, sym_flags); 1416 return event->latency_trace(iter, sym_flags);
1419 if (ret) 1417
1420 return ret; 1418 if (!trace_seq_printf(s, "Unknown type %d\n", entry->type))
1421 return TRACE_TYPE_HANDLED; 1419 goto partial;
1422 }
1423 1420
1424 trace_seq_printf(s, "Unknown type %d\n", entry->type);
1425 return TRACE_TYPE_HANDLED; 1421 return TRACE_TYPE_HANDLED;
1422partial:
1423 return TRACE_TYPE_PARTIAL_LINE;
1426} 1424}
1427 1425
1428static enum print_line_t print_trace_fmt(struct trace_iterator *iter) 1426static enum print_line_t print_trace_fmt(struct trace_iterator *iter)
@@ -1431,7 +1429,6 @@ static enum print_line_t print_trace_fmt(struct trace_iterator *iter)
1431 unsigned long sym_flags = (trace_flags & TRACE_ITER_SYM_MASK); 1429 unsigned long sym_flags = (trace_flags & TRACE_ITER_SYM_MASK);
1432 struct trace_entry *entry; 1430 struct trace_entry *entry;
1433 struct trace_event *event; 1431 struct trace_event *event;
1434 int ret;
1435 1432
1436 entry = iter->ent; 1433 entry = iter->ent;
1437 1434
@@ -1440,22 +1437,19 @@ static enum print_line_t print_trace_fmt(struct trace_iterator *iter)
1440 event = ftrace_find_event(entry->type); 1437 event = ftrace_find_event(entry->type);
1441 1438
1442 if (trace_flags & TRACE_ITER_CONTEXT_INFO) { 1439 if (trace_flags & TRACE_ITER_CONTEXT_INFO) {
1443 ret = trace_print_context(iter); 1440 if (!trace_print_context(iter))
1444 if (ret) 1441 goto partial;
1445 return ret;
1446 } 1442 }
1447 1443
1448 if (event && event->trace) { 1444 if (event && event->trace)
1449 ret = event->trace(iter, sym_flags); 1445 return event->trace(iter, sym_flags);
1450 if (ret) 1446
1451 return ret; 1447 if (!trace_seq_printf(s, "Unknown type %d\n", entry->type))
1452 return TRACE_TYPE_HANDLED; 1448 goto partial;
1453 }
1454 ret = trace_seq_printf(s, "Unknown type %d\n", entry->type);
1455 if (!ret)
1456 return TRACE_TYPE_PARTIAL_LINE;
1457 1449
1458 return TRACE_TYPE_HANDLED; 1450 return TRACE_TYPE_HANDLED;
1451partial:
1452 return TRACE_TYPE_PARTIAL_LINE;
1459} 1453}
1460 1454
1461static enum print_line_t print_raw_fmt(struct trace_iterator *iter) 1455static enum print_line_t print_raw_fmt(struct trace_iterator *iter)
@@ -1463,29 +1457,25 @@ static enum print_line_t print_raw_fmt(struct trace_iterator *iter)
1463 struct trace_seq *s = &iter->seq; 1457 struct trace_seq *s = &iter->seq;
1464 struct trace_entry *entry; 1458 struct trace_entry *entry;
1465 struct trace_event *event; 1459 struct trace_event *event;
1466 int ret;
1467 1460
1468 entry = iter->ent; 1461 entry = iter->ent;
1469 1462
1470 if (trace_flags & TRACE_ITER_CONTEXT_INFO) { 1463 if (trace_flags & TRACE_ITER_CONTEXT_INFO) {
1471 ret = trace_seq_printf(s, "%d %d %llu ", 1464 if (!trace_seq_printf(s, "%d %d %llu ",
1472 entry->pid, iter->cpu, iter->ts); 1465 entry->pid, iter->cpu, iter->ts))
1473 if (!ret) 1466 goto partial;
1474 return TRACE_TYPE_PARTIAL_LINE;
1475 } 1467 }
1476 1468
1477 event = ftrace_find_event(entry->type); 1469 event = ftrace_find_event(entry->type);
1478 if (event && event->raw) { 1470 if (event && event->raw)
1479 ret = event->raw(iter, 0); 1471 return event->raw(iter, 0);
1480 if (ret) 1472
1481 return ret; 1473 if (!trace_seq_printf(s, "%d ?\n", entry->type))
1482 return TRACE_TYPE_HANDLED; 1474 goto partial;
1483 }
1484 ret = trace_seq_printf(s, "%d ?\n", entry->type);
1485 if (!ret)
1486 return TRACE_TYPE_PARTIAL_LINE;
1487 1475
1488 return TRACE_TYPE_HANDLED; 1476 return TRACE_TYPE_HANDLED;
1477partial:
1478 return TRACE_TYPE_PARTIAL_LINE;
1489} 1479}
1490 1480
1491static enum print_line_t print_hex_fmt(struct trace_iterator *iter) 1481static enum print_line_t print_hex_fmt(struct trace_iterator *iter)
@@ -1504,8 +1494,11 @@ static enum print_line_t print_hex_fmt(struct trace_iterator *iter)
1504 } 1494 }
1505 1495
1506 event = ftrace_find_event(entry->type); 1496 event = ftrace_find_event(entry->type);
1507 if (event && event->hex) 1497 if (event && event->hex) {
1508 event->hex(iter, 0); 1498 int ret = event->hex(iter, 0);
1499 if (ret != TRACE_TYPE_HANDLED)
1500 return ret;
1501 }
1509 1502
1510 SEQ_PUT_FIELD_RET(s, newline); 1503 SEQ_PUT_FIELD_RET(s, newline);
1511 1504
@@ -1544,7 +1537,7 @@ static enum print_line_t print_bin_fmt(struct trace_iterator *iter)
1544 1537
1545 event = ftrace_find_event(entry->type); 1538 event = ftrace_find_event(entry->type);
1546 if (event && event->binary) 1539 if (event && event->binary)
1547 event->binary(iter, 0); 1540 return event->binary(iter, 0);
1548 1541
1549 return TRACE_TYPE_HANDLED; 1542 return TRACE_TYPE_HANDLED;
1550} 1543}