tracing mini-HOWTO

tracing mini-HOWTO:

# echo 0 > tracing_on:禁用跟踪的快速方法
# echo 1 > tracing_on:重新启用跟踪的快速方法

Important files:
 trace                  - 缓冲区的静态内容
							要清空缓冲区,请写入该文件:echo > trace
 trace_pipe 		    - 一个消耗读取来查看缓冲区的内容
 current_tracer 		- 函数和延迟跟踪器
 available_tracers 		- 为 current_tracer 配置的跟踪程序列表
 error_log 				- 失败命令的错误日志(支持它)
 buffer_size_kb 		- 查看和修改每个 CPU 缓冲区的大小
 buffer_total_size_kb 	- 查看所有 CPU 缓冲区的总大小
 
 trace_clock 			-更改用于排序事件的时钟
		 local:		每个cpu时钟,但可能不会跨 cpu 同步
		global:		跨cpu同步,但会减慢跟踪速度。
	   counter:		不是时钟,只是一个增量
		uptime:		从开机时间开始快速计时
		  perf:		与perf事件使用的时钟相同
		
 timestamp_mode 		-查看用于时间戳事件的模式
	     delta:		与缓冲区范围的时间戳的差值
	  absolute:		绝对(独立)时间戳
	   
 trace_marker 			-写入这个文件,写到内核缓冲区
 
 trace_marker_raw 		-写入该文件将二进制数据写入内核缓冲区
 tracing_cpumask 		-限制要跟踪的 cpu
 instances 				-使用:mkdir instances/foo 创建子缓冲区
						 用 rmdir 删除子缓冲区
 trace_options 			-设置格式或修改跟踪发生的方式
						前缀'no'来禁用一个选项
						选项名称
						
 saved_cmdlines_size 	- echo command number > saved_cmdlines_size :存储 comm-pid 列表
 
 snapshot 				-类似于'trace',但显示静态的内容
						 快照缓冲区。阅读内容了解更多内容
						 信息
						 
 dynamic_events 		-创建/追加/删除/显示通用动态事件
						 写入此文件以定义/取消定义新的跟踪事件。					 
 kprobe_events 			-创建/追加/删除/显示内核动态事件
						 写入此文件以定义/取消定义新的跟踪事件。
 uprobe_events 			-创建/追加/删除/显示用户空间动态事件
						 写入此文件以定义/取消定义新的跟踪事件。
						 
		 accepts:  event-definitions (one definition per line)
           Format: p[:[<group>/]<event>] <place> [<args>]
                   r[maxactive][:[<group>/]<event>] <place> [<args>]
                   s:[synthetic/]<event> <field> [<field>]
                   -:[<group>/]<event>
            place: [<module>:]<symbol>[+<offset>]|<memaddr>
