Skip to content

Commit 52a7f16

Browse files
tzanussirostedt
authored andcommitted
tracing: Add support for multiple hist triggers per event
Allow users to define any number of hist triggers per trace event. Any number of hist triggers may be added for a given event, which may differ by key, value, or filter. Reading the event's 'hist' file will display the output of all the hist triggers defined on an event concatenated in the order they were defined. Link: http://lkml.kernel.org/r/48a0c8dd34c344571de880fb35e211c6d9a28961.1457029949.git.tom.zanussi@linux.intel.com Signed-off-by: Tom Zanussi <[email protected]> Tested-by: Masami Hiramatsu <[email protected]> Reviewed-by: Namhyung Kim <[email protected]> Signed-off-by: Steven Rostedt <[email protected]>
1 parent 0fc3813 commit 52a7f16

File tree

3 files changed

+293
-41
lines changed

3 files changed

+293
-41
lines changed

Documentation/trace/events.txt

Lines changed: 148 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -550,12 +550,14 @@ The following commands are supported:
550550

551551
'hist' triggers add a 'hist' file to each event's subdirectory.
552552
Reading the 'hist' file for the event will dump the hash table in
553-
its entirety to stdout. Each printed hash table entry is a simple
554-
list of the keys and values comprising the entry; keys are printed
555-
first and are delineated by curly braces, and are followed by the
556-
set of value fields for the entry. By default, numeric fields are
557-
displayed as base-10 integers. This can be modified by appending
558-
any of the following modifiers to the field name:
553+
its entirety to stdout. If there are multiple hist triggers
554+
attached to an event, there will be a table for each trigger in the
555+
output. Each printed hash table entry is a simple list of the keys
556+
and values comprising the entry; keys are printed first and are
557+
delineated by curly braces, and are followed by the set of value
558+
fields for the entry. By default, numeric fields are displayed as
559+
base-10 integers. This can be modified by appending any of the
560+
following modifiers to the field name:
559561

