How to get linux kernel page size programmatically

前端 未结 7 1438
悲哀的现实
悲哀的现实 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条回答
  •  孤独总比滥情好
    2021-01-31 08:46

    This is what I finally did:

    • Re-work my current module to take a new module parameter called page_shift and used that to calculate the PAGE_SIZE (PAGE_SIZE = 1 << PAGE_SHIFT)
    • Created a module loader wrapper which gets the current system PAGE_SHIFT using getconf API from libc. This wrapper gets the current system page shift and pass it as a module parameter.

    Right now the module is being loaded on different architectures with different PAGE_SIZE without any problems.

提交回复
热议问题