memory-managementlinux-kernellinux-device-driverkmallocvmalloc

kmallc and vmalloc return logical address?


Although there are many threads already running on kmalloc and vmalloc but I did not get my exact answer so I am putting it here.

As far I know,

kmalloc : It is kernel API which allocates physically as well virtually contiguous memory.

vmalloc : It is kernel API which allocates physically non contiguous but virtually contiguous memory.

Now my question is : In both cases (kmalloc or vmalloc) address or say pointer returned by both APIs is LOGICAL ADDRESS correct ?

Memory Management has always been grey part for me in linux kernel so please correct me if my understanding is wrong.


Solution

  • Yes, the pointer can be dereferenced in your code to access the allocated memory.

    Those functions that return another kind of memory reference do not return void* I think. They usually return unsigned long or typedef'd types.