1

basically vmalloc pages cannot be swap out, so it's not in the LRU list. is it possible to add a vmalloc page to the LRU list? so that kernel can stats the usage on that page and swap out it if it's not frequently used?

Thanks

user1073939
  • 151
  • 2
  • 5
  • Pretty sure only locked pages are barred from swapping. `vmalloc` just allocates contiguous pages of virtual memory. – Brian Cain Dec 01 '11 at 17:15
  • To Brian, vmalloc allocates pages(may/probably NOT physical contiguous) and map them in vmalloc area as contiguous virtual address. – Lai Jiangshan Jul 13 '12 at 11:39

1 Answers1

4

vmalloc() gives service to the kernel core, and some paths in the kernel which access the vmalloc()-ed memory can not sleep nor can't take any lock nor can't be preempted. If a accessing vmalloc()-ed page is swaped out, these paths will have to compete some locks and try to swap it in, they may also need to be preempted or sleep, so these paths enter a bug situation which can't be fix.

So the answer is "NO".

Lai Jiangshan
  • 1,420
  • 1
  • 13
  • 23
  • Could you explain that in more detail? – John Jun 27 '20 at 14:22
  • I found this duplicate question: https://stackoverflow.com/questions/4535379/do-kernel-pages-get-swapped-out with multiple answers. Also, looking in kernel 5.8 sources (on x86), I see that `handle_page_fault` calls `do_kern_addr_fault` for kernel memory, which doesn't have any handling of swap, while `do_user_addr_fault` does. – Jong Aug 11 '20 at 23:41