Basic of virtual memory of Linux

  • Published on
    20-May-2015

  • View
    8.164

  • Download
    2

Embed Size (px)

DESCRIPTION

written in Japanese

Transcript

  • 1. Linux 2007.2.22 original2012.10.27 revival 1

2. 2007CELF http://tree.celinuxforum.org/CelfPubWiki/JapanTechnicalJamboree13 2 3. OSLinux 4. Linux 4 5. virtual, logical ... real, physical 5 6. 6 7. 7 8. LinuxWindow CEPCOSOSOS Linux8 9. ROM,RAM,I/OROMRAMI/OI/OI/O9 10. 10 11. : Wikipedia11 12. ROMy RAM MMUI/O xLinux kernelI/O I/O 12 13. CPU ROMy RAM MMU xI/OI/O CPUI/OCPU13 14. ROM yRAMMMUx I/OI/OCPU I/O 14 15. MMU 3122 21 12 11 0 Directory Index Page Table IndexPage OffsetPage DirectoryBase RegisterPage Directory Directory Page TableEntry No page! ... page fault Page TablePage Entry 15 16. TLB ... Translation Lookaside Buffers key TLBPage Directory, Page Table 16 17. ROM RAMI/OI/O 17 18. 4Kbytes2 1. (mmap) 2. >= 18 19. (1) read access 19 20. (2) DMA 20 21. (3) data ... 21 22. (2) 22 23. (2) swap deviceLinuxswap device 23 24. DMAno page24 25. A BRead only25write 26. A Write writeaccess r/w private read onlyB26 27. Awriteaccessread/writecopyread onlyBread/write 27 28. process A BC 0x00000000 user space... 13GB TASK_SIZEkernelspace 0xffffffffRead/Write/ExecuteTASK_SIZEi3860xc0000000ARM 0xbf000000 28 29. cat /proc//maps00101000-0011a000 r-xp 00000000 fd:00 15172739 /lib/ld-2.4.so0011a000-0011b000 r-xp 00018000 fd:00 15172739 /lib/ld-2.4.so0011b000-0011c000 rwxp 00019000 fd:00 15172739 /lib/ld-2.4.so0011e000-0024a000 r-xp 00000000 fd:00 15172740 /lib/libc-2.4.so0024a000-0024d000 r-xp 0012b000 fd:00 15172740 /lib/libc-2.4.so0024d000-0024e000 rwxp 0012e000 fd:00 15172740 /lib/libc-2.4.so0024e000-00251000 rwxp 0024e000 00:00 008048000-08049000 r-xp 00000000 fd:00 11666681 /home/koba/lab/loop/a.out08049000-0804a000 rw-p 00000000 fd:00 11666681 /home/koba/lab/loop/a.outb7fef000-b7ff1000 rw-p b7fef000 00:00 0b7fff000-b8000000 rw-p b7fff000 00:00 0bffeb000-c0000000 rw-p bffeb000 00:00 0[stack] file offsetinodefile name r: readdevice w: write major:minor x: execute s: shared 29 p: private (copy on write) 30. ()cat /proc//smaps....0011e000-0024a000 r-xp 00000000 fd:00 15172740 /lib/libc-2.4.soSize:1200 kBRss:136 kB RSS = Shared_Clean: 136 kBShared_Dirty: 0 kBPrivate_Clean:0 kBPrivate_Dirty:0 kB0024a000-0024d000 r-xp 0012b000 fd:00 15172740 /lib/libc-2.4.soSize:12 kBRss:8 kBShared_Clean: 0 kBShared_Dirty: 0 kBPrivate_Clean:0 kBPrivate_Dirty:8 kB0024d000-0024e000 rwxp 0012e000 fd:00 15172740 /lib/libc-2.4.soSize: 4 kBRss:4 kBShared_Clean: 0 kBShared_Dirty: 0 kBPrivate_Clean:0 kBPrivate_Dirty:4 kB 30.... 31. mmap#include void *mmap(void *start, size_t length, int prot, int flags,int fd, off_t offset);int munmap(void *start, sizt_t length); / prot PROT_NONE PROT_EXEC, PROT_READ, PROT_WRITEOR flags MAP_FIXED, MAP_SHARED, MAP_PRIVATE, MAP_ANONYMOUS, ... 31 32. mmaptips MAP_FIXED MAP_FIXEDmunmap mmapmunmap32 33. mmap(1) malloc malloc/freemunmapaddr, size mmap 1mmapmunmap glibcmalloc mallocmmap DEFAULT_MMAP_THRESHOLD = (128*1024) 33 34. mmap(2) read, write mmap Java1.4 java.nio.MappedByteBuffer 34 35. mmap(3) R/W shared IPC (shmget, shmat,..) 35 36. mmap(4) I/O /dev/mem read/write /dev/memroot 36 37. TLB mmap 37 38. Linux kernel http://www.kernel.org/ GNU C http://www.gnu.org/software/libc/ LINUX 2 Linux2.6 SoftBank Creative Linux man WEB 38 39. 2007 CELFBootTimeResources KernelXIP NOR ApplicationXIP (DataReadInPlace) CELFMemoryManagementResouces Huge/large/superpages Page cache compression zram 3.8staging 39