armor defending against memory consistency model
play

ArMOR : Defending Against Memory Consistency Model - PowerPoint PPT Presentation

ArMOR : Defending Against Memory Consistency Model Mismatches in Heterogeneous Architectures Daniel Lus0g , Caroline Trippel, Michael Pellauer, and Margaret


  1. ArMOR : ¡Defending ¡ Against ¡Memory ¡ Consistency ¡Model ¡ Mismatches ¡in ¡ Heterogeneous ¡ Architectures ¡ ¡ Daniel ¡Lus0g , ¡Caroline ¡ Trippel, ¡Michael ¡Pellauer, ¡ and ¡Margaret ¡Martonosi ¡ “Armour ¡of ¡Sir ¡James ¡Scudamore ¡(1595)”, ¡Todd ¡Hoogerland, ¡CC-­‑BY-­‑SA-­‑3.0 ¡ hQp://commons.wikimedia.org/wiki/File:Scudamorearmor2.jpg ¡ Lus$g ¡et ¡al., ¡“ArMOR: ¡Defending ¡Against ¡MCM ¡Mismatches…” ¡ 1 ¡

  2. Mo$va$on: ¡MCMs ¡Are ¡S$ll ¡Difficult! ¡ • Are ¡memory ¡consistency ¡models ¡(MCMs) ¡a ¡solved ¡ problem? ¡Not ¡en$rely! ¡ – Proper ¡MCM ¡specifica$on: ¡ “Big” ¡ Loca$on ¡ only ¡par$ally ¡solved ¡ Cores ¡ “LiQle” ¡ GPU ¡ – MCM-­‑aware ¡compila$on: ¡ Cores ¡ Display ¡ DSP ¡ only ¡par$ally ¡solved ¡ ISP ¡ – Cross-­‑MCM ¡dynamic ¡ Mul$media ¡ Modem ¡ binary ¡transla$on: ¡ Qualcomm ¡Snapdragon ¡810 ¡ previously ¡unsolved! ¡ • With ¡the ¡emergence ¡of ¡architecturally ¡ heterogeneous ¡(and ¡hence ¡MCM-­‑heterogeneous) ¡ systems, ¡the ¡problems ¡are ¡only ¡going ¡to ¡get ¡worse! ¡ Lus$g ¡et ¡al., ¡“ArMOR: ¡Defending ¡Against ¡MCM ¡Mismatches…” ¡ 2 ¡

  3. Mo$va$on: ¡MCMs ¡Are ¡S$ll ¡Difficult! ¡ • Are ¡memory ¡consistency ¡models ¡(MCMs) ¡a ¡solved ¡ problem? ¡Not ¡en$rely! ¡ – Proper ¡MCM ¡specifica$on: ¡ “Big” ¡ Loca$on ¡ only ¡par$ally ¡solved ¡ Cores ¡ “LiQle” ¡ MMU ¡ GPU ¡ – MCM-­‑aware ¡compila$on: ¡ Cores ¡ ¡ MMU MMU ¡ Display ¡ DSP ¡ only ¡par$ally ¡solved ¡ MMU ¡ MMU ¡ ISP ¡ – Cross-­‑MCM ¡dynamic ¡ Mul$media ¡ Modem ¡ MMU ¡ MMU ¡ binary ¡transla$on: ¡ Qualcomm ¡Snapdragon ¡810 ¡ previously ¡unsolved! ¡ • With ¡the ¡emergence ¡of ¡architecturally ¡ heterogeneous ¡(and ¡hence ¡MCM-­‑heterogeneous) ¡ systems, ¡the ¡problems ¡are ¡only ¡going ¡to ¡get ¡worse! ¡ Lus$g ¡et ¡al., ¡“ArMOR: ¡Defending ¡Against ¡MCM ¡Mismatches…” ¡ 3 ¡

  4. ArMOR ¡Overview ¡ • Goal: ¡Take ¡the ¡guesswork ¡out ¡of ¡specifying ¡ and ¡analyzing ¡memory ¡consistency ¡models ¡ (MCMs) ¡within ¡compilers, ¡emulators, ¡etc. ¡ • Contribu$ons: ¡ 1. MOST: ¡precise, ¡portable, ¡general-­‑purpose ¡ MCM ¡specifica0on ¡format ¡ 2. MOST ¡ analysis/manipula0on ¡ methodology ¡that ¡ enables ¡flexible ¡compila$on/transla$on/etc. ¡ 3. Case ¡study: ¡automa$c ¡genera$on ¡of ¡ inter-­‑MCM ¡ dynamic ¡binary ¡transla0on ¡modules ¡(“shims”) ¡ Lus$g ¡et ¡al., ¡“ArMOR: ¡Defending ¡Against ¡MCM ¡Mismatches…” ¡ 4 ¡

  5. Outline ¡ Total ¡Store ¡Ordering ¡(TSO) ¡ B ¡ Ld ¡ St ¡ • Why ¡are ¡MCMs ¡inherently ¡too ¡ A ¡ Ld ¡ ✔ ¡ ✔ ¡ complicated ¡for ¡simplified ¡ specifica$ons ¡like ¡these? ¡ St ¡ — ¡ ✔ ¡ B ¡ Ld. ¡ Ld. ¡ • ArMOR ¡solu$on: ¡MOSTs ¡ St. ¡ Same ¡ Diff. ¡ A ¡ Addr. ¡ Addr. ¡ – Memory ¡Ordering ¡ Load ¡ ✔ ¡ ✔ ¡ ✔ ¡ Specifica$on ¡Tables ¡ Store ¡ — ¡ ✔ L ¡ ✔ S ¡ • Case ¡study: ¡cross-­‑MCM ¡dynamic ¡binary ¡ transla$on ¡ Lus$g ¡et ¡al., ¡“ArMOR: ¡Defending ¡Against ¡MCM ¡Mismatches…” ¡ 5 ¡

  6. What ¡Problems ¡Can ¡MCMs ¡Cause? ¡ public ¡class ¡ Counter ¡{ ¡ ¡ ¡ private ¡int ¡ c ¡= ¡0; ¡ ¡ ¡ ¡ public ¡void ¡ increment() ¡{ ¡ ¡ ¡ ¡ ¡ synchronized (this) ¡{ ¡c++; ¡} ¡ ¡ ¡} ¡ Wrap ¡“ c++; ” ¡in ¡a ¡mutex ¡ } ¡ to ¡make ¡it ¡thread-­‑safe ¡ Lus$g ¡et ¡al., ¡“ArMOR: ¡Defending ¡Against ¡MCM ¡Mismatches…” ¡ 6 ¡

  7. What ¡if ¡Mutexes ¡Fail ¡to ¡Address ¡MCMs? ¡ Thread ¡0 ¡ Thread ¡1 ¡ ... ¡ ldr ¡r1,[r2] ¡(r1=0) ¡ (mutex ¡acquire) ¡ add ¡r1,r1,1 ¡(r1=1) ¡ ¡ str ¡r1,[r2] ¡ ¡(c=1) ¡ ldr ¡r1,[r2] ¡(r1=1) ¡ ¡ add ¡r1,r1,1 ¡(r1=2) ¡ (mutex ¡release) ¡ str ¡r1,[r2] ¡ ¡(c=2) ¡ ¡ ... ¡ ¡ Lus$g ¡et ¡al., ¡“ArMOR: ¡Defending ¡Against ¡MCM ¡Mismatches…” ¡ 7 ¡

  8. What ¡if ¡Mutexes ¡Fail ¡to ¡Address ¡MCMs? ¡ What ¡if ¡hardware ¡ Thread ¡0 ¡ Thread ¡1 ¡ dynamically ¡reorders ¡ ... ¡ the ¡acquire ¡and ¡the ¡ ldr ¡r1,[r2] ¡(r1=0) ¡ (mutex ¡acquire) ¡ subsequent ¡load? ¡ add ¡r1,r1,1 ¡(r1=1) ¡ ¡ str ¡r1,[r2] ¡ ¡(c=1) ¡ ¡ ldr ¡r1,[r2] ¡(r1=1) ¡ ¡ add ¡r1,r1,1 ¡(r1=2) ¡ (mutex ¡release) ¡ str ¡r1,[r2] ¡ ¡(c=2) ¡ ¡ ... ¡ ¡ Lus$g ¡et ¡al., ¡“ArMOR: ¡Defending ¡Against ¡MCM ¡Mismatches…” ¡ 8 ¡

  9. What ¡if ¡Mutexes ¡Fail ¡to ¡Address ¡MCMs? ¡ What ¡if ¡hardware ¡ Thread ¡0 ¡ Thread ¡1 ¡ ldr ¡r1,[r2] ¡( r1=0 ) ¡ dynamically ¡reorders ¡ ... ¡ the ¡acquire ¡and ¡the ¡ ldr ¡r1,[r2] ¡(r1=0) ¡ (mutex ¡acquire) ¡ subsequent ¡load? ¡ add ¡r1,r1,1 ¡(r1=1) ¡ ¡ str ¡r1,[r2] ¡ ¡(c=1) ¡ ¡ ¡ add ¡r1,r1,1 ¡(r1=1) ¡ (mutex ¡release) ¡ str ¡r1,[r2] ¡ ¡( c=1 ) ¡ ¡ ... ¡ ¡ Lus$g ¡et ¡al., ¡“ArMOR: ¡Defending ¡Against ¡MCM ¡Mismatches…” ¡ 9 ¡

  10. Mutexes ¡Need ¡Fences…But ¡Which ¡Ones? ¡ Thread ¡0 ¡ Thread ¡1 ¡ ... ¡ ldr ¡r1,[r2] ¡(r1=0) ¡ (mutex ¡acquire) ¡ add ¡r1,r1,1 ¡(r1=1) ¡ fence ¡ str ¡r1,[r2] ¡ ¡(c=1) ¡ ldr ¡r1,[r2] ¡(r1=1) ¡ fence ¡ add ¡r1,r1,1 ¡(r1=2) ¡ (mutex ¡release) ¡ str ¡r1,[r2] ¡ ¡(c=2) ¡ ¡ ... ¡ ¡ Lus$g ¡et ¡al., ¡“ArMOR: ¡Defending ¡Against ¡MCM ¡Mismatches…” ¡ 10 ¡

  11. Mutexes ¡Need ¡Fences…But ¡Which ¡Ones? ¡ Need ¡to ¡choose ¡fences ¡with ¡ Thread ¡0 ¡ Thread ¡1 ¡ “any à store” ¡and ¡“load à any” ¡seman$cs ¡ ... ¡ ldr ¡r1,[r2] ¡(r1=0) ¡ (mutex ¡acquire) ¡ add ¡r1,r1,1 ¡(r1=1) ¡ fence(load à any) ¡ str ¡r1,[r2] ¡ ¡(c=1) ¡ ldr ¡r1,[r2] ¡(r1=1) ¡ fence(any à store) ¡ add ¡r1,r1,1 ¡(r1=2) ¡ (mutex ¡release) ¡ str ¡r1,[r2] ¡ ¡(c=2) ¡ ¡ (Source: ¡Google ¡ ... ¡ ART ¡Compiler) ¡ ¡ Lus$g ¡et ¡al., ¡“ArMOR: ¡Defending ¡Against ¡MCM ¡Mismatches…” ¡ 11 ¡

  12. The ¡MCM ¡Analysis ¡Guessing ¡Game ¡ • Q: ¡How ¡to ¡compile ¡ Requirements ¡ fence(load à any) ¡for ¡ARM? ¡ of ¡ Acquire ¡ • Consider ¡two ¡op$ons: ¡ Seman$cs: ¡ fence(load à any) ¡ Option ¡1: ¡ Option ¡2: ¡ B ¡ Ld ¡ St ¡ A ¡ dmb ¡ishld ¡ dmb ¡ish ¡ B ¡ B ¡ Ld ¡ ✔ ¡ ✔ ¡ Ld ¡ St ¡ Ld ¡ St ¡ A ¡ A ¡ St ¡ — ¡ — ¡ Ld ¡ ✔ ¡ ✔ ¡ Ld ¡ ✔ ¡ ✔ ¡ St ¡ — ¡ — ¡ St ¡ ✔ ¡ ✔ ¡ (Source: ¡Google ¡ ART ¡Compiler) ¡ Lus$g ¡et ¡al., ¡“ArMOR: ¡Defending ¡Against ¡MCM ¡Mismatches…” ¡ 12 ¡

  13. The ¡MCM ¡Analysis ¡Guessing ¡Game ¡ Although ¡“ dmb ¡ishld ” ¡ • Q: ¡How ¡to ¡compile ¡ Requirements ¡ looks ¡sufficient, ¡it ¡actually ¡ fence(load à any) ¡for ¡ARM? ¡ of ¡ Acquire ¡ may ¡be ¡too ¡weak! ¡But ¡why? ¡ • Consider ¡two ¡op$ons: ¡ Seman$cs: ¡ fence(load à any) ¡ Option ¡1: ¡ Option ¡2: ¡ B ¡ Ld ¡ St ¡ A ¡ dmb ¡ishld ¡ dmb ¡ish ¡ B ¡ B ¡ Ld ¡ ✔ ¡ ✔ ¡ Ld ¡ St ¡ Ld ¡ St ¡ A ¡ A ¡ St ¡ — ¡ — ¡ Ld ¡ ✔ ¡ ✔ ¡ Ld ¡ ✔ ¡ ✔ ¡ St ¡ — ¡ — ¡ St ¡ ✔ ¡ ✔ ¡ (Source: ¡Google ¡ ART ¡Compiler) ¡ Lus$g ¡et ¡al., ¡“ArMOR: ¡Defending ¡Against ¡MCM ¡Mismatches…” ¡ 13 ¡

  14. Why ¡Low-­‑Level ¡MCM ¡Details ¡MaQer ¡ The ¡store ¡happens ¡ Thread ¡0 ¡ Thread ¡1 ¡ before ¡the ¡load ¡only ¡ ... ¡ if ¡the ¡orderings ¡ ldr ¡r1,[r2] ¡(r1=0) ¡ (mutex ¡acquire) ¡ are ¡transi$ve ¡ add ¡r1,r1,1 ¡(r1=1) ¡ ¡ str ¡r1,[r2] ¡ ¡(c=1) ¡ ldr ¡r1,[r2] ¡(r1=1) ¡ ¡ (mutex ¡release) ¡ ¡ ¡ Lus$g ¡et ¡al., ¡“ArMOR: ¡Defending ¡Against ¡MCM ¡Mismatches…” ¡ 14 ¡

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend