1 / 15

配置記憶體

配置記憶體. 通訊4A 496430033汪建廷. 配置記憶體. 通訊4A 496430033汪建廷. Outline. Kmalloc 記憶體劃分區 Lookaside Caches 記憶池 Scullc 配置大塊記憶體 Scullp Scullv. Kmalloc. 用法 Kmalloc(size ,flag) 配置旗標 (1)GEP_KERNEL (可能休眠) (2)GEP_ATOMIC (用於interupt 不會 休眠).

Download Presentation

配置記憶體

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. 配置記憶體 • 通訊4A 496430033汪建廷

  2. 配置記憶體 • 通訊4A 496430033汪建廷

  3. Outline • Kmalloc • 記憶體劃分區 • Lookaside Caches • 記憶池 • Scullc • 配置大塊記憶體 • Scullp • Scullv

  4. Kmalloc • 用法 Kmalloc(size ,flag) • 配置旗標 • (1)GEP_KERNEL (可能休眠) • (2)GEP_ATOMIC (用於interupt 不會 • 休眠)

  5. 記憶體劃分區 • Normal • DMA (__GEP_DMA) • 高址區 (__GEP_HIGHUSER)

  6. 補充DMA ,高址區 • 直接記憶體存取(direct memory access)為一個特殊的硬體結構,它允許介面裝置與記憶體之間直接轉移資料,而不需經由CPU的參與。 • 高位址:不能直接存取 需要靠MAPPING到 • 一段特殊位址

  7. Size • 使用PAGE管理記憶體 • 幾種不同固定容量的記憶物件 • 同大小的記憶物件放在同一個集散區

  8. Lookaside Caches • 高需求量的物件集散區 • Slab allocate • 創建:kmem_cache_create() • 配置:創建成功後呼叫 kmem_cache_alloc • 釋放物件:kmem_cache_free() • 釋放快取:kmem_cache_destroy() 卸載模組 • 查取快取用量:cat /proc/slabinfo

  9. Scullc

  10. 記憶池 • 用途:關鍵時絕對能配置到記憶體 • 創建:mempool_create() • 配置:mempool_alloc() • 改變大小:mempool_resize() • 釋放物件:mempool_free() • 釋放記憶池:mempool_destroy()

  11. 配置大塊記憶體 • 配置:__get_free_page(flags , order) • 意義:配置連續記憶區 • order:配置2的order次方頁 • 如:order=3 就是配置 8頁 • 查取每一階的記憶頁有多少記憶頁可用 • cat /proc/buddyinfo

  12. Scullp

  13. alloc_pages() 十五章 • 記憶體配置引擎: • alloc_pages_node(nid,flags,order) • nid:節點辨識碼 (緊鄰一組特定處理器) • 巨集:alloc_pages(flag,order) • 釋放配置記憶體 • free_pages • free_hot_page (常駐處理器快取) • free_cold_page (不常駐)

  14. vmalloc • 作用:在虛擬位址配置一段連續記憶體 • (不代表實體記體連續) • 每一頁個別呼叫 alloc_page() • 差異:kmalloc 的虛擬位址 跟實體位址一對一 • vmalloc 的位址是人工虛擬出來需靠分頁表 • 使用時機:配置一大塊連續緩衝區供軟體使用 • (如create_module()時容納模組) • 缺點:不能用於中斷期 • (kmalloc GEP_KERNEL 有可能休眠)

  15. Scullv

More Related