Re: [PATCH V6 13/15] perf intel-pt: Add support for text poke events
From: Adrian Hunter
Date: Tue Apr 21 2020 - 09:11:14 EST
On 21/04/20 4:06 pm, Jiri Olsa wrote:
> On Tue, Apr 21, 2020 at 04:02:32PM +0300, Adrian Hunter wrote:
>> On 21/04/20 3:50 pm, Jiri Olsa wrote:
>>> On Sun, Apr 05, 2020 at 11:13:25PM +0300, Adrian Hunter wrote:
>>>> Select text poke events when available and the kernel is being traced.
>>>> Process text poke events to invalidate entries in Intel PT's instruction
>>>> cache.
>>>>
>>>> Example:
>>>>
>>>> The example requires kernel config:
>>>> CONFIG_PROC_SYSCTL=y
>>>> CONFIG_SCHED_DEBUG=y
>>>> CONFIG_SCHEDSTATS=y
>>>>
>>>> Before:
>>>>
>>>> # perf record -o perf.data.before --kcore -a -e intel_pt//k -m,64M &
>>>> # cat /proc/sys/kernel/sched_schedstats
>>>> 0
>>>> # echo 1 > /proc/sys/kernel/sched_schedstats
>>>> # cat /proc/sys/kernel/sched_schedstats
>>>> 1
>>>> # echo 0 > /proc/sys/kernel/sched_schedstats
>>>> # cat /proc/sys/kernel/sched_schedstats
>>>> 0
>>>> # kill %1
>>>> [ perf record: Woken up 1 times to write data ]
>>>> [ perf record: Captured and wrote 3.341 MB perf.data.before ]
>>>> [1]+ Terminated perf record -o perf.data.before --kcore -a -e intel_pt//k -m,64M
>>>> # perf script -i perf.data.before --itrace=e >/dev/null
>>>> Warning:
>>>> 474 instruction trace errors
>>>>
>>>> After:
>>>>
>>>> # perf record -o perf.data.after --kcore -a -e intel_pt//k -m,64M &
>>>> # cat /proc/sys/kernel/sched_schedstats
>>>> 0
>>>> # echo 1 > /proc/sys/kernel/sched_schedstats
>>>> # cat /proc/sys/kernel/sched_schedstats
>>>> 1
>>>> # echo 0 > /proc/sys/kernel/sched_schedstats
>>>> # cat /proc/sys/kernel/sched_schedstats
>>>> 0
>>>> # kill %1
>>>> [ perf record: Woken up 1 times to write data ]
>>>> [ perf record: Captured and wrote 2.646 MB perf.data.after ]
>>>> [1]+ Terminated perf record -o perf.data.after --kcore -a -e intel_pt//k -m,64M
>>>> # perf script -i perf.data.after --itrace=e >/dev/null
>>>
>>>
>>> I'm still seeing some, probably I'm missing some CONFIG, will check
>>>
>>> # ./perf record -o perf.data.after --kcore -a -e intel_pt//k -m,64M &
>>> [1] 5880
>>> # cat /proc/sys/kernel/sched_schedstats
>>> 0
>>> # echo 1 > /proc/sys/kernel/sched_schedstats
>>> # cat /proc/sys/kernel/sched_schedstats
>>> 1
>>> # echo 0 > /proc/sys/kernel/sched_schedstats
>>> # kill %1
>>> # [ perf record: Woken up 1 times to write data ]
>>> [ perf record: Captured and wrote 6.181 MB perf.data.after ]
>>> [1]+ Terminated ./perf record -o perf.data.after --kcore -a -e intel_pt//k -m,64M
>>> # ./perf script --itrace=e -i perf.data.after > /dev/null
>>> Warning:
>>> 18837 instruction trace errors
>>>
>>> # ./perf script --itrace=e -i perf.data.after | head
>>> instruction trace error type 1 time 9274.420582345 cpu 9 pid 845 tid 845 ip 0xffffffff814e6cf2 code 6: Trace doesn't match instruction
>>> instruction trace error type 1 time 9274.422229726 cpu 39 pid 5880 tid 5880 ip 0xffffffffa030a320 code 6: Trace doesn't match instruction
>>> instruction trace error type 1 time 9274.422231972 cpu 39 pid 5880 tid 5880 ip 0xffffffffa0315c1c code 6: Trace doesn't match instruction
>>> instruction trace error type 1 time 9274.422236141 cpu 39 pid 5880 tid 5880 ip 0xffffffff81143263 code 6: Trace doesn't match instruction
>>> instruction trace error type 1 time 9274.422237424 cpu 39 pid 5880 tid 5880 ip 0xffffffff8115c388 code 6: Trace doesn't match instruction
>>> instruction trace error type 1 time 9274.422239028 cpu 39 pid 5880 tid 5880 ip 0xffffffff811428c9 code 6: Trace doesn't match instruction
>>> instruction trace error type 1 time 9274.422239028 cpu 39 pid 5880 tid 5880 ip 0xffffffffa13279fb code 5: Failed to get instruction
>>> instruction trace error type 1 time 9274.422242556 cpu 39 pid 5880 tid 5880 ip 0xffffffff814e9c73 code 6: Trace doesn't match instruction
>>> instruction trace error type 1 time 9274.422258915 cpu 39 pid 5880 tid 5880 ip 0xffffffff810d7da2 code 6: Trace doesn't match instruction
>>> instruction trace error type 1 time 9274.422258915 cpu 39 pid 5880 tid 5880 ip 0xffffffffa030a0b2 code 6: Trace doesn't match instruction
>>
>> I don't think it can be CONFIG. Can you share the branch you are using?
>> Then I can test it.
>>
>
> I built the one you mentioned in cover email:
> git://git.infradead.org/users/ahunter/linux-perf.git text_poke
The tools and the kernel?
Does it successfully decode anything? e.g.
./perf script --itrace=be -i perf.data.after | head