place (kretprobe): [<module>:]<symbol>[+<offset>]%return|<memaddr>
   place (uprobe): <path>:<offset>[%return][(ref_ctr_offset)]
             args: <name>=fetcharg[:type]
         fetcharg: %<register>, @<address>, @<symbol>[+|-<offset>],
                   $stack<index>, $stack, $retval, $comm, $arg<N>,
                   +|-[u]<offset>(<fetcharg>), \imm-value, \"imm-string"
             type: s8/16/32/64, u8/16/32/64, x8/16/32/64, string, symbol,
                   b<bit-width>@<bit-offset>/<container-size>, ustring,
                   <type>\[<array-size>\]
            field: <stype> <name>;
            stype: u8/u16/u32/u64, s8/s16/s32/s64, pid_t,
                   [unsigned] char/int/long
  events/               - Directory containing all trace event subsystems:
      enable            - Write 0/1 to enable/disable tracing of all events
  events/<system>/      - Directory containing all trace events for <system>:
      enable            - Write 0/1 to enable/disable tracing of all <system>
                          events
      filter            - If set, only events passing filter are traced
  events/<system>/<event>/      - Directory containing control files for
                          <event>:
      enable            - Write 0/1 to enable/disable tracing of <event>
      filter            - If set, only events passing filter are traced
      trigger           - If set, a command to perform when event is hit
            Format: <trigger>[:count][if <filter>]
           trigger: traceon, traceoff
                    enable_event:<system>:<event>
                    disable_event:<system>:<event>
                    enable_hist:<system>:<event>
                    disable_hist:<system>:<event>
                    stacktrace
                    snapshot
                    hist (see below)
           example: echo traceoff > events/block/block_unplug/trigger
                    echo traceoff:3 > events/block/block_unplug/trigger
                    echo 'enable_event:kmem:kmalloc:3 if nr_rq > 1' > \
                          events/block/block_unplug/trigger
           The first disables tracing every time block_unplug is hit.
           The second disables tracing the first 3 times block_unplug is hit.
           The third enables the kmalloc event the first 3 times block_unplug
             is hit and has value of greater than 1 for the 'nr_rq' event field.
           Like function triggers, the counter is only decremented if it
            enabled or disabled tracing.
           To remove a trigger without a count:
             echo '!<trigger> > <system>/<event>/trigger
           To remove a trigger with a count:
             echo '!<trigger>:0 > <system>/<event>/trigger
           Filters can be ignored when removing a trigger.
      hist trigger      - If set, event hits are aggregated into a hash table
            Format: hist:keys=<field1[,field2,...]>
                    [:values=<field1[,field2,...]>]
                    [:sort=<field1[,field2,...]>]
                    [:size=#entries]
                    [:pause][:continue][:clear]
                    [:name=histname1]
                    [:<handler>.<action>]
                    [if <filter>]

            Note, special fields can be used as well:
                    common_timestamp - to record current timestamp
                    common_cpu - to record the CPU the event happened on

            When a matching event is hit, an entry is added to a hash
            table using the key(s) and value(s) named, and the value of a
            sum called 'hitcount' is incremented.  Keys and values
            correspond to fields in the event's format description.  Keys
            can be any field, or the special string 'stacktrace'.
            Compound keys consisting of up to two fields can be specified
            by the 'keys' keyword.  Values must correspond to numeric
            fields.  Sort keys consisting of up to two fields can be
            specified using the 'sort' keyword.  The sort direction can
            be modified by appending '.descending' or '.ascending' to a
            sort field.  The 'size' parameter can be used to specify more
            or fewer than the default 2048 entries for the hashtable size.
            If a hist trigger is given a name using the 'name' parameter,
            its histogram data will be shared with other triggers of the
            same name, and trigger hits will update this common data.

            Reading the 'hist' file for the event will dump the hash
            table in its entirety to stdout.  If there are multiple hist
            triggers attached to an event, there will be a table for each
            trigger in the output.  The table displayed for a named
            trigger will be the same as any other instance having the
            same name.  The default format used to display a given field
            can be modified by appending any of the following modifiers
            to the field name, as applicable:

                    .hex        display a number as a hex value
                    .sym        display an address as a symbol
                    .sym-offset display an address as a symbol and offset
                    .execname   display a common_pid as a program name
                    .syscall    display a syscall id as a syscall name
                    .log2       display log2 value rather than raw number
                    .usecs      display a common_timestamp in microseconds

            The 'pause' parameter can be used to pause an existing hist
            trigger or to start a hist trigger but not log any events
            until told to do so.  'continue' can be used to start or
            restart a paused hist trigger.

            The 'clear' parameter will clear the contents of a running
            hist trigger and leave its current paused/active state
            unchanged.

            The enable_hist and disable_hist triggers can be used to
            have one event conditionally start and stop another event's
            already-attached hist trigger.  The syntax is analogous to
            the enable_event and disable_event triggers.

            Hist trigger handlers and actions are executed whenever a
            a histogram entry is added or updated.  They take the form:

                <handler>.<action>

            The available handlers are:

                onmatch(matching.event)  - invoke on addition or update
                onmax(var)               - invoke if var exceeds current max
                onchange(var)            - invoke action if var changes

            The available actions are:

                trace(<synthetic_event>,param list)  - generate synthetic event
                save(field,...)                      - save current event fields
                snapshot()                           - snapshot the trace buffer

  events/synthetic_events       - Create/append/remove/show synthetic events
          Write into this file to define/undefine new synthetic events.
             example: echo 'myevent u64 lat; char name[]' >> synthetic_events

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值