Corundum: Statically-Enforced Persistent Memory Safety

Corundum: Statically-Enforced Persistent Memory Safety

Corundum: Statically-Enforced Persistent Memory Safety Morteza Hoseinzadeh Steven Swanson University of California, San Diego University of California, San Diego San Diego, California, USA San Diego, California, USA [email protected] [email protected] ABSTRACT DRAM in the early 1970’s. PM offers numerous potential bene- Fast, byte-addressable, persistent main memories (PM) make it fits including improved memory system capacity, lower-latency possible to build complex data structures that can survive system and higher-bandwidth relative to disk-based storage, and a uni- failures. Programming for PM is challenging, not least because it fied programming model for persistent and volatile program state. combines well-known programming challenges like locking, mem- However, it also poses a host of novel challenges. For instance, it ory management, and pointer safety with novel PM-specific bug requires memory controller and ISA support, new operating system types. It also requires logging updates to PM to facilitate recovery facilities, and it places large, new burdens on programmers. after a crash. A misstep in any of these areas can corrupt data, leak The programming challenges it poses are daunting and stem resources, or prevent successful recovery after a crash. Existing PM directly from its non-volatility, high-performance, and direct con- libraries in a variety of languages ś C, C++, Java, Go ś simplify nection to the processor’s memory bus. PM’s raw performance some of these problems, but they still require the programmer to demands the removal of system software from the common-case learn (and flawlessly apply) complex rules to ensure correctness. access path, its non-volatility requires that (if it is to be used as Opportunities for data-destroying bugs abound. storage) updates must be robust in the face of system failures, and This paper presents Corundum, a Rust-based library with an its memory-like interface forces application software to deal di- idiomatic PM programming interface and leverages Rust’s type rectly with issues like fault tolerance and error recovery rather system to statically avoid most common PM programming bugs. than relying on layers of system software. Corundum lets programmers develop persistent data structures In addition, programming with PM exacerbates the impact of using familiar Rust constructs and have confidence that they will existing types of bugs and introduces novel classes of program- be free of those bugs. We have implemented Corundum and found ming errors. Common errors like memory leaks, dangling pointers, its performance to be as good as or better than Intel’s widely-used concurrency bugs, and data structure corruption have permanent PMDK library, HP’s Atlas, Mnemosyne, and go-pmem. effects (rather than dissipating on restart). New errors are also pos- sible: A programmer might forget to log an update to a persistent CCS CONCEPTS structure or create a pointer from a persistent data structure to volatile memory. The former error may manifest during recovery · Information systems → Storage class memory; · Software while the latter is inherently unsafe since, after restart, the pointer and its engineering → Formal software verification; Software to volatile memory is meaningless and dereferencing it will result testing and debugging;· Hardware → Non-volatile memory. in (at best) an exception. The challenges of programming correctly with PM are among KEYWORDS the largest potential obstacles to wide-spread adoption of PM and non-volatile memory programming library, static bug detection, our ability to fully exploit its capabilities. If programmers cannot crash-consistent programming reliably write and modify code that correctly and safely modifies ACM Reference Format: persistent data structures, PM will be hobbled as a storage technol- Morteza Hoseinzadeh and Steven Swanson. 2021. Corundum: Statically- ogy. Enforced Persistent Memory Safety. In Proceedings of the 26th ACM Interna- Some of the bugs that PM programs suffer from have been the tional Conference on Architectural Support for Programming Languages and subject of years of research and practical tool building. The solu- Operating Systems (ASPLOS ’21), April 19–23, 2021, Virtual, USA. ACM, New tions and approaches to these problems range from programming York, NY, USA, 14 pages. https://doi.org/10.1145/3445814.3446710 disciplines to improved library support to debugging tools to pro- gramming language facilities. 1 INTRODUCTION Given the enhanced importance of memory and concurrency er- rors in PM programming, it makes sense to adopt the most effective Persistent main memory (PM) is the first new memory technol- and reliable mechanisms available for avoiding them. ogy to arrive in the memory hierarchy since the appearance of The Rust programming language provides programming language- based mechanisms to avoid a host of common memory and concur- Permission to make digital or hard copies of part or all of this work for personal or classroom use is granted without fee provided that copies are not made or distributed rency errors. Its type system, standard library, and łborrow checkerž for profit or commercial advantage and that copies bear this notice and the full citation allow the Rust compiler to statically prevent data races, synchro- on the first page. Copyrights for third-party components of this work must be honored. For all other uses, contact the owner/author(s). nization errors, and most memory allocation errors. Further, the ASPLOS ’21, April 19–23, 2021, Virtual, USA performance of the resulting machine code is comparable with that © 2021 Copyright held by the owner/author(s). of compiled C or C++. In addition to these built-in static checks, ACM ISBN 978-1-4503-8317-2/21/04. Rust also provides facilities that make it easy (and idiomatic) to https://doi.org/10.1145/3445814.3446710 429 ASPLOS ’21, April 19–23, 2021, Virtual, USA Morteza Hoseinzadeh and Steven Swanson create new types of smart pointers that integrate cleanly with the 2.1.1 PM Programming Support. While DAX mmap() provides ac- rest of the language. Its type system also make data modification cess, productively and safely using PM presents challenges that typ- explicit and easy to control. ical PM programming libraries address. To be successful, Corundum We have leveraged Rust’s abilities to create Corundum, a library must address these as well. Below, we outline the most important (or łcratež in Rust parlance) that lets programmers build persis- of these challenges. tent data structures. Corundum provides basic PM programming PM libraries provide access to multiple independent pools of facilities (e.g., opening and mapping persistent memory pools) and persistent memory, each with a root object from which other objects a persistent software transactional memory interface to provide are reachable. atomic updates to persistent data. Each pool has a private, atomic memory allocator for allocating Uniquely, Corundum uses static checking (in almost all cases) to and reclaiming space within the pool that is robust in the face of enforce key PM programming invariants: system crashes. Libraries usually identify which types can exist in a pool. For • Corundum prevents the creation of unsafe pointers between instance, the library may provide a base class or interface that non-volatile memory regions (or łpoolsž) and pointers from persistent object should inherit from or implement. those pools into volatile memory. Finally, PM libraries provide a means to express atomic sections, • Corundum ensures that programs only modify persistent usually in the form of a persistent software transactional memory [7, memory within transactions and that they log all updates to 11, 33] mechanism that specifies regions of code that should be persistent state. atomic both with respect to failure and to concurrent transactions. • Corundum prevents most persistent memory allocation er- rors (e.g. dangling pointers, and multiple frees) in the pres- ence of multiple, independent pools of PM. 2.1.2 PM Bugs. PM programmers must reckon with a wide range of potential bugs that can cause permanent corruption, lead to Our experience building Corundum demonstrates the benefits unsafe behavior, or leak resources. These include common memory that a strong type system can bring to PM programming. We evalu- allocation/deallocation errors and race conditions as well as PM- ate Corundum quantitatively and qualitatively by comparing it to specific challenges. existing PM programming libraries. We find that Corundum pro- The three most critical types of PM-specific bugs are logging vides stronger guarantees than other libraries and that it is as fast errors, unsafe inter-pool pointers, and pointers into closed pools. or faster than most of them. We also highlight some changes to Logging errors An atomic section must log all persistent updates Rust that would make Corundum even more powerful and efficient. so the transaction can roll back in case of a system failure [9ś11, 13, The rest of paper is organized as follows. Section 2 gives a brief 28, 36]. Failing to manually log an update (as some systems require) background information on PM programming and the Rust lan- can let a poorly-timed system crash compromise data integrity. guage. Section 3 describes Corundum. In Section 4 we evaluate our Updates can be hard to recognize in code, leading to unlogged library. Section 5 places Corundum in context relative to related updates. For instance, passing the address of a field of a persistent work. Finally, Section 6 concludes. struct to a library function might (to the programmer’s surprise) modify the data it points to. 2 BACKGROUND Inter-pool pointers PM programs can simultaneously access sev- Corundum adds PM programming support to Rust by providing eral, independent PM pools in addition to the conventional, volatile facilities for accessing persistent memory, providing a transaction heap and stack. The PM pools need to be self-contained so that one mechanism to ensure consistency in the case of failure, and statically pool does not contain a pointer into another pool or into volatile detecting common PM programming bugs.

View Full Text

Details

  • File Type
    pdf
  • Upload Time
    -
  • Content Languages
    English
  • Upload User
    Anonymous/Not logged-in
  • File Pages
    14 Page
  • File Size
    -

Download

Channel Download Status
Express Download Enable

Copyright

We respect the copyrights and intellectual property rights of all users. All uploaded documents are either original works of the uploader or authorized works of the rightful owners.

  • Not to be reproduced or distributed without explicit permission.
  • Not used for commercial purposes outside of approved use cases.
  • Not used to infringe on the rights of the original creators.
  • If you believe any content infringes your copyright, please contact us immediately.

Support

For help with questions, suggestions, or problems, please contact us