drm: micro optimise cache flushing
authorDave Airlie <airlied@redhat.com>
Wed, 19 Sep 2012 01:12:41 +0000 (11:12 +1000)
committerDave Airlie <airlied@gmail.com>
Wed, 19 Sep 2012 09:59:26 +0000 (19:59 +1000)
We hit this a lot with i915 and although we'd like to engineer things to hit
it a lot less, this commit at least makes it consume a few less cycles.

from something containing
movzwl 0x0(%rip),%r10d
to
add    %r8,%rdx

I only noticed it while using perf to profile something else.

Reviewed-by: Chris Wilson <chris@chris-wilson.co.uk>
Signed-off-by: Dave Airlie <airlied@redhat.com>
drivers/gpu/drm/drm_cache.c

index 08758e061478eb77e2db77794d1d5e54c8625474..3dbc7f17eb1146a00cba823151dc2ea8f83ac2a1 100644 (file)
@@ -37,12 +37,13 @@ drm_clflush_page(struct page *page)
 {
        uint8_t *page_virtual;
        unsigned int i;
+       const int size = boot_cpu_data.x86_clflush_size;
 
        if (unlikely(page == NULL))
                return;
 
        page_virtual = kmap_atomic(page);
-       for (i = 0; i < PAGE_SIZE; i += boot_cpu_data.x86_clflush_size)
+       for (i = 0; i < PAGE_SIZE; i += size)
                clflush(page_virtual + i);
        kunmap_atomic(page_virtual);
 }