Re: [PATCH v2 0/4] perf: Make SIGTRAP and __perf_pending_irq() work on RT.

From: Arnaldo Carvalho de Melo
Date: Wed Mar 13 2024 - 15:10:53 EST


On Wed, Mar 13, 2024 at 03:14:28PM -0300, Arnaldo Carvalho de Melo wrote:
> On Wed, Mar 13, 2024 at 12:23:32PM -0300, Arnaldo Carvalho de Melo wrote:
> > On Wed, Mar 13, 2024 at 03:35:27PM +0100, Marco Elver wrote:
> > > On Tue, 12 Mar 2024 at 19:08, Sebastian Andrzej Siewior <bigeasy@xxxxxxxxxxxxx> wrote:
> > > > Arnaldo reported that "perf test sigtrap" fails on PREEMPT_RT. Sending
> > > > the signal gets delayed until event_sched_out() which then uses
> > > > task_work_add() for its delivery. This breaks on PREEMPT_RT because the
> > > > signal is delivered with disabled preemption.
>
> > > > While looking at this, I also stumbled upon __perf_pending_irq() which
> > > > requires disabled interrupts but this is not the case on PREEMPT_RT.
>
> > > > This series aim to address both issues while not introducing a new issue
> > > > at the same time ;)
> > > > Any testing is appreciated.
>
> > > > v1…v2: https://lore.kernel.org/all/20240308175810.2894694-1-bigeasy@xxxxxxxxxxxxx/
> > > > - Marco pointed me to the testsuite that showed two problems:
> > > > - Delayed task_work from NMI / missing events.
> > > > Fixed by triggering dummy irq_work to enforce an interrupt for
> > > > the exit-to-userland path which checks task_work
> > > > - Increased ref-count on clean up/ during exec.
> > > > Mostly addressed by the former change. There is still a window
> > > > if the NMI occurs during execve(). This is addressed by removing
> > > > the task_work before free_event().
> > > > The testsuite (remove_on_exec) fails sometimes if the event/
> > > > SIGTRAP is sent before the sighandler is installed.
> >
> > > Tested-by: Marco Elver <elver@xxxxxxxxxx>

> > > It does pass the tests in tools/testing/selftests/perf_events (non-RT
> > > kernel, lockdep enabled). But I do recall this being a particularly
> > > sharp corner of perf, so any additional testing and review here is
> > > useful.
>
> > Right, I'm testing with the full 'perf test' suite now.
>
> 'perf test' doesn't show any regression, now I'm running Vince Weaver's
> https://github.com/deater/perf_event_tests, storing the results with
> this patchset and then without, to do a diff, lets see...

[root@nine perf_event_tests]# diff -u results.6.8.0-rc7-rt6 results.6.8.0-rc7.sebastian-rt6+ | grep ^[+-]
--- results.6.8.0-rc7-rt6 2024-03-13 15:26:37.923323518 -0300
+++ results.6.8.0-rc7.sebastian-rt6+ 2024-03-13 15:14:11.505333801 -0300
-Linux nine 6.8.0-rc7-rt6 #1 SMP PREEMPT_RT Fri Mar 8 17:36:48 -03 2024 x86_64 x86_64 x86_64 GNU/Linux
+Linux nine 6.8.0-rc7.sebastian-rt6+ #2 SMP PREEMPT_RT Tue Mar 12 18:01:31 -03 2024 x86_64 x86_64 x86_64 GNU/Linux
- Testing "branch-misses" generalized event... FAILED
+ Testing "branch-misses" generalized event... PASSED
- Testing uncore events... SKIPPED
+ Testing uncore events... PASSED
- We are running release 6.8.0-rc7-rt6
+ We are running release 6.8.0-rc7.sebastian-rt6+
- Running on CPU 4
+ Running on CPU 2
- Running on CPU 6
+ Running on CPU 2
- Measuring on CPU 5
-Running on CPU 6
-Measuring on CPU 5
+ Measuring on CPU 6
+Running on CPU 2
+Measuring on CPU 6
[root@nine perf_event_tests]#

So basically:

- Testing "branch-misses" generalized event... FAILED
+ Testing "branch-misses" generalized event... PASSED
- Testing uncore events... SKIPPED
+ Testing uncore events... PASSED

So things improved! I'll re-run to see if these results are stable...

- Arnaldo