Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1416748 > unrolled thread

[PATCH 00/10] x86: use gcc 6+ asm flag output feature

Started by"H. Peter Anvin" <hpa@linux.intel.com>
First post2016-06-08 01:40 +0200
Last post2016-06-08 11:00 +0200
Articles 5 — 4 participants

Back to article view | Back to linux.kernel


Contents

  [PATCH 00/10] x86: use gcc 6+ asm flag output feature "H. Peter Anvin" <hpa@linux.intel.com> - 2016-06-08 01:40 +0200
    [PATCH 10/10] x86, asm, boot: Use CC_SET()/CC_OUT() in arch/x86/boot/boot.h "H. Peter Anvin" <hpa@linux.intel.com> - 2016-06-08 01:40 +0200
      [tip:x86/asm] x86, asm, boot: Use CC_SET()/CC_OUT() in  arch/x86/boot/boot.h "tip-bot for H. Peter Anvin" <tipbot@zytor.com> - 2016-06-08 01:50 +0200
    Re: [PATCH 00/10] x86: use gcc 6+ asm flag output feature Peter Zijlstra <peterz@infradead.org> - 2016-06-08 10:10 +0200
      Re: [PATCH 00/10] x86: use gcc 6+ asm flag output feature "H. Peter Anvin" <hpa@zytor.com> - 2016-06-08 11:00 +0200

#1416748 — [PATCH 00/10] x86: use gcc 6+ asm flag output feature

From"H. Peter Anvin" <hpa@linux.intel.com>
Date2016-06-08 01:40 +0200
Subject[PATCH 00/10] x86: use gcc 6+ asm flag output feature
Message-ID<rHyLf-GT-5@gated-at.bofh.it>
From: "H. Peter Anvin" <hpa@zytor.com>

gcc 6+ has the ability to let flags (actually, conditions, which are
specific combinations of flags) to be used directly as asm() outputs.
The syntax for that is "=@cc<cc>" where <cc> is the same set of
letters that would be used in a j<cc> or set<cc> instruction
(e.g. "=@ccz" to test the ZF flag.)

This patchset by itself reduces the size of the x86-64 kernel by
0.12%, from a baseline of 4.7-rc2 built with gcc 6.1 (first line is
with the patchset, the second one is without):

     text       data       bss        dec       hex filename
     
 68245656   41004339  20533248  129783243   7bc55cb o.i386-allconfig/vmlinux
 68355716   41008499  20533248  129897463   7be13f7 o.i386-allconfig/vmlinux

127384005  129742359  38150144  295276508  11998fdc o.x86_64-allconfig/vmlinux
127538765  129742295  38150144  295431204  119bec24 o.x86_64-allconfig/vmlinux

[toc] | [next] | [standalone]


#1416749 — [PATCH 10/10] x86, asm, boot: Use CC_SET()/CC_OUT() in arch/x86/boot/boot.h

From"H. Peter Anvin" <hpa@linux.intel.com>
Date2016-06-08 01:40 +0200
Subject[PATCH 10/10] x86, asm, boot: Use CC_SET()/CC_OUT() in arch/x86/boot/boot.h
Message-ID<rHyLg-GT-39@gated-at.bofh.it>
In reply to#1416748
Remove open-coded uses of set instructions to use CC_SET()/CC_OUT() in
arch/x86/boot/boot.h.

Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
---
 arch/x86/boot/boot.h | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/arch/x86/boot/boot.h b/arch/x86/boot/boot.h
index 2edb2d5..7c1495f 100644
--- a/arch/x86/boot/boot.h
+++ b/arch/x86/boot/boot.h
@@ -24,6 +24,7 @@
 #include <linux/types.h>
 #include <linux/edd.h>
 #include <asm/setup.h>
+#include <asm/asm.h>
 #include "bitops.h"
 #include "ctype.h"
 #include "cpuflags.h"
@@ -179,15 +180,15 @@ static inline void wrgs32(u32 v, addr_t addr)
 static inline bool memcmp_fs(const void *s1, addr_t s2, size_t len)
 {
 	bool diff;
-	asm volatile("fs; repe; cmpsb; setnz %0"
-		     : "=qm" (diff), "+D" (s1), "+S" (s2), "+c" (len));
+	asm volatile("fs; repe; cmpsb" CC_SET(nz)
+		     : CC_OUT(nz) (diff), "+D" (s1), "+S" (s2), "+c" (len));
 	return diff;
 }
 static inline bool memcmp_gs(const void *s1, addr_t s2, size_t len)
 {
 	bool diff;
-	asm volatile("gs; repe; cmpsb; setnz %0"
-		     : "=qm" (diff), "+D" (s1), "+S" (s2), "+c" (len));
+	asm volatile("gs; repe; cmpsb" CC_SET(nz)
+		     : CC_OUT(nz) (diff), "+D" (s1), "+S" (s2), "+c" (len));
 	return diff;
 }
 
-- 
2.7.3.0.11.gd79db92

[toc] | [prev] | [next] | [standalone]


