本文主要是介绍Page_owner使用简介,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
目录
背景
Page_owner介绍
Page_owner支持
cmdline开启Page_owner
解析工具
复现问题
小结
背景
在项目中有一部分camera相关的包括camera driver使用大于等于order3的内存分配点,并没有统计到camera provider进程上。所以想通过page_owner,调查一下相机没有统计到的内存申请。
Page_owner介绍
page owner is for the tracking about who allocated each page. It can be used to debug memory leak or to find a memory hogger.
官方介绍如下:
page owner: Tracking about who allocated each page — The Linux Kernel documentation
Page_owner支持
CONFIG_PAGE_OWNER=y
cmdline开启Page_owner
在BoardConfig.mk文件中,加上对应makefile的修改。
解析工具
page_owner.sh
#!/bin/bashadb shell 'cat /sys/kernel/debug/page_owner > /data/local/tmp/page_owner_full.txt'adb pull /data/local/tmp/page_owner_full.txtgrep -v ^PFN page_owner_full.txt > page_owner.txt./page_owner_sort page_owner.txt sorted_page_owner.txt
复现问题
复现问题后执行:./page_owner.sh
最终生成:sorted_page_owner.txt
如下类似内容:
1 times:
Page allocated via order 9, mask 0x1521c2(__GFP_HIGHMEM|__GFP_IO|__GFP_FS|__GFP_NOWARN|__GFP_NORETRY|__GFP_COMP|__GFP_ZERO|__GFP_HARDWALL), pid 2379, tgid 1603 (Preview_2), ts 128125282786 ns, free_ts 75571306063 nspost_alloc_hook+0x1c0/0x208prep_new_page+0x28/0x12cget_page_from_freelist+0x1190/0x12b4__alloc_pages+0x12c/0x2fcqcom_extend_sys_heap_alloc_largest_available+0x2cc/0xa98 [qcom_dma_heaps]system_qcom_sg_buffer_alloc+0xf4/0x380 [qcom_dma_heaps]system_heap_allocate+0x90/0x168 [qcom_dma_heaps]dma_heap_buffer_alloc+0x5c/0x6ccam_mem_util_get_dma_buf+0x2c4/0x718 [camera] cam_mem_mgr_alloc_and_map+0x284/0x7f8 [camera] cam_private_ioctl+0x318/0x274c [camera] __video_do_ioctl+0x298/0x4dcvideo_usercopy+0x43c/0xb38video_ioctl2+0x18/0x28v4l2_ioctl+0x6c/0x84__arm64_sys_ioctl+0xa8/0xe41 times:
Page allocated via order 0, mask 0x100dc0(GFP_USER|__GFP_ZERO), pid 14313, tgid 1603 (SyncThread), ts 128067784036 ns, free_ts 127389201898 nspost_alloc_hook+0x1c0/0x208prep_new_page+0x28/0x12cget_page_from_freelist+0x1190/0x12b4__alloc_pages+0x12c/0x2fcqcom_io_pgtable_alloc_page+0xa0/0x1e8 [qcom_iommu_util]__arm_lpae_alloc_pages+0x34/0x178 [qcom_iommu_util]__arm_lpae_map+0x258/0x4fc [qcom_iommu_util]__arm_lpae_map+0x4c4/0x4fc [qcom_iommu_util]qcom_arm_lpae_map_pages+0xf4/0x168 [qcom_iommu_util]arm_smmu_map_pages+0xd0/0x26c [arm_smmu]__iommu_map+0x1d0/0x330__iommu_map_sg+0xcc/0x1d4iommu_map_sg+0x14/0x20cam_smmu_map_buffer_validate+0x744/0x9c8 [camera] cam_smmu_map_user_iova+0x31c/0x5b8 [camera] cam_mem_util_map_hw_va+0x1c8/0x3b4 [camera]
小结
后续总结一下更多关于 page_owner的实战内容。
这篇关于Page_owner使用简介的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!