On Wed, Mar 24, 2021 at 01:35:17PM +0100, Thomas Hellström (Intel) wrote:
On 3/24/21 1:24 PM, Jason Gunthorpe wrote:But we don't really care about the size of the fault when we stuff the
On Wed, Mar 24, 2021 at 10:56:43AM +0100, Daniel Vetter wrote:I figure that would probably work, but since the huge_fault() interface is
On Tue, Mar 23, 2021 at 06:06:53PM +0100, Thomas Hellström (Intel) wrote:Why should the driver be so specific?
On 3/23/21 5:37 PM, Jason Gunthorpe wrote:The somewhat annoying thing is that we'd need an error code so we fall
On Tue, Mar 23, 2021 at 05:34:51PM +0100, Thomas Hellström (Intel) wrote:Good point. No, currently it's only conditioned on transhuge page support.
Isn't the devmap PTE flag arch optional? Does this fall back to notYes, that should work.@@ -210,6 +211,20 @@ static vm_fault_t ttm_bo_vm_insert_huge(struct vm_fault *vmf,I think we can do this statically:
if ((pfn & (fault_page_size - 1)) != 0)
goto out_fallback;
+ /*
+ * Huge entries must be special, that is marking them as devmap
+ * with no backing device map range. If there is a backing
+ * range, Don't insert a huge entry.
+ * If this check turns out to be too much of a performance hit,
+ * we can instead have drivers indicate whether they may have
+ * backing device map ranges and if not, skip this lookup.
+ */
- if it's system memory we know there's no devmap for it, and we do the
trick to block gup_fast
- if it's iomem, we know gup_fast wont work anyway if don't set PFN_DEV,I think gup_fast will unfortunately mistake a huge iomem page for an
so might as well not do that
ordinary page and try to access a non-existant struct page for it, unless we
do the devmap trick.
And the lookup would then be for the rare case where a driver would have
already registered a dev_pagemap for an iomem area which may also be mapped
through TTM (like the patch from Felix a couple of weeks ago). If a driver
can promise not to do that, then we can safely remove the lookup.
using huge pages on arches that don't support it?
Need to condition it on also devmap support.
Also, I feel like this code to install "pte_special" huge pages doesI could add helpers in huge_memory.c:
not belong in the drm subsystem..
vmf_insert_pfn_pmd_prot_special() and
vmf_insert_pfn_pud_prot_special()
back to pte fault handling. That's at least my understanding of how
pud/pmd fault handling works. Not sure how awkward that is going to be
with the overall fault handling flow.
But aside from that I think this makes tons of sense.
vmf_insert_pfn_range_XXX()
And it will figure out the optimal way to build the page tables.
Driver should provide the largest physically contiguous range it can
already providing the size of the fault based on how the pagetable is
currently populated I figure that would have to move a lot of that logic
into that helper...
pfns.
The device might use it when handling the fault, but once the fault is
handled the device knows what the contiguous pfn range is that it has
available to stuff into the page tables, it just tells the vmf_insert
what it was able to create, and it creates the necessary page table
structure.
The size of the hole in the page table is really only advisory, the
device may not want to make a 2M or 1G page entry and may prefer to
only create 4k.
In an ideal world the creation/destruction of page table levels would
by dynamic at this point, like THP.