Re: How to use huge pages in drivers?

Dominique Martinet
2019-09-03T21:28:34Z

Matthew Wilcox wrote on Tue, Sep 03, 2019:
> > What I'd like to know is:
> > - we know (assuming the other side isn't too bugged, but if it is we're
> > fucked up anyway) exactly what huge-page-sized physical memory range has
> > been mapped on the other side, is there a way to manually gather the
> > pages corresponding and merge them into a huge page?
>
> You're using the word 'page' here, but I suspect what you really mean is
> "pfn" or "pte". As you've described it, it doesn't matter what data structure
> Linux is using for the memory, since Linux doesn't know about the memory.

Correct, we're already using vmf_insert_pfn

> We have vmf_insert_pfn_pmd() which is designed to be called from your
> ->huge_fault handler. See dev_dax_huge_fault() -> __dev_dax_pmd_fault()
> for an example. It's a fairly new mechanism, so I don't think it's
> popular with device drivers yet.
>
> All you really need is the physical address of the memory to make this work.

Great; I'm not sure how I had missed the pmd variant here. It's even
been around for long enough to be available on our "old" el7 kernels so
I'll be able to test this quickly.

Thanks!
--
Dominique