11. Linux 地址轉換參考
/*
* This is useful to dump out the page tables associated with
* 'addr' in mm 'mm'.
*/
void show_pte(struct mm_struct *mm, unsigned long addr);
? virt_to_phys(virt_addr);
? phys_to_virt(phys_addr);
? arch/arm/mm/fault.c
? 可以參考kernel及user space的address轉換過程
12. Linux memory map
? 如果想要dump kernel space的page table可以打
開”CONFIG_ARM_PTDUMP”
? mount -t debugfs none /sys/kernel/debug/
? cat /sys/kernel/debug/kernel_page_tables
在開機過程也會有kernel space memory map輸出
22. gfp_mask flag
旗標 說明
GFP_ATOMIC The allocation is high priority and must not
sleep
GFP_NOWAIT Like GFP_ATOMIC, except that the call
will not fallback on emergency
memory pools.
GFP_NOIO This allocation can block, but must not
initiate disk I/O.
GFP_NOFS This allocation can block and can initiate
disk I/O, if it must, but it
will not initiate a filesystem operation.
23. gfp_mask flag
旗標 說明
GFP_KERNEL This is a normal allocation and might
block. This is the flag to use
in process context code when it is safe to
sleep
GFP_USER This is a normal allocation and might
block. This flag is used to
allocate memory for user-space
processes.
GFP_HIGHUSER This is an allocation from
ZONE_HIGHMEM and might block.
GFP_DMA This is an allocation from ZONE_DMA.
26. The SLAB allocator
? slab/slub/slob目前在linux kernel中是可選的
? SLOB: As compact as possible
? SLAB: As cache friendly as possible. Benchmark
friendly
? SLUB: Simple and instruction cost counts. Superior
debugging. Defragmentation. Execution time friendly.
? kmalloc() -> kmem_cache_create(),
kmem_cache_alloc()
? 對於一個系統效能來說我們需要避免分配與釋放struct 物件頻繁發生
? cache 常用資料結構,必要時再釋放
? Per CPU cache
? Colored object提升CPU cache命中
34. Reference
? 内存管理(一)node & zone
http://blog.chinaunix.net/uid-30282771-id-5171166.html
? 内存-内核空间
https://jin-yang.github.io/post/kernel-memory-management-
from-kernel-view.html
? Virtual Memory and Linux
https://events.linuxfoundation.org/sites/events/files/slides/elc_2
016_mem.pdf
? Slab allocators in the Linux Kernel: SLAB, SLOB, SLUB
https://events.linuxfoundation.org/sites/events/files/slides/slaba
llocators.pdf