From: Dave Gordon <david.s.gordon@intel.com>
To: Chris Wilson <chris@chris-wilson.co.uk>, dri-devel@lists.freedesktop.org
Cc: intel-gfx@lists.freedesktop.org
Subject: Re: [PATCH] drm: Avoid the double clflush on the last cache line in drm_clflush_virt_range()
Date: Thu, 11 Jun 2015 09:25:16 +0100 [thread overview]
Message-ID: <557945EC.8000809@intel.com> (raw)
In-Reply-To: <1433948281-25791-1-git-send-email-chris@chris-wilson.co.uk>
On 10/06/15 15:58, Chris Wilson wrote:
> As the clflush operates on cache lines, and we can flush any byte
> address, in order to flush all bytes given in the range we issue an
> extra clflush on the last byte to ensure the last cacheline is flushed.
> We can can the iteration to be over the actual cache lines to avoid this
> double clflush on the last byte.
>
> Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
> Cc: Imre Deak <imre.deak@intel.com>
> ---
> drivers/gpu/drm/drm_cache.c | 5 +++--
> 1 file changed, 3 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/gpu/drm/drm_cache.c b/drivers/gpu/drm/drm_cache.c
> index 9a62d7a53553..6743ff7dccfa 100644
> --- a/drivers/gpu/drm/drm_cache.c
> +++ b/drivers/gpu/drm/drm_cache.c
> @@ -130,11 +130,12 @@ drm_clflush_virt_range(void *addr, unsigned long length)
> {
> #if defined(CONFIG_X86)
> if (cpu_has_clflush) {
> + const int size = boot_cpu_data.x86_clflush_size;
> void *end = addr + length;
> + addr = (void *)(((unsigned long)addr) & -size);
Should this cast be to uintptr_t? Or intptr_t, as size has somewhat
strangely been defined as signed? To complete the mix, x86_clflush_size
is 'u16'! So maybe we should write
+ const size_t size = boot_cpu_data.x86_clflush_size;
+ const size_t mask = ~(size - 1);
void *end = addr + length;
+ addr = (void *)(((uintptr_t)addr) & mask);
> mb();
> - for (; addr < end; addr += boot_cpu_data.x86_clflush_size)
> + for (; addr < end; addr += size)
> clflushopt(addr);
> - clflushopt(end - 1);
> mb();
> return;
> }
>
.Dave.
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
next prev parent reply other threads:[~2015-06-11 8:25 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-06-10 14:58 [PATCH] drm: Avoid the double clflush on the last cache line in drm_clflush_virt_range() Chris Wilson
2015-06-11 8:25 ` Dave Gordon [this message]
2015-06-11 8:33 ` Chris Wilson
2015-06-18 15:31 ` [Intel-gfx] " Imre Deak
2015-06-18 15:37 ` Daniel Vetter
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=557945EC.8000809@intel.com \
--to=david.s.gordon@intel.com \
--cc=chris@chris-wilson.co.uk \
--cc=dri-devel@lists.freedesktop.org \
--cc=intel-gfx@lists.freedesktop.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox