From: Borislav Petkov <bp@alien8.de>
To: Chris Wilson <chris@chris-wilson.co.uk>
Cc: Daniel Vetter <daniel.vetter@ffwll.ch>,
linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org,
Ross Zwisler <ross.zwisler@linux.intel.com>,
"H . Peter Anvin" <hpa@linux.intel.com>
Subject: Re: [PATCH] x86: Add an explicit barrier() to clflushopt()
Date: Mon, 19 Oct 2015 12:16:12 +0200 [thread overview]
Message-ID: <20151019101612.GA20341@pd.tnic> (raw)
In-Reply-To: <1445248735-11915-1-git-send-email-chris@chris-wilson.co.uk>
On Mon, Oct 19, 2015 at 10:58:55AM +0100, Chris Wilson wrote:
> During testing we observed that the last cacheline was not being flushed
> from a
>
> mb()
> for (addr = addr & -clflush_size; addr < end; addr += clflush_size)
> clflushopt();
> mb()
>
> loop (where the initial addr and end were not cacheline aligned).
>
> Changing the loop from addr < end to addr <= end, or replacing the
> clflushopt() with clflush() both fixed the testcase. Hinting that GCC
> was miscompling the assembly within the loop and specifically the
> alternative within clflushopt() was confusing the loop optimizer.
>
> Adding a barrier() into clflushopt() is enough for GCC to dtrt, but
> solving why GCC is not seeing the constraints from the alternative_io()
> would be smarter...
Hmm, would something like adding the memory clobber to the
alternative_io() definition work?
---
diff --git a/arch/x86/include/asm/alternative.h b/arch/x86/include/asm/alternative.h
index 7bfc85bbb8ff..d923e5dacdb1 100644
--- a/arch/x86/include/asm/alternative.h
+++ b/arch/x86/include/asm/alternative.h
@@ -207,7 +207,7 @@ static inline int alternatives_text_reserved(void *start, void *end)
/* Like alternative_input, but with a single output argument */
#define alternative_io(oldinstr, newinstr, feature, output, input...) \
asm volatile (ALTERNATIVE(oldinstr, newinstr, feature) \
- : output : "i" (0), ## input)
+ : output : "i" (0), ## input : "memory")
/* Like alternative_io, but for replacing a direct call with another one. */
#define alternative_call(oldfunc, newfunc, feature, output, input...) \
--
Regards/Gruss,
Boris.
ECO tip #101: Trim your mails when you reply.
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/dri-devel
WARNING: multiple messages have this Message-ID (diff)
From: Borislav Petkov <bp@alien8.de>
To: Chris Wilson <chris@chris-wilson.co.uk>
Cc: linux-kernel@vger.kernel.org,
Ross Zwisler <ross.zwisler@linux.intel.com>,
"H . Peter Anvin" <hpa@linux.intel.com>,
Imre Deak <imre.deak@intel.com>,
Daniel Vetter <daniel.vetter@ffwll.ch>,
dri-devel@lists.freedesktop.org
Subject: Re: [PATCH] x86: Add an explicit barrier() to clflushopt()
Date: Mon, 19 Oct 2015 12:16:12 +0200 [thread overview]
Message-ID: <20151019101612.GA20341@pd.tnic> (raw)
In-Reply-To: <1445248735-11915-1-git-send-email-chris@chris-wilson.co.uk>
On Mon, Oct 19, 2015 at 10:58:55AM +0100, Chris Wilson wrote:
> During testing we observed that the last cacheline was not being flushed
> from a
>
> mb()
> for (addr = addr & -clflush_size; addr < end; addr += clflush_size)
> clflushopt();
> mb()
>
> loop (where the initial addr and end were not cacheline aligned).
>
> Changing the loop from addr < end to addr <= end, or replacing the
> clflushopt() with clflush() both fixed the testcase. Hinting that GCC
> was miscompling the assembly within the loop and specifically the
> alternative within clflushopt() was confusing the loop optimizer.
>
> Adding a barrier() into clflushopt() is enough for GCC to dtrt, but
> solving why GCC is not seeing the constraints from the alternative_io()
> would be smarter...
Hmm, would something like adding the memory clobber to the
alternative_io() definition work?
---
diff --git a/arch/x86/include/asm/alternative.h b/arch/x86/include/asm/alternative.h
index 7bfc85bbb8ff..d923e5dacdb1 100644
--- a/arch/x86/include/asm/alternative.h
+++ b/arch/x86/include/asm/alternative.h
@@ -207,7 +207,7 @@ static inline int alternatives_text_reserved(void *start, void *end)
/* Like alternative_input, but with a single output argument */
#define alternative_io(oldinstr, newinstr, feature, output, input...) \
asm volatile (ALTERNATIVE(oldinstr, newinstr, feature) \
- : output : "i" (0), ## input)
+ : output : "i" (0), ## input : "memory")
/* Like alternative_io, but for replacing a direct call with another one. */
#define alternative_call(oldfunc, newfunc, feature, output, input...) \
--
Regards/Gruss,
Boris.
ECO tip #101: Trim your mails when you reply.
next prev parent reply other threads:[~2015-10-19 10:16 UTC|newest]
Thread overview: 55+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-10-19 9:58 [PATCH] x86: Add an explicit barrier() to clflushopt() Chris Wilson
2015-10-19 9:58 ` Chris Wilson
2015-10-19 10:16 ` Borislav Petkov [this message]
2015-10-19 10:16 ` Borislav Petkov
2015-10-19 11:05 ` Chris Wilson
2015-10-19 11:05 ` Chris Wilson
2015-10-19 11:25 ` Borislav Petkov
2015-10-19 11:25 ` Borislav Petkov
2015-10-19 18:29 ` Ross Zwisler
2016-01-07 10:16 ` Chris Wilson
2016-01-07 10:16 ` Chris Wilson
2016-01-07 17:55 ` Andy Lutomirski
2016-01-07 17:55 ` Andy Lutomirski
2016-01-07 19:44 ` Chris Wilson
2016-01-07 19:44 ` Chris Wilson
2016-01-07 21:05 ` H. Peter Anvin
2016-01-07 21:54 ` Chris Wilson
2016-01-07 21:54 ` Chris Wilson
2016-01-07 22:29 ` H. Peter Anvin
2016-01-07 22:29 ` H. Peter Anvin
2016-01-07 22:32 ` H. Peter Anvin
2016-01-07 22:32 ` H. Peter Anvin
2016-01-09 5:55 ` H. Peter Anvin
2016-01-09 8:01 ` Chris Wilson
2016-01-09 8:01 ` Chris Wilson
2016-01-09 22:36 ` Andy Lutomirski
2016-01-09 22:36 ` Andy Lutomirski
2016-01-11 11:28 ` Chris Wilson
2016-01-11 11:28 ` Chris Wilson
2016-01-11 20:11 ` Linus Torvalds
2016-01-11 20:11 ` Linus Torvalds
2016-01-11 21:05 ` Chris Wilson
2016-01-11 21:05 ` Chris Wilson
2016-01-12 16:37 ` Chris Wilson
2016-01-12 16:37 ` Chris Wilson
2016-01-12 17:05 ` Linus Torvalds
2016-01-12 17:05 ` Linus Torvalds
2016-01-12 21:13 ` Chris Wilson
2016-01-12 21:13 ` Chris Wilson
2016-01-12 22:07 ` Linus Torvalds
2016-01-12 22:07 ` Linus Torvalds
2016-01-13 0:55 ` Chris Wilson
2016-01-13 0:55 ` Chris Wilson
2016-01-13 2:06 ` Linus Torvalds
2016-01-13 2:06 ` Linus Torvalds
2016-01-13 2:42 ` Andy Lutomirski
2016-01-13 2:42 ` Andy Lutomirski
2016-01-13 4:39 ` Linus Torvalds
2016-01-13 4:39 ` Linus Torvalds
2016-01-13 12:34 ` Chris Wilson
2016-01-13 12:34 ` Chris Wilson
2016-01-13 18:45 ` Linus Torvalds
2016-01-13 18:45 ` Linus Torvalds
2016-01-12 17:17 ` H. Peter Anvin
2016-01-12 17:17 ` H. Peter Anvin
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=20151019101612.GA20341@pd.tnic \
--to=bp@alien8.de \
--cc=chris@chris-wilson.co.uk \
--cc=daniel.vetter@ffwll.ch \
--cc=dri-devel@lists.freedesktop.org \
--cc=hpa@linux.intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=ross.zwisler@linux.intel.com \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.