Perf Mem -D Report

Understanding the perf report

Zulan is quite close and all his suggestions should be followed through.

From the man page of perf report:

The command column in the perf report output refers to the process from which the samples were collected. In per-thread/per-process mode, this is always the name of the monitored command. But in cpu-wide mode, the command can vary.

Because you are measuring per-cpu context switch events as can be seen from your perf record ... -cpu=8... command, the perf report command will start to report PID/TID of next/prev task. You can see this here -

per-cpu context switch records pid/tid

Now the value -1 refers to a process which is dead, i.e. the process has gone beyond the state of being a zombie process. This means the task_struct members now point to already freed memory and no dereferencing should be allowed.The do_task_dead method should clearly reflect this.
This is where the pid of the process is being returned as -1 and simultaneously reported in perf report.

There is an extensive discussion on this problem. Initially a value of 0 used to refer to such a process state in the perf report output but as you may have guessed, pid=0 refers to the idle thread and hence a value of -1 is used.

perf-report show value of CPU register

Try perf script data dumping command with the iregs field: perf script -F ip,sym,iregs. All fields -F are documented with source code of tools/perf/builtin-script.c - struct output_option .. all_output_options, and iregs is still here (also OPT_CALLBACK('F', "fields" ... in same file). There is also perf-script.txt documentation - https://github.com/torvalds/linux/blob/master/tools/perf/Documentation/perf-script.txt#L115

-F::
--fields::
Comma separated list of fields to print. Options are:
comm, tid, pid, time, cpu, event, trace, ip, sym, dso, addr, symoff,
srcline, period, iregs, brstack, brstacksym, flags, bpf-output, brstackinsn,
callindent, insn, insnlen. Field list can be prepended with the type, trace, sw or hw,
to indicate to which event type the field list applies.

There were commits into linux kernel git which mention flag --intr-regs. Start from option implementation:

https://github.com/torvalds/linux/search?utf8=%E2%9C%93&q=intr-regs&type=

tools/perf/builtin-record.c
OPT_CALLBACK_OPTARG('I', "intr-regs", &record.opts.sample_intr_regs, NULL, "any register",

Then search for 'sample_intr_regs' in commits: https://github.com/torvalds/linux/search?q=sample_intr_regs&type=Commits

Several commits were about kernel part and perf_attr debug print. But this has example of intr-regs printing (Sep 1, 2015)
https://github.com/torvalds/linux/commit/532026612455a4a6fd27c1b2e7111263f63218a2

Pull perf/core improvements and fixes from Arnaldo Carvalho de Melo:
- Add ability to specify to select which registers to record,
to reduce the size of perf.data files, and also allow printing
the registers in 'perf script': (Stephane Eranian)

  # perf record --intr-regs=AX,SP usleep 1
[ perf record: Woken up 1 times to write data ]
[ perf record: Captured and wrote 0.016 MB perf.data (8 samples) ]
# perf script -F ip,sym,iregs | tail -5
ffffffff8105f42a native_write_msr_safe AX:0xf SP:0xffff8802629c3c00
ffffffff8105f42a native_write_msr_safe AX:0xf SP:0xffff8802629c3c00
ffffffff81761ac0 _raw_spin_lock AX:0xffff8801bfcf8020 SP:0xffff8802629c3ce8
ffffffff81202bf8 __vma_adjust_trans_huge AX:0x7ffc75200000 SP:0xffff8802629c3b30
ffffffff8122b089 dput AX:0x101 SP:0xffff8802629c3c78
#


Related Topics



Leave a reply



Submit