GCMA Overview. LG Electronics CTO Software Platform Laboratory Minchan Kim

Similar documents
GCMA: Guaranteed Contiguous Memory Allocator. SeongJae Park

Swapping and embedded:

Caching and reliability

Transcendent Memory on Linux

Adapted from instructor s supplementary material from Computer. Patterson & Hennessy, 2008, MK]

ECE 598 Advanced Operating Systems Lecture 14

CFLRU:A A Replacement Algorithm for Flash Memory

Topics. File Buffer Cache for Performance. What to Cache? COS 318: Operating Systems. File Performance and Reliability

EECS 482 Introduction to Operating Systems

Conoscere e ottimizzare l'i/o su Linux. Andrea Righi -

SAY-Go: Towards Transparent and Seamless Storage-As-You-Go with Persistent Memory

Lecture 21: Virtual Memory. Spring 2018 Jason Tang

Memory Hierarchy Motivation, Definitions, Four Questions about Memory Hierarchy

Transcendent Memory and Friends (Not just for virtualization anymore!) Dan Magenheimer, Oracle Corp.

Recall: Address Space Map. 13: Memory Management. Let s be reasonable. Processes Address Space. Send it to disk. Freeing up System Memory

Swapping. Jin-Soo Kim Computer Systems Laboratory Sungkyunkwan University

CS370 Operating Systems

Contiguous memory allocation in Linux user-space

An Evolutionary Study of Linux Memory Management for Fun and Profit

NUMA replicated pagecache for Linux

18-447: Computer Architecture Lecture 18: Virtual Memory III. Yoongu Kim Carnegie Mellon University Spring 2013, 3/1

Swapping. Operating Systems I. Swapping. Motivation. Paging Implementation. Demand Paging. Active processes use more physical memory than system has

Memory Technology. Caches 1. Static RAM (SRAM) Dynamic RAM (DRAM) Magnetic disk. Ideal memory. 0.5ns 2.5ns, $2000 $5000 per GB

Contents. Memory System Overview Cache Memory. Internal Memory. Virtual Memory. Memory Hierarchy. Registers In CPU Internal or Main memory

ECE 571 Advanced Microprocessor-Based Design Lecture 12

Xen on ARM. How fast is it, really? Stefano Stabellini. 18 August 2014

Using Transparent Compression to Improve SSD-based I/O Caches

Filesystem. Disclaimer: some slides are adopted from book authors slides with permission 1

NVDIMM Overview. Technology, Linux, and Xen

Chapter 10: Case Studies. So what happens in a real operating system?

EECS150 - Digital Design Lecture 11 SRAM (II), Caches. Announcements

Course Outline. Processes CPU Scheduling Synchronization & Deadlock Memory Management File Systems & I/O Distributed Systems

Memory Externalization With userfaultfd Red Hat, Inc.

Cascade Mapping: Optimizing Memory Efficiency for Flash-based Key-value Caching

NVMFS: A New File System Designed Specifically to Take Advantage of Nonvolatile Memory

! What is main memory? ! What is static and dynamic allocation? ! What is segmentation? Maria Hybinette, UGA. High Address (0x7fffffff) !

DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING UNIT I

CS3350B Computer Architecture

Swapping. Jinkyu Jeong Computer Systems Laboratory Sungkyunkwan University

Efficient Memory Management on Mobile Devices

Lecture 13: Address Translation

Tuning Android for low RAM

Virtual Memory Management

COSC3330 Computer Architecture Lecture 20. Virtual Memory

PROJECT 6: PINTOS FILE SYSTEM. CS124 Operating Systems Winter , Lecture 25

EECS151/251A Spring 2018 Digital Design and Integrated Circuits. Instructors: John Wawrzynek and Nick Weaver. Lecture 19: Caches EE141

Virtual Memory Design and Implementation

CS 61C: Great Ideas in Computer Architecture. Multilevel Caches, Cache Questions

Memory Management Outline. Operating Systems. Motivation. Paging Implementation. Accessing Invalid Pages. Performance of Demand Paging

COEN-4730 Computer Architecture Lecture 3 Review of Caches and Virtual Memory

Memory Management. q Basic memory management q Swapping q Kernel memory allocation q Next Time: Virtual memory

CS510 Operating System Foundations. Jonathan Walpole

MTD Based Compressed Swapping for Embedded Linux.

Paging algorithms. CS 241 February 10, Copyright : University of Illinois CS 241 Staff 1