560562
.hex display a number as a hex value
561563
.sym display an address as a symbol
@@ -1667,3 +1669,143 @@ The following commands are supported:
16671669
.
16681670
.
16691671
.
1672+
1673+
The following example demonstrates how multiple hist triggers can be
1674+
attached to a given event. This capability can be useful for
1675+
creating a set of different summaries derived from the same set of
1676+
events, or for comparing the effects of different filters, among
1677+
other things.
1678+
1679+
# echo 'hist:keys=skbaddr.hex:vals=len if len < 0' >> \
1680+
/sys/kernel/debug/tracing/events/net/netif_receive_skb/trigger
1681+
# echo 'hist:keys=skbaddr.hex:vals=len if len > 4096' >> \
1682+
/sys/kernel/debug/tracing/events/net/netif_receive_skb/trigger
1683+
# echo 'hist:keys=skbaddr.hex:vals=len if len == 256' >> \
1684+
/sys/kernel/debug/tracing/events/net/netif_receive_skb/trigger
1685+
# echo 'hist:keys=skbaddr.hex:vals=len' >> \
1686+
/sys/kernel/debug/tracing/events/net/netif_receive_skb/trigger
1687+
# echo 'hist:keys=len:vals=common_preempt_count' >> \
1688+
/sys/kernel/debug/tracing/events/net/netif_receive_skb/trigger
1689+
1690+
The above set of commands create four triggers differing only in
1691+
their filters, along with a completely different though fairly
1692+
nonsensical trigger. Note that in order to append multiple hist
1693+
triggers to the same file, you should use the '>>' operator to
1694+
append them ('>' will also add the new hist trigger, but will remove
1695+
any existing hist triggers beforehand).
1696+
1697+
Displaying the contents of the 'hist' file for the event shows the
1698+
contents of all five histograms:
1699+
1700+
# cat /sys/kernel/debug/tracing/events/net/netif_receive_skb/hist
1701+
1702+
# event histogram
1703+
#
1704+
# trigger info: hist:keys=len:vals=hitcount,common_preempt_count:sort=hitcount:size=2048 [active]
1705+
#
1706+
1707+
{ len: 176 } hitcount: 1 common_preempt_count: 0
1708+
{ len: 223 } hitcount: 1 common_preempt_count: 0
1709+
{ len: 4854 } hitcount: 1 common_preempt_count: 0
1710+
{ len: 395 } hitcount: 1 common_preempt_count: 0
1711+
{ len: 177 } hitcount: 1 common_preempt_count: 0
1712+
{ len: 446 } hitcount: 1 common_preempt_count: 0
1713+
{ len: 1601 } hitcount: 1 common_preempt_count: 0
1714+
.
1715+
.
1716+
.
1717+
{ len: 1280 } hitcount: 66 common_preempt_count: 0
1718+
{ len: 116 } hitcount: 81 common_preempt_count: 40
1719+
{ len: 708 } hitcount: 112 common_preempt_count: 0
1720+
{ len: 46 } hitcount: 221 common_preempt_count: 0
1721+
{ len: 1264 } hitcount: 458 common_preempt_count: 0
1722+
1723+
Totals:
1724+
Hits: 1428
1725+
Entries: 147
1726+
Dropped: 0
1727+
1728+
1729+
# event histogram
1730+
#
1731+
# trigger info: hist:keys=skbaddr.hex:vals=hitcount,len:sort=hitcount:size=2048 [active]
1732+
#
1733+
1734+
{ skbaddr: ffff8800baee5e00 } hitcount: 1 len: 130
1735+
{ skbaddr: ffff88005f3d5600 } hitcount: 1 len: 1280
1736+
{ skbaddr: ffff88005f3d4900 } hitcount: 1 len: 1280
1737+
{ skbaddr: ffff88009fed6300 } hitcount: 1 len: 115
1738+
{ skbaddr: ffff88009fe0ad00 } hitcount: 1 len: 115
1739+
{ skbaddr: ffff88008cdb1900 } hitcount: 1 len: 46
1740+
{ skbaddr: ffff880064b5ef00 } hitcount: 1 len: 118
1741+
{ skbaddr: ffff880044e3c700 } hitcount: 1 len: 60
1742+
{ skbaddr: ffff880100065900 } hitcount: 1 len: 46
1743+
{ skbaddr: ffff8800d46bd500 } hitcount: 1 len: 116
1744+
{ skbaddr: ffff88005f3d5f00 } hitcount: 1 len: 1280
1745+
{ skbaddr: ffff880100064700 } hitcount: 1 len: 365
1746+
{ skbaddr: ffff8800badb6f00 } hitcount: 1 len: 60
1747+
.
1748+
.
1749+
.
1750+
{ skbaddr: ffff88009fe0be00 } hitcount: 27 len: 24677
1751+
{ skbaddr: ffff88009fe0a400 } hitcount: 27 len: 23052
1752+
{ skbaddr: ffff88009fe0b700 } hitcount: 31 len: 25589
1753+
{ skbaddr: ffff88009fe0b600 } hitcount: 32 len: 27326
1754+
{ skbaddr: ffff88006a462800 } hitcount: 68 len: 71678
1755+
{ skbaddr: ffff88006a463700 } hitcount: 70 len: 72678
1756+
{ skbaddr: ffff88006a462b00 } hitcount: 71 len: 77589
1757+
{ skbaddr: ffff88006a463600 } hitcount: 73 len: 71307
1758+
{ skbaddr: ffff88006a462200 } hitcount: 81 len: 81032
1759+
1760+
Totals:
1761+
Hits: 1451
1762+
Entries: 318
1763+
Dropped: 0
1764+
1765+
1766+
# event histogram
1767+
#
1768+
# trigger info: hist:keys=skbaddr.hex:vals=hitcount,len:sort=hitcount:size=2048 if len == 256 [active]
1769+
#
1770+
1771+
1772+
Totals:
1773+
Hits: 0
1774+
Entries: 0
1775+
Dropped: 0
1776+
1777+
1778+
# event histogram
1779+
#
1780+
# trigger info: hist:keys=skbaddr.hex:vals=hitcount,len:sort=hitcount:size=2048 if len > 4096 [active]
1781+
#
1782+
1783+
{ skbaddr: ffff88009fd2c300 } hitcount: 1 len: 7212
1784+
{ skbaddr: ffff8800d2bcce00 } hitcount: 1 len: 7212
1785+
{ skbaddr: ffff8800d2bcd700 } hitcount: 1 len: 7212
1786+
{ skbaddr: ffff8800d2bcda00 } hitcount: 1 len: 21492
1787+
{ skbaddr: ffff8800ae2e2d00 } hitcount: 1 len: 7212
1788+
{ skbaddr: ffff8800d2bcdb00 } hitcount: 1 len: 7212
1789+
{ skbaddr: ffff88006a4df500 } hitcount: 1 len: 4854
1790+
{ skbaddr: ffff88008ce47b00 } hitcount: 1 len: 18636
1791+
{ skbaddr: ffff8800ae2e2200 } hitcount: 1 len: 12924
1792+
{ skbaddr: ffff88005f3e1000 } hitcount: 1 len: 4356
1793+
{ skbaddr: ffff8800d2bcdc00 } hitcount: 2 len: 24420
1794+
{ skbaddr: ffff8800d2bcc200 } hitcount: 2 len: 12996
1795+
1796+
Totals:
1797+
Hits: 14
1798+
Entries: 12
1799+
Dropped: 0
1800+
1801+
1802+
# event histogram
1803+
#
1804+
# trigger info: hist:keys=skbaddr.hex:vals=hitcount,len:sort=hitcount:size=2048 if len < 0 [active]
1805+
#
1806+
1807+
1808+
Totals:
1809+
Hits: 0
1810+
Entries: 0
1811+
Dropped: 0

kernel/trace/trace.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3856,9 +3856,11 @@ static const char readme_msg[] =
38563856
"\t sort field. The 'size' parameter can be used to specify more\n"
38573857
"\t or fewer than the default 2048 entries for the hashtable size.\n\n"
38583858
"\t Reading the 'hist' file for the event will dump the hash\n"
3859-
"\t table in its entirety to stdout. The default format used to\n"
3860-
"\t display a given field can be modified by appending any of the\n"
3861-
"\t following modifiers to the field name, as applicable:\n\n"
3859+
"\t table in its entirety to stdout. If there are multiple hist\n"
3860+
"\t triggers attached to an event, there will be a table for each\n"
3861+
"\t trigger in the output. The default format used to display a\n"
3862+
"\t given field can be modified by appending any of the following\n"
3863+
"\t modifiers to the field name, as applicable:\n\n"
38623864
"\t .hex display a number as a hex value\n"
38633865
"\t .sym display an address as a symbol\n"
38643866
"\t .sym-offset display an address as a symbol and offset\n"

0 commit comments

Comments
 (0)