[PATCH] tools/lib/api: Check nonfilterable in fdarray__filter()

From: Namhyung Kim

Date: Fri Jul 10 2026 - 15:44:36 EST


IIUC fdarray__filter() should check filterable events only and leave
non-filterable events to be handled outside. The recent change to set
fd to -1 made perf record test stuck forever. Adding the check the flag
fixes the problem for me.

Before:
$ timeout 100 sudo perf test 105
105: perf record tests : Running (1 active)

Signal (15) while running tests.
Terminating tests with the same signal
Internal test harness failure. Completing any started tests:
105: perf record tests : FAILED!

=== Test Summary ===
Passed main tests : 0
Passed subtests : 0
Skipped tests : 0
Failed tests : 1
List of failed tests:
105: perf record tests

After:
$ time sudo perf test 105
105: perf record tests : Ok

=== Test Summary ===
Passed main tests : 1
Passed subtests : 0
Skipped tests : 0
Failed tests : 0

real 0m52.472s
user 0m0.830s
sys 0m0.535s

Fixes:f94563fac269 ("perf record: fix poll storm when monitored threads exit")
Cc: Jiawei Sun <abyssmystery@xxxxxxxxx>
Signed-off-by: Namhyung Kim <namhyung@xxxxxxxxxx>
---
tools/lib/api/fd/array.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/tools/lib/api/fd/array.c b/tools/lib/api/fd/array.c
index ffe8272af59b2da0..b4570e4981492cd7 100644
--- a/tools/lib/api/fd/array.c
+++ b/tools/lib/api/fd/array.c
@@ -117,6 +117,8 @@ int fdarray__filter(struct fdarray *fda, short revents,
for (fd = 0; fd < fda->nr; ++fd) {
if (!fda->entries[fd].events)
continue;
+ if (fda->priv[fd].flags & fdarray_flag__nonfilterable)
+ continue;

if (fda->entries[fd].revents & revents) {
if (entry_destructor)
@@ -132,8 +134,7 @@ int fdarray__filter(struct fdarray *fda, short revents,
continue;
}

- if (!(fda->priv[fd].flags & fdarray_flag__nonfilterable))
- ++nr;
+ ++nr;
}

return nr;
--
2.55.0.795.g602f6c329a-goog