* [PATCH -tip 2/3] x86/asm/32: Modernize __constant_memcpy()
2025-05-06 16:52 [PATCH -tip 1/3] x86/asm/32: Modernize memset() functions Uros Bizjak
@ 2025-05-06 16:52 ` Uros Bizjak
2025-05-06 16:52 ` [PATCH -tip 3/3] x86/asm/32: Modernize _memcpy() Uros Bizjak
2025-05-06 17:54 ` [PATCH -tip 1/3] x86/asm/32: Modernize memset() functions H. Peter Anvin
2 siblings, 0 replies; 9+ messages in thread
From: Uros Bizjak @ 2025-05-06 16:52 UTC (permalink / raw)
To: x86, linux-kernel
Cc: Uros Bizjak, Thomas Gleixner, Ingo Molnar, Borislav Petkov,
Dave Hansen, H. Peter Anvin
Use inout "+" constraint modifier where appropriate and declare
temporary variables as unsigned long.
No functional changes intended.
Signed-off-by: Uros Bizjak <ubizjak@gmail.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: Borislav Petkov <bp@alien8.de>
Cc: Dave Hansen <dave.hansen@linux.intel.com>
Cc: "H. Peter Anvin" <hpa@zytor.com>
---
arch/x86/include/asm/string_32.h | 51 +++++++++++++-------------------
1 file changed, 21 insertions(+), 30 deletions(-)
diff --git a/arch/x86/include/asm/string_32.h b/arch/x86/include/asm/string_32.h
index 9152d2c0f60e..00d497837571 100644
--- a/arch/x86/include/asm/string_32.h
+++ b/arch/x86/include/asm/string_32.h
@@ -52,7 +52,7 @@ static __always_inline void *__memcpy(void *to, const void *from, size_t n)
static __always_inline void *__constant_memcpy(void *to, const void *from,
size_t n)
{
- long esi, edi;
+ unsigned long esi, edi;
if (!n)
return to;
@@ -84,60 +84,51 @@ static __always_inline void *__constant_memcpy(void *to, const void *from,
return to;
}
- esi = (long)from;
- edi = (long)to;
+ esi = (unsigned long)from;
+ edi = (unsigned long)to;
if (n >= 5 * 4) {
/* large block: use rep prefix */
- int ecx;
+ unsigned long ecx = n >> 2;
asm volatile("rep movsl"
- : "=&c" (ecx), "=&D" (edi), "=&S" (esi)
- : "0" (n / 4), "1" (edi), "2" (esi)
- : "memory"
- );
+ : "+D" (edi), "+S" (esi), "+c" (ecx)
+ : : "memory");
} else {
/* small block: don't clobber ecx + smaller code */
if (n >= 4 * 4)
asm volatile("movsl"
- : "=&D"(edi), "=&S"(esi)
- : "0"(edi), "1"(esi)
- : "memory");
+ : "+D" (edi), "+S" (esi)
+ : : "memory");
if (n >= 3 * 4)
asm volatile("movsl"
- : "=&D"(edi), "=&S"(esi)
- : "0"(edi), "1"(esi)
- : "memory");
+ : "+D" (edi), "+S" (esi)
+ : : "memory");
if (n >= 2 * 4)
asm volatile("movsl"
- : "=&D"(edi), "=&S"(esi)
- : "0"(edi), "1"(esi)
- : "memory");
+ : "+D" (edi), "+S" (esi)
+ : : "memory");
if (n >= 1 * 4)
asm volatile("movsl"
- : "=&D"(edi), "=&S"(esi)
- : "0"(edi), "1"(esi)
- : "memory");
+ : "+D" (edi), "+S" (esi)
+ : : "memory");
}
- switch (n % 4) {
+ switch (n & 3) {
/* tail */
case 0:
return to;
case 1:
asm volatile("movsb"
- : "=&D"(edi), "=&S"(esi)
- : "0"(edi), "1"(esi)
- : "memory");
+ : "+D" (edi), "+S" (esi)
+ : : "memory");
return to;
case 2:
asm volatile("movsw"
- : "=&D"(edi), "=&S"(esi)
- : "0"(edi), "1"(esi)
- : "memory");
+ : "+D" (edi), "+S" (esi)
+ : : "memory");
return to;
default:
asm volatile("movsw\n\tmovsb"
- : "=&D"(edi), "=&S"(esi)
- : "0"(edi), "1"(esi)
- : "memory");
+ : "+D" (edi), "+S" (esi)
+ : : "memory");
return to;
}
}
--
2.49.0
^ permalink raw reply related [flat|nested] 9+ messages in thread* [PATCH -tip 3/3] x86/asm/32: Modernize _memcpy()
2025-05-06 16:52 [PATCH -tip 1/3] x86/asm/32: Modernize memset() functions Uros Bizjak
2025-05-06 16:52 ` [PATCH -tip 2/3] x86/asm/32: Modernize __constant_memcpy() Uros Bizjak
@ 2025-05-06 16:52 ` Uros Bizjak
2025-05-06 17:34 ` Uros Bizjak
2025-05-06 17:54 ` [PATCH -tip 1/3] x86/asm/32: Modernize memset() functions H. Peter Anvin
2 siblings, 1 reply; 9+ messages in thread
From: Uros Bizjak @ 2025-05-06 16:52 UTC (permalink / raw)
To: x86, linux-kernel
Cc: Uros Bizjak, Thomas Gleixner, Ingo Molnar, Borislav Petkov,
Dave Hansen, H. Peter Anvin
Use inout "+" constraint modifier where appropriate, declare
temporary variables as unsigned long and rewrite parts of assembly
in plain C. The memcpy() function shrinks by 10 bytes, from:
00e778d0 <memcpy>:
e778d0: 55 push %ebp
e778d1: 89 e5 mov %esp,%ebp
e778d3: 83 ec 0c sub $0xc,%esp
e778d6: 89 5d f4 mov %ebx,-0xc(%ebp)
e778d9: 89 c3 mov %eax,%ebx
e778db: 89 c8 mov %ecx,%eax
e778dd: 89 75 f8 mov %esi,-0x8(%ebp)
e778e0: c1 e9 02 shr $0x2,%ecx
e778e3: 89 d6 mov %edx,%esi
e778e5: 89 7d fc mov %edi,-0x4(%ebp)
e778e8: 89 df mov %ebx,%edi
e778ea: f3 a5 rep movsl %ds:(%esi),%es:(%edi)
e778ec: 89 c1 mov %eax,%ecx
e778ee: 83 e1 03 and $0x3,%ecx
e778f1: 74 02 je e778f5 <memcpy+0x25>
e778f3: f3 a4 rep movsb %ds:(%esi),%es:(%edi)
e778f5: 8b 75 f8 mov -0x8(%ebp),%esi
e778f8: 89 d8 mov %ebx,%eax
e778fa: 8b 5d f4 mov -0xc(%ebp),%ebx
e778fd: 8b 7d fc mov -0x4(%ebp),%edi
e77900: 89 ec mov %ebp,%esp
e77902: 5d pop %ebp
e77903: c3 ret
to:
00e778b0 <memcpy>:
e778b0: 55 push %ebp
e778b1: 89 e5 mov %esp,%ebp
e778b3: 83 ec 08 sub $0x8,%esp
e778b6: 89 75 f8 mov %esi,-0x8(%ebp)
e778b9: 89 d6 mov %edx,%esi
e778bb: 89 ca mov %ecx,%edx
e778bd: 89 7d fc mov %edi,-0x4(%ebp)
e778c0: c1 e9 02 shr $0x2,%ecx
e778c3: 89 c7 mov %eax,%edi
e778c5: f3 a5 rep movsl %ds:(%esi),%es:(%edi)
e778c7: 83 e2 03 and $0x3,%edx
e778ca: 74 04 je e778d0 <memcpy+0x20>
e778cc: 89 d1 mov %edx,%ecx
e778ce: f3 a4 rep movsb %ds:(%esi),%es:(%edi)
e778d0: 8b 75 f8 mov -0x8(%ebp),%esi
e778d3: 8b 7d fc mov -0x4(%ebp),%edi
e778d6: 89 ec mov %ebp,%esp
e778d8: 5d pop %ebp
e778d9: c3 ret
due to a better register allocation, avoiding the call-saved
%ebx register.
No functional changes intended.
Signed-off-by: Uros Bizjak <ubizjak@gmail.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: Borislav Petkov <bp@alien8.de>
Cc: Dave Hansen <dave.hansen@linux.intel.com>
Cc: "H. Peter Anvin" <hpa@zytor.com>
---
arch/x86/include/asm/string_32.h | 22 ++++++++++++----------
1 file changed, 12 insertions(+), 10 deletions(-)
diff --git a/arch/x86/include/asm/string_32.h b/arch/x86/include/asm/string_32.h
index 00d497837571..6a4062414495 100644
--- a/arch/x86/include/asm/string_32.h
+++ b/arch/x86/include/asm/string_32.h
@@ -32,16 +32,18 @@ extern size_t strlen(const char *s);
static __always_inline void *__memcpy(void *to, const void *from, size_t n)
{
- int d0, d1, d2;
- asm volatile("rep movsl\n\t"
- "movl %4,%%ecx\n\t"
- "andl $3,%%ecx\n\t"
- "jz 1f\n\t"
- "rep movsb\n\t"
- "1:"
- : "=&c" (d0), "=&D" (d1), "=&S" (d2)
- : "0" (n / 4), "g" (n), "1" ((long)to), "2" ((long)from)
- : "memory");
+ unsigned long esi = (unsigned long)from;
+ unsigned long edi = (unsigned long)to;
+ unsigned long ecx = n >> 2;
+
+ asm volatile("rep movsl"
+ : "+D" (edi), "+S" (esi), "+c" (ecx)
+ : : "memory");
+ ecx = n & 3;
+ if (ecx)
+ asm volatile("rep movsb"
+ : "+D" (edi), "+S" (esi), "+c" (ecx)
+ : : "memory");
return to;
}
--
2.49.0
^ permalink raw reply related [flat|nested] 9+ messages in thread* Re: [PATCH -tip 3/3] x86/asm/32: Modernize _memcpy()
2025-05-06 16:52 ` [PATCH -tip 3/3] x86/asm/32: Modernize _memcpy() Uros Bizjak
@ 2025-05-06 17:34 ` Uros Bizjak
2025-05-07 20:28 ` David Laight
0 siblings, 1 reply; 9+ messages in thread
From: Uros Bizjak @ 2025-05-06 17:34 UTC (permalink / raw)
To: x86, linux-kernel
Cc: Thomas Gleixner, Ingo Molnar, Borislav Petkov, Dave Hansen,
H. Peter Anvin
On Tue, May 6, 2025 at 6:52 PM Uros Bizjak <ubizjak@gmail.com> wrote:
>
> Use inout "+" constraint modifier where appropriate, declare
> temporary variables as unsigned long and rewrite parts of assembly
> in plain C. The memcpy() function shrinks by 10 bytes, from:
>
> 00e778d0 <memcpy>:
> e778d0: 55 push %ebp
> e778d1: 89 e5 mov %esp,%ebp
> e778d3: 83 ec 0c sub $0xc,%esp
> e778d6: 89 5d f4 mov %ebx,-0xc(%ebp)
> e778d9: 89 c3 mov %eax,%ebx
> e778db: 89 c8 mov %ecx,%eax
> e778dd: 89 75 f8 mov %esi,-0x8(%ebp)
> e778e0: c1 e9 02 shr $0x2,%ecx
> e778e3: 89 d6 mov %edx,%esi
> e778e5: 89 7d fc mov %edi,-0x4(%ebp)
> e778e8: 89 df mov %ebx,%edi
> e778ea: f3 a5 rep movsl %ds:(%esi),%es:(%edi)
> e778ec: 89 c1 mov %eax,%ecx
> e778ee: 83 e1 03 and $0x3,%ecx
> e778f1: 74 02 je e778f5 <memcpy+0x25>
> e778f3: f3 a4 rep movsb %ds:(%esi),%es:(%edi)
> e778f5: 8b 75 f8 mov -0x8(%ebp),%esi
> e778f8: 89 d8 mov %ebx,%eax
> e778fa: 8b 5d f4 mov -0xc(%ebp),%ebx
> e778fd: 8b 7d fc mov -0x4(%ebp),%edi
> e77900: 89 ec mov %ebp,%esp
> e77902: 5d pop %ebp
> e77903: c3 ret
>
> to:
>
> 00e778b0 <memcpy>:
> e778b0: 55 push %ebp
> e778b1: 89 e5 mov %esp,%ebp
> e778b3: 83 ec 08 sub $0x8,%esp
> e778b6: 89 75 f8 mov %esi,-0x8(%ebp)
> e778b9: 89 d6 mov %edx,%esi
> e778bb: 89 ca mov %ecx,%edx
> e778bd: 89 7d fc mov %edi,-0x4(%ebp)
> e778c0: c1 e9 02 shr $0x2,%ecx
> e778c3: 89 c7 mov %eax,%edi
> e778c5: f3 a5 rep movsl %ds:(%esi),%es:(%edi)
> e778c7: 83 e2 03 and $0x3,%edx
> e778ca: 74 04 je e778d0 <memcpy+0x20>
> e778cc: 89 d1 mov %edx,%ecx
> e778ce: f3 a4 rep movsb %ds:(%esi),%es:(%edi)
> e778d0: 8b 75 f8 mov -0x8(%ebp),%esi
> e778d3: 8b 7d fc mov -0x4(%ebp),%edi
> e778d6: 89 ec mov %ebp,%esp
> e778d8: 5d pop %ebp
> e778d9: c3 ret
>
> due to a better register allocation, avoiding the call-saved
Oops, this should have been written as "... avoiding the callee-saved ..."
> %ebx register.
Uros.
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH -tip 3/3] x86/asm/32: Modernize _memcpy()
2025-05-06 17:34 ` Uros Bizjak
@ 2025-05-07 20:28 ` David Laight
2025-05-07 21:29 ` Uros Bizjak
0 siblings, 1 reply; 9+ messages in thread
From: David Laight @ 2025-05-07 20:28 UTC (permalink / raw)
To: Uros Bizjak
Cc: x86, linux-kernel, Thomas Gleixner, Ingo Molnar, Borislav Petkov,
Dave Hansen, H. Peter Anvin
On Tue, 6 May 2025 19:34:34 +0200
Uros Bizjak <ubizjak@gmail.com> wrote:
> On Tue, May 6, 2025 at 6:52 PM Uros Bizjak <ubizjak@gmail.com> wrote:
> >
> > Use inout "+" constraint modifier where appropriate, declare
> > temporary variables as unsigned long and rewrite parts of assembly
> > in plain C. The memcpy() function shrinks by 10 bytes, from:
> >
> > 00e778d0 <memcpy>:
> > e778d0: 55 push %ebp
> > e778d1: 89 e5 mov %esp,%ebp
> > e778d3: 83 ec 0c sub $0xc,%esp
> > e778d6: 89 5d f4 mov %ebx,-0xc(%ebp)
> > e778d9: 89 c3 mov %eax,%ebx
> > e778db: 89 c8 mov %ecx,%eax
> > e778dd: 89 75 f8 mov %esi,-0x8(%ebp)
> > e778e0: c1 e9 02 shr $0x2,%ecx
> > e778e3: 89 d6 mov %edx,%esi
> > e778e5: 89 7d fc mov %edi,-0x4(%ebp)
> > e778e8: 89 df mov %ebx,%edi
> > e778ea: f3 a5 rep movsl %ds:(%esi),%es:(%edi)
> > e778ec: 89 c1 mov %eax,%ecx
> > e778ee: 83 e1 03 and $0x3,%ecx
> > e778f1: 74 02 je e778f5 <memcpy+0x25>
> > e778f3: f3 a4 rep movsb %ds:(%esi),%es:(%edi)
Hmmm....
IIRC you really don't want to be doing a [1..3] byte 'rep movsb' there.
Some cpu will run it quickly - but most of those will do a 'rep movsb' faster.
It would also be interesting to try to measure the cost of the 'je'
being mispredicted.
I bet a beer or two that at least one cpu can't abort the setup cost
of the 'rep movsb' - so you take the full hit.
I do need to rerun my 'rep movsb' performance measurements using data
dependencies (not lfence/mfence) to synchronise things.
The 'before' data dependency is easy: count += (clocks & volatile_zero).
The 'after' one can be done the same way if using the performance counters.
It is probably enough to use the updated value of %si or %di rather than
doing a read-back of the last memory write.
I've done that for a different function and can see how the clock count
for divide depends on its arguments.
David
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH -tip 3/3] x86/asm/32: Modernize _memcpy()
2025-05-07 20:28 ` David Laight
@ 2025-05-07 21:29 ` Uros Bizjak
0 siblings, 0 replies; 9+ messages in thread
From: Uros Bizjak @ 2025-05-07 21:29 UTC (permalink / raw)
To: David Laight
Cc: x86, linux-kernel, Thomas Gleixner, Ingo Molnar, Borislav Petkov,
Dave Hansen, H. Peter Anvin
On Wed, May 7, 2025 at 10:28 PM David Laight
<david.laight.linux@gmail.com> wrote:
>
> On Tue, 6 May 2025 19:34:34 +0200
> Uros Bizjak <ubizjak@gmail.com> wrote:
>
> > On Tue, May 6, 2025 at 6:52 PM Uros Bizjak <ubizjak@gmail.com> wrote:
> > >
> > > Use inout "+" constraint modifier where appropriate, declare
> > > temporary variables as unsigned long and rewrite parts of assembly
> > > in plain C. The memcpy() function shrinks by 10 bytes, from:
> > >
> > > 00e778d0 <memcpy>:
> > > e778d0: 55 push %ebp
> > > e778d1: 89 e5 mov %esp,%ebp
> > > e778d3: 83 ec 0c sub $0xc,%esp
> > > e778d6: 89 5d f4 mov %ebx,-0xc(%ebp)
> > > e778d9: 89 c3 mov %eax,%ebx
> > > e778db: 89 c8 mov %ecx,%eax
> > > e778dd: 89 75 f8 mov %esi,-0x8(%ebp)
> > > e778e0: c1 e9 02 shr $0x2,%ecx
> > > e778e3: 89 d6 mov %edx,%esi
> > > e778e5: 89 7d fc mov %edi,-0x4(%ebp)
> > > e778e8: 89 df mov %ebx,%edi
> > > e778ea: f3 a5 rep movsl %ds:(%esi),%es:(%edi)
> > > e778ec: 89 c1 mov %eax,%ecx
> > > e778ee: 83 e1 03 and $0x3,%ecx
> > > e778f1: 74 02 je e778f5 <memcpy+0x25>
> > > e778f3: f3 a4 rep movsb %ds:(%esi),%es:(%edi)
>
> Hmmm....
> IIRC you really don't want to be doing a [1..3] byte 'rep movsb' there.
> Some cpu will run it quickly - but most of those will do a 'rep movsb' faster.
>
> It would also be interesting to try to measure the cost of the 'je'
> being mispredicted.
> I bet a beer or two that at least one cpu can't abort the setup cost
> of the 'rep movsb' - so you take the full hit.
The intention of the patch was to keep the existing functionality, and
modernize/rewrite the assembly to use inout constraint modifiers. In
passing, some parts of the assembly were converted to plain C. At
least to me, the source code is much easier to read this way, and also
enables some compiler optimizations that result in better assembly.
Perhaps functional improvements can be implemented as follow-up
patches.
Uros.
> I do need to rerun my 'rep movsb' performance measurements using data
> dependencies (not lfence/mfence) to synchronise things.
> The 'before' data dependency is easy: count += (clocks & volatile_zero).
> The 'after' one can be done the same way if using the performance counters.
> It is probably enough to use the updated value of %si or %di rather than
> doing a read-back of the last memory write.
>
> I've done that for a different function and can see how the clock count
> for divide depends on its arguments.
>
> David
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH -tip 1/3] x86/asm/32: Modernize memset() functions
2025-05-06 16:52 [PATCH -tip 1/3] x86/asm/32: Modernize memset() functions Uros Bizjak
2025-05-06 16:52 ` [PATCH -tip 2/3] x86/asm/32: Modernize __constant_memcpy() Uros Bizjak
2025-05-06 16:52 ` [PATCH -tip 3/3] x86/asm/32: Modernize _memcpy() Uros Bizjak
@ 2025-05-06 17:54 ` H. Peter Anvin
2025-05-06 18:22 ` Linus Torvalds
2 siblings, 1 reply; 9+ messages in thread
From: H. Peter Anvin @ 2025-05-06 17:54 UTC (permalink / raw)
To: Uros Bizjak, x86, linux-kernel
Cc: Thomas Gleixner, Ingo Molnar, Borislav Petkov, Dave Hansen,
torvalds
On May 6, 2025 9:52:06 AM PDT, Uros Bizjak <ubizjak@gmail.com> wrote:
>Use inout "+" constraint modifier where appropriate and declare
>temporary variable using __auto_type, similar to what x86_64 does.
>
>No functional changes intended.
>
>Signed-off-by: Uros Bizjak <ubizjak@gmail.com>
>Cc: Thomas Gleixner <tglx@linutronix.de>
>Cc: Ingo Molnar <mingo@kernel.org>
>Cc: Borislav Petkov <bp@alien8.de>
>Cc: Dave Hansen <dave.hansen@linux.intel.com>
>Cc: "H. Peter Anvin" <hpa@zytor.com>
>---
> arch/x86/include/asm/string_32.h | 24 ++++++++++++------------
> 1 file changed, 12 insertions(+), 12 deletions(-)
>
>diff --git a/arch/x86/include/asm/string_32.h b/arch/x86/include/asm/string_32.h
>index e9cce169bb4c..9152d2c0f60e 100644
>--- a/arch/x86/include/asm/string_32.h
>+++ b/arch/x86/include/asm/string_32.h
>@@ -164,12 +164,12 @@ extern void *memchr(const void *cs, int c, size_t count);
>
> static inline void *__memset_generic(void *s, char c, size_t count)
> {
>- int d0, d1;
>+ const __auto_type s0 = s;
> asm volatile("rep stosb"
>- : "=&c" (d0), "=&D" (d1)
>- : "a" (c), "1" (s), "0" (count)
>+ : "+D" (s), "+c" (count)
>+ : "a" (c)
> : "memory");
>- return s;
>+ return s0;
> }
>
> /* we might want to write optimized versions of these later */
>@@ -197,23 +197,23 @@ extern void *memset(void *, int, size_t);
> #define __HAVE_ARCH_MEMSET16
> static inline void *memset16(uint16_t *s, uint16_t v, size_t n)
> {
>- int d0, d1;
>+ const __auto_type s0 = s;
> asm volatile("rep stosw"
>- : "=&c" (d0), "=&D" (d1)
>- : "a" (v), "1" (s), "0" (n)
>+ : "+D" (s), "+c" (n)
>+ : "a" (v)
> : "memory");
>- return s;
>+ return s0;
> }
>
> #define __HAVE_ARCH_MEMSET32
> static inline void *memset32(uint32_t *s, uint32_t v, size_t n)
> {
>- int d0, d1;
>+ const __auto_type s0 = s;
> asm volatile("rep stosl"
>- : "=&c" (d0), "=&D" (d1)
>- : "a" (v), "1" (s), "0" (n)
>+ : "+D" (s), "+c" (n)
>+ : "a" (v)
> : "memory");
>- return s;
>+ return s0;
> }
>
> /*
So __auto_type is spelled "auto" in newer C versions, but "auto" was a (completely useless!) keyword going all the way back to K&R C. Can anyone think of a reason why we don't do:
#define auto __auto_type
... and just start using the modern keyword right away?
-hpa
^ permalink raw reply [flat|nested] 9+ messages in thread* Re: [PATCH -tip 1/3] x86/asm/32: Modernize memset() functions
2025-05-06 17:54 ` [PATCH -tip 1/3] x86/asm/32: Modernize memset() functions H. Peter Anvin
@ 2025-05-06 18:22 ` Linus Torvalds
2025-05-07 0:31 ` H. Peter Anvin
0 siblings, 1 reply; 9+ messages in thread
From: Linus Torvalds @ 2025-05-06 18:22 UTC (permalink / raw)
To: H. Peter Anvin
Cc: Uros Bizjak, x86, linux-kernel, Thomas Gleixner, Ingo Molnar,
Borislav Petkov, Dave Hansen
On Tue, 6 May 2025 at 10:55, H. Peter Anvin <hpa@zytor.com> wrote:
>
> Can anyone think of a reason why we don't do:
>
> #define auto __auto_type
>
> ... and just start using the modern keyword right away?
Yeah, make it so. The original 'auto' was useless as you say, and
afaik we've never used it in the kernel.
And the one advantage of it being that historically useless keyword is
that we can't have variables called 'auto' anywhere either.
So it should be a safe thing to do.
Linus
^ permalink raw reply [flat|nested] 9+ messages in thread* Re: [PATCH -tip 1/3] x86/asm/32: Modernize memset() functions
2025-05-06 18:22 ` Linus Torvalds
@ 2025-05-07 0:31 ` H. Peter Anvin
0 siblings, 0 replies; 9+ messages in thread
From: H. Peter Anvin @ 2025-05-07 0:31 UTC (permalink / raw)
To: Linus Torvalds
Cc: Uros Bizjak, x86, linux-kernel, Thomas Gleixner, Ingo Molnar,
Borislav Petkov, Dave Hansen
On May 6, 2025 11:22:49 AM PDT, Linus Torvalds <torvalds@linux-foundation.org> wrote:
>On Tue, 6 May 2025 at 10:55, H. Peter Anvin <hpa@zytor.com> wrote:
>>
>> Can anyone think of a reason why we don't do:
>>
>> #define auto __auto_type
>>
>> ... and just start using the modern keyword right away?
>
>Yeah, make it so. The original 'auto' was useless as you say, and
>afaik we've never used it in the kernel.
>
>And the one advantage of it being that historically useless keyword is
>that we can't have variables called 'auto' anywhere either.
>
>So it should be a safe thing to do.
>
> Linus
Ok, I'll cook up a patchset. Should be trivial.
^ permalink raw reply [flat|nested] 9+ messages in thread