1

I know how vmalloc() does。 When a process(in kernel space) want to access the memory that belongs to vmalloc(),a page fault happens and does the synchronization。

But when it invokes the vfree(), how the process update its page table to sync with the master kernel page table? Or I have some understandings with it.

Thanks.

Zhao Yuhao
  • 11
  • 1

1 Answers1

0

your understanding of memory allocation is seems to be incorrect. No memory belongs to vmalloc. A fixed virtual address (of kernel space) is assigned to vmalloc at boot up time. Later when vmalloc is called then virtual addresses are picked from fix allocated range and physical memory pages are allocated from buddy system.

Virtual addresses and physical pages are mapped one to one.

when vfree() is called, the virtual address range is freed again , so does the physical pages are return to buddy system.

Hope this correct your understanding.

I suggest you go through some online tutorial about kernel memory as also reading them now.

Pradeep Goswami
  • 1,785
  • 1
  • 15
  • 24
  • Yes, you are right. But my question is that the page table of process need be synchronized with the master kernel page table when vmalloc() or vfree() happens by page fault. I know why page fault happens after vmalloc() happens, but I don't why page fault happens after vfree() is invoked. – Zhao Yuhao Sep 01 '15 at 13:42
  • @ZhaoYuhao 1)Master page table don't need to syncronized with kernel page table they have only reference to it.2)page fault did not happen with vmalloc is done 3)page fault does not happen when vfree() callled. – Pradeep Goswami Sep 02 '15 at 02:25
  • Oh, yes, you're right! I have been misunderstanding all the time. Thank you very much! you are so nice – Zhao Yuhao Sep 02 '15 at 14:32