Patch "perf trace: Do not lose last events in a race" has been added to the 5.15-stable tree

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This is a note to let you know that I've just added the patch titled

    perf trace: Do not lose last events in a race

to the 5.15-stable tree which can be found at:
    http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
     perf-trace-do-not-lose-last-events-in-a-race.patch
and it can be found in the queue-5.15 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree,
please let <stable@xxxxxxxxxxxxxxx> know about it.



commit d558759b8a76ff3ae3561c0ec1d7f79c28ea7be6
Author: Benjamin Peterson <benjamin@xxxxxxxxxxx>
Date:   Thu Nov 7 23:21:26 2024 +0000

    perf trace: Do not lose last events in a race
    
    [ Upstream commit 3fd7c36973a250e17a4ee305a31545a9426021f4 ]
    
    If a perf trace event selector specifies a maximum number of events to output
    (i.e., "/nr=N/" syntax), the event printing handler, trace__event_handler,
    disables the event selector after the maximum number events are
    printed.
    
    Furthermore, trace__event_handler checked if the event selector was
    disabled before doing any work. This avoided exceeding the maximum
    number of events to print if more events were in the buffer before the
    selector was disabled.
    
    However, the event selector can be disabled for reasons other than
    exceeding the maximum number of events. In particular, when the traced
    subprocess exits, the main loop disables all event selectors. This meant
    the last events of a traced subprocess might be lost to the printing
    handler's short-circuiting logic.
    
    This nondeterministic problem could be seen by running the following many times:
    
      $ perf trace -e syscalls:sys_enter_exit_group true
    
    trace__event_handler should simply check for exceeding the maximum number of
    events to print rather than the state of the event selector.
    
    Fixes: a9c5e6c1e9bff42c ("perf trace: Introduce per-event maximum number of events property")
    Signed-off-by: Benjamin Peterson <benjamin@xxxxxxxxxxx>
    Tested-by: Howard Chu <howardchu95@xxxxxxxxx>
    Cc: Adrian Hunter <adrian.hunter@xxxxxxxxx>
    Cc: Alexander Shishkin <alexander.shishkin@xxxxxxxxxxxxxxx>
    Cc: Ian Rogers <irogers@xxxxxxxxxx>
    Cc: Ingo Molnar <mingo@xxxxxxxxxx>
    Cc: Jiri Olsa <jolsa@xxxxxxxxxx>
    Cc: Kan Liang <kan.liang@xxxxxxxxxxxxxxx>
    Cc: Mark Rutland <mark.rutland@xxxxxxx>
    Cc: Namhyung Kim <namhyung@xxxxxxxxxx>
    Cc: Peter Zijlstra <peterz@xxxxxxxxxxxxx>
    Link: https://lore.kernel.org/r/20241107232128.108981-1-benjamin@xxxxxxxxxxx
    Signed-off-by: Arnaldo Carvalho de Melo <acme@xxxxxxxxxx>
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

diff --git a/tools/perf/builtin-trace.c b/tools/perf/builtin-trace.c
index b179995cef96a..49a968bdd3a27 100644
--- a/tools/perf/builtin-trace.c
+++ b/tools/perf/builtin-trace.c
@@ -2775,13 +2775,8 @@ static int trace__event_handler(struct trace *trace, struct evsel *evsel,
 {
 	struct thread *thread;
 	int callchain_ret = 0;
-	/*
-	 * Check if we called perf_evsel__disable(evsel) due to, for instance,
-	 * this event's max_events having been hit and this is an entry coming
-	 * from the ring buffer that we should discard, since the max events
-	 * have already been considered/printed.
-	 */
-	if (evsel->disabled)
+
+	if (evsel->nr_events_printed >= evsel->max_events)
 		return 0;
 
 	thread = machine__findnew_thread(trace->host, sample->pid, sample->tid);




[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux