Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1232074 > unrolled thread
| Started by | Denys Vlasenko <dvlasenk@redhat.com> |
|---|---|
| First post | 2015-09-24 14:10 +0200 |
| Last post | 2015-09-25 14:30 +0200 |
| Articles | 3 — 3 participants |
Back to article view | Back to linux.kernel
[PATCH] x86/processor.h: Force inlining of cpu_relax() Denys Vlasenko <dvlasenk@redhat.com> - 2015-09-24 14:10 +0200
Re: [PATCH] x86/processor.h: Force inlining of cpu_relax() Borislav Petkov <bp@alien8.de> - 2015-09-25 13:50 +0200
[tip:x86/asm] x86/asm: Force inlining of cpu_relax() tip-bot for Denys Vlasenko <tipbot@zytor.com> - 2015-09-25 14:30 +0200
| From | Denys Vlasenko <dvlasenk@redhat.com> |
|---|---|
| Date | 2015-09-24 14:10 +0200 |
| Subject | [PATCH] x86/processor.h: Force inlining of cpu_relax() |
| Message-ID | <qcdvz-2yv-11@gated-at.bofh.it> |
On x86, cpu_relax() simply calls rep_nop(), which generates one
instruction, PAUSE (aka REP NOP).
With this config:
http://busybox.net/~vda/kernel_config_OPTIMIZE_INLINING_and_Os
gcc-4.7.2 does not always inline rep_nop(): it generates
several copies of this:
<rep_nop> (16 copies, 194 calls):
55 push %rbp
48 89 e5 mov %rsp,%rbp
f3 90 pause
5d pop %rbp
c3 retq
See https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66122
This patch fixes this via s/inline/__always_inline/
on rep_nop() and cpu_relax().
(Forcing inlining only on rep_nop() causes gcc to
deinline cpu_relax(), with almost no change in generated code).
text data bss dec hex filename
88118971 19905208 36421632 144445811 89c1173 vmlinux.before
88118139 19905208 36421632 144444979 89c0e33 vmlinux
Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
CC: Ingo Molnar <mingo@kernel.org>
CC: Andy Lutomirski <luto@amacapital.net>
CC: "H. Peter Anvin" <hpa@zytor.com>
CC: Borislav Petkov <bp@alien8.de>
CC: Brian Gerst <brgerst@gmail.com>
CC: x86@kernel.org
CC: linux-kernel@vger.kernel.org
---
arch/x86/include/asm/processor.h | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/arch/x86/include/asm/processor.h b/arch/x86/include/asm/processor.h
index 19577dd..b55f309 100644
--- a/arch/x86/include/asm/processor.h
+++ b/arch/x86/include/asm/processor.h
@@ -556,12 +556,12 @@ static inline unsigned int cpuid_edx(unsigned int op)
}
/* REP NOP (PAUSE) is a good thing to insert into busy-wait loops. */
-static inline void rep_nop(void)
+static __always_inline void rep_nop(void)
{
asm volatile("rep; nop" ::: "memory");
}
-static inline void cpu_relax(void)
+static __always_inline void cpu_relax(void)
{
rep_nop();
}
--
1.8.1.4
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
[toc] | [next] | [standalone]
| From | Borislav Petkov <bp@alien8.de> |
|---|---|
| Date | 2015-09-25 13:50 +0200 |
| Message-ID | <qczFM-h5-11@gated-at.bofh.it> |
| In reply to | #1232074 |
On Thu, Sep 24, 2015 at 02:02:29PM +0200, Denys Vlasenko wrote:
> On x86, cpu_relax() simply calls rep_nop(), which generates one
> instruction, PAUSE (aka REP NOP).
>
> With this config:
> http://busybox.net/~vda/kernel_config_OPTIMIZE_INLINING_and_Os
> gcc-4.7.2 does not always inline rep_nop(): it generates
> several copies of this:
>
> <rep_nop> (16 copies, 194 calls):
> 55 push %rbp
> 48 89 e5 mov %rsp,%rbp
> f3 90 pause
> 5d pop %rbp
> c3 retq
>
> See https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66122
>
> This patch fixes this via s/inline/__always_inline/
> on rep_nop() and cpu_relax().
> (Forcing inlining only on rep_nop() causes gcc to
> deinline cpu_relax(), with almost no change in generated code).
>
> text data bss dec hex filename
> 88118971 19905208 36421632 144445811 89c1173 vmlinux.before
> 88118139 19905208 36421632 144444979 89c0e33 vmlinux
Looks ok to me, text even grows smaller.
Acked-by: Borislav Petkov <bp@suse.de>
--
Regards/Gruss,
Boris.
ECO tip #101: Trim your mails when you reply.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
[toc] | [prev] | [next] | [standalone]
| From | tip-bot for Denys Vlasenko <tipbot@zytor.com> |
|---|---|
| Date | 2015-09-25 14:30 +0200 |
| Subject | [tip:x86/asm] x86/asm: Force inlining of cpu_relax() |
| Message-ID | <qcAiv-1fs-35@gated-at.bofh.it> |
| In reply to | #1232074 |
Commit-ID: 0b101e62afe626ecae60173f92f1e0ec72151653
Gitweb: http://git.kernel.org/tip/0b101e62afe626ecae60173f92f1e0ec72151653
Author: Denys Vlasenko <dvlasenk@redhat.com>
AuthorDate: Thu, 24 Sep 2015 14:02:29 +0200
Committer: Ingo Molnar <mingo@kernel.org>
CommitDate: Fri, 25 Sep 2015 09:44:34 +0200
x86/asm: Force inlining of cpu_relax()
On x86, cpu_relax() simply calls rep_nop(), which generates one
instruction, PAUSE (aka REP NOP).
With this config:
http://busybox.net/~vda/kernel_config_OPTIMIZE_INLINING_and_Os
gcc-4.7.2 does not always inline rep_nop(): it generates several
copies of this:
<rep_nop> (16 copies, 194 calls):
55 push %rbp
48 89 e5 mov %rsp,%rbp
f3 90 pause
5d pop %rbp
c3 retq
See: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66122
This patch fixes this via s/inline/__always_inline/
on rep_nop() and cpu_relax().
( Forcing inlining only on rep_nop() causes GCC to
deinline cpu_relax(), with almost no change in generated code).
text data bss dec hex filename
88118971 19905208 36421632 144445811 89c1173 vmlinux.before
88118139 19905208 36421632 144444979 89c0e33 vmlinux
Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
Cc: Andy Lutomirski <luto@amacapital.net>
Cc: Borislav Petkov <bp@alien8.de>
Cc: Brian Gerst <brgerst@gmail.com>
Cc: H. Peter Anvin <hpa@zytor.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: linux-kernel@vger.kernel.org
Link: http://lkml.kernel.org/r/1443096149-27291-1-git-send-email-dvlasenk@redhat.com
Signed-off-by: Ingo Molnar <mingo@kernel.org>
---
arch/x86/include/asm/processor.h | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/arch/x86/include/asm/processor.h b/arch/x86/include/asm/processor.h
index 19577dd..b55f309 100644
--- a/arch/x86/include/asm/processor.h
+++ b/arch/x86/include/asm/processor.h
@@ -556,12 +556,12 @@ static inline unsigned int cpuid_edx(unsigned int op)
}
/* REP NOP (PAUSE) is a good thing to insert into busy-wait loops. */
-static inline void rep_nop(void)
+static __always_inline void rep_nop(void)
{
asm volatile("rep; nop" ::: "memory");
}
-static inline void cpu_relax(void)
+static __always_inline void cpu_relax(void)
{
rep_nop();
}
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
[toc] | [prev] | [standalone]
Back to top | Article view | linux.kernel
csiph-web