I am trying to implement a memory management kernel module. This module uses mmap()
system call. After implementation, I tried calling mmap which gives me an error Resource temporarily unavailable
I went through this thread. The solution does not work in my case.
Here is the kernel implementation:- Excluding variable declarations.
kmalloc_ptr = kmalloc(size, GFP_KERNEL)
static int simple_mmap(struct file *filp, struct vm_area_struct *vma)
{
remap = remap_pfn_range(vma, vma->vm_start, (virt_to_phys)(kmalloc_ptr) >> 12,
vma->vm_end - vma->vm_start,
vma->vm_page_prot)
return -EAGAIN;
value in remap
is 0
I found the error, I was not something wrong with the the mapping as I had suspected.
The error was remap should be used as
`if ((remap_pfn_range(vma, vma->vm_start, (unsigned long long)(virt_to_phys((void *)mapped_data)) >> PAGE_SHIFT, size, vma->vm_page_prot))
return -EAGAIN`;