#1416752 — [tip:x86/asm] x86, asm, boot: Use CC_SET()/CC_OUT() in arch/x86/boot/boot.h

From"tip-bot for H. Peter Anvin" <tipbot@zytor.com>
Date2016-06-08 01:50 +0200
Subject[tip:x86/asm] x86, asm, boot: Use CC_SET()/CC_OUT() in arch/x86/boot/boot.h
Message-ID<rHyUV-KQ-9@gated-at.bofh.it>
In reply to#1416749
Commit-ID:  8d0d5a8abd88fa9671867b8b8ab4ee61b85c0c81
Gitweb:     http://git.kernel.org/tip/8d0d5a8abd88fa9671867b8b8ab4ee61b85c0c81
Author:     H. Peter Anvin <hpa@linux.intel.com>
AuthorDate: Tue, 7 Jun 2016 16:31:09 -0700
Committer:  H. Peter Anvin <hpa@linux.intel.com>
CommitDate: Tue, 7 Jun 2016 16:36:42 -0700

x86, asm, boot: Use CC_SET()/CC_OUT() in arch/x86/boot/boot.h

Remove open-coded uses of set instructions to use CC_SET()/CC_OUT() in
arch/x86/boot/boot.h.

Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
Link: http://lkml.kernel.org/r/1465342269-492350-11-git-send-email-hpa@linux.intel.com
---
 arch/x86/boot/boot.h | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/arch/x86/boot/boot.h b/arch/x86/boot/boot.h
index 2edb2d5..7c1495f 100644
--- a/arch/x86/boot/boot.h
+++ b/arch/x86/boot/boot.h
@@ -24,6 +24,7 @@
 #include <linux/types.h>
 #include <linux/edd.h>
 #include <asm/setup.h>
+#include <asm/asm.h>
 #include "bitops.h"
 #include "ctype.h"
 #include "cpuflags.h"
@@ -179,15 +180,15 @@ static inline void wrgs32(u32 v, addr_t addr)
 static inline bool memcmp_fs(const void *s1, addr_t s2, size_t len)
 {
 	bool diff;
-	asm volatile("fs; repe; cmpsb; setnz %0"
-		     : "=qm" (diff), "+D" (s1), "+S" (s2), "+c" (len));
+	asm volatile("fs; repe; cmpsb" CC_SET(nz)
+		     : CC_OUT(nz) (diff), "+D" (s1), "+S" (s2), "+c" (len));
 	return diff;
 }
 static inline bool memcmp_gs(const void *s1, addr_t s2, size_t len)
 {
 	bool diff;
-	asm volatile("gs; repe; cmpsb; setnz %0"
-		     : "=qm" (diff), "+D" (s1), "+S" (s2), "+c" (len));
+	asm volatile("gs; repe; cmpsb" CC_SET(nz)
+		     : CC_OUT(nz) (diff), "+D" (s1), "+S" (s2), "+c" (len));
 	return diff;
 }
 

[toc] | [prev] | [next] | [standalone]


#1417013

FromPeter Zijlstra <peterz@infradead.org>
Date2016-06-08 10:10 +0200
Message-ID<rHGIO-64G-27@gated-at.bofh.it>
In reply to#1416748
On Tue, Jun 07, 2016 at 04:30:59PM -0700, H. Peter Anvin wrote:
> From: "H. Peter Anvin" <hpa@zytor.com>
> 
> gcc 6+ has the ability to let flags (actually, conditions, which are
> specific combinations of flags) to be used directly as asm() outputs.
> The syntax for that is "=@cc<cc>" where <cc> is the same set of
> letters that would be used in a j<cc> or set<cc> instruction
> (e.g. "=@ccz" to test the ZF flag.)
> 
> This patchset by itself reduces the size of the x86-64 kernel by
> 0.12%, from a baseline of 4.7-rc2 built with gcc 6.1 (first line is
> with the patchset, the second one is without):
> 
>      text       data       bss        dec       hex filename
>      
>  68245656   41004339  20533248  129783243   7bc55cb o.i386-allconfig/vmlinux
>  68355716   41008499  20533248  129897463   7be13f7 o.i386-allconfig/vmlinux
> 
> 127384005  129742359  38150144  295276508  11998fdc o.x86_64-allconfig/vmlinux
> 127538765  129742295  38150144  295431204  119bec24 o.x86_64-allconfig/vmlinux


Very nice!

Acked-by: Peter Zijlstra (Intel) <peterz@infradead.org>

Do you happen to know if GCC plans to support other architectures for
=@cc ?

[toc] | [prev] | [next] | [standalone]


#1417106

From"H. Peter Anvin" <hpa@zytor.com>
Date2016-06-08 11:00 +0200
Message-ID<rHHvd-6mU-39@gated-at.bofh.it>
In reply to#1417013
On 06/08/16 01:00, Peter Zijlstra wrote:
> 
> Do you happen to know if GCC plans to support other architectures for
> =@cc ?
> 

I think it would depend on those architectures.  I suspect it makes
sense for some architectures and not at all for others.  Either way, it
is a completely architecture-dependent feature.

	-hpa

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web