summaryrefslogtreecommitdiffstats
path: root/sanitizer.py
diff options
context:
space:
mode:
Diffstat (limited to 'sanitizer.py')
-rw-r--r--sanitizer.py46
1 files changed, 46 insertions, 0 deletions
diff --git a/sanitizer.py b/sanitizer.py
new file mode 100644
index 0000000..d1764dd
--- /dev/null
+++ b/sanitizer.py
@@ -0,0 +1,46 @@
1###############################################################################
2# Description
3###############################################################################
4
5# Sanitize input. (There are a number of goofy issues with the sched_trace
6# output.)
7
8###############################################################################
9# Public functions
10###############################################################################
11
12def sanitizer(stream):
13 jobs_released = []
14 for record in stream:
15
16 # All records with job < 2 are garbage
17 if record.job < 2:
18 continue
19
20 # Some records with job == 2 are garbage
21 if record.job==2:
22
23 # There is a duplicate release of every job 2
24 # This will throw away the second one
25 if (record.type_name == 'release' and
26 (record.pid,record.job) in jobs_released):
27 continue
28
29 # Job 2 has a resume that is garbage
30 if record.type_name == 'resume':
31 continue
32
33 # Record job releases. This helps with filtering out
34 # the second release of job 2 and renumbering final switch_aways
35 # (see below).
36 if record.type_name == 'release':
37 jobs_released.append((record.pid,record.job))
38
39 # By default, the switch_away for a job (after it has completed)
40 # is maked as being for job+1, which has not been released.
41 # Correct this.
42 if record.type_name == 'switch_away':
43 if (record.pid,record.job) not in jobs_released:
44 record.job -= 1
45
46 yield record