Proposal of Live Dump

Operating System Supports for SCM as Main Memory Systems (Focusing on ibuddy)

Page Tables. Jinkyu Jeong Computer Systems Laboratory Sungkyunkwan University

FILE SYSTEMS, PART 2. CS124 Operating Systems Fall , Lecture 24

CS370 Operating Systems

OS PMM - More space: if you give an OS more memory

Memory Management. Disclaimer: some slides are adopted from book authors slides with permission 1

File Systems. Chapter 11, 13 OSPP

Chapter 8: Virtual Memory. Operating System Concepts Essentials 2 nd Edition

Red Hat Enterprise Linux on IBM System z Performance Evaluation

vcacheshare: Automated Server Flash Cache Space Management in a Virtualiza;on Environment

LECTURE 10: Improving Memory Access: Direct and Spatial caches

COMP9242 Advanced OS. Copyright Notice. The Memory Wall. Caching. These slides are distributed under the Creative Commons Attribution 3.

I/O and file systems. Dealing with device heterogeneity

Operating Systems Lecture 6: Memory Management II

Chapter 5. Large and Fast: Exploiting Memory Hierarchy

Memory Allocation. Static Allocation. Dynamic Allocation. Dynamic Storage Allocation. CS 414: Operating Systems Spring 2008

CS 152 Computer Architecture and Engineering. Lecture 7 - Memory Hierarchy-II

Android Memory Management

- SLED: single large expensive disk - RAID: redundant array of (independent, inexpensive) disks

Design Issues 1 / 36. Local versus Global Allocation. Choosing

Virtual Memory: From Address Translation to Demand Paging

2. PICTURE: Cut and paste from paper

Memory Management. Disclaimer: some slides are adopted from book authors slides with permission 1

Handout 4 Memory Hierarchy

Virtual Memory Design and Implementation

Chapter 9: Virtual Memory

Memory Management. Frédéric Haziza Spring Department of Computer Systems Uppsala University

COS 318: Operating Systems. File Systems. Topics. Evolved Data Center Storage Hierarchy. Traditional Data Center Storage Hierarchy

CS370 Operating Systems

The Beast We Call A3. CS 161: Lecture 10 3/7/17

Ext4 Filesystem Scaling

Virtual Memory Management in Linux (Part II)

Memory Management Topics. CS 537 Lecture 11 Memory. Virtualizing Resources

File system fun. File systems: traditionally hardest part of OS. - More papers on FSes than any other single topic

Ext3/4 file systems. Don Porter CSE 506

Page Replacement. (and other virtual memory policies) Kevin Webb Swarthmore College March 27, 2018

FS Consistency & Journaling

SLES11-SP1 Driver Performance Evaluation

Paging. Jin-Soo Kim Computer Systems Laboratory Sungkyunkwan University

Process. One or more threads of execution Resources required for execution. Memory (RAM) Others

Memory Hierarchy. Maurizio Palesi. Maurizio Palesi 1

Computer Systems Laboratory Sungkyunkwan University

Chapter 5. Large and Fast: Exploiting Memory Hierarchy

File system fun. File systems: traditionally hardest part of OS

Beyond Block I/O: Rethinking

Transcription:

GCMA Overview LG Electronics CTO Software Platform Laboratory Minchan Kim <minchan.kim@lge.com>

Contents Background Problems GCMA Basic GCMA Pros and Cons

Background Need for physical contiguous memory for a long time Reserve during boot Array vs. malloc problem What is CMA (Contiguous memory allocator)? Allow reserved memory to be able to be migrated out How it works Reserves an amount of memory during boot Allows it to be allocated for only movable pages Migrates and/or discards them out if some drivers ask

CMA Problems - I No guarantee of successful allocation Any one in kernel can pin any one of movable pages for a long time get_user_pages Object dependency get_page High latency of the allocation Migration overhead (rmap overhead, memory copy and LRU churn) Reclaim overhead, sometime OOM Stall caused by dirty page write Swap out/throw workingset pages out

CMA Problems - II Code complexity Add a ton of logics in core MM Fragile hooks in core MM made lots of bugs FS/MM/Driver dependency

Guaranteed CMA Basic Goals Request of allocation should be always successful The latency of allocation should be minimized How it works Reserves an amount of memory during boot Allows it to be allocated for the [least recently used out-of-kernel] pages Discards and/or migrates them out if some driver ask

