Re: [PATCH v3 4/8] perf trace: Filter enum arguments with enum names
From: Howard Chu
Date: Fri Jun 28 2024 - 10:45:07 EST
Hello,
Making this error message better is great for user experience. I will
implement this.
Thanks,
Howard
On Fri, Jun 28, 2024 at 10:41 PM Arnaldo Carvalho de Melo
<acme@xxxxxxxxxx> wrote:
>
> On Tue, Jun 25, 2024 at 02:13:41AM +0800, Howard Chu wrote:
> > Before:
> >
> > perf $ ./perf trace -e timer:hrtimer_start --filter='mode!=HRTIMER_MODE_ABS_PINNED_HARD' --max-events=1
> > No resolver (strtoul) for "mode" in "timer:hrtimer_start", can't set filter "(mode!=HRTIMER_MODE_ABS_PINNED_HARD) && (common_pid != 281988)"
> >
> > After:
> >
> > perf $ ./perf trace -e timer:hrtimer_start --filter='mode!=HRTIMER_MODE_ABS_PINNED_HARD' --max-events=1
> > 0.000 :0/0 timer:hrtimer_start(hrtimer: 0xffff9498a6ca5f18, function: 0xffffffffa77a5be0, expires: 12351248764875, softexpires: 12351248764875, mode: HRTIMER_MODE_ABS)
> >
> > && and ||:
> >
> > perf $ ./perf trace -e timer:hrtimer_start --filter='mode != HRTIMER_MODE_ABS_PINNED_HARD && mode != HRTIMER_MODE_ABS' --max-events=1
> > 0.000 Hyprland/534 timer:hrtimer_start(hrtimer: 0xffff9497801a84d0, function: 0xffffffffc04cdbe0, expires: 12639434638458, softexpires: 12639433638458, mode: HRTIMER_MODE_REL)
> >
> > perf $ ./perf trace -e timer:hrtimer_start --filter='mode == HRTIMER_MODE_REL || mode == HRTIMER_MODE_PINNED' --max-events=1
> > 0.000 ldlck-test/60639 timer:hrtimer_start(hrtimer: 0xffffb16404ee7bf8, function: 0xffffffffa7790420, expires: 12772614418016, softexpires: 12772614368016, mode: HRTIMER_MODE_REL)
> >
> > Switching it up, using both enum name and integer value(--filter='mode == HRTIMER_MODE_ABS_PINNED_HARD || mode == 0'):
> >
> > perf $ ./perf trace -e timer:hrtimer_start --filter='mode == HRTIMER_MODE_ABS_PINNED_HARD || mode == 0' --max-events=3
> > 0.000 :0/0 timer:hrtimer_start(hrtimer: 0xffff9498a6ca5f18, function: 0xffffffffa77a5be0, expires: 12601748739825, softexpires: 12601748739825, mode: HRTIMER_MODE_ABS_PINNED_HARD)
> > 0.036 :0/0 timer:hrtimer_start(hrtimer: 0xffff9498a6ca5f18, function: 0xffffffffa77a5be0, expires: 12518758748124, softexpires: 12518758748124, mode: HRTIMER_MODE_ABS_PINNED_HARD)
> > 0.172 tmux: server/41881 timer:hrtimer_start(hrtimer: 0xffffb164081e7838, function: 0xffffffffa7790420, expires: 12518768255836, softexpires: 12518768205836, mode: HRTIMER_MODE_ABS)
> >
> > P.S.
> > perf $ pahole hrtimer_mode
> > enum hrtimer_mode {
> > HRTIMER_MODE_ABS = 0,
> > HRTIMER_MODE_REL = 1,
> > HRTIMER_MODE_PINNED = 2,
> > HRTIMER_MODE_SOFT = 4,
> > HRTIMER_MODE_HARD = 8,
> > HRTIMER_MODE_ABS_PINNED = 2,
> > HRTIMER_MODE_REL_PINNED = 3,
> > HRTIMER_MODE_ABS_SOFT = 4,
> > HRTIMER_MODE_REL_SOFT = 5,
> > HRTIMER_MODE_ABS_PINNED_SOFT = 6,
> > HRTIMER_MODE_REL_PINNED_SOFT = 7,
> > HRTIMER_MODE_ABS_HARD = 8,
> > HRTIMER_MODE_REL_HARD = 9,
> > HRTIMER_MODE_ABS_PINNED_HARD = 10,
> > HRTIMER_MODE_REL_PINNED_HARD = 11,
> > };
> >
> > Committer testing:
>
> Further testing:
>
> root@number:~# perf trace -e timer:hrtimer_start --filter='mode != HRTIMER_MODE_ABS_PINNED_WRONG'
> "HRTIMER_MODE_ABS_PINNED_WRONG" not found for "mode" in "timer:hrtimer_start", can't set filter "(mode != HRTIMER_MODE_ABS_PINNED_WRONG) && (common_pid != 103306 && common_pid != 3476)"
> root@number:~#
>
> Maybe we can list the possibilities, i.e. print all of 'enum
> hrtimer_mode'
>
> This can be on a followup patch, just recording the idea here.
>
> - Arnaldo