How to pin and get kernel pages in Linux?

648 Views Asked by At

I am allocating memory to the buffer in kernel space. I want to pin the pages and get the pinned kernel pages. But I did not find any APIs to do that. There is one API called get_kernel_page(unsigned long start, int write, struct ** pages) which pins a single page in kernel space. If I want to pin more than one page (Ex: 25 pages) in kernel space then there is no API to do that. My questions are,

  1. Does anyone know how to pin pages in kernel space by just sending starting address of the buffer and number of pages to be pinned?
  2. If the allocated memory in kernel space is physically non-contiguous and virtually contiguous, then can we pin the pages?

NOTE: There is an API called get_user_pages_fast(unsigned long start, int nr_pages ,int write, struct ** pages) which pins the pages. But here the memory should be allocated in user space. I want similar API to pin the memory which is allocated in kernel space

0

There are 0 best solutions below