Cache Related Preemption Delay Computation for Set

advertisement
Cache Related Preemption Delay Computation for
Set-Associative Caches
Pitfalls and Solutions
Claire Burguière, Jan Reineke, Sebastian Altmeyer
Workshop on WCET Analysis, Dublin 2009
saarland
university
computer science
saarland
university
Context
computer science
Preemptive scheduling
Cache related preemption delay (CRPD):
I
I
Impact of preemption on the cache content
Overall cost of additional reloads due to preemption
T1
T2
= CRPD
= Task Activation
Burguière, Reineke, Altmeyer
CRPD for set-associative caches
WCET, Dublin 2009
2 / 13
CRPD computation for set-associative caches
saarland
university
computer science
CRPD computation:
I
I
Useful Cache Blocks (UCB)
Evicting Cache Blocks (ECB)
CRPD for set-associative caches:
⇒ Pitfalls:
I
I
LRU: CRPD not bounded by the number of ECBs
FIFO and PLRU: CRPD not bounded
Burguière, Reineke, Altmeyer
CRPD for set-associative caches
WCET, Dublin 2009
3 / 13
saarland
university
Useful Cache Block - [Lee et al., 1996]
computer science
Definition (Useful Cache Block)
A memory block m at program point P is called a useful cache block, if
a) m may be cached at P
b) m may be reused at program point P 0 that may be reached from P
with no eviction of m on this path.
= hit
= miss
P
A
B
D
C
B
A
C
Cache Content:
[A, B, C, D]
Burguière, Reineke, Altmeyer
CRPD for set-associative caches
WCET, Dublin 2009
4 / 13
saarland
university
Useful Cache Block - [Lee et al., 1996]
computer science
Definition (Useful Cache Block)
A memory block m at program point P is called a useful cache block, if
a) m may be cached at P
b) m may be reused at program point P 0 that may be reached from P
with no eviction of m on this path.
= hit
= miss
P
A
B
D
C
B
A
C
Cache Content:
[A, B, C, D]
Burguière, Reineke, Altmeyer
CRPD for set-associative caches
WCET, Dublin 2009
4 / 13
saarland
university
Useful Cache Block - [Lee et al., 1996]
computer science
Definition (Useful Cache Block)
A memory block m at program point P is called a useful cache block, if
a) m may be cached at P
b) m may be reused at program point P 0 that may be reached from P
with no eviction of m on this path.
= hit
= miss
P
A
B
CRPDLRU
=
LRU
CRPDUCB
(s)
=
c
X
D
C
B
C
CRPDLRU (s)
s=1
BRT · min(|UCB(s)|, n)
Burguière, Reineke, Altmeyer
A
Cache Content:
[A, B, C, D]
CRPD for set-associative caches
n = associativity
BRT = Block Reload Time
WCET, Dublin 2009
4 / 13
saarland
university
Evicting Cache Blocks
[Tomiyama and Dutt, 2000]
computer science
Definition (Evicting Cache Blocks (ECB))
A memory block of the preempting task is called an evicting cache
block, if it may be accessed during the execution of the preempting
task.
Cache Content:
[A, B, C, D]
A
B
C
X
Y
Z
Cache Content:
[X , Y , Z , D]
B
A
C
= additional miss due to preemption (CRPD)
Burguière, Reineke, Altmeyer
CRPD for set-associative caches
WCET, Dublin 2009
5 / 13
saarland
university
Evicting Cache Blocks
[Tomiyama and Dutt, 2000]
computer science
Definition (Evicting Cache Blocks (ECB))
A memory block of the preempting task is called an evicting cache
block, if it may be accessed during the execution of the preempting
task.
Cache Content:
[A, B, C, D]
A
C
B
X
Y
Z
Cache Content:
[X , Y , Z , D]
B
A
C
= additional miss due to preemption (CRPD)
?
LRU
CRPDECB
(s) = BRT · min(|ECB(s)|, n)
Burguière, Reineke, Altmeyer
CRPD for set-associative caches
WCET, Dublin 2009
5 / 13
CRPD computation for LRU using ECB: Pitfall
saarland
university
computer science
0x08
0x09
0x0a
0x0b
[b, a, 9, 8]
Burguière, Reineke, Altmeyer
8
[8, b, a, 9]
9
[9, 8, b, a]
a
[a, 9, 8, b]
CRPD for set-associative caches
b
[b, a, 9, 8]
0 misses
WCET, Dublin 2009
6 / 13
CRPD computation for LRU using ECB: Pitfall
saarland
university
computer science
0x08
0x09
0x0a
0x0b
[b, a, 9, 8]
ECBs
= {e}
[e, b, a, 9]
8
8∗
[8, b, a, 9]
[8, e, b, a]
9
9∗
[9, 8, b, a]
[9, 8, e, b]
a
a∗
[a, 9, 8, b]
[a, 9, 8, e]
b
b∗
[b, a, 9, 8]
0 misses
[b, a, 9, 8]
4 misses
|UCB(s)| = 4
|ECB(s)| = 1
n=4
number of additional misses= 4
Burguière, Reineke, Altmeyer
CRPD for set-associative caches
WCET, Dublin 2009
6 / 13
LRU: new computation of CRPD using ECB
saarland
university
computer science
ECB derivation used only to know if the set is used by the
preempting task:
0
if ECB(s) = ∅
LRU
CRPDECB (s) =
BRT · n otherwise
Burguière, Reineke, Altmeyer
CRPD for set-associative caches
WCET, Dublin 2009
7 / 13
saarland
university
CRPD for FIFO: Pitfalls
[b, a]
Burguière, Reineke, Altmeyer
a
[b, a]
e∗
[e, b]
computer science
b
[e, b]
c∗
[c, e]
CRPD for set-associative caches
e
[c, e]
2 misses
WCET, Dublin 2009
8 / 13
saarland
university
CRPD for FIFO: Pitfalls
ECBs
= {x}
[b, a]
[x, b]
a
a∗
[b, a]
[a, x]
e∗
e∗
[e, b]
[e, a]
computer science
b
b∗
[e, b]
[b, e]
c∗
c∗
[c, e]
[c, b]
e
e∗
[c, e]
2 misses
[e, c]
5 misses
|UCB(s)| = 2
|ECB(s)| = 1
n=2
But: number of additional misses= 3
Burguière, Reineke, Altmeyer
CRPD for set-associative caches
WCET, Dublin 2009
8 / 13
Definition – Relative Miss-Competitiveness
saarland
university
computer science
Notation
mP (p, s)
=
number of misses that policy P incurs on
access sequence s ∈ M ∗ starting in state p
Definition (Relative miss competitiveness)
Policy P is (k , c)-miss-competitive relative to policy Q, if
mP (p, s) ≤ k · mQ (q, s) + c
for all access sequences s ∈ M ∗ and compatible cache-set states p, q.
Burguière, Reineke, Altmeyer
CRPD for set-associative caches
WCET, Dublin 2009
9 / 13
Definition – Relative Miss-Competitiveness
saarland
university
computer science
Notation
mP (p, s)
=
number of misses that policy P incurs on
access sequence s ∈ M ∗ starting in state p
Definition (Relative miss competitiveness)
Policy P is (k , c)-miss-competitive relative to policy Q, if
mP (p, s) ≤ k · mQ (q, s) + c
for all access sequences s ∈ M ∗ and compatible cache-set states p, q.
PLRU(n) is (1, 0)-miss-competitive relative to LRU(1 + log2 n).
FIFO(n) is ( n−rn+1 , r )-miss-competitive relative to LRU(r ).
Burguière, Reineke, Altmeyer
CRPD for set-associative caches
WCET, Dublin 2009
9 / 13
saarland
university
A sequence of memory accesses
computer science
Notation:
I m = number of misses
I m = number of misses in the case of preemption
mpre = 4
mpost = 2
mpre = mpre = 4
mpost = mpost + mCRPD = 5
Burguière, Reineke, Altmeyer
CRPD for set-associative caches
WCET, Dublin 2009
10 / 13
saarland
university
A sequence of memory accesses
computer science
Notation:
I m = number of misses
I m = number of misses in the case of preemption
mpre = 4
mpost = 2
mpre = mpre = 4
mpost = mpost + mCRPD = 5
Relative miss competitiveness:
m(t)
=
Burguière, Reineke, Altmeyer
(t)
(t)
mpre
+ mpost
CRPD for set-associative caches
WCET, Dublin 2009
10 / 13
saarland
university
A sequence of memory accesses
computer science
Notation:
I m = number of misses
I m = number of misses in the case of preemption
mpre = 4
mpost = 2
mpre = mpre = 4
mpost = mpost + mCRPD = 5
Relative miss competitiveness:
m(t)
(t)
=
(t)
mpre
+ mpost
≤
[k · mpre
Burguière, Reineke, Altmeyer
LRU(s)
LRU(s)
+ c] + [k · (mpost
CRPD for set-associative caches
LRU(s)
+ mCRPD ) + c]
WCET, Dublin 2009
10 / 13
saarland
university
A sequence of memory accesses
computer science
Notation:
I m = number of misses
I m = number of misses in the case of preemption
mpre = 4
mpost = 2
mpre = mpre = 4
mpost = mpost + mCRPD = 5
Relative miss competitiveness:
m(t)
(t)
=
(t)
mpre
+ mpost
≤
[k · mpre
=
[k · (mpre
Burguière, Reineke, Altmeyer
LRU(s)
LRU(s)
+ c] + [k · (mpost
LRU(s)
LRU(s)
+ mpost
LRU(s)
+ mCRPD ) + c]
LRU(s)
) + c] + [k · mCRPD + c]
CRPD for set-associative caches
WCET, Dublin 2009
10 / 13
saarland
university
A sequence of memory accesses
computer science
Notation:
I m = number of misses
I m = number of misses in the case of preemption
mpre = 4
mpost = 2
mpre = mpre = 4
mpost = mpost + mCRPD = 5
Relative miss competitiveness:
m(t)
(t)
=
(t)
mpre
+ mpost
≤
[k · mpre
=
[k · (mpre
=
[k · m LRU(s) + c] + [k · mCRPD + c]
Burguière, Reineke, Altmeyer
LRU(s)
LRU(s)
+ c] + [k · (mpost
LRU(s)
LRU(s)
+ mpost
LRU(s)
+ mCRPD ) + c]
LRU(s)
) + c] + [k · mCRPD + c]
LRU(s)
CRPD for set-associative caches
WCET, Dublin 2009
10 / 13
saarland
university
Relative Competitiveness – Application
computer science
PLRU(8) using LRU(4):
LRU(4)
m PLRU(8) ≤ m LRU(4) + mCRPD
FIFO(8) using LRU(5):
LRU(5)
m FIFO(8) ≤ (2 · m LRU(5) + 5) + (2 · mCRPD + 5)
Burguière, Reineke, Altmeyer
CRPD for set-associative caches
WCET, Dublin 2009
11 / 13
saarland
university
Conclusions
computer science
Pitfalls
Solutions
LRU:
|ECBs| is not an
upper-bound
LRU:
|ECBs| = 0
⇒ the set is not used
FIFO and PLRU:
|UCBs|, |ECBs| and n
do not bound the number
of additional misses
FIFO and PLRU:
using relative
competitiveness
and LRU bounds
Burguière, Reineke, Altmeyer
CRPD for set-associative caches
WCET, Dublin 2009
12 / 13
Further reading
saarland
university
computer science
Altmeyer, S. and Burguière, C. (2009).
A New Notion of Useful Cache Block to Improve the Bounds of Cache-Related Preemption
Delay.
In ECRTS ’09 pp. 109–118, IEEE Computer Society.
Lee, C.-G., Hahn, J., Min, S. L., Ha, R., Hong, S., Park, C. Y., Lee, M. and Kim, C. S.
(1996).
Analysis of cache-related preemption delay in fixed-priority preemptive scheduling.
In RTSS’96 p. 264, IEEE Computer Society.
Negi, H. S., Mitra, T. and Roychoudhury, A. (2003).
Accurate estimation of cache-related preemption delay.
In CODES+ISSS’03 ACM.
Reineke, J. (2008).
Caches in WCET Analysis.
PhD thesis, Universität des Saarlandes, Saarbrücken.
Staschulat, J. and Ernst, R. (2007).
Scalable precision cache analysis for real-time software.
ACM TECS 6, 25.
Tan, Y. and Mooney, V. (2004).
Integrated intra- and inter-task cache analysis for preemptive multi-tasking real-time
systems.
In SCOPES’04 pp. 182–199,.
Tomiyama, H. and Dutt, N. D. (2000).
CRPD
for set-associative
caches
WCET, Dublinreal-time
2009
13 / 13
to bound
cache-related
preemption
delay in preemptive
Burgui
ère, Reineke,
Program
pathAltmeyer
analysis
saarland
university
Upper-bound on the CRPD - direct-mapped caches
computer science
using UCB [Lee et al., 1996]:
CRPDUCB = BRT · |{si | ∃m ∈ UCB : m mod c = si }|
using ECB [Tomiyama and Dutt, 2000]:
CRPDECB = BRT · |{si | ∃m ∈ ECB : m mod c = si }|
using UCB and ECB [Negi et al., 2003, Tan and Mooney, 2004]:
CRPDUCB&ECB
= BRT · |{si |
∃m ∈ UCB : m mod c = si
∧∃m0 ∈ ECB : m0 mod c = si }|
Burguière, Reineke, Altmeyer
CRPD for set-associative caches
WCET, Dublin 2009
13 / 13
saarland
university
Relative Competitiveness – Example
m(t)
pre
mpre = 4
mpost = 2
mpre = mpre = 4
mpost = mpost + mCRPD = 5
(t)
LRU(s)
≤ k · mpre
+c
LRU(s)
= k · mpre
+c
m(t)
computer science
mpost
LRU(s)
≤ k · mpost + c
LRU(s)
LRU(s)
= k · (mpost + mCRPD ) + c
(t)
= m(t)
pre + mpost
LRU(s)
≤ k · mpre
LRU(s)
+ c + k · (mpost
LRU(s)
LRU(s)
LRU(s)
+ mCRPD ) + c
LRU(s)
=
(k · (mpre
=
(k · m LRU(s) + c) + (k · mCRPD + c).
Burguière, Reineke, Altmeyer
+ mpost
) + c) + (k · mCRPD + c)
LRU(s)
CRPD for set-associative caches
WCET, Dublin 2009
13 / 13
saarland
university
Relative Competitiveness – Application
computer science
PLRU(n) using LRU(1 + log2 n):
I
k = 1, c = 0
LRU(1+log2 n)
m PLRU(n) ≤ m LRU(1+log2 n) + mCRPD
I
Example (n=8):
LRU(4)
m PLRU(8) ≤ m LRU(4) + mCRPD
FIFO(n) using LRU(r ):
I
k=
n
n−r +1 , c
=r
m FIFO(n) ≤ (
I
n
n
LRU(r )
· m LRU(r ) + r ) + (
· mCRPD + r )
n−r +1
n−r +1
Example (n=8,r=5):
LRU(5)
m FIFO(8) ≤ (2 · m LRU(5) + 5) + (2 · mCRPD + 5)
Burguière, Reineke, Altmeyer
CRPD for set-associative caches
WCET, Dublin 2009
13 / 13
saarland
university
CRPD for PLRU: Pitfalls
1
a
1
b
ECBs
= {x, y}
c
d
a
y
b
c
c
a
a
b
d
c
b
a
d
c
b
a
y
1
b
d
c
b
a
y
1
b
d
c
d
b
a
a
c
c
0 misses
d
1
0
1
y
b
d*
1
c
0
1
0
a*
0
1
c
d
0
d
1
1
b
0
1
x
d
0
1
y
b
1
a
0
1
c*
1
x
d
1
b
0
1
1
y
0
b*
0
x
d
0
c
0
0
d*
0
1
b
0
1
1
0
a
0
d
1
computer science
b
1
d
a
5 misses
c
|UCB(s)| = 4
|ECB(s)| = 2
n=4
But: number of additional misses= 5
Burguière, Reineke, Altmeyer
CRPD for set-associative caches
WCET, Dublin 2009
13 / 13
Download