diff options
author | Ingo Molnar <mingo@elte.hu> | 2009-01-06 04:18:43 -0500 |
---|---|---|
committer | Ingo Molnar <mingo@elte.hu> | 2009-01-06 04:18:43 -0500 |
commit | 99793e3dbe39a50d871eedc361659a894601e2bf (patch) | |
tree | a676d42a42f4c884e38121e5a5a4d6630929a9f7 /kernel/trace/trace.c | |
parent | 3e80680208ba6ce9635ca7c21ad0019442ea166a (diff) | |
parent | a103e2ab7377dbbef2506be59c49a3f2ae10b60b (diff) |
Merge branches 'tracing/kmemtrace2' and 'tracing/ftrace' into tracing/urgent
Diffstat (limited to 'kernel/trace/trace.c')
-rw-r--r-- | kernel/trace/trace.c | 741 |
1 files changed, 41 insertions, 700 deletions
diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c index c580233add95..0418fc338b5c 100644 --- a/kernel/trace/trace.c +++ b/kernel/trace/trace.c | |||
@@ -37,6 +37,7 @@ | |||
37 | #include <linux/irqflags.h> | 37 | #include <linux/irqflags.h> |
38 | 38 | ||
39 | #include "trace.h" | 39 | #include "trace.h" |
40 | #include "trace_output.h" | ||
40 | 41 | ||
41 | #define TRACE_BUFFER_FLAGS (RB_FL_OVERWRITE) | 42 | #define TRACE_BUFFER_FLAGS (RB_FL_OVERWRITE) |
42 | 43 | ||
@@ -329,132 +330,6 @@ __update_max_tr(struct trace_array *tr, struct task_struct *tsk, int cpu) | |||
329 | tracing_record_cmdline(current); | 330 | tracing_record_cmdline(current); |
330 | } | 331 | } |
331 | 332 | ||
332 | /** | ||
333 | * trace_seq_printf - sequence printing of trace information | ||
334 | * @s: trace sequence descriptor | ||
335 | * @fmt: printf format string | ||
336 | * | ||
337 | * The tracer may use either sequence operations or its own | ||
338 | * copy to user routines. To simplify formating of a trace | ||
339 | * trace_seq_printf is used to store strings into a special | ||
340 | * buffer (@s). Then the output may be either used by | ||
341 | * the sequencer or pulled into another buffer. | ||
342 | */ | ||
343 | int | ||
344 | trace_seq_printf(struct trace_seq *s, const char *fmt, ...) | ||
345 | { | ||
346 | int len = (PAGE_SIZE - 1) - s->len; | ||
347 | va_list ap; | ||
348 | int ret; | ||
349 | |||
350 | if (!len) | ||
351 | return 0; | ||
352 | |||
353 | va_start(ap, fmt); | ||
354 | ret = vsnprintf(s->buffer + s->len, len, fmt, ap); | ||
355 | va_end(ap); | ||
356 | |||
357 | /* If we can't write it all, don't bother writing anything */ | ||
358 | if (ret >= len) | ||
359 | return 0; | ||
360 | |||
361 | s->len += ret; | ||
362 | |||
363 | return len; | ||
364 | } | ||
365 | |||
366 | /** | ||
367 | * trace_seq_puts - trace sequence printing of simple string | ||
368 | * @s: trace sequence descriptor | ||
369 | * @str: simple string to record | ||
370 | * | ||
371 | * The tracer may use either the sequence operations or its own | ||
372 | * copy to user routines. This function records a simple string | ||
373 | * into a special buffer (@s) for later retrieval by a sequencer | ||
374 | * or other mechanism. | ||
375 | */ | ||
376 | static int | ||
377 | trace_seq_puts(struct trace_seq *s, const char *str) | ||
378 | { | ||
379 | int len = strlen(str); | ||
380 | |||
381 | if (len > ((PAGE_SIZE - 1) - s->len)) | ||
382 | return 0; | ||
383 | |||
384 | memcpy(s->buffer + s->len, str, len); | ||
385 | s->len += len; | ||
386 | |||
387 | return len; | ||
388 | } | ||
389 | |||
390 | static int | ||
391 | trace_seq_putc(struct trace_seq *s, unsigned char c) | ||
392 | { | ||
393 | if (s->len >= (PAGE_SIZE - 1)) | ||
394 | return 0; | ||
395 | |||
396 | s->buffer[s->len++] = c; | ||
397 | |||
398 | return 1; | ||
399 | } | ||
400 | |||
401 | static int | ||
402 | trace_seq_putmem(struct trace_seq *s, void *mem, size_t len) | ||
403 | { | ||
404 | if (len > ((PAGE_SIZE - 1) - s->len)) | ||
405 | return 0; | ||
406 | |||
407 | memcpy(s->buffer + s->len, mem, len); | ||
408 | s->len += len; | ||
409 | |||
410 | return len; | ||
411 | } | ||
412 | |||
413 | #define MAX_MEMHEX_BYTES 8 | ||
414 | #define HEX_CHARS (MAX_MEMHEX_BYTES*2 + 1) | ||
415 | |||
416 | static int | ||
417 | trace_seq_putmem_hex(struct trace_seq *s, void *mem, size_t len) | ||
418 | { | ||
419 | unsigned char hex[HEX_CHARS]; | ||
420 | unsigned char *data = mem; | ||
421 | int i, j; | ||
422 | |||
423 | #ifdef __BIG_ENDIAN | ||
424 | for (i = 0, j = 0; i < len; i++) { | ||
425 | #else | ||
426 | for (i = len-1, j = 0; i >= 0; i--) { | ||
427 | #endif | ||
428 | hex[j++] = hex_asc_hi(data[i]); | ||
429 | hex[j++] = hex_asc_lo(data[i]); | ||
430 | } | ||
431 | hex[j++] = ' '; | ||
432 | |||
433 | return trace_seq_putmem(s, hex, j); | ||
434 | } | ||
435 | |||
436 | static int | ||
437 | trace_seq_path(struct trace_seq *s, struct path *path) | ||
438 | { | ||
439 | unsigned char *p; | ||
440 | |||
441 | if (s->len >= (PAGE_SIZE - 1)) | ||
442 | return 0; | ||
443 | p = d_path(path, s->buffer + s->len, PAGE_SIZE - s->len); | ||
444 | if (!IS_ERR(p)) { | ||
445 | p = mangle_path(s->buffer + s->len, p, "\n"); | ||
446 | if (p) { | ||
447 | s->len = p - s->buffer; | ||
448 | return 1; | ||
449 | } | ||
450 | } else { | ||
451 | s->buffer[s->len++] = '?'; | ||
452 | return 1; | ||
453 | } | ||
454 | |||
455 | return 0; | ||
456 | } | ||
457 | |||
458 | static void | 333 | static void |
459 | trace_seq_reset(struct trace_seq *s) | 334 | trace_seq_reset(struct trace_seq *s) |
460 | { | 335 | { |
@@ -1472,154 +1347,6 @@ static void s_stop(struct seq_file *m, void *p) | |||
1472 | mutex_unlock(&trace_types_lock); | 1347 | mutex_unlock(&trace_types_lock); |
1473 | } | 1348 | } |
1474 | 1349 | ||
1475 | #ifdef CONFIG_KRETPROBES | ||
1476 | static inline const char *kretprobed(const char *name) | ||
1477 | { | ||
1478 | static const char tramp_name[] = "kretprobe_trampoline"; | ||
1479 | int size = sizeof(tramp_name); | ||
1480 | |||
1481 | if (strncmp(tramp_name, name, size) == 0) | ||
1482 | return "[unknown/kretprobe'd]"; | ||
1483 | return name; | ||
1484 | } | ||
1485 | #else | ||
1486 | static inline const char *kretprobed(const char *name) | ||
1487 | { | ||
1488 | return name; | ||
1489 | } | ||
1490 | #endif /* CONFIG_KRETPROBES */ | ||
1491 | |||
1492 | static int | ||
1493 | seq_print_sym_short(struct trace_seq *s, const char *fmt, unsigned long address) | ||
1494 | { | ||
1495 | #ifdef CONFIG_KALLSYMS | ||
1496 | char str[KSYM_SYMBOL_LEN]; | ||
1497 | const char *name; | ||
1498 | |||
1499 | kallsyms_lookup(address, NULL, NULL, NULL, str); | ||
1500 | |||
1501 | name = kretprobed(str); | ||
1502 | |||
1503 | return trace_seq_printf(s, fmt, name); | ||
1504 | #endif | ||
1505 | return 1; | ||
1506 | } | ||
1507 | |||
1508 | static int | ||
1509 | seq_print_sym_offset(struct trace_seq *s, const char *fmt, | ||
1510 | unsigned long address) | ||
1511 | { | ||
1512 | #ifdef CONFIG_KALLSYMS | ||
1513 | char str[KSYM_SYMBOL_LEN]; | ||
1514 | const char *name; | ||
1515 | |||
1516 | sprint_symbol(str, address); | ||
1517 | name = kretprobed(str); | ||
1518 | |||
1519 | return trace_seq_printf(s, fmt, name); | ||
1520 | #endif | ||
1521 | return 1; | ||
1522 | } | ||
1523 | |||
1524 | #ifndef CONFIG_64BIT | ||
1525 | # define IP_FMT "%08lx" | ||
1526 | #else | ||
1527 | # define IP_FMT "%016lx" | ||
1528 | #endif | ||
1529 | |||
1530 | int | ||
1531 | seq_print_ip_sym(struct trace_seq *s, unsigned long ip, unsigned long sym_flags) | ||
1532 | { | ||
1533 | int ret; | ||
1534 | |||
1535 | if (!ip) | ||
1536 | return trace_seq_printf(s, "0"); | ||
1537 | |||
1538 | if (sym_flags & TRACE_ITER_SYM_OFFSET) | ||
1539 | ret = seq_print_sym_offset(s, "%s", ip); | ||
1540 | else | ||
1541 | ret = seq_print_sym_short(s, "%s", ip); | ||
1542 | |||
1543 | if (!ret) | ||
1544 | return 0; | ||
1545 | |||
1546 | if (sym_flags & TRACE_ITER_SYM_ADDR) | ||
1547 | ret = trace_seq_printf(s, " <" IP_FMT ">", ip); | ||
1548 | return ret; | ||
1549 | } | ||
1550 | |||
1551 | static inline int seq_print_user_ip(struct trace_seq *s, struct mm_struct *mm, | ||
1552 | unsigned long ip, unsigned long sym_flags) | ||
1553 | { | ||
1554 | struct file *file = NULL; | ||
1555 | unsigned long vmstart = 0; | ||
1556 | int ret = 1; | ||
1557 | |||
1558 | if (mm) { | ||
1559 | const struct vm_area_struct *vma; | ||
1560 | |||
1561 | down_read(&mm->mmap_sem); | ||
1562 | vma = find_vma(mm, ip); | ||
1563 | if (vma) { | ||
1564 | file = vma->vm_file; | ||
1565 | vmstart = vma->vm_start; | ||
1566 | } | ||
1567 | if (file) { | ||
1568 | ret = trace_seq_path(s, &file->f_path); | ||
1569 | if (ret) | ||
1570 | ret = trace_seq_printf(s, "[+0x%lx]", ip - vmstart); | ||
1571 | } | ||
1572 | up_read(&mm->mmap_sem); | ||
1573 | } | ||
1574 | if (ret && ((sym_flags & TRACE_ITER_SYM_ADDR) || !file)) | ||
1575 | ret = trace_seq_printf(s, " <" IP_FMT ">", ip); | ||
1576 | return ret; | ||
1577 | } | ||
1578 | |||
1579 | static int | ||
1580 | seq_print_userip_objs(const struct userstack_entry *entry, struct trace_seq *s, | ||
1581 | unsigned long sym_flags) | ||
1582 | { | ||
1583 | struct mm_struct *mm = NULL; | ||
1584 | int ret = 1; | ||
1585 | unsigned int i; | ||
1586 | |||
1587 | if (trace_flags & TRACE_ITER_SYM_USEROBJ) { | ||
1588 | struct task_struct *task; | ||
1589 | /* | ||
1590 | * we do the lookup on the thread group leader, | ||
1591 | * since individual threads might have already quit! | ||
1592 | */ | ||
1593 | rcu_read_lock(); | ||
1594 | task = find_task_by_vpid(entry->ent.tgid); | ||
1595 | if (task) | ||
1596 | mm = get_task_mm(task); | ||
1597 | rcu_read_unlock(); | ||
1598 | } | ||
1599 | |||
1600 | for (i = 0; i < FTRACE_STACK_ENTRIES; i++) { | ||
1601 | unsigned long ip = entry->caller[i]; | ||
1602 | |||
1603 | if (ip == ULONG_MAX || !ret) | ||
1604 | break; | ||
1605 | if (i && ret) | ||
1606 | ret = trace_seq_puts(s, " <- "); | ||
1607 | if (!ip) { | ||
1608 | if (ret) | ||
1609 | ret = trace_seq_puts(s, "??"); | ||
1610 | continue; | ||
1611 | } | ||
1612 | if (!ret) | ||
1613 | break; | ||
1614 | if (ret) | ||
1615 | ret = seq_print_user_ip(s, mm, ip, sym_flags); | ||
1616 | } | ||
1617 | |||
1618 | if (mm) | ||
1619 | mmput(mm); | ||
1620 | return ret; | ||
1621 | } | ||
1622 | |||
1623 | static void print_lat_help_header(struct seq_file *m) | 1350 | static void print_lat_help_header(struct seq_file *m) |
1624 | { | 1351 | { |
1625 | seq_puts(m, "# _------=> CPU# \n"); | 1352 | seq_puts(m, "# _------=> CPU# \n"); |
@@ -1755,52 +1482,6 @@ lat_print_timestamp(struct trace_seq *s, u64 abs_usecs, | |||
1755 | trace_seq_puts(s, " : "); | 1482 | trace_seq_puts(s, " : "); |
1756 | } | 1483 | } |
1757 | 1484 | ||
1758 | static const char state_to_char[] = TASK_STATE_TO_CHAR_STR; | ||
1759 | |||
1760 | static int task_state_char(unsigned long state) | ||
1761 | { | ||
1762 | int bit = state ? __ffs(state) + 1 : 0; | ||
1763 | |||
1764 | return bit < sizeof(state_to_char) - 1 ? state_to_char[bit] : '?'; | ||
1765 | } | ||
1766 | |||
1767 | /* | ||
1768 | * The message is supposed to contain an ending newline. | ||
1769 | * If the printing stops prematurely, try to add a newline of our own. | ||
1770 | */ | ||
1771 | void trace_seq_print_cont(struct trace_seq *s, struct trace_iterator *iter) | ||
1772 | { | ||
1773 | struct trace_entry *ent; | ||
1774 | struct trace_field_cont *cont; | ||
1775 | bool ok = true; | ||
1776 | |||
1777 | ent = peek_next_entry(iter, iter->cpu, NULL); | ||
1778 | if (!ent || ent->type != TRACE_CONT) { | ||
1779 | trace_seq_putc(s, '\n'); | ||
1780 | return; | ||
1781 | } | ||
1782 | |||
1783 | do { | ||
1784 | cont = (struct trace_field_cont *)ent; | ||
1785 | if (ok) | ||
1786 | ok = (trace_seq_printf(s, "%s", cont->buf) > 0); | ||
1787 | |||
1788 | ftrace_disable_cpu(); | ||
1789 | |||
1790 | if (iter->buffer_iter[iter->cpu]) | ||
1791 | ring_buffer_read(iter->buffer_iter[iter->cpu], NULL); | ||
1792 | else | ||
1793 | ring_buffer_consume(iter->tr->buffer, iter->cpu, NULL); | ||
1794 | |||
1795 | ftrace_enable_cpu(); | ||
1796 | |||
1797 | ent = peek_next_entry(iter, iter->cpu, NULL); | ||
1798 | } while (ent && ent->type == TRACE_CONT); | ||
1799 | |||
1800 | if (!ok) | ||
1801 | trace_seq_putc(s, '\n'); | ||
1802 | } | ||
1803 | |||
1804 | static void test_cpu_buff_start(struct trace_iterator *iter) | 1485 | static void test_cpu_buff_start(struct trace_iterator *iter) |
1805 | { | 1486 | { |
1806 | struct trace_seq *s = &iter->seq; | 1487 | struct trace_seq *s = &iter->seq; |
@@ -1824,17 +1505,14 @@ print_lat_fmt(struct trace_iterator *iter, unsigned int trace_idx, int cpu) | |||
1824 | struct trace_seq *s = &iter->seq; | 1505 | struct trace_seq *s = &iter->seq; |
1825 | unsigned long sym_flags = (trace_flags & TRACE_ITER_SYM_MASK); | 1506 | unsigned long sym_flags = (trace_flags & TRACE_ITER_SYM_MASK); |
1826 | struct trace_entry *next_entry; | 1507 | struct trace_entry *next_entry; |
1508 | struct trace_event *event; | ||
1827 | unsigned long verbose = (trace_flags & TRACE_ITER_VERBOSE); | 1509 | unsigned long verbose = (trace_flags & TRACE_ITER_VERBOSE); |
1828 | struct trace_entry *entry = iter->ent; | 1510 | struct trace_entry *entry = iter->ent; |
1829 | unsigned long abs_usecs; | 1511 | unsigned long abs_usecs; |
1830 | unsigned long rel_usecs; | 1512 | unsigned long rel_usecs; |
1831 | u64 next_ts; | 1513 | u64 next_ts; |
1832 | char *comm; | 1514 | char *comm; |
1833 | int S, T; | 1515 | int ret; |
1834 | int i; | ||
1835 | |||
1836 | if (entry->type == TRACE_CONT) | ||
1837 | return TRACE_TYPE_HANDLED; | ||
1838 | 1516 | ||
1839 | test_cpu_buff_start(iter); | 1517 | test_cpu_buff_start(iter); |
1840 | 1518 | ||
@@ -1859,96 +1537,16 @@ print_lat_fmt(struct trace_iterator *iter, unsigned int trace_idx, int cpu) | |||
1859 | lat_print_generic(s, entry, cpu); | 1537 | lat_print_generic(s, entry, cpu); |
1860 | lat_print_timestamp(s, abs_usecs, rel_usecs); | 1538 | lat_print_timestamp(s, abs_usecs, rel_usecs); |
1861 | } | 1539 | } |
1862 | switch (entry->type) { | ||
1863 | case TRACE_FN: { | ||
1864 | struct ftrace_entry *field; | ||
1865 | |||
1866 | trace_assign_type(field, entry); | ||
1867 | |||
1868 | seq_print_ip_sym(s, field->ip, sym_flags); | ||
1869 | trace_seq_puts(s, " ("); | ||
1870 | seq_print_ip_sym(s, field->parent_ip, sym_flags); | ||
1871 | trace_seq_puts(s, ")\n"); | ||
1872 | break; | ||
1873 | } | ||
1874 | case TRACE_CTX: | ||
1875 | case TRACE_WAKE: { | ||
1876 | struct ctx_switch_entry *field; | ||
1877 | |||
1878 | trace_assign_type(field, entry); | ||
1879 | |||
1880 | T = task_state_char(field->next_state); | ||
1881 | S = task_state_char(field->prev_state); | ||
1882 | comm = trace_find_cmdline(field->next_pid); | ||
1883 | trace_seq_printf(s, " %5d:%3d:%c %s [%03d] %5d:%3d:%c %s\n", | ||
1884 | field->prev_pid, | ||
1885 | field->prev_prio, | ||
1886 | S, entry->type == TRACE_CTX ? "==>" : " +", | ||
1887 | field->next_cpu, | ||
1888 | field->next_pid, | ||
1889 | field->next_prio, | ||
1890 | T, comm); | ||
1891 | break; | ||
1892 | } | ||
1893 | case TRACE_SPECIAL: { | ||
1894 | struct special_entry *field; | ||
1895 | |||
1896 | trace_assign_type(field, entry); | ||
1897 | |||
1898 | trace_seq_printf(s, "# %ld %ld %ld\n", | ||
1899 | field->arg1, | ||
1900 | field->arg2, | ||
1901 | field->arg3); | ||
1902 | break; | ||
1903 | } | ||
1904 | case TRACE_STACK: { | ||
1905 | struct stack_entry *field; | ||
1906 | |||
1907 | trace_assign_type(field, entry); | ||
1908 | |||
1909 | for (i = 0; i < FTRACE_STACK_ENTRIES; i++) { | ||
1910 | if (i) | ||
1911 | trace_seq_puts(s, " <= "); | ||
1912 | seq_print_ip_sym(s, field->caller[i], sym_flags); | ||
1913 | } | ||
1914 | trace_seq_puts(s, "\n"); | ||
1915 | break; | ||
1916 | } | ||
1917 | case TRACE_PRINT: { | ||
1918 | struct print_entry *field; | ||
1919 | |||
1920 | trace_assign_type(field, entry); | ||
1921 | 1540 | ||
1922 | seq_print_ip_sym(s, field->ip, sym_flags); | 1541 | event = ftrace_find_event(entry->type); |
1923 | trace_seq_printf(s, ": %s", field->buf); | 1542 | if (event && event->latency_trace) { |
1924 | if (entry->flags & TRACE_FLAG_CONT) | 1543 | ret = event->latency_trace(s, entry, sym_flags); |
1925 | trace_seq_print_cont(s, iter); | 1544 | if (ret) |
1926 | break; | 1545 | return ret; |
1927 | } | 1546 | return TRACE_TYPE_HANDLED; |
1928 | case TRACE_BRANCH: { | ||
1929 | struct trace_branch *field; | ||
1930 | |||
1931 | trace_assign_type(field, entry); | ||
1932 | |||
1933 | trace_seq_printf(s, "[%s] %s:%s:%d\n", | ||
1934 | field->correct ? " ok " : " MISS ", | ||
1935 | field->func, | ||
1936 | field->file, | ||
1937 | field->line); | ||
1938 | break; | ||
1939 | } | 1547 | } |
1940 | case TRACE_USER_STACK: { | ||
1941 | struct userstack_entry *field; | ||
1942 | |||
1943 | trace_assign_type(field, entry); | ||
1944 | 1548 | ||
1945 | seq_print_userip_objs(field, s, sym_flags); | 1549 | trace_seq_printf(s, "Unknown type %d\n", entry->type); |
1946 | trace_seq_putc(s, '\n'); | ||
1947 | break; | ||
1948 | } | ||
1949 | default: | ||
1950 | trace_seq_printf(s, "Unknown type %d\n", entry->type); | ||
1951 | } | ||
1952 | return TRACE_TYPE_HANDLED; | 1550 | return TRACE_TYPE_HANDLED; |
1953 | } | 1551 | } |
1954 | 1552 | ||
@@ -1957,19 +1555,15 @@ static enum print_line_t print_trace_fmt(struct trace_iterator *iter) | |||
1957 | struct trace_seq *s = &iter->seq; | 1555 | struct trace_seq *s = &iter->seq; |
1958 | unsigned long sym_flags = (trace_flags & TRACE_ITER_SYM_MASK); | 1556 | unsigned long sym_flags = (trace_flags & TRACE_ITER_SYM_MASK); |
1959 | struct trace_entry *entry; | 1557 | struct trace_entry *entry; |
1558 | struct trace_event *event; | ||
1960 | unsigned long usec_rem; | 1559 | unsigned long usec_rem; |
1961 | unsigned long long t; | 1560 | unsigned long long t; |
1962 | unsigned long secs; | 1561 | unsigned long secs; |
1963 | char *comm; | 1562 | char *comm; |
1964 | int ret; | 1563 | int ret; |
1965 | int S, T; | ||
1966 | int i; | ||
1967 | 1564 | ||
1968 | entry = iter->ent; | 1565 | entry = iter->ent; |
1969 | 1566 | ||
1970 | if (entry->type == TRACE_CONT) | ||
1971 | return TRACE_TYPE_HANDLED; | ||
1972 | |||
1973 | test_cpu_buff_start(iter); | 1567 | test_cpu_buff_start(iter); |
1974 | 1568 | ||
1975 | comm = trace_find_cmdline(iter->ent->pid); | 1569 | comm = trace_find_cmdline(iter->ent->pid); |
@@ -1988,129 +1582,17 @@ static enum print_line_t print_trace_fmt(struct trace_iterator *iter) | |||
1988 | if (!ret) | 1582 | if (!ret) |
1989 | return TRACE_TYPE_PARTIAL_LINE; | 1583 | return TRACE_TYPE_PARTIAL_LINE; |
1990 | 1584 | ||
1991 | switch (entry->type) { | 1585 | event = ftrace_find_event(entry->type); |
1992 | case TRACE_FN: { | 1586 | if (event && event->trace) { |
1993 | struct ftrace_entry *field; | 1587 | ret = event->trace(s, entry, sym_flags); |
1994 | 1588 | if (ret) | |
1995 | trace_assign_type(field, entry); | 1589 | return ret; |
1996 | 1590 | return TRACE_TYPE_HANDLED; | |
1997 | ret = seq_print_ip_sym(s, field->ip, sym_flags); | ||
1998 | if (!ret) | ||
1999 | return TRACE_TYPE_PARTIAL_LINE; | ||
2000 | if ((sym_flags & TRACE_ITER_PRINT_PARENT) && | ||
2001 | field->parent_ip) { | ||
2002 | ret = trace_seq_printf(s, " <-"); | ||
2003 | if (!ret) | ||
2004 | return TRACE_TYPE_PARTIAL_LINE; | ||
2005 | ret = seq_print_ip_sym(s, | ||
2006 | field->parent_ip, | ||
2007 | sym_flags); | ||
2008 | if (!ret) | ||
2009 | return TRACE_TYPE_PARTIAL_LINE; | ||
2010 | } | ||
2011 | ret = trace_seq_printf(s, "\n"); | ||
2012 | if (!ret) | ||
2013 | return TRACE_TYPE_PARTIAL_LINE; | ||
2014 | break; | ||
2015 | } | ||
2016 | case TRACE_CTX: | ||
2017 | case TRACE_WAKE: { | ||
2018 | struct ctx_switch_entry *field; | ||
2019 | |||
2020 | trace_assign_type(field, entry); | ||
2021 | |||
2022 | T = task_state_char(field->next_state); | ||
2023 | S = task_state_char(field->prev_state); | ||
2024 | ret = trace_seq_printf(s, " %5d:%3d:%c %s [%03d] %5d:%3d:%c\n", | ||
2025 | field->prev_pid, | ||
2026 | field->prev_prio, | ||
2027 | S, | ||
2028 | entry->type == TRACE_CTX ? "==>" : " +", | ||
2029 | field->next_cpu, | ||
2030 | field->next_pid, | ||
2031 | field->next_prio, | ||
2032 | T); | ||
2033 | if (!ret) | ||
2034 | return TRACE_TYPE_PARTIAL_LINE; | ||
2035 | break; | ||
2036 | } | ||
2037 | case TRACE_SPECIAL: { | ||
2038 | struct special_entry *field; | ||
2039 | |||
2040 | trace_assign_type(field, entry); | ||
2041 | |||
2042 | ret = trace_seq_printf(s, "# %ld %ld %ld\n", | ||
2043 | field->arg1, | ||
2044 | field->arg2, | ||
2045 | field->arg3); | ||
2046 | if (!ret) | ||
2047 | return TRACE_TYPE_PARTIAL_LINE; | ||
2048 | break; | ||
2049 | } | ||
2050 | case TRACE_STACK: { | ||
2051 | struct stack_entry *field; | ||
2052 | |||
2053 | trace_assign_type(field, entry); | ||
2054 | |||
2055 | for (i = 0; i < FTRACE_STACK_ENTRIES; i++) { | ||
2056 | if (i) { | ||
2057 | ret = trace_seq_puts(s, " <= "); | ||
2058 | if (!ret) | ||
2059 | return TRACE_TYPE_PARTIAL_LINE; | ||
2060 | } | ||
2061 | ret = seq_print_ip_sym(s, field->caller[i], | ||
2062 | sym_flags); | ||
2063 | if (!ret) | ||
2064 | return TRACE_TYPE_PARTIAL_LINE; | ||
2065 | } | ||
2066 | ret = trace_seq_puts(s, "\n"); | ||
2067 | if (!ret) | ||
2068 | return TRACE_TYPE_PARTIAL_LINE; | ||
2069 | break; | ||
2070 | } | ||
2071 | case TRACE_PRINT: { | ||
2072 | struct print_entry *field; | ||
2073 | |||
2074 | trace_assign_type(field, entry); | ||
2075 | |||
2076 | seq_print_ip_sym(s, field->ip, sym_flags); | ||
2077 | trace_seq_printf(s, ": %s", field->buf); | ||
2078 | if (entry->flags & TRACE_FLAG_CONT) | ||
2079 | trace_seq_print_cont(s, iter); | ||
2080 | break; | ||
2081 | } | ||
2082 | case TRACE_GRAPH_RET: { | ||
2083 | return print_graph_function(iter); | ||
2084 | } | ||
2085 | case TRACE_GRAPH_ENT: { | ||
2086 | return print_graph_function(iter); | ||
2087 | } | ||
2088 | case TRACE_BRANCH: { | ||
2089 | struct trace_branch *field; | ||
2090 | |||
2091 | trace_assign_type(field, entry); | ||
2092 | |||
2093 | trace_seq_printf(s, "[%s] %s:%s:%d\n", | ||
2094 | field->correct ? " ok " : " MISS ", | ||
2095 | field->func, | ||
2096 | field->file, | ||
2097 | field->line); | ||
2098 | break; | ||
2099 | } | 1591 | } |
2100 | case TRACE_USER_STACK: { | 1592 | ret = trace_seq_printf(s, "Unknown type %d\n", entry->type); |
2101 | struct userstack_entry *field; | 1593 | if (!ret) |
2102 | 1594 | return TRACE_TYPE_PARTIAL_LINE; | |
2103 | trace_assign_type(field, entry); | ||
2104 | 1595 | ||
2105 | ret = seq_print_userip_objs(field, s, sym_flags); | ||
2106 | if (!ret) | ||
2107 | return TRACE_TYPE_PARTIAL_LINE; | ||
2108 | ret = trace_seq_putc(s, '\n'); | ||
2109 | if (!ret) | ||
2110 | return TRACE_TYPE_PARTIAL_LINE; | ||
2111 | break; | ||
2112 | } | ||
2113 | } | ||
2114 | return TRACE_TYPE_HANDLED; | 1596 | return TRACE_TYPE_HANDLED; |
2115 | } | 1597 | } |
2116 | 1598 | ||
@@ -2118,152 +1600,47 @@ static enum print_line_t print_raw_fmt(struct trace_iterator *iter) | |||
2118 | { | 1600 | { |
2119 | struct trace_seq *s = &iter->seq; | 1601 | struct trace_seq *s = &iter->seq; |
2120 | struct trace_entry *entry; | 1602 | struct trace_entry *entry; |
1603 | struct trace_event *event; | ||
2121 | int ret; | 1604 | int ret; |
2122 | int S, T; | ||
2123 | 1605 | ||
2124 | entry = iter->ent; | 1606 | entry = iter->ent; |
2125 | 1607 | ||
2126 | if (entry->type == TRACE_CONT) | ||
2127 | return TRACE_TYPE_HANDLED; | ||
2128 | |||
2129 | ret = trace_seq_printf(s, "%d %d %llu ", | 1608 | ret = trace_seq_printf(s, "%d %d %llu ", |
2130 | entry->pid, iter->cpu, iter->ts); | 1609 | entry->pid, iter->cpu, iter->ts); |
2131 | if (!ret) | 1610 | if (!ret) |
2132 | return TRACE_TYPE_PARTIAL_LINE; | 1611 | return TRACE_TYPE_PARTIAL_LINE; |
2133 | 1612 | ||
2134 | switch (entry->type) { | 1613 | event = ftrace_find_event(entry->type); |
2135 | case TRACE_FN: { | 1614 | if (event && event->raw) { |
2136 | struct ftrace_entry *field; | 1615 | ret = event->raw(s, entry, 0); |
2137 | 1616 | if (ret) | |
2138 | trace_assign_type(field, entry); | 1617 | return ret; |
2139 | 1618 | return TRACE_TYPE_HANDLED; | |
2140 | ret = trace_seq_printf(s, "%x %x\n", | ||
2141 | field->ip, | ||
2142 | field->parent_ip); | ||
2143 | if (!ret) | ||
2144 | return TRACE_TYPE_PARTIAL_LINE; | ||
2145 | break; | ||
2146 | } | ||
2147 | case TRACE_CTX: | ||
2148 | case TRACE_WAKE: { | ||
2149 | struct ctx_switch_entry *field; | ||
2150 | |||
2151 | trace_assign_type(field, entry); | ||
2152 | |||
2153 | T = task_state_char(field->next_state); | ||
2154 | S = entry->type == TRACE_WAKE ? '+' : | ||
2155 | task_state_char(field->prev_state); | ||
2156 | ret = trace_seq_printf(s, "%d %d %c %d %d %d %c\n", | ||
2157 | field->prev_pid, | ||
2158 | field->prev_prio, | ||
2159 | S, | ||
2160 | field->next_cpu, | ||
2161 | field->next_pid, | ||
2162 | field->next_prio, | ||
2163 | T); | ||
2164 | if (!ret) | ||
2165 | return TRACE_TYPE_PARTIAL_LINE; | ||
2166 | break; | ||
2167 | } | ||
2168 | case TRACE_SPECIAL: | ||
2169 | case TRACE_USER_STACK: | ||
2170 | case TRACE_STACK: { | ||
2171 | struct special_entry *field; | ||
2172 | |||
2173 | trace_assign_type(field, entry); | ||
2174 | |||
2175 | ret = trace_seq_printf(s, "# %ld %ld %ld\n", | ||
2176 | field->arg1, | ||
2177 | field->arg2, | ||
2178 | field->arg3); | ||
2179 | if (!ret) | ||
2180 | return TRACE_TYPE_PARTIAL_LINE; | ||
2181 | break; | ||
2182 | } | 1619 | } |
2183 | case TRACE_PRINT: { | 1620 | ret = trace_seq_printf(s, "%d ?\n", entry->type); |
2184 | struct print_entry *field; | 1621 | if (!ret) |
2185 | 1622 | return TRACE_TYPE_PARTIAL_LINE; | |
2186 | trace_assign_type(field, entry); | ||
2187 | 1623 | ||
2188 | trace_seq_printf(s, "# %lx %s", field->ip, field->buf); | ||
2189 | if (entry->flags & TRACE_FLAG_CONT) | ||
2190 | trace_seq_print_cont(s, iter); | ||
2191 | break; | ||
2192 | } | ||
2193 | } | ||
2194 | return TRACE_TYPE_HANDLED; | 1624 | return TRACE_TYPE_HANDLED; |
2195 | } | 1625 | } |
2196 | 1626 | ||
2197 | #define SEQ_PUT_FIELD_RET(s, x) \ | ||
2198 | do { \ | ||
2199 | if (!trace_seq_putmem(s, &(x), sizeof(x))) \ | ||
2200 | return 0; \ | ||
2201 | } while (0) | ||
2202 | |||
2203 | #define SEQ_PUT_HEX_FIELD_RET(s, x) \ | ||
2204 | do { \ | ||
2205 | BUILD_BUG_ON(sizeof(x) > MAX_MEMHEX_BYTES); \ | ||
2206 | if (!trace_seq_putmem_hex(s, &(x), sizeof(x))) \ | ||
2207 | return 0; \ | ||
2208 | } while (0) | ||
2209 | |||
2210 | static enum print_line_t print_hex_fmt(struct trace_iterator *iter) | 1627 | static enum print_line_t print_hex_fmt(struct trace_iterator *iter) |
2211 | { | 1628 | { |
2212 | struct trace_seq *s = &iter->seq; | 1629 | struct trace_seq *s = &iter->seq; |
2213 | unsigned char newline = '\n'; | 1630 | unsigned char newline = '\n'; |
2214 | struct trace_entry *entry; | 1631 | struct trace_entry *entry; |
2215 | int S, T; | 1632 | struct trace_event *event; |
2216 | 1633 | ||
2217 | entry = iter->ent; | 1634 | entry = iter->ent; |
2218 | 1635 | ||
2219 | if (entry->type == TRACE_CONT) | ||
2220 | return TRACE_TYPE_HANDLED; | ||
2221 | |||
2222 | SEQ_PUT_HEX_FIELD_RET(s, entry->pid); | 1636 | SEQ_PUT_HEX_FIELD_RET(s, entry->pid); |
2223 | SEQ_PUT_HEX_FIELD_RET(s, iter->cpu); | 1637 | SEQ_PUT_HEX_FIELD_RET(s, iter->cpu); |
2224 | SEQ_PUT_HEX_FIELD_RET(s, iter->ts); | 1638 | SEQ_PUT_HEX_FIELD_RET(s, iter->ts); |
2225 | 1639 | ||
2226 | switch (entry->type) { | 1640 | event = ftrace_find_event(entry->type); |
2227 | case TRACE_FN: { | 1641 | if (event && event->hex) |
2228 | struct ftrace_entry *field; | 1642 | event->hex(s, entry, 0); |
2229 | 1643 | ||
2230 | trace_assign_type(field, entry); | ||
2231 | |||
2232 | SEQ_PUT_HEX_FIELD_RET(s, field->ip); | ||
2233 | SEQ_PUT_HEX_FIELD_RET(s, field->parent_ip); | ||
2234 | break; | ||
2235 | } | ||
2236 | case TRACE_CTX: | ||
2237 | case TRACE_WAKE: { | ||
2238 | struct ctx_switch_entry *field; | ||
2239 | |||
2240 | trace_assign_type(field, entry); | ||
2241 | |||
2242 | T = task_state_char(field->next_state); | ||
2243 | S = entry->type == TRACE_WAKE ? '+' : | ||
2244 | task_state_char(field->prev_state); | ||
2245 | SEQ_PUT_HEX_FIELD_RET(s, field->prev_pid); | ||
2246 | SEQ_PUT_HEX_FIELD_RET(s, field->prev_prio); | ||
2247 | SEQ_PUT_HEX_FIELD_RET(s, S); | ||
2248 | SEQ_PUT_HEX_FIELD_RET(s, field->next_cpu); | ||
2249 | SEQ_PUT_HEX_FIELD_RET(s, field->next_pid); | ||
2250 | SEQ_PUT_HEX_FIELD_RET(s, field->next_prio); | ||
2251 | SEQ_PUT_HEX_FIELD_RET(s, T); | ||
2252 | break; | ||
2253 | } | ||
2254 | case TRACE_SPECIAL: | ||
2255 | case TRACE_USER_STACK: | ||
2256 | case TRACE_STACK: { | ||
2257 | struct special_entry *field; | ||
2258 | |||
2259 | trace_assign_type(field, entry); | ||
2260 | |||
2261 | SEQ_PUT_HEX_FIELD_RET(s, field->arg1); | ||
2262 | SEQ_PUT_HEX_FIELD_RET(s, field->arg2); | ||
2263 | SEQ_PUT_HEX_FIELD_RET(s, field->arg3); | ||
2264 | break; | ||
2265 | } | ||
2266 | } | ||
2267 | SEQ_PUT_FIELD_RET(s, newline); | 1644 | SEQ_PUT_FIELD_RET(s, newline); |
2268 | 1645 | ||
2269 | return TRACE_TYPE_HANDLED; | 1646 | return TRACE_TYPE_HANDLED; |
@@ -2282,9 +1659,6 @@ static enum print_line_t print_printk_msg_only(struct trace_iterator *iter) | |||
2282 | if (!ret) | 1659 | if (!ret) |
2283 | return TRACE_TYPE_PARTIAL_LINE; | 1660 | return TRACE_TYPE_PARTIAL_LINE; |
2284 | 1661 | ||
2285 | if (entry->flags & TRACE_FLAG_CONT) | ||
2286 | trace_seq_print_cont(s, iter); | ||
2287 | |||
2288 | return TRACE_TYPE_HANDLED; | 1662 | return TRACE_TYPE_HANDLED; |
2289 | } | 1663 | } |
2290 | 1664 | ||
@@ -2292,53 +1666,19 @@ static enum print_line_t print_bin_fmt(struct trace_iterator *iter) | |||
2292 | { | 1666 | { |
2293 | struct trace_seq *s = &iter->seq; | 1667 | struct trace_seq *s = &iter->seq; |
2294 | struct trace_entry *entry; | 1668 | struct trace_entry *entry; |
1669 | struct trace_event *event; | ||
2295 | 1670 | ||
2296 | entry = iter->ent; | 1671 | entry = iter->ent; |
2297 | 1672 | ||
2298 | if (entry->type == TRACE_CONT) | ||
2299 | return TRACE_TYPE_HANDLED; | ||
2300 | |||
2301 | SEQ_PUT_FIELD_RET(s, entry->pid); | 1673 | SEQ_PUT_FIELD_RET(s, entry->pid); |
2302 | SEQ_PUT_FIELD_RET(s, entry->cpu); | 1674 | SEQ_PUT_FIELD_RET(s, entry->cpu); |
2303 | SEQ_PUT_FIELD_RET(s, iter->ts); | 1675 | SEQ_PUT_FIELD_RET(s, iter->ts); |
2304 | 1676 | ||
2305 | switch (entry->type) { | 1677 | event = ftrace_find_event(entry->type); |
2306 | case TRACE_FN: { | 1678 | if (event && event->binary) |
2307 | struct ftrace_entry *field; | 1679 | event->binary(s, entry, 0); |
2308 | |||
2309 | trace_assign_type(field, entry); | ||
2310 | |||
2311 | SEQ_PUT_FIELD_RET(s, field->ip); | ||
2312 | SEQ_PUT_FIELD_RET(s, field->parent_ip); | ||
2313 | break; | ||
2314 | } | ||
2315 | case TRACE_CTX: { | ||
2316 | struct ctx_switch_entry *field; | ||
2317 | |||
2318 | trace_assign_type(field, entry); | ||
2319 | |||
2320 | SEQ_PUT_FIELD_RET(s, field->prev_pid); | ||
2321 | SEQ_PUT_FIELD_RET(s, field->prev_prio); | ||
2322 | SEQ_PUT_FIELD_RET(s, field->prev_state); | ||
2323 | SEQ_PUT_FIELD_RET(s, field->next_pid); | ||
2324 | SEQ_PUT_FIELD_RET(s, field->next_prio); | ||
2325 | SEQ_PUT_FIELD_RET(s, field->next_state); | ||
2326 | break; | ||
2327 | } | ||
2328 | case TRACE_SPECIAL: | ||
2329 | case TRACE_USER_STACK: | ||
2330 | case TRACE_STACK: { | ||
2331 | struct special_entry *field; | ||
2332 | |||
2333 | trace_assign_type(field, entry); | ||
2334 | 1680 | ||
2335 | SEQ_PUT_FIELD_RET(s, field->arg1); | 1681 | return TRACE_TYPE_HANDLED; |
2336 | SEQ_PUT_FIELD_RET(s, field->arg2); | ||
2337 | SEQ_PUT_FIELD_RET(s, field->arg3); | ||
2338 | break; | ||
2339 | } | ||
2340 | } | ||
2341 | return 1; | ||
2342 | } | 1682 | } |
2343 | 1683 | ||
2344 | static int trace_empty(struct trace_iterator *iter) | 1684 | static int trace_empty(struct trace_iterator *iter) |
@@ -3013,6 +2353,7 @@ static int tracing_set_tracer(char *buf) | |||
3013 | if (ret) | 2353 | if (ret) |
3014 | goto out; | 2354 | goto out; |
3015 | } | 2355 | } |
2356 | init_tracer_stat(t); | ||
3016 | 2357 | ||
3017 | trace_branch_enable(tr); | 2358 | trace_branch_enable(tr); |
3018 | out: | 2359 | out: |
@@ -3877,7 +3218,7 @@ __init static int tracer_alloc_buffers(void) | |||
3877 | #else | 3218 | #else |
3878 | current_trace = &nop_trace; | 3219 | current_trace = &nop_trace; |
3879 | #endif | 3220 | #endif |
3880 | 3221 | init_tracer_stat(current_trace); | |
3881 | /* All seems OK, enable tracing */ | 3222 | /* All seems OK, enable tracing */ |
3882 | tracing_disabled = 0; | 3223 | tracing_disabled = 0; |
3883 | 3224 | ||