Cache Related Preemption Delay for Set-Associative Caches Resilience Analysis Sebastian Altmeyer, Claire Burguière, Jan Reineke Predator Meeting, Pisa 2010 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 Altmeyer, Burguière, Reineke CRPD for set-associative caches Predator, Pisa 2010 2 / 16 CRPD for set-associative caches - LRU saarland university computer science CRPD computation: I I preempted task: Useful Cache Blocks (UCB) preempting task: Evicting Cache Blocks (ECB) CRPD from UCB and ECB: I Previous combination overestimates ⇒ Some UCBs remain useful under preemption Altmeyer, Burguière, Reineke CRPD for set-associative caches Predator, Pisa 2010 3 / 16 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 c X C D B C CRPDsUCB CRPDUCB = CRPDsUCB = BRT × min(|UCB(s)|, n) s=1 Altmeyer, Burguière, Reineke A Cache Content: [A, B, C, D] CRPD for set-associative caches n = associativity BRT = Block Reload Time Predator, Pisa 2010 4 / 16 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 c X C D B C CRPDsUCB CRPDUCB = CRPDsUCB = BRT × min(|UCB(s)|, n) s=1 Altmeyer, Burguière, Reineke A Cache Content: [A, B, C, D] CRPD for set-associative caches n = associativity BRT = Block Reload Time Predator, Pisa 2010 4 / 16 saarland university Evicting Cache Blocks [Tomiyama & 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) s CRPDECB = Altmeyer, Burguière, Reineke 0 if ECB(s) = ∅ BRT × n otherwise CRPD for set-associative caches Predator, Pisa 2010 5 / 16 saarland university Impact of the preempting task on the preempted task computer science CRPD (using UCB and ECB) CRPDUCB&ECB = c X min(CRPDsUCB , CRPDsECB ) s=1 Altmeyer, Burguière, Reineke CRPD for set-associative caches Predator, Pisa 2010 6 / 16 saarland university Impact of the preempting task on the preempted task (example) [c, b, a, x] 0x0a 0x0b 0x0c ECBs = {e} [e, c, b, a] a a [a, c, b, x] [a, e, c, b] b b [b, a, c, x] [b, a, e, c] computer science c c [c, b, a, x] no miss [c, b, a, e] no miss CRPDUCB ⇒ |UCB| = 3 CRPDECB ⇒ n = 4 CRPDUCB&ECB = min(CRPDUCB , CRPDECB ) ⇒ 3 I Overestimation: number of additional misses= 0 < 3 Why? I I I |ECB| to evict a UCB = 2 but, |ECB| = 1 One single ECB is not sufficient to evict a UCB Altmeyer, Burguière, Reineke CRPD for set-associative caches Predator, Pisa 2010 7 / 16 saarland university Refinement computer science Determining max|ECB| s.t. no additional cache miss occur m ∈ UCB m is 4-resilient (res(m) = 4) Altmeyer, Burguière, Reineke m a1 a2 a3 m [m, , , , , , , ] [a3 , a2 , a1 , m, , , , ] [m, a3 , a2 , a1 , , , , ] CRPD for set-associative caches Predator, Pisa 2010 8 / 16 saarland university Resilience analysis computer science Definition (Resilience) The resilience resP (m) of memory block m at program point P is the greatest l, such that all possible next accesses to m, a) that would be hits without preemption, b) would still be hits in case of a preemption with l accesses at P. preempted task m ∈ UCB res(m) = 4 m a1 a2 preempting task [m, , , , , , , ] ECB = {e1 , e2 , e3 , e4 } a3 [a3 , e4 , e3 , e2 , e1 , a2 , a1 , m] m [m, a3 , e4 , e3 , e2 , e1 , a2 , a1 ] if |ECB| ≤ l then the UCB is not evicted Altmeyer, Burguière, Reineke CRPD for set-associative caches Predator, Pisa 2010 9 / 16 saarland university CRPD using resilience computer science CRPD (combining UCB and ECB by using resilience) blocks contributing to CRPD CRPD ≤ BRT × z }| { | UCB \ {m | res(m) = |ECB|} | | {z } | {z } useful Altmeyer, Burguière, Reineke CRPD for set-associative caches remain useful Predator, Pisa 2010 10 / 16 saarland university CRPD using resilience - example [c, b, a, x] 0x0a 0x0b 0x0c ECBs = {e} [e, c, b, a] I I I a a [a, c, b, x] [a, e, c, b] b b [b, a, c, x] [b, a, e, c] computer science c c [c, b, a, x] no miss [c, b, a, e] no miss |ECB| = 1 res(a) = res(b) = res(c) = 1 res CRPDUCB&ECB = BRT × |UCB \ {m | res(m) = |ECB| }| = 0 Instead of: CRPDUCB&ECB = min(CRPDUCB , CRPDECB ) = 3 × BRT Altmeyer, Burguière, Reineke CRPD for set-associative caches Predator, Pisa 2010 11 / 16 saarland university Evaluation Setting computer science Cachesize 8KB 8 ways 32 sets linesize 32 bytes LRU caches Testcases: Mälardalen benchmark suite: Altmeyer, Burguière, Reineke CRPD for set-associative caches Predator, Pisa 2010 12 / 16 saarland university Evaluation Benchmarks Task minmax insertsort fibcall fac bs bsort100 ns matmult fir crc select qsort-exam sqrt qurt Altmeyer, Burguière, Reineke Code Size 608B 384B 256B 256B 320B 544B 576B 864B 928B 1216B 1280B 1440B 3680B 4160B computer science Cache Util. 7.4% 4.7% 3.1% 3.1% 3.9% 6.6% 7% 10.5% 11.3% 14.8% 15.6% 17.6% 44.9% 50.8% CRPD for set-associative caches |UCB| 4 5 5 6 8 10 11 12 22 35 37 42 101 118 Predator, Pisa 2010 13 / 16 saarland university Evaluation computer science preempted by fibcall (#ECBs= 8) 100 10 1 min in f max sertso ac rt bs bso n rt10 s 0 mat f mult ir crc sele qso sqrt xam crc sele qso sqrt xam ct rt-e preempted by qurt (#ECBs= 121) 100 10 1 min in f max sertso ac rt resilience Altmeyer, Burguière, Reineke bs bso n rt10 s 0 tan mat f mult ir UCB & ECB CRPD for set-associative caches ct rt-e #UCBs Predator, Pisa 2010 14 / 16 saarland university Conclusions computer science UCB and ECB analyses: I pessimistic overapproximation of the CRPD Resilience analysis: I I regain some precision reduce pessimism Resilience analysis: I I simple data-flow analyses similar to UCB analysis for LRU Altmeyer, Burguière, Reineke CRPD for set-associative caches Predator, Pisa 2010 15 / 16 saarland university Further reading computer science Altmeyer, S. & Burguière, C. (2009). In Proceedings of the 21st Euromicro Conference on Real-Time Systems (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. & Kim, C. S. (1996). In RTSS’96 p. 264, IEEE Computer Society. Negi, H. S., Mitra, T. & Roychoudhury, A. (2003). In CODES+ISSS’03 ACM. Reineke, J. (2008). Caches in WCET Analysis. PhD thesis, Universität des Saarlandes, Saarbrücken. Staschulat, J. & Ernst, R. (2007). ACM Trans. on Embedded Computing Sys. 6, 25. Tan, Y. & Mooney, V. (2004). In SCOPES’04 pp. 182–199,. Tomiyama, H. & Dutt, N. D. (2000). In CODES’00 ACM. Altmeyer, Burguière, Reineke CRPD for set-associative caches Predator, Pisa 2010 16 / 16 saarland university m m (a) Altmeyer, Burguière, Reineke m m 2-resilient m m is not useful 2-resilient computer science 2-resilient 0-resilient 0-resilient l-resilience analysis m (b) CRPD for set-associative caches Predator, Pisa 2010 16 / 16 saarland university CPRD using ECB: Pitfall 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 Altmeyer, Burguière, Reineke CRPD for set-associative caches Predator, Pisa 2010 16 / 16 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 & Dutt, 2000]: CRPDECB = BRT · |{si | ∃m ∈ ECB : m mod c = si }| using UCB and ECB [Negi et al., 2003, Tan & Mooney, 2004]: CRPDUCB&ECB = BRT · |{si | ∃m ∈ UCB : m mod c = si ∧∃m0 ∈ ECB : m0 mod c = si }| Altmeyer, Burguière, Reineke CRPD for set-associative caches Predator, Pisa 2010 16 / 16 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 Altmeyer, Burguière, Reineke CRPD for set-associative caches Predator, Pisa 2010 16 / 16 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 Altmeyer, Burguière, Reineke CRPD for set-associative caches Predator, Pisa 2010 16 / 16