Re: [PATCH v5 2/2] kvm: Use huge pages for DAX-backed files

From: Barret Rhoden
Date: Fri Dec 13 2019 - 09:13:11 EST

On 12/12/19 8:07 PM, Liran Alon wrote:
I was a little hesitant to change the this to handle 1 GB pages with this patchset at first. I didn't want to break the non-DAX case stuff by doing so.

Why would it affect non-DAX case?
Your patch should just make hugepage_adjust() to parse page-tables only in case is_zone_device_page(). Otherwise, page tables shouldnât be parsed.
i.e. THP merged pages should still be detected by PageTransCompoundMap().

That's what I already do. But if I wanted to make the hugepage_adjust() function also handle the change to 1 GB, then that code would apply to THP too. I didn't want to do that without knowing the implications for THP.

Specifically, can a THP page be 1 GB, and if so, how can you tell? If you can't tell easily, I could walk the page table for all cases, instead of just zone_device().

I prefer to walk page-tables only for is_zone_device_page().

Is there another way to tell if a THP page is 1 GB? Anyway, this is the sort of stuff I didn't want to mess around with.

hugepage_adjust() seemed like a reasonable place to get a huge (2MB) page table entry out of a DAX mapping. I didn't want to proliferate another special case for upgrading to a larger PTE size (i.e. how hugetlbfs and THP have separate mechanisms), so I hopped on to the "can we do a 2MB mapping even though host_mapping_level() didn't say so" case - which is my interpretation of what huge_adjust() is for.