mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Peter Zijlstra <peterz@infradead.org>
To: "Mi, Dapeng" <dapeng1.mi@linux.intel.com>
Cc: mingo@kernel.org, ravi.bangoria@amd.com,
	lucas.demarchi@intel.com, linux-kernel@vger.kernel.org,
	acme@kernel.org, namhyung@kernel.org, mark.rutland@arm.com,
	alexander.shishkin@linux.intel.com, jolsa@kernel.org,
	irogers@google.com, adrian.hunter@intel.com,
	kan.liang@linux.intel.com, james.clark@linaro.org
Subject: Re: [PATCH v3 7/7] perf: Make perf_pmu_unregister() useable
Date: Thu, 17 Apr 2025 10:07:25 +0200	[thread overview]
Message-ID: <20250417080725.GH38216@noisy.programming.kicks-ass.net> (raw)
In-Reply-To: <a0e3eccd-314a-4073-a570-0fe7b27c25c8@linux.intel.com>

On Mon, Apr 14, 2025 at 08:37:07AM +0800, Mi, Dapeng wrote:

> It seems this patch would break the task attached events counting like the
> below command shows.
> 

Right, found another report for that yesterday.

---
Subject: perf: Fix perf-stat / read()
From: Peter Zijlstra <peterz@infradead.org>
Date: Wed Apr 16 20:50:27 CEST 2025

In the zeal to adjust all event->state checks to include the new
REVOKED state, one adjustment was made in error. Notably it resulted
in read() on the perf filedesc to stop working for any state lower
than ERROR, specifically EXIT.

This leads to problems with (among others) perf-stat, which wants to
read the counts after a program has finished execution.

Fixes: da916e96e2de ("perf: Make perf_pmu_unregister() useable")
Reported-by: "Mi, Dapeng" <dapeng1.mi@linux.intel.com>
Reported-by: James Clark <james.clark@linaro.org>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Link: https://lkml.kernel.org/r/77036114-8723-4af9-a068-1d535f4e2e81@linaro.org
---
 kernel/events/core.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

--- a/kernel/events/core.c
+++ b/kernel/events/core.c
@@ -6023,7 +6023,7 @@ __perf_read(struct perf_event *event, ch
 	 * error state (i.e. because it was pinned but it couldn't be
 	 * scheduled on to the CPU at some point).
 	 */
-	if (event->state <= PERF_EVENT_STATE_ERROR)
+	if (event->state == PERF_EVENT_STATE_ERROR)
 		return 0;
 
 	if (count < event->read_size)

  reply	other threads:[~2025-04-17  8:07 UTC|newest]

Thread overview: 43+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-03-07 19:33 [PATCH v3 0/7] perf: Make perf_pmu_unregister() usable Peter Zijlstra
2025-03-07 19:33 ` [PATCH v3 1/7] perf: Ensure bpf_perf_link path is properly serialized Peter Zijlstra
2025-03-07 19:33 ` [PATCH v3 2/7] perf: Simplify child event tear-down Peter Zijlstra
2025-03-07 19:33 ` [PATCH v3 3/7] perf: Simplify perf_event_free_task() wait Peter Zijlstra
2025-03-17  6:49   ` Ravi Bangoria
2025-04-02  9:15     ` Peter Zijlstra
2025-04-08 19:05   ` [tip: perf/core] " tip-bot2 for Peter Zijlstra
2025-04-09 13:01     ` Frederic Weisbecker
2025-04-10  9:34       ` Peter Zijlstra
2025-04-10  9:45         ` Frederic Weisbecker
2025-04-17 12:03       ` Ingo Molnar
2025-04-17 13:01       ` [tip: perf/core] perf/core: Fix put_ctx() ordering tip-bot2 for Frederic Weisbecker
2025-03-07 19:33 ` [PATCH v3 4/7] perf: Simplify perf_event_release_kernel() Peter Zijlstra
2025-04-08 19:05   ` [tip: perf/core] " tip-bot2 for Peter Zijlstra
2025-03-07 19:33 ` [PATCH v3 5/7] perf: Unify perf_event_free_task() / perf_event_exit_task_context() Peter Zijlstra
2025-03-10 15:35   ` [PATCH v3a " Peter Zijlstra
2025-04-08 19:05   ` [tip: perf/core] " tip-bot2 for Peter Zijlstra
2025-03-07 19:33 ` [PATCH v3 6/7] perf: Rename perf_event_exit_task(.child) Peter Zijlstra
2025-03-10 11:08   ` Ravi Bangoria
2025-03-10 14:47     ` Peter Zijlstra
2025-03-10 15:20       ` Ravi Bangoria
2025-03-10 15:27         ` Peter Zijlstra
2025-03-10 15:37   ` [PATCH v3a " Peter Zijlstra
2025-03-12  6:31     ` Ravi Bangoria
2025-03-12 10:16       ` Peter Zijlstra
2025-03-07 19:33 ` [PATCH v3 7/7] perf: Make perf_pmu_unregister() useable Peter Zijlstra
2025-03-10 15:35   ` Ravi Bangoria
2025-03-10 16:14     ` Peter Zijlstra
2025-03-10 16:46   ` Ravi Bangoria
2025-03-12 12:57     ` Peter Zijlstra
2025-03-12 13:57       ` Ravi Bangoria
2025-04-08 19:05   ` [tip: perf/core] " tip-bot2 for Peter Zijlstra
2025-04-17  8:08     ` Peter Zijlstra
2025-04-17 13:01       ` [tip: perf/core] perf/core: Fix event timekeeping merge tip-bot2 for Peter Zijlstra
2025-04-14  0:37   ` [PATCH v3 7/7] perf: Make perf_pmu_unregister() useable Mi, Dapeng
2025-04-17  8:07     ` Peter Zijlstra [this message]
2025-04-17  8:24       ` Mi, Dapeng
2025-04-17 11:30       ` [tip: perf/core] perf/core: Fix perf-stat / read() tip-bot2 for Peter Zijlstra
2025-04-17 13:01       ` tip-bot2 for Peter Zijlstra
2025-03-17  6:54 ` [PATCH v3 0/7] perf: Make perf_pmu_unregister() usable Ravi Bangoria
2025-04-08 19:05 ` [tip: perf/core] perf: Rename perf_event_exit_task(.child) tip-bot2 for Peter Zijlstra
2025-04-08 19:05 ` [tip: perf/core] perf: Simplify child event tear-down tip-bot2 for Peter Zijlstra
2025-04-08 19:05 ` [tip: perf/core] perf: Ensure bpf_perf_link path is properly serialized tip-bot2 for Peter Zijlstra

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20250417080725.GH38216@noisy.programming.kicks-ass.net \
    --to=peterz@infradead.org \
    --cc=acme@kernel.org \
    --cc=adrian.hunter@intel.com \
    --cc=alexander.shishkin@linux.intel.com \
    --cc=dapeng1.mi@linux.intel.com \
    --cc=irogers@google.com \
    --cc=james.clark@linaro.org \
    --cc=jolsa@kernel.org \
    --cc=kan.liang@linux.intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lucas.demarchi@intel.com \
    --cc=mark.rutland@arm.com \
    --cc=mingo@kernel.org \
    --cc=namhyung@kernel.org \
    --cc=ravi.bangoria@amd.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®