GCMA Pros Guarantee of successful allocation GCMA pages are out of kernel's control Low latency Least recently used pages by cleancache/frontswap How to handle [ephemeral persistent] pages discard, write back, put back No migration/reclaim overhead Complexity Never touch core MM, all of logics are self-contained Flexible for adding policy

GCMA Cons Low cache hit ratio imposes memcpy + reclaim cost Moves page reclaim overhead from CMA allocation time to runtime

GCMA Implementation Details and Performance Evaluation SeongJae Park <sj38.park@gmail.com>

Nice To Meet You SeongJae Park <sj38.park@gmail.com> dcslab@snu.ac.kr Global Open Frontier Lab

TL;DR GCMA is Abbrev of Guaranteed Contiguous Memory Allocator Guarantees Allocation success Minimized latency http://i2.kym-cdn.com/photos/images/original/000/049/561/tldr_pope.jpg

GCMA: Implementation

GCMA Basic Idea 1. Reserves an amount of memory during boot 2. Allow the memory to contig allocation and LRU / easily discardable pages 3. Drain LRU / easily discardable pages for contig allocation If necessary

GCMA vs CMA: Similarity 1. Reserves an amount of memory during boot 2. Allow the memory to contig allocation and LRU / easily discardable pages 3. Drain LRU / easily discardable pages for contig allocation If necessary

GCMA vs CMA: Similarity 1. Reserves an amount of memory during boot 2. Allow the memory to contig allocation and LRU / easily discardable pages 3. Drain LRU / easily discardable pages for contig allocation If necessary So, GCMA simply use CMA code rather than re-inventing the wheel

GCMA Architecture GCMA is integrated in CMA CMA Interface CMA Internal GCMA Interface Page Migration GCMA Internal LRU / Easily Discardable Pages Manager

GCMA Inside CMA GCMA uses CMA reserved area struct cma { unsigned long unsigned long unsigned long struct gcma }; base_pfn; count; *bitmap; *gcma; GCMA allocates free contig area which CMA found pfn = cma->base_pfn + (bitmap_no << cma->order_per_bit); mutex_lock(&cma_mutex); if (cma->gcma) ret = gcma_alloc_contig(cma->gcma, pfn, count); else ret = alloc_contig_range(pfn, pfn + count, MIGRATE_CMA);

GCMA Basic Idea: Done 1. Reserves an amount of memory during boot 2. Allow the memory to contig allocation and LRU / easily discardable pages 3. Drain LRU / easily discardable pages for contig allocation If necessary

GCMA Basic Idea: TODOs 1. Reserves an amount of memory during boot 2. Allow the memory to contig allocation and LRU / easily discardable pages 3. Drain LRU / easily discardable pages for contig allocation If necessary

Background: Frontswap Hook layer between Memory & Swap-Device A page can be stored inside Frontswap before going to Swap-Device if possible Fast, Narrow Memory Frontswap Front-end Frontswap Backend Slow, Large Swap Device

Page Inside Frontswap Least Recently Used Could be free after write-back as soon as want if it works as write-through (The data is already in swap-device) after put-back (It would come back to frontswap again soon)

Page Inside Frontswap Least Recently Used Could be free after write-back as soon as want if it works as write-through (The data is already in swap-device) after put-back (It would come back to frontswap again soon) 1. Reserves an amount of memory during boot 2. Allow the memory to contig allocation and LRU / easily discardable pages 3. Drain LRU / easily discardable pages for contig allocation If necessary

Page Inside Frontswap Least Recently Used Could be free after write-back Fits for our goal! as soon as want if it works as write-through (The data is already in swap-device) after put-back (It would come back to frontswap again soon) 1. Reserves an amount of memory during boot 2. Allow the memory to contig allocation and LRU / easily discardable pages 3. Drain LRU / easily discardable pages for contig allocation If necessary

Frontswap Backend Using GCMA Allow write-through Frontswap-backend page could be allocated from GCMA Enhance memory efficiency If the region with the Frontswap-backend page should be allocated for CMA guest Free the page and use it The page could be free safely because the Frontswap-backend is working in write-through mode

Weakness of The Implementation It could degrade system performance Write-through could slow system Wear-leveling needs for Flash swap-device Write-through could crash flash swap-device Recommend Zram as swap-device Could be helpful

GCMA Data Structures CMA bitmap manages contiguously allocated regions contig bitmap Reserved Area

GCMA Data Structures CMA bitmap manages contiguously allocated regions Frontswap tree red-black tree For Frontswap Entries Reserved Area

