1 # The MIT License (MIT)
3 # Copyright (C) 2015 - Julien Desfossez <jdesfossez@efficios.com>
4 # 2015 - Antoine Busque <abusque@efficios.com>
6 # Permission is hereby granted, free of charge, to any person obtaining a copy
7 # of this software and associated documentation files (the "Software"), to deal
8 # in the Software without restriction, including without limitation the rights
9 # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 # copies of the Software, and to permit persons to whom the Software is
11 # furnished to do so, subject to the following conditions:
13 # The above copyright notice and this permission notice shall be included in
14 # all copies or substantial portions of the Software.
16 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
27 class IrqStateProvider(sp
.StateProvider
):
28 def __init__(self
, state
):
30 'irq_handler_entry': self
._process
_irq
_handler
_entry
,
31 'irq_handler_exit': self
._process
_irq
_handler
_exit
,
32 'softirq_raise': self
._process
_softirq
_raise
,
33 'softirq_entry': self
._process
_softirq
_entry
,
34 'softirq_exit': self
._process
_softirq
_exit
37 super().__init
__(state
, cbs
)
39 def _get_cpu(self
, cpu_id
):
40 if cpu_id
not in self
._state
.cpus
:
41 self
._state
.cpus
[cpu_id
] = sv
.CPU(cpu_id
)
43 return self
._state
.cpus
[cpu_id
]
46 def _process_irq_handler_entry(self
, event
):
47 cpu
= self
._get
_cpu
(event
['cpu_id'])
48 irq
= sv
.HardIRQ
.new_from_irq_handler_entry(event
)
49 cpu
.current_hard_irq
= irq
51 self
._state
.send_notification_cb('irq_handler_entry',
53 irq_name
=event
['name'])
55 def _process_irq_handler_exit(self
, event
):
56 cpu
= self
._get
_cpu
(event
['cpu_id'])
57 if cpu
.current_hard_irq
is None or \
58 cpu
.current_hard_irq
.id != event
['irq']:
59 cpu
.current_hard_irq
= None
62 cpu
.current_hard_irq
.end_ts
= event
.timestamp
63 cpu
.current_hard_irq
.ret
= event
['ret']
65 self
._state
.send_notification_cb('irq_handler_exit',
66 hard_irq
=cpu
.current_hard_irq
)
67 cpu
.current_hard_irq
= None
70 def _process_softirq_raise(self
, event
):
71 cpu
= self
._get
_cpu
(event
['cpu_id'])
74 if vec
not in cpu
.current_softirqs
:
75 cpu
.current_softirqs
[vec
] = []
77 # Don't append a SoftIRQ object if one has already been raised,
78 # because they are level-triggered. The only exception to this
79 # is if the first SoftIRQ object already had a begin_ts which
80 # means this raise was triggered after its entry, and will be
81 # handled in the following softirq_entry
82 if cpu
.current_softirqs
[vec
] and \
83 cpu
.current_softirqs
[vec
][0].begin_ts
is None:
86 irq
= sv
.SoftIRQ
.new_from_softirq_raise(event
)
87 cpu
.current_softirqs
[vec
].append(irq
)
89 def _process_softirq_entry(self
, event
):
90 cpu
= self
._get
_cpu
(event
['cpu_id'])
93 if cpu
.current_softirqs
[vec
]:
94 cpu
.current_softirqs
[vec
][0].begin_ts
= event
.timestamp
96 # SoftIRQ entry without a corresponding raise
97 irq
= sv
.SoftIRQ
.new_from_softirq_entry(event
)
98 cpu
.current_softirqs
[vec
].append(irq
)
100 def _process_softirq_exit(self
, event
):
101 cpu
= self
._get
_cpu
(event
['cpu_id'])
104 if vec
not in cpu
.current_softirqs
:
107 cpu
.current_softirqs
[vec
][0].end_ts
= event
.timestamp
108 self
._state
.send_notification_cb('softirq_exit',
109 softirq
=cpu
.current_softirqs
[vec
][0])
110 del cpu
.current_softirqs
[vec
][0]
This page took 0.031943 seconds and 5 git commands to generate.