Re: [bug report][stable] perf probe: failed to add events

From: Adrian Hunter
Date: Wed Feb 27 2019 - 07:41:29 EST


On 26/02/19 4:20 PM, Arnaldo Carvalho de Melo wrote:
> Em Tue, Feb 26, 2019 at 02:08:02PM +0100, Greg KH escreveu:
>> On Tue, Feb 26, 2019 at 08:32:34PM +0800, Joseph Qi wrote:
>>>
>>>
>>> On 19/2/26 17:05, Greg KH wrote:
>>>> On Tue, Feb 26, 2019 at 03:31:14PM +0800, Joseph Qi wrote:
>>>>> Hi,
>>>>>
>>>>> I'm using kernel v4.19.24 and have found that there is an issue when
>>>>> using perf probe to define a new dynamic tracepoint.
>>>>>
>>>>> $ perf probe -a handle_mm_fault
>>>>> Failed to write event: Numerical result out of range
>>>>> Error: Failed to add events.
>>>>>
>>>>> I've also tried kernel v4.20, and it can pass.
>>>>
>>>> Ick, has this ever worked on the 4.19 stable tree? If so, any chance
>>>> you can run 'git bisect' to find the offending commit?
>>>>
>>> >From my test, v4.19.0 also has this issue.
>>> Bisect locates that it is introduced by commit bf904d2762ee
>>> "x86/pti/64: Remove the SYSCALL64 entry trampoline".
>>
>> But that commit was in 4.20, not 4.19. So if this never worked, it's
>> not a regression?
>>
>> confused,
>
> Adrian, Ideas?
>

Seems to be fixed by this:

From: Adrian Hunter <adrian.hunter@xxxxxxxxx>
Date: Wed, 27 Feb 2019 05:35:25 +0200
Subject: [PATCH] perf probe: Fix getting the kernel map

Since commit 4d99e4136580 ("perf machine: Workaround missing maps for x86
PTI entry trampolines"), perf tools has been creating more than one kernel
map, however 'perf probe' assumed there could be only one.

Fix by using machine__kernel_map() to get the main kernel map.

Signed-off-by: Adrian Hunter <adrian.hunter@xxxxxxxxx>
Fixes: 4d99e4136580 ("perf machine: Workaround missing maps for x86 PTI entry trampolines")
---
tools/perf/util/probe-event.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/tools/perf/util/probe-event.c b/tools/perf/util/probe-event.c
index e86f8be89157..6cd96f9b346d 100644
--- a/tools/perf/util/probe-event.c
+++ b/tools/perf/util/probe-event.c
@@ -157,8 +157,10 @@ static struct map *kernel_get_module_map(const char *module)
if (module && strchr(module, '/'))
return dso__new_map(module);

- if (!module)
- module = "kernel";
+ if (!module) {
+ pos = machine__kernel_map(host_machine);
+ return map__get(pos);
+ }

for (pos = maps__first(maps); pos; pos = map__next(pos)) {
/* short_name is "[module]" */
--
2.19.1