How to get linux kernel page size programmatically

前端 未结 7 1440
悲哀的现实
悲哀的现实 2021-01-31 07:56

I am working on a Linux module for IA64. My current problem is that the driver uses the PAGE_SIZE and PAGE_SHIFT macros for dma page allocation. The problem I am having is tha

7条回答
  •  梦毁少年i
    2021-01-31 08:44

    One approximate method is to read /proc/meminfo and check Mapped size ( on mine its 52544 kB as of now ) and then check nr_mapped in /proc/vmstat ( on mine its 131136 as of now ). Finally PAGE_SIZE = Mapped/nr_mapped. Sometimes this gives you an accurate value ( as in the current example I've quoted ) and sometimes its approximate but very close. Hope this helps!

提交回复
热议问题