How to mmap any address space using huge pages?

Chan Kim ckim at etri.re.kr
Thu Oct 21 03:16:00 EDT 2021


Hi, Adam

Did you tell the OS to reserve huge pages?

(in ubuntu, add vm.nr_hugepages = N in /etc/sysctl.conf or

Add hugepages=16, hugepagesz=256M in bootcommd)

Just in case you didn’t set it.

Thanks,

Chan Kim

 

From: Adam Turowski <adam.s.turowski at gmail.com> 
Sent: Friday, October 15, 2021 10:08 PM
To: kernelnewbies at kernelnewbies.org
Subject: How to mmap any address space using huge pages?

 

Hello all,


I have a device and I need to mmap it into a user space using 1GB huge pages. AFAIK I cannot use HugeTLB nor THP because they're backed by the memory. The remap_pfn_range doesn't use huge pages neither. So I used a huge_fault handler to set up the pud descriptor myself (arm64 here, so no transparent puds) and that works. The problem is that the kernel warns about a bad pud when the vma mapping is removed, the zap_pud_range function doesn't accept block puds. The vunmap_pud_range function works with block puds and checks for their presence and calls the pud_clear_huge function. If I add this function call to the zap_pud_range function, the warnings are gone.

 

Am I missing something? What is the proper way to mmap (and munmap) any address space using huge pages (esp. 1GB pages)?

 

Thanks

 

--

Regards,

Adam Turowski

 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.kernelnewbies.org/pipermail/kernelnewbies/attachments/20211021/c200bdb6/attachment.html>


More information about the Kernelnewbies mailing list