aboutsummaryrefslogtreecommitdiffstats
path: root/kernel/trace/trace.c
diff options
context:
space:
mode:
authorFrederic Weisbecker <fweisbec@gmail.com>2008-09-29 14:18:34 -0400
committerIngo Molnar <mingo@elte.hu>2008-10-14 04:39:00 -0400
commit2c4f035f6c3e8fda661eb6105aa51ef07aa71607 (patch)
tree9bac9e431789f2f551b6b6b2f86463b0b568bf19 /kernel/trace/trace.c
parent777e208d40d0953efc6fb4ab58590da3f7d8f02d (diff)
tracing/ftrace: change the type of the print_line callback
We need a kind of disambiguation when a print_line callback returns 0. _There is not enough space to print all the entry. Please flush the seq and retry. _I can't handle this type of entry This patch changes the type of this callback for better information. Also some changes have been made in this V2. _ Only relay to default functions after the print_line callback fails. _ This patch doesn't fix the issue with the broken pipe (see patch 2/4 for that) Some things are still in discussion: _ Find better names for the enum print_line_t values _ Change the type of print_trace_line into boolean. Patches to change that can be sent later. Signed-off-by: Frederic Weisbecker <fweisbec@gmail.com> Acked-by: Pekka Paalanen <pq@iki.fi> Signed-off-by: Ingo Molnar <mingo@elte.hu>
Diffstat (limited to 'kernel/trace/trace.c')
-rw-r--r--kernel/trace/trace.c77
1 files changed, 41 insertions, 36 deletions
diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c
index ed9e47c18810..b38a4bb40548 100644
--- a/kernel/trace/trace.c
+++ b/kernel/trace/trace.c
@@ -1250,7 +1250,7 @@ void trace_seq_print_cont(struct trace_seq *s, struct trace_iterator *iter)
1250 trace_seq_putc(s, '\n'); 1250 trace_seq_putc(s, '\n');
1251} 1251}
1252 1252
1253static int 1253static enum print_line_t
1254print_lat_fmt(struct trace_iterator *iter, unsigned int trace_idx, int cpu) 1254print_lat_fmt(struct trace_iterator *iter, unsigned int trace_idx, int cpu)
1255{ 1255{
1256 struct trace_seq *s = &iter->seq; 1256 struct trace_seq *s = &iter->seq;
@@ -1267,7 +1267,7 @@ print_lat_fmt(struct trace_iterator *iter, unsigned int trace_idx, int cpu)
1267 unsigned state; 1267 unsigned state;
1268 1268
1269 if (entry->type == TRACE_CONT) 1269 if (entry->type == TRACE_CONT)
1270 return 1; 1270 return TRACE_TYPE_HANDLED;
1271 1271
1272 next_entry = find_next_entry(iter, NULL, &next_ts); 1272 next_entry = find_next_entry(iter, NULL, &next_ts);
1273 if (!next_entry) 1273 if (!next_entry)
@@ -1357,10 +1357,10 @@ print_lat_fmt(struct trace_iterator *iter, unsigned int trace_idx, int cpu)
1357 default: 1357 default:
1358 trace_seq_printf(s, "Unknown type %d\n", entry->type); 1358 trace_seq_printf(s, "Unknown type %d\n", entry->type);
1359 } 1359 }
1360 return 1; 1360 return TRACE_TYPE_HANDLED;
1361} 1361}
1362 1362
1363static int print_trace_fmt(struct trace_iterator *iter) 1363static enum print_line_t print_trace_fmt(struct trace_iterator *iter)
1364{ 1364{
1365 struct trace_seq *s = &iter->seq; 1365 struct trace_seq *s = &iter->seq;
1366 unsigned long sym_flags = (trace_flags & TRACE_ITER_SYM_MASK); 1366 unsigned long sym_flags = (trace_flags & TRACE_ITER_SYM_MASK);
@@ -1376,7 +1376,7 @@ static int print_trace_fmt(struct trace_iterator *iter)
1376 entry = iter->ent; 1376 entry = iter->ent;
1377 1377
1378 if (entry->type == TRACE_CONT) 1378 if (entry->type == TRACE_CONT)
1379 return 1; 1379 return TRACE_TYPE_HANDLED;
1380 1380
1381 comm = trace_find_cmdline(iter->ent->pid); 1381 comm = trace_find_cmdline(iter->ent->pid);
1382 1382
@@ -1386,13 +1386,13 @@ static int print_trace_fmt(struct trace_iterator *iter)
1386 1386
1387 ret = trace_seq_printf(s, "%16s-%-5d ", comm, entry->pid); 1387 ret = trace_seq_printf(s, "%16s-%-5d ", comm, entry->pid);
1388 if (!ret) 1388 if (!ret)
1389 return 0; 1389 return TRACE_TYPE_PARTIAL_LINE;
1390 ret = trace_seq_printf(s, "[%03d] ", iter->cpu); 1390 ret = trace_seq_printf(s, "[%03d] ", iter->cpu);
1391 if (!ret) 1391 if (!ret)
1392 return 0; 1392 return TRACE_TYPE_PARTIAL_LINE;
1393 ret = trace_seq_printf(s, "%5lu.%06lu: ", secs, usec_rem); 1393 ret = trace_seq_printf(s, "%5lu.%06lu: ", secs, usec_rem);
1394 if (!ret) 1394 if (!ret)
1395 return 0; 1395 return TRACE_TYPE_PARTIAL_LINE;
1396 1396
1397 switch (entry->type) { 1397 switch (entry->type) {
1398 case TRACE_FN: { 1398 case TRACE_FN: {
@@ -1400,12 +1400,12 @@ static int print_trace_fmt(struct trace_iterator *iter)
1400 1400
1401 ret = seq_print_ip_sym(s, field->ip, sym_flags); 1401 ret = seq_print_ip_sym(s, field->ip, sym_flags);
1402 if (!ret) 1402 if (!ret)
1403 return 0; 1403 return TRACE_TYPE_PARTIAL_LINE;
1404 if ((sym_flags & TRACE_ITER_PRINT_PARENT) && 1404 if ((sym_flags & TRACE_ITER_PRINT_PARENT) &&
1405 field->parent_ip) { 1405 field->parent_ip) {
1406 ret = trace_seq_printf(s, " <-"); 1406 ret = trace_seq_printf(s, " <-");
1407 if (!ret) 1407 if (!ret)
1408 return 0; 1408 return TRACE_TYPE_PARTIAL_LINE;
1409 if (kretprobed(field->parent_ip)) 1409 if (kretprobed(field->parent_ip))
1410 ret = trace_seq_puts(s, KRETPROBE_MSG); 1410 ret = trace_seq_puts(s, KRETPROBE_MSG);
1411 else 1411 else
@@ -1413,11 +1413,11 @@ static int print_trace_fmt(struct trace_iterator *iter)
1413 field->parent_ip, 1413 field->parent_ip,
1414 sym_flags); 1414 sym_flags);
1415 if (!ret) 1415 if (!ret)
1416 return 0; 1416 return TRACE_TYPE_PARTIAL_LINE;
1417 } 1417 }
1418 ret = trace_seq_printf(s, "\n"); 1418 ret = trace_seq_printf(s, "\n");
1419 if (!ret) 1419 if (!ret)
1420 return 0; 1420 return TRACE_TYPE_PARTIAL_LINE;
1421 break; 1421 break;
1422 } 1422 }
1423 case TRACE_CTX: 1423 case TRACE_CTX:
@@ -1439,7 +1439,7 @@ static int print_trace_fmt(struct trace_iterator *iter)
1439 field->next_prio, 1439 field->next_prio,
1440 T); 1440 T);
1441 if (!ret) 1441 if (!ret)
1442 return 0; 1442 return TRACE_TYPE_PARTIAL_LINE;
1443 break; 1443 break;
1444 } 1444 }
1445 case TRACE_SPECIAL: { 1445 case TRACE_SPECIAL: {
@@ -1450,7 +1450,7 @@ static int print_trace_fmt(struct trace_iterator *iter)
1450 field->arg2, 1450 field->arg2,
1451 field->arg3); 1451 field->arg3);
1452 if (!ret) 1452 if (!ret)
1453 return 0; 1453 return TRACE_TYPE_PARTIAL_LINE;
1454 break; 1454 break;
1455 } 1455 }
1456 case TRACE_STACK: { 1456 case TRACE_STACK: {
@@ -1460,16 +1460,16 @@ static int print_trace_fmt(struct trace_iterator *iter)
1460 if (i) { 1460 if (i) {
1461 ret = trace_seq_puts(s, " <= "); 1461 ret = trace_seq_puts(s, " <= ");
1462 if (!ret) 1462 if (!ret)
1463 return 0; 1463 return TRACE_TYPE_PARTIAL_LINE;
1464 } 1464 }
1465 ret = seq_print_ip_sym(s, field->caller[i], 1465 ret = seq_print_ip_sym(s, field->caller[i],
1466 sym_flags); 1466 sym_flags);
1467 if (!ret) 1467 if (!ret)
1468 return 0; 1468 return TRACE_TYPE_PARTIAL_LINE;
1469 } 1469 }
1470 ret = trace_seq_puts(s, "\n"); 1470 ret = trace_seq_puts(s, "\n");
1471 if (!ret) 1471 if (!ret)
1472 return 0; 1472 return TRACE_TYPE_PARTIAL_LINE;
1473 break; 1473 break;
1474 } 1474 }
1475 case TRACE_PRINT: { 1475 case TRACE_PRINT: {
@@ -1482,10 +1482,10 @@ static int print_trace_fmt(struct trace_iterator *iter)
1482 break; 1482 break;
1483 } 1483 }
1484 } 1484 }
1485 return 1; 1485 return TRACE_TYPE_HANDLED;
1486} 1486}
1487 1487
1488static int print_raw_fmt(struct trace_iterator *iter) 1488static enum print_line_t print_raw_fmt(struct trace_iterator *iter)
1489{ 1489{
1490 struct trace_seq *s = &iter->seq; 1490 struct trace_seq *s = &iter->seq;
1491 struct trace_entry *entry; 1491 struct trace_entry *entry;
@@ -1495,12 +1495,12 @@ static int print_raw_fmt(struct trace_iterator *iter)
1495 entry = iter->ent; 1495 entry = iter->ent;
1496 1496
1497 if (entry->type == TRACE_CONT) 1497 if (entry->type == TRACE_CONT)
1498 return 1; 1498 return TRACE_TYPE_HANDLED;
1499 1499
1500 ret = trace_seq_printf(s, "%d %d %llu ", 1500 ret = trace_seq_printf(s, "%d %d %llu ",
1501 entry->pid, iter->cpu, iter->ts); 1501 entry->pid, iter->cpu, iter->ts);
1502 if (!ret) 1502 if (!ret)
1503 return 0; 1503 return TRACE_TYPE_PARTIAL_LINE;
1504 1504
1505 switch (entry->type) { 1505 switch (entry->type) {
1506 case TRACE_FN: { 1506 case TRACE_FN: {
@@ -1510,7 +1510,7 @@ static int print_raw_fmt(struct trace_iterator *iter)
1510 field->ip, 1510 field->ip,
1511 field->parent_ip); 1511 field->parent_ip);
1512 if (!ret) 1512 if (!ret)
1513 return 0; 1513 return TRACE_TYPE_PARTIAL_LINE;
1514 break; 1514 break;
1515 } 1515 }
1516 case TRACE_CTX: 1516 case TRACE_CTX:
@@ -1533,7 +1533,7 @@ static int print_raw_fmt(struct trace_iterator *iter)
1533 field->next_prio, 1533 field->next_prio,
1534 T); 1534 T);
1535 if (!ret) 1535 if (!ret)
1536 return 0; 1536 return TRACE_TYPE_PARTIAL_LINE;
1537 break; 1537 break;
1538 } 1538 }
1539 case TRACE_SPECIAL: 1539 case TRACE_SPECIAL:
@@ -1545,7 +1545,7 @@ static int print_raw_fmt(struct trace_iterator *iter)
1545 field->arg2, 1545 field->arg2,
1546 field->arg3); 1546 field->arg3);
1547 if (!ret) 1547 if (!ret)
1548 return 0; 1548 return TRACE_TYPE_PARTIAL_LINE;
1549 break; 1549 break;
1550 } 1550 }
1551 case TRACE_PRINT: { 1551 case TRACE_PRINT: {
@@ -1557,7 +1557,7 @@ static int print_raw_fmt(struct trace_iterator *iter)
1557 break; 1557 break;
1558 } 1558 }
1559 } 1559 }
1560 return 1; 1560 return TRACE_TYPE_HANDLED;
1561} 1561}
1562 1562
1563#define SEQ_PUT_FIELD_RET(s, x) \ 1563#define SEQ_PUT_FIELD_RET(s, x) \
@@ -1572,7 +1572,7 @@ do { \
1572 return 0; \ 1572 return 0; \
1573} while (0) 1573} while (0)
1574 1574
1575static int print_hex_fmt(struct trace_iterator *iter) 1575static enum print_line_t print_hex_fmt(struct trace_iterator *iter)
1576{ 1576{
1577 struct trace_seq *s = &iter->seq; 1577 struct trace_seq *s = &iter->seq;
1578 unsigned char newline = '\n'; 1578 unsigned char newline = '\n';
@@ -1582,7 +1582,7 @@ static int print_hex_fmt(struct trace_iterator *iter)
1582 entry = iter->ent; 1582 entry = iter->ent;
1583 1583
1584 if (entry->type == TRACE_CONT) 1584 if (entry->type == TRACE_CONT)
1585 return 1; 1585 return TRACE_TYPE_HANDLED;
1586 1586
1587 SEQ_PUT_HEX_FIELD_RET(s, entry->pid); 1587 SEQ_PUT_HEX_FIELD_RET(s, entry->pid);
1588 SEQ_PUT_HEX_FIELD_RET(s, iter->cpu); 1588 SEQ_PUT_HEX_FIELD_RET(s, iter->cpu);
@@ -1628,10 +1628,10 @@ static int print_hex_fmt(struct trace_iterator *iter)
1628 } 1628 }
1629 SEQ_PUT_FIELD_RET(s, newline); 1629 SEQ_PUT_FIELD_RET(s, newline);
1630 1630
1631 return 1; 1631 return TRACE_TYPE_HANDLED;
1632} 1632}
1633 1633
1634static int print_bin_fmt(struct trace_iterator *iter) 1634static enum print_line_t print_bin_fmt(struct trace_iterator *iter)
1635{ 1635{
1636 struct trace_seq *s = &iter->seq; 1636 struct trace_seq *s = &iter->seq;
1637 struct trace_entry *entry; 1637 struct trace_entry *entry;
@@ -1639,7 +1639,7 @@ static int print_bin_fmt(struct trace_iterator *iter)
1639 entry = iter->ent; 1639 entry = iter->ent;
1640 1640
1641 if (entry->type == TRACE_CONT) 1641 if (entry->type == TRACE_CONT)
1642 return 1; 1642 return TRACE_TYPE_HANDLED;
1643 1643
1644 SEQ_PUT_FIELD_RET(s, entry->pid); 1644 SEQ_PUT_FIELD_RET(s, entry->pid);
1645 SEQ_PUT_FIELD_RET(s, iter->cpu); 1645 SEQ_PUT_FIELD_RET(s, iter->cpu);
@@ -1686,13 +1686,18 @@ static int trace_empty(struct trace_iterator *iter)
1686 if (!ring_buffer_iter_empty(iter->buffer_iter[cpu])) 1686 if (!ring_buffer_iter_empty(iter->buffer_iter[cpu]))
1687 return 0; 1687 return 0;
1688 } 1688 }
1689 return 1; 1689 return TRACE_TYPE_HANDLED;
1690} 1690}
1691 1691
1692static int print_trace_line(struct trace_iterator *iter) 1692static enum print_line_t print_trace_line(struct trace_iterator *iter)
1693{ 1693{
1694 if (iter->trace && iter->trace->print_line) 1694 enum print_line_t ret;
1695 return iter->trace->print_line(iter); 1695
1696 if (iter->trace && iter->trace->print_line) {
1697 ret = iter->trace->print_line(iter);
1698 if (ret != TRACE_TYPE_UNHANDLED)
1699 return ret;
1700 }
1696 1701
1697 if (trace_flags & TRACE_ITER_BIN) 1702 if (trace_flags & TRACE_ITER_BIN)
1698 return print_bin_fmt(iter); 1703 return print_bin_fmt(iter);
@@ -2525,11 +2530,11 @@ tracing_read_pipe(struct file *filp, char __user *ubuf,
2525 ring_buffer_lock(iter->tr->buffer, &flags); 2530 ring_buffer_lock(iter->tr->buffer, &flags);
2526 2531
2527 while (find_next_entry_inc(iter) != NULL) { 2532 while (find_next_entry_inc(iter) != NULL) {
2528 int ret; 2533 enum print_line_t ret;
2529 int len = iter->seq.len; 2534 int len = iter->seq.len;
2530 2535
2531 ret = print_trace_line(iter); 2536 ret = print_trace_line(iter);
2532 if (!ret) { 2537 if (ret == TRACE_TYPE_PARTIAL_LINE) {
2533 /* don't print partial lines */ 2538 /* don't print partial lines */
2534 iter->seq.len = len; 2539 iter->seq.len = len;
2535 break; 2540 break;