Re: [PATCH v4] s390/pai: Handle multiple PMU stop callback invocations

Vasily Gorbik <[email protected]>
Newsgroups org.kernel.vger.linux-s390
Message-ID <[email protected]>
On Wed, Aug 19, 2026 at 07:58:55AM +0200, Thomas Richter wrote:
> Handle the following scenario:
> The kernel protects itself against a very high sampling load and
> throttles the sampling using:
> 
>   perf_event_throttle() --> PMU->stop()
> 
> Shortly later the scheduler may terminate the task and removes it from the
> CPU. It again calls
> 
>   PMU->stop()
> 
> which results in two invocations of PMU->stop() called back to back.
> Protect against this and check the PERF_HES_STOPPED bit on function
> entry.  If it is already set return.
> Clear bit PERF_HES_STOPPED in PMU->start().
> 
> Prohibit ioctl(fd, PERF_EVENT_IOC_PERIOD, ...) call for this event.
> It sets perf_event::event_limit to a positive value and causes
> perf_event_overflow() to invoke pai_stop() call back function when
> perf_event::event_limit hits zero. This is not supported because the
> sample events CRYPTO_ALL and NNPA_ALL are only taken at schedule out
> of a task.
> 
> Use list_for_each_entry_safe() for safe iteration over syswide_list
> in pai_have_samples().
> 
>  #Cc: [email protected] # v6.19+
> Fixes: 9f66572f2889 ("s390/pai_crypto: Enable per-task and system-wide sampling event")
> Fixes: 582cc1b28e8c ("s390/pai_ext: Enable per-task and system-wide sampling event")
> Signed-off-by: Thomas Richter <[email protected]>
> Reviewed-by: Sumanth Korikkar <[email protected]>
> Suggested-by: Heiko Carstens <[email protected]>
> ---
>  arch/s390/kernel/perf_pai.c | 25 +++++++++++++++++++++++--
>  1 file changed, 23 insertions(+), 2 deletions(-)

Applied, thank you!
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.