Deadlock

Undeliverable packets & solutions
• Deadlock: packets are unable to progress
– Prevention, avoidance, recovery
• Livelock: packets cannot reach their destination
– Minimal paths, Restricted nonminimal paths,
Probabilistic avoidance
• Starvation: resources are never allocated
– Resource assignment scheme
NC2 (No.4)
1
Deadlock prevention
• Deadlock is a situation that occurs when a cycle of
packets are waiting for one another to release
resources, and hence are blocked indefinitely.
• Resources (channels or buffers) are reserved
before starting packet transmission so that a
request never leads to a deadlock.
• All the variants of circuit switching, when
backtracking is allowed, are classified into
deadlock prevention.
NC2 (No.4)
2
Deadlock avoidance
• Resources are requested only when they are
really needed to forward a packet.
• A common technique consists of
establishing an ordering between resources
and granting resources to each packet in
decreasing order.
• Almost all modern networks use deadlock
avoidance.
NC2 (No.4)
3
Deadlock recovery
• Deadlock is possible and some detection
mechanism must be provided.
• If a deadlock is detected, some resources
are deallocated and granted to other packets.
• This strategy is used if deadlocks are rare,
otherwise the overhead of deadlock
detection and recovery degrade
performance considerably.
NC2 (No.4)
4
Livelock
• A packet may be traveling around its
destination node, never reaching it because
the channels required to do so are occupied
by other packets.
• It can only occur when packets are allowed
to follow nonminimal paths.
• It can be prevented by limiting the number
of misrouting operations.
NC2 (No.4)
5
starvation
• A packet may be permanently stopped if
traffic is intense and the resources requested
by it are always granted to other packets
also requesting them.
• A correct resource assignment solves it.
– A simple demand-slotted round-robin scheme is
enough to produce a fair use of resources.
NC2 (No.4)
6
Routing and selection functions
• A routing function supplies a set of output
channels based on the current and
destination nodes.
• The routing function determines it is
deadlock-free or not.
• A selection function decides an output
channel from the set based on the status
(free or not).
NC2 (No.4)
7
Router model
Input
channels
Injection
channel
LC
LC
LC
LC
switch
LC
LC
LC
LC
LC
Routing
and
arbitration
LC
Output
Channel
selection
Ejection
channel
LC: Link Controller
NC2 (No.4)
8
Channel dependency (1/3)
node
channel
c0
n0
c3
n3
n1
c0
c1
c3
c2
c1
c2
n2
NC2 (No.4)
9
Channel dependency (2/3)
ch0
n0
n1
Node i to j
ca0
ch3
ch1
ca1
ca3
Use cai for ∀j < i
ca2
n3
Use chi for ∀j > i
n2
ch2
NC2 (No.4)
10
Channel dependency graph
ch0
ch1
ca1
ca3
ca2
ch2
NC2 (No.4)
11
definitions
• Routing function R is connected if it is able to
establish a path between every pair of nodes in a
network.
• A deterministic routing, restricting the routing
function will disconnect the channel dependency
graph because a single path is supplied for each
packet.
• A deterministic routing function R for an
interconnection network is deadlock-free if and
only if there are no cycles in its channel
dependency graph.
NC2 (No.4)
12
Deadlock-freedom on a ring
ch0
0
ch1
n
1
ca0
ca1
dateline
NC2 (No.4)
13
Channel dependency (3/3)
ch0
n0
n1
Node i to j
ca0
ch1
ca1
ca3
Use cai for ∀j ≠ i
ca2
n3
Use chi for ∀j > i
n2
ch2
NC2 (No.4)
14
Extended channel dependency graph
ch0
ch1
ca0
ca1
Escape
channel
Escape
path
ca3
ca2
ch2
NC2 (No.4)
15
Theory of deadlock avoidance
• A restricted routing function, that is only
supplies escape channels, is referred to as
routing subfunction.
• A connected routing function R for a
network is deadlock-free if and only if there
exists a routing subfunction R1 that is
connected and has no cycles in its extended
channel dependency graph (theorem 3.1).
NC2 (No.4)
16
Deadlock-freedom on SAF and VCT
• A connected routing function R for an
interconnection network I=G(N,C) is
deadlock-free if there exists a channel
subset C1⊆C such that the routing
subfunction R1(x,y)=R(x,y)∩C1, ∀x,y⊆N
is connected and deadlock-free.
N: set of nodes, C: set of channels
C1=∪ ∀x,y⊆N R1(x,y)
NC2 (No.4)
17
Deadlock-freedom on wormhole (1/2)
• Packets usually occupy several channels
when blocked.
• There will exist channel dependencies
between nonadjacent channels.
• Dependencies between nonadjacent
channels are not important when all the
channels of the network are considered
because they cannot produce cycles.
NC2 (No.4)
18
Deadlock-freedom on wormhole
(2/2)
• Theorem 3.1 is valid for SAF, VCT, and
wormhole switching under the conditions:
A queue cannot contain flits belonging to
different packet.
NC2 (No.4)
19
Injection limitation (1/2)
• If there is at least one empty packet buffer
in a ring, there is no deadlock because a
packet from the previous node is able to
advance and soon or later, all the packets
will advance.
• Two or more empty buffers in the local
queue are required to inject new packet.
NC2 (No.4)
20
Injection limitation (2/2)
node0
PE
node1
node2
PE
PE
node3
PE
Node1 and 2 are not allowed to inject a new packet
into the ring, because there are less than two empty
buffers.
NC2 (No.4)
21
Deflection routing
• When the number of input channels is equal to the
number of output channels, incoming packet will
always find a free output channel.
• If it is possible, a minimal path is selected.
Otherwise, the packet is misrouted.
• When a node is injecting a packet into the network
and all the output ports are busy, one incoming
packet is buffered in a local memory.
• The buffered packet is reinjected before injecting
any new packets.
NC2 (No.4)
22
Deadlock avoidance in MINs (1/2)
• If a packet may not cross the network
several times (recirculation), the packet is
only routed from left to right.
• There are only dependencies between
channels in a given stage to channels in the
next stages.
• There is not any cyclic dependency between
channels, thus avoiding deadlocks.
NC2 (No.4)
23
Deadlock avoidance in MINs (2/2)
• When the recirculation is allowed, the
behavior of MINs regarding deadlocks is
similar to that of direct networks.
• The theoretical results for the latter are valid
for the former (cyclic channel dependencies
cause deadlocks).
• We can focus on the topology connecting
the switches of MINs.
NC2 (No.4)
24
Deadlock prevention in circuit switching
• Circuit switching reserves all the resources before
they are used, so no deadlocks arise.
• When the probe, which sets up the whole path,
cannot advance, it is allowed to backtrack
( releasing some previously reserved resources).
• If backtracking is not allowed, the behavior
regarding deadlocks is identical to that of
wormhole switching.
NC2 (No.4)
25
Deadlock probability (1/2)
• Routing freedom (routing options available to a
packet being routed) affects the probability of
deadlock.
• Routing freedom can be increased by adding
physical/virtual channels, and increasing the
adaptivity of the routing algorithm.
• When the rouging freedom increases, the
probability of deadlock decreases.
NC2 (No.4)
26
Deadlock probability (2/2)
• It was shown that deadlocks can be highly
improbable when sufficient routing freedom is
provided and fully exploited by the routing
function.
• Deadlock recovery-based algorithms designed
primarily to maximize routing freedom.
• Limiting packet injection also reduce the
probability of deadlock.
NC2 (No.4)
27
Detection of deadlocks (1/2)
• A deadlock configuration often involves
several packets.
• Completely accurate deadlock detection
mechanisms are not feasible because they
require exchanging information between
nodes (not always possible).
• Less accurate heuristic mechanisms that use
only local information are preferred.
NC2 (No.4)
28
Detection of deadlocks (2/2)
• If a header flit is clocked for longer than a certain
amount of time, is can be assumed that the
corresponding packet is potentially deadlocked.
• A source or intermediate node has counter to
measure the timeout.
• Heuristic deadlock mechanisms are not accurate,
so it is important to minimize false-deadlock
detection.
NC2 (No.4)
29
Progressive and regressive recovery
(1/2)
• Progressive recovery deallocates resources
from packets and reassign them to
deadlocked packets for quick delivery.
• Regressive recovery deallocates resources
from deadlocked packets, usually killing
them (abort-and retry).
NC2 (No.4)
30
Progressive and regressive recovery
(2/2)
• If a deadlock is detected at the source node,
regressive recovery is usually used.
(a packet is killed and injected again after a
random delay)
• If a deadlock is detected at the intermediate
node containing a header, both progressive
and regressive mechanisms are possible.
NC2 (No.4)
31
Deadlock recovery router (Disha)
Injection
channel
Input
channels
LC
LC
LC
LC
switch
LC
LC
LC
LC
LC
Routing
and
arbitration
Ejection
channel
Output
channels
LC
Deadlock buffer
NC2 (No.4)
32
Deadlock Recovery by Disha
ejection
Deadlock buffer
NC2 (No.4)
33
Sequential deadlock recovery
• Deadlock freedom on the deadlock buffer is
essential to recovery.
• The number of deadlock buffer per node is
limited, sequential recovery scheme was
proposed.
• Only a packet at a time is allowed to use the
deadlock buffer (restricting access with a
circulating token).
NC2 (No.4)
34
Concurrent deadlock recovery
• An arbiter is required in each node so that
simultaneous requests for the use of
deadlock buffer coming from different input
channels are handled.
• A routing subfunction, that is connected and
has no cyclic dependencies between
resources, is defined for the deadlock buffer
(Hamiltonian paths).
NC2 (No.4)
35
Hamiltonian paths (for 4x4 mesh)
0
1
2
3
7
6
5
4
8
9
a
b
f
e
d
c
NC2 (No.4)
36
Livelock avoidance
• By limiting misrouting, there is an upperbound for the number of channels reserved
by a packet, thus avoiding livelock.
• Misrouting can be limited by adding a field
to a packet header to keep misrouting count.
• In deflection routing, misrouting cannot be
limited. It has been shown that it is livelockfree in a probablistic way.
NC2 (No.4)
37
history
• Early work on deadlock-free interconnection
networks identified the technique of enumerating
network resources and traversing these resources
an increasing order.
• Linder and Harden developed a method that
makes arbitrary adaptive routing deadlock-free but
at the cost of a number of virtual channels (1991).
• Duato’s protocol has been used in several
networks such as Cray T3E and the Alpha 21364.
NC2 (No.4)
38