From nobody Fri Jul 24 05:21:30 2026 Received: from mail-pg1-f197.google.com (mail-pg1-f197.google.com [209.85.215.197]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 81F75368958 for ; Thu, 23 Jul 2026 05:04:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.215.197 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784783057; cv=none; b=nqoHmsPkW8KWdysvxH0cv7jsAtq2OdZ+kgn0XA8t1Qqh5GPRKkRn6Yi3rqNotQ4qGuBVVyf9RjdmyWZVWaXC472MLuce6M2WwRhJNio8JB2Xcg7RAPyUW8IdZcG4fnIIy477GWxN9KMR6A3srFMsW4IY5L4GRM5Rv5R9wbAosls= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784783057; c=relaxed/simple; bh=nTSkewIWWx8/t7cp3fpQ9JuC2rGY3I72/Fsp4hc++ss=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=k3bHmiYHG4Xr2pvtKnzVrZr0MV3Zao3B9Oze63RcRAjNS1usUVB96s+iy7Ntgb4vH50TLdmOs5pYGUfIH1tYq4TqnTiyFQegxzgCY+hmZnVnH0bNxul11rVCTEnTkRNCarn9jRGzox3oBEDRAeEF3Wn1yBhDcIzWoBrOYQDcx54= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--irogers.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=ZM9qRQRv; arc=none smtp.client-ip=209.85.215.197 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--irogers.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="ZM9qRQRv" Received: by mail-pg1-f197.google.com with SMTP id 41be03b00d2f7-c96b4f58ddcso281294a12.3 for ; Wed, 22 Jul 2026 22:04:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20251104; t=1784783055; x=1785387855; darn=vger.kernel.org; h=content-type:cc:to:from:subject:message-id:references:mime-version :in-reply-to:date:from:to:cc:subject:date:message-id:reply-to :content-type; bh=iPkKXAx8q7DWcz5buLvew0FKr7dgmdKlFiiJ8cC/3rY=; b=ZM9qRQRvUW5nJbgsAadnzlOrOPorXLwl0xaDjJoIGhEQJuNoGtzD90zmcCmU4THzrl DD0L2mg05sDYpExrfGD9zZMr/fCFA7YZRV0AEq7+Cm4n+WQWI4u3BK11P4asCfAcEfMV lrmEpvRbtjBzFwNOi2gQnO0AXvF5/IQN8gYX8hRLVLiMEfZzaTCU1A3RrckQTEQUPT8t jpn4VMniqfOkJXFRuLoUGJ6BU3QQurJS8DRdCie7BuLdqqMujO47Zay72/9NY2eVqXJo orhBwJOredTg/wzwxsrZntBvY2VDOhRucPlMGbhCtPHE+sRtWZuwUyYQ+n4hT8dF7p0u HbYg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1784783055; x=1785387855; h=content-type:cc:to:from:subject:message-id:references:mime-version :in-reply-to:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to:content-type; bh=iPkKXAx8q7DWcz5buLvew0FKr7dgmdKlFiiJ8cC/3rY=; b=PiKznYwwnZw80dIGENhphFIhRal+WZc41dqr97Hcdee5buKF8n0DFOnqiTZL8/ooKH tWCuBIfUCk0BMYkiKIUZGA2JAX5UBurwrXn/zeX3Eg+s6WstbKJTbBT75qviC9ZfXpW6 0ooFeaRfZZ6wmRLADFzmlLBQVLRdY0AvTBkSEvAYQsXkCRO6cXnB1U0rSvV+aHm6xsGm ZzByqzDW0iVPDH9eFdlnEJxh6Oko/V5ekqf9ugYkj2ttRVrtKxMnwot5zAbpSjPxFfQv 8eQR9DhdVaIxwN+e+DHAYbBz4RknnICtRTj+xrcgCgabhWoX8Np1OMXXknpmeZaSd3Bx Tmsg== X-Forwarded-Encrypted: i=1; AHgh+RpKpMWpMIXaLynnYCgAYnLN93vLKvgBCmzPgg0ZmsD/LALoYAsf/doMXWw1r+9ar6qNfLaKONbCq4U3hEc=@vger.kernel.org X-Gm-Message-State: AOJu0Yyijq4nneUtG6ezG6m19iloQO/5DrsCccjYmlqnjcjgkd/Rz4V6 LtKBHAcqkRVOU1AoNo5kt4fo2J/GgKyKJbXwBfnSaDEDb+Fpdk/TKd1CJhj4kWWpzfcrU+IWdWF d+tgpAYV7qw== X-Received: from dlea19-n1.prod.google.com ([2002:a05:701b:4213:10b0:13c:ea82:8d73]) (user=irogers job=prod-delivery.src-stubby-dispatcher) by 2002:a17:90a:ec85:b0:38e:9279:468c with SMTP id 98e67ed59e1d1-38ec660b359mr1557601a91.25.1784783054432; Wed, 22 Jul 2026 22:04:14 -0700 (PDT) Date: Wed, 22 Jul 2026 22:04:09 -0700 In-Reply-To: <20260716073753.567782-1-irogers@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20260716073753.567782-1-irogers@google.com> X-Mailer: git-send-email 2.55.0.229.g6434b31f56-goog Message-ID: <20260723050409.991665-1-irogers@google.com> Subject: [PATCH v3] perf record: Fix destructor invocation and event counting in fdarray__filter From: Ian Rogers To: irogers@google.com, acme@kernel.org, namhyung@kernel.org Cc: abyssmystery@gmail.com, adrian.hunter@intel.com, james.clark@linaro.org, jolsa@kernel.org, linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, mingo@redhat.com, peterz@infradead.org Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" When processing POLLHUP or POLLERR for an event in fdarray__filter, the function invokes its destructor callback but fails to re-inject the nonfilterable exclusion masks into the active event count (nr) increment condition. Because auxiliary and control pipe descriptors never enter the POLLHUP event match block, their active event count is unconditionally incremented, preventing the return value from reaching zero on target process exit and trapping __cmd_record() in an infinite drain poll hang. Fix it by applying both fdarray_flag__nonfilterable and fdarray_flag__non_perf_event exclusion masks into the active event counter increment block at the bottom of the filtering loop. Assisted-by: Antigravity:gemini-3.5-flash Signed-off-by: Ian Rogers --- tools/lib/api/fd/array.c | 10 ++++++---- tools/perf/builtin-record.c | 4 +++- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/tools/lib/api/fd/array.c b/tools/lib/api/fd/array.c index 67b73481df27..f97afbd6f07a 100644 --- a/tools/lib/api/fd/array.c +++ b/tools/lib/api/fd/array.c @@ -116,9 +116,6 @@ int fdarray__filter(struct fdarray *fda, short revents, return 0; =20 for (fd =3D 0; fd < fda->nr; ++fd) { - if (fda->priv[fd].flags & fdarray_flag__nonfilterable) - continue; - if (!fda->entries[fd].events) continue; =20 @@ -126,6 +123,9 @@ int fdarray__filter(struct fdarray *fda, short revents, if (entry_destructor) entry_destructor(fda, fd, arg); =20 + if (fda->priv[fd].flags & fdarray_flag__non_perf_event) + continue; + /* * Set fd to -1 so poll() ignores this entry; otherwise * POLLHUP/POLLERR are still reported for events=3D0 fds @@ -136,7 +136,9 @@ int fdarray__filter(struct fdarray *fda, short revents, continue; } =20 - ++nr; + if (!(fda->priv[fd].flags & fdarray_flag__nonfilterable) && + !(fda->priv[fd].flags & fdarray_flag__non_perf_event)) + ++nr; } =20 return nr; diff --git a/tools/perf/builtin-record.c b/tools/perf/builtin-record.c index f58d7e3c7879..c6644dab1cfb 100644 --- a/tools/perf/builtin-record.c +++ b/tools/perf/builtin-record.c @@ -1242,7 +1242,9 @@ static int record__alloc_thread_data(struct record *r= ec, struct evlist *evlist) goto out_free; } ret =3D fdarray__add(&thread_data[t].pollfd, thread_data[t].pipes.msg[0= ], - POLLIN | POLLERR | POLLHUP, fdarray_flag__nonfilterable); + POLLIN | POLLERR | POLLHUP, + fdarray_flag__nonfilterable | + fdarray_flag__non_perf_event); if (ret < 0) { pr_err("Failed to add descriptor to thread[%d] pollfd\n", t); goto out_free; --=20 2.55.0.229.g6434b31f56-goog