blob: 598379a794934bde0b669c2a94c903f56068b6f7 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
|
###############################################################################
# Description
###############################################################################
# Sanitize input. (There are a number of goofy issues with the sched_trace
# output.)
###############################################################################
# Public functions
###############################################################################
def sanitizer(stream):
job_2s_released = [] # list of tasks which have released their job 2s
jobs_switched_to = []
for record in stream:
# Ignore records which are not events (e.g. the num_cpus record)
if record.record_type != 'event':
yield record
continue
# All records with job < 2 are garbage
if record.job < 2:
continue
# Some records with job == 2 are garbage
if record.job==2:
# There is a duplicate release of every job 2
# This will throw away the second one
if record.type_name == 'release':
if record.pid in job_2s_released:
continue
else:
job_2s_released.append(record.pid)
# Job 2 has a resume that is garbage
if record.type_name == 'resume':
continue
# By default, the switch_away for a job (after it has completed)
# is maked as being for job+1, which has never been switched to.
# We can correct this if we note which jobs really
# have been switched to.
if record.type_name == 'switch_to':
jobs_switched_to.append((record.pid,record.job))
if record.type_name == 'switch_away':
if (record.pid,record.job) not in jobs_switched_to:
record.job -= 1
yield record
|