perf scripts python: Fix printing of switch events

commit 0f80bfbf4919e32f52fe1312c3900ff4fbb7eeb9 upstream.

The script displays only the last of consecutive switch
statements but that may not be the last switch event for the CPU. Fix by
keeping a dictionary of last context switch keyed by CPU, and make it
possible to see all switch events by adding option --all-switch-events.

Fixes: a92bf335fd82eeee ("perf scripts python: Add branches to script")
Signed-off-by: Adrian Hunter <>
Cc: Jiri Olsa <>
Cc: Namhyung Kim <>
Cc: Riccardo Mancini <>
Signed-off-by: Arnaldo Carvalho de Melo <>
Signed-off-by: Greg Kroah-Hartman <>
1 file changed