1 Immediate Multi-Threaded Dynamic Software Updates Using Stack Reconstruction Kristis Makris Rida A. Bazzi

Slides:



Advertisements
Similar presentations
More on Processes Chapter 3. Process image _the physical representation of a process in the OS _an address space consisting of code, data and stack segments.
Advertisements

Dynamic Software Updates: The State Mapping Problem Rida A. Bazzi Kristis Makris Peyman Nayeri Jun Shen ARIZONA STATE UNIVERSITY.
R4 Dynamically loading processes. Overview R4 is closely related to R3, much of what you have written for R3 applies to R4 In R3, we executed procedures.
The Interface Definition Language for Fail-Safe C Kohei Suenaga, Yutaka Oiwa, Eijiro Sumii, Akinori Yonezawa University of Tokyko.
The Kernel Abstraction. Challenge: Protection How do we execute code with restricted privileges? – Either because the code is buggy or if it might be.
1 Created by Another Process Reason: modeling concurrent sub-tasks Fetch large amount data from network and process them Two sub-tasks: fetching  processing.
Day 10 Threads. Threads and Processes  Process is seen as two entities Unit of resource allocation (process or task) Unit of dispatch or scheduling (thread.
Presented By Srinivas Sundaravaradan. MACH µ-Kernel system based on message passing Over 5000 cycles to transfer a short message Buffering IPC L3 Similar.
Contiki A Lightweight and Flexible Operating System for Tiny Networked Sensors Presented by: Jeremy Schiff.
Processes CSCI 444/544 Operating Systems Fall 2008.
Precept 3 COS 461. Concurrency is Useful Multi Processor/Core Multiple Inputs Don’t wait on slow devices.
Threads 1 CS502 Spring 2006 Threads CS-502 Spring 2006.
Run-Time Storage Organization
Threads CSCI 444/544 Operating Systems Fall 2008.
Threads. Processes and Threads  Two characteristics of “processes” as considered so far: Unit of resource allocation Unit of dispatch  Characteristics.
PRASHANTHI NARAYAN NETTEM.
CS533 Concepts of Operating Systems Class 9 Lightweight Remote Procedure Call (LRPC) Rizal Arryadi.
CSE 451: Operating Systems Autumn 2013 Module 6 Review of Processes, Kernel Threads, User-Level Threads Ed Lazowska 570 Allen.
1 Lecture 4: Threads Operating System Fall Contents Overview: Processes & Threads Benefits of Threads Thread State and Operations User Thread.
Process Introspection: A Checkpoint Mechanism for High Performance Heterogeneous Distributed Systems. University of Virginia. Author: Adam J. Ferrari.
Computer Science Detecting Memory Access Errors via Illegal Write Monitoring Ongoing Research by Emre Can Sezer.
Lecture 2 Foundations and Definitions Processes/Threads.
Computer Architecture and Operating Systems CS 3230: Operating System Section Lecture OS-1 Process Concepts Department of Computer Science and Software.
Lecture 3 Process Concepts. What is a Process? A process is the dynamic execution context of an executing program. Several processes may run concurrently,
© Janice Regan, CMPT 300, May CMPT 300 Introduction to Operating Systems Introduction to Concurrency.
1 Lecture 4: Threads Advanced Operating System Fall 2010.
© Janice Regan, CMPT 300, May CMPT 300 Introduction to Operating Systems Operating Systems Processes and Threads.
CSC 322 Operating Systems Concepts Lecture - 7: by Ahmed Mumtaz Mustehsan Special Thanks To: Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall,
Lecture 4 Mechanisms & Kernel for NOSs. Mechanisms for Network Operating Systems  Network operating systems provide three basic mechanisms that support.
Threads. Readings r Silberschatz et al : Chapter 4.
UDI Technology Benefits Slide 1 Uniform Driver Interface UDI Technology Benefits.
Implementing Remote Procedure Call Landon Cox February 12, 2016.
Contents 1.Overview 2.Multithreading Model 3.Thread Libraries 4.Threading Issues 5.Operating-system Example 2 OS Lab Sun Suk Kim.
1 Module 3: Processes Reading: Chapter Next Module: –Inter-process Communication –Process Scheduling –Reading: Chapter 4.5, 6.1 – 6.3.
1 Chapter 5: Threads Overview Multithreading Models & Issues Read Chapter 5 pages
Memory Protection: Kernel and User Address Spaces Andy Wang Operating Systems COP 4610 / CGS 5765.
Processes and threads.
Operating Systems CMPSC 473
Chapter 3: Process Concept
Memory Protection: Kernel and User Address Spaces
Chapter 9: Virtual Memory
Protection of System Resources
Day 12 Threads.
Process Management Presented By Aditya Gupta Assistant Professor
Intro to Processes CSSE 332 Operating Systems
Chapter 4: Threads.
Introduction to Operating Systems
Memory Protection: Kernel and User Address Spaces
Chapter 3 Process Management.
Memory Protection: Kernel and User Address Spaces
Memory Protection: Kernel and User Address Spaces
Chapter 9: Virtual-Memory Management
Chap. 8 :: Subroutines and Control Abstraction
Chap. 8 :: Subroutines and Control Abstraction
System Structure and Process Model
        Jefferson’s Polygraph
CSE 451: Operating Systems Spring 2012 Module 6 Review of Processes, Kernel Threads, User-Level Threads Ed Lazowska 570 Allen.
System Calls David Ferry CSCI 3500 – Operating Systems
Threads Chapter 5 2/17/2019 B.Ramamurthy.
Code-Pointer Integrity
Threads Chapter 5 2/23/2019 B.Ramamurthy.
Prof. Leonardo Mostarda University of Camerino
Still Chapter 2 (Based on Silberchatz’s text and Nachos Roadmap.)
Lecture 7: Flexible Address Translation
Runtime Environments What is in the memory?.
Outline Chapter 2 (cont) Chapter 3: Processes Virtual machines
Foundations and Definitions
Chapter 3: Process Concept
Memory Protection: Kernel and User Address Spaces
Dynamic Binary Translators and Instrumenters
Presentation transcript:

1 Immediate Multi-Threaded Dynamic Software Updates Using Stack Reconstruction Kristis Makris Rida A. Bazzi

2 Motivation Software update problem: replace old version with new version Traditional approach is static: – stop, update, restart – Impairs high-availability Dynamic software update (DSU) can help minimize downtime

3 main f g h f Stack Execution trace g request update h g

4 main f g h f Stack Execution trace g request update h g h g f ? g g

5 Type-safety: No old code executed on new data; and vice versa typedef struct { char name[64]; float balance; } customer_record_v1_t; old version typedef struct { char name[64]; int number_of_accesses; float balance; } customer_record_v2_t; new version 0.0 John memory alignment f() writes balance = John memory alignment 145 g() is called data are transformed g() writes balance = g() returns; f() executes f() reads incorrect balance = 0

6 main f g h f Stack Execution trace g request update h g h g f g h g f main Is old version in valid state ? Is there a valid mapping ? Undecidable problem – Need user input Should provide useful safety guarantees

7 main f g h f Stack Execution trace g request update h g h g f g h g f main f g h update finished Undecidable problem – Need user input Should provide useful safety guarantees

8 Useful DSU Safety Guarantees Atomic update (subsumes type-safety) Transaction-safety Thread-safety

9 Atomic Update – At no time does the executing application expect different representations of state – After the update only new code executes over the new state; no old code ever executes again hybrid execution new version resume map state pause old version

10 Transaction-safety Some code executes only in old or only in new version Requires user annotations f() {... while(condition) { i(); j(); k(); }... } do not update inside region

11 Thread-safety while (condition) { recv(&data); process(&data); } server clients active connections new connections active connections new connections old code active connections new connections new code

12 Providing thread-safety requires immediate updates – Atomic update – Bounded delay Existing DSU mechanisms do not provide support for immediate updates

13 Our Results First general DSU mechanism that supports – Immediate updates Atomic update Bounded delay Multi-threaded – Update active code and data – Low data-access overhead

14 Our Approach: UpStare Compiler, patch-generator, runtime – Insert update points – Source-to-source transformations of C programs – Architecture and OS independent Immediate multi-threaded updates – Atomic update: using stack reconstruction – Bounded delay: converting blocking calls to non-blocking – Multithreaded: safely blocking all threads

15 block until unroll finishes Stack Reconstruction: unrolling main() _main() a() b() c() e() f() g() main() _main() a() b() c() d() i() _i() k() m() Thread 1Thread 2Thread 3 g() f() e() c() b() a() _main() m() k() _i() d() c() b() a() _main() saved frames block all threads map global variables

16 Stack Reconstruction: restoring main() _main() a() b() c() e() d() main() _main() a() b() c() d() i() _i_new() k() m() Thread 1Thread 2Thread 3 g() f() e() c() b() a() _main() m() k() _i() d() c() b() a() _main() saved frames p() copy map Can update: local variables formal parameters return addresses Program Counter apply stack transformers - split functions - map continuation - merge functions together

17 Continuation Points main() { UPDATE_POINT(); a(); c(); g(); } a() { UPDATE_POINT(); b(); } b() { UPDATE_POINT(); d(); while(condition) { UPDATE_POINT(); e(); } main() _main() old version

18 Continuation Points main() { UPDATE_POINT(); a(); c(); g(); } a() { UPDATE_POINT(); b(); } b() { UPDATE_POINT(); d(); while(condition) { UPDATE_POINT(); e(); } main() _main() old version

19 Continuation Points main() { UPDATE_POINT(); a(); c(); g(); } a() { UPDATE_POINT(); b(); } b() { UPDATE_POINT(); d(); while(condition) { UPDATE_POINT(); e(); } main() _main() a() old version

20 Continuation Points main() { UPDATE_POINT(); a(); c(); g(); } a() { UPDATE_POINT(); b(); } b() { UPDATE_POINT(); d(); while(condition) { UPDATE_POINT(); e(); } main() _main() a() old version

21 Continuation Points main() { UPDATE_POINT(); a(); c(); g(); } a() { UPDATE_POINT(); b(); } b() { UPDATE_POINT(); d(); while(condition) { UPDATE_POINT(); e(); } main() _main() a() b() old version

22 Continuation Points main() { UPDATE_POINT(); a(); c(); g(); } a() { UPDATE_POINT(); b(); } b() { UPDATE_POINT(); d(); while(condition) { UPDATE_POINT(); e(); } main() _main() a() b() d() old version

23 Continuation Points main() { UPDATE_POINT(); a(); c(); g(); } a() { UPDATE_POINT(); b(); } b() { UPDATE_POINT(); d(); while(condition) { UPDATE_POINT(); e(); } main() _main() a() b() old version

24 Continuation Points main() { UPDATE_POINT(); a(); c(); g(); } a() { UPDATE_POINT(); b(); } b() { UPDATE_POINT(); // CP 1 d(); // CP 2 while(condition) { UPDATE_POINT(); // CP 3 e(); // CP 4 } main() _main() a() b() Saved continuation points: b_CP_3 initiate an update old version

25 Continuation Points main() { UPDATE_POINT(); a(); c(); g(); } a() { UPDATE_POINT(); // CP 1 b(); // CP 2 } main() _main() a() Saved continuation points: b_CP_3 a_CP_2

26 Continuation Points main() { UPDATE_POINT(); // CP 1 a(); // CP 2 c(); // CP 3 g(); // CP 4 } main() _main() Saved continuation points: b_CP_3 a_CP_2 _main_CP_2

27 Continuation Points main() _main() Saved continuation points: b_CP_3 a_CP_2 _main_CP_2 Restored continuation points: _main_CP_2 main() { UPDATE_POINT(); a(); // CP 2 c(); g(); } new version

28 Continuation Points main() _main() Saved continuation points: b_CP_3 a_CP_2 _main_CP_2 Restored continuation points: _main_CP_2 new version main() { UPDATE_POINT(); a(); // CP 2 c(); g(); } a() { UPDATE_POINT(); b(); // CP 2 } a() a_CP_2

29 main() { UPDATE_POINT(); a(); c(); g(); } a() { UPDATE_POINT(); b(); } b() { UPDATE_POINT(); // CP 1 d(); // CP 2 f(); // CP 3 while(condition) { UPDATE_POINT(); // CP 4 e(); // CP 5 } Continuation Points main() _main() a() Saved continuation points: b_CP_3 a_CP_2 _main_CP_2 Restored continuation points: _main_CP_2 a_CP_2 b_CP_4 b() new version

30 Multi-Threaded Updates HAS lock L WANTS lock L voluntarily blocked blocked Thread 1Thread 2 LOCK(L); UPDATE_POINT(); LOCK(L); Detect if all threads are blocked Treat locks as update points Multi-Process Updates wrap fork(), wait(), waitpid() coordinate atomic reconstruction

31 Bounded Delay SOME DATA stack data buffer YYYYYYYYY YY ZZZZZZZZZZ other data functionA() { char data[SIZE];... recv(FD, &data);... } heap SOME DATA save issue non-blocking XXXXXXXXX SOME DATA MORE DATA voluntarily block restore SOME DATA MORE DATA RECV(FD,&data); SELECT(FD); UPDATE_POINT(); RECV_FINISH(FD,&data);

32 Evaluation KissFFT – Small, data-intensive application (2,000 LoC) Very Secure FTP Daemon – Medium-sized application (12,000 LoC) – Forks non-communicating connection handlers PostgreSQL DBMS – Large application (postmaster: 225,000 LoC) – Forks communicating connection handlers Shared Memory

33 KissFFT v1.2.0 Overhead – Execution time: 38%; faster than Ginseng (150%) functionA functionB uninstrumented version desired optimization outside.text segment code for restoring instrumented version code for unrolling code for update points

34 Very Secure FTP Daemon Updates – Under two use cases: idle client, file transfer – 13 updates (5.5 years-worth) – 11 manual continuation mappings – Latency 60ms (50ms to block all threads) Overhead – Latency: retrieve a 32-byte file 1000 times – Throughput: retrieve a 300MB file – In-memory and on-disk, over cross-over cable

35 vsFTPd Overhead Latency: 16-17% (1.6ms); throughput: 0%

36 PostgreSQL DBMS Updates – 1 update: v to v – No manual continuation points; latency 60ms Overhead – Latency: run 1 transaction 1000 times – Throughput: “TPC-B like” pgbench; 100,000 txs – In-memory and on-disk, over cross-over cable

37 PostgreSQL Latency Latency: 89-97% (22.5ms)

38 PostgreSQL Throughput Throughput: 41% in-memory; 26% on-disk

39 Related Work Application DSU – OPUS: Small, isolated, feature-less updates – POLUS: Cannot update local variables – Ginseng: Data-access indirection Kernel DSU – DynAMOS,KSplice Data-access indirection; limited safety – K42: Immediate updates; specially crafted

40 On-going and Future Work Move cold code at end of process image Automatically map pointers – Developed in previous work; not integrated yet Runtime safety checking – Transaction-safety through dynamic stack tracing Temporary overhead 10-12% Semantic analysis – Identify nature of updates and prove correctness – Reduce user input Update in-transit data and files

41 Conclusion UpStare: Dynamic Software Updating – Source-to-source transformation of C applications – Useful safety guarantees Stack reconstruction – Update active code and data atomically – No data-access indirection Multi-threaded and multi-process updates Immediate updates – Convert blocking calls to non-blocking Demonstrated updates – vsFTPd: 13 updates (5.5 years-worth); 12,000 LOC – PostgreSQL v7.4.16; over 200,000 LOC Low overhead (0-26%); unoptimized

42 Questions ?