]> asedeno.scripts.mit.edu Git - linux.git/commitdiff
drm/i915: Only initialize partially filled pagetables
authorChris Wilson <chris@chris-wilson.co.uk>
Fri, 8 Sep 2017 18:16:22 +0000 (19:16 +0100)
committerChris Wilson <chris@chris-wilson.co.uk>
Sat, 9 Sep 2017 08:03:05 +0000 (09:03 +0100)
If we know that we will completely fill a pagetable (i.e. we are
inserting a complete set of 512 pages), we can skip prefilling that PT
with scratch entries. If we have to abort the insertion prior to writing
the real entries, we will teardown the pagetable and remove it from the
page directory (so that we will restart the allocation next time).

We could do similar tricks for the PD and PDP, but the likelihood of a
single insertion covering the entire 512 entries diminishes, as do the
cycle savings. The saving are even greater (relatively) when we are
preallocating page tables for huge pages, as then we never need to fill
the page table.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Cc: Matthew Auld <matthew.auld@intel.com>
Cc: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20170908181622.17791-1-chris@chris-wilson.co.uk
Reviewed-by: Matthew Auld <matthew.auld@intel.com>
drivers/gpu/drm/i915/i915_gem_gtt.c

index c33c2f97c814ba2bc3b6c22b4e3bcbd99a6bd2b4..33181d6eac3fdc5bf102bb403cd7c6d76ce78d43 100644 (file)
@@ -1168,19 +1168,22 @@ static int gen8_ppgtt_alloc_pd(struct i915_address_space *vm,
        unsigned int pde;
 
        gen8_for_each_pde(pt, pd, start, length, pde) {
+               int count = gen8_pte_count(start, length);
+
                if (pt == vm->scratch_pt) {
                        pt = alloc_pt(vm);
                        if (IS_ERR(pt))
                                goto unwind;
 
-                       gen8_initialize_pt(vm, pt);
+                       if (count < GEN8_PTES)
+                               gen8_initialize_pt(vm, pt);
 
                        gen8_ppgtt_set_pde(vm, pd, pt, pde);
                        pd->used_pdes++;
                        GEM_BUG_ON(pd->used_pdes > I915_PDES);
                }
 
-               pt->used_ptes += gen8_pte_count(start, length);
+               pt->used_ptes += count;
        }
        return 0;