GCMA Data Structures CMA bitmap manages contiguously allocated regions Frontswap tree red-black tree For Frontswap Entries GCMA bitmap CMA bitmap & Frontswap Pages gcma->bitmap Reserved Area

GCMA Data Structures CMA bitmap manages contiguously allocated regions Frontswap tree red-black tree For Frontswap Entries GCMA bitmap CMA bitmap & Frontswap Pages contig bitmap gcma->bitmap Reserved Area

GCMA Scenario Let s allocate contig area a area a contig bitmap Reserved Area gcma->bitmap

GCMA Scenario Let s allocate contig area a area a contig bitmap Reserved Area gcma->bitmap Ah, there are two frontswap pages in the area. Hey, get off those two pages!

GCMA Scenario Let s allocate contig area a area a Got it! BAM! contig bitmap Reserved Area gcma->bitmap Ah, there are two frontswap pages in the area. Hey, get off those two pages!

GCMA Scenario Let s allocate contig area a area a Done! contig bitmap Reserved Area gcma->bitmap

GCMA Scenario Let s allocate contig area a area a Done! contig bitmap Reserved Area gcma->bitmap Ok, it s clean now! Go ahead!

GCMA Scenario Thanks! Done! area a contig bitmap Reserved Area gcma->bitmap Ok, it s clean now! Go ahead!

GCMA: Evaluation

Evaluation Environment: Machine CuBox-i4 Pro 4 Cores, ARMv7 1GHz 800 MiB DDR3 RAM (shrinked for stress) Class 10 SanDisk 16 GiB microsd Card http://www.solid-run.com/wp-content/uploads/2014/06/cubox-i-second-562x421.png

Evaluation Environment: Variants Baseline: Linux v3.17, 128 MiB Swap CMA: Baseline + 256 MiB CMA GCMA: Baseline + 256 MiB GCMA GCMA.ZRAM: GCMA + 128 MiB Zram swap

Evaluation Workload Background Workload Linux v3.12.6 defconfig build 4 jobs per core(make -j 16) Allocation(Foreground) Workload Request 1-32K contiguous pages(4 KiB - 128 MiB) Repeat 32 Requests, Get Average

Average Latency CMA shows much higher allocation latency than GCMA & GCMA.ZRAM

Latency Distribution: 4 MiB alloc GCMA shows stabler distribution than CMA CMA takes 4-8 seconds in worst case CMA GCMA GCMA.ZRAM

Latency Distribution: 4 MiB alloc GCMA shows stabler distribution than CMA CMA takes 4-8 seconds in worst case CMA GCMA GCMA.ZRAM 4-8 seconds

Latency Distribution Legends: Number of requested contig pages CMA GCMA Latency (micro seconds)

Latency Distribution Legends: Number of requested contig pages CMA GCMA Dense: Latency is predictable Sparse: Latency is unpredictable Latency (micro seconds)

Latency Distribution Legends: Number of requested contig pages CMA GCMA Latency (micro seconds) 4-8 secs 32-64 msecs

Background Workload Performance time make -j 16 frontswap pages of gcma: 10,949 stored, 10,829 reclaimed frontswap pages of gcma.zram: 11,859 stored, 11,739 reclaimed

Background Workload Performance time make -j 16 zram helps system performance frontswap pages of gcma: 10,449 stored, 10,829 reclaimed frontswap pages of gcma.zram: 11,859 stored, 11,739 reclaimed

Future Work Cleancache backend Configurable discard policy http://tiki.oneworld.net/time_machine/images/timemachine.gif

How to Use GCMA Turn on CONFIG_GCMA - cma_declare_contiguous() + gcma_declare_contiguous() That s all modification clients need

Profiling Tool See how the GCMA working using $DEBUGFS_DIR/gcma/ (stored_pages loaded_pages evicted_pages reclaimed_pages) gcma# ls evicted_pages loaded_pages reclaimed_pages stored_pages

Disclaimer GCMA is not magic, it has trade-off GCMA is not CMA alternative or enemy Each allocator has own merits and demerits GCMA and CMA could coexist http://www.glsict.com/images/disclaimer.gif

Summary: GCMA... Guarantees allocation success and fast latency Have trade-off for system performance Recommends Zram swap Could be used with very little modification on client code

Code Release Just unmatured RFC yet, though https://github.com/sjp38/linux.gcma.git Also available from LKML Appreciates every comments and review :D

Thank You Any question?