Skip to contentSkip to conversation

drm: micro optimise cache flushing

PATCH In review Dave Airlie 3 participants 3 messages Sep 19, 2012 – Sep 20, 2012

Subsystems (2)
lore
Share & tools
lore

Dave Airlie

author maintainer
#0 lore raw

PATCH 1/1 drm: micro optimise cache flushing

From: Dave Airlie <[email protected]>

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.

---
 drivers/gpu/drm/drm_cache.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/gpu/drm/drm_cache.c +2 -1
index 08758e0..3dbc7f1 100644
@@ -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);
 }
Signature · 1 line
1.7.12
Reviewed-by on v1 1/1
#1 lore raw
Quoted 5 lines · Dave Airlie

From: Dave Airlie <[email protected]>

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.

Quoted 8 lines

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

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

I would have thought this is something the compiler should, with the appropriate hints, be smart enough to decide for itself as boot_cpu_data should be constant once defined. *shrug*
-Chris

Signature · 1 line
Chris Wilson, Intel Open Source Technology Centre
#2 lore raw
Quoted 11 lines · Chris Wilson
Quoted 10 lines · Dave Airlie

From: Dave Airlie <[email protected]>

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

Quoted 8 lines
Quoted 3 lines

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

I would have thought this is something the compiler should, with the appropriate hints, be smart enough to decide for itself as boot_cpu_data should be constant once defined. *shrug*

Since it's not obvious the compiler isn't smart enough, should the code carry a comment so we don't forget?

BR,
Jani.