linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] x86/csum: fix compilation error for UM
@ 2021-11-18 17:52 Eric Dumazet
  2021-11-18 18:22 ` Peter Zijlstra
  2021-11-23  8:53 ` [tip: x86/core] x86/csum: Fix " tip-bot2 for Eric Dumazet
  0 siblings, 2 replies; 3+ messages in thread
From: Eric Dumazet @ 2021-11-18 17:52 UTC (permalink / raw)
  To: Peter Zijlstra
  Cc: linux-kernel, Eric Dumazet, Eric Dumazet, Alexander Duyck,
	Johannes Berg, kernel test robot

From: Eric Dumazet <edumazet@google.com>

load_unaligned_zeropad() is not yet universal.

ARCH=um SUBARCH=x86_64 builds do not have it.

When CONFIG_DCACHE_WORD_ACCESS is not set, simply continue
the bisection with 4, 2 and 1 byte steps.

Fixes: df4554cebdaa ("x86/csum: Rewrite/optimize csum_partial()")
Signed-off-by: Eric Dumazet <edumazet@google.com>
Cc: Peter Zijlstra (Intel) <peterz@infradead.org>
Cc: Alexander Duyck <alexanderduyck@fb.com>
Cc: Johannes Berg <johannes.berg@intel.com>
Reported-by: kernel test robot <lkp@intel.com>
---
 arch/x86/lib/csum-partial_64.c | 26 ++++++++++++++++++++++++++
 1 file changed, 26 insertions(+)

diff --git a/arch/x86/lib/csum-partial_64.c b/arch/x86/lib/csum-partial_64.c
index 5ec35626945b6db2f7f41c6d46d5e422810eac46..1eb8f2d11f7c785be624eba315fe9ca7989fd56d 100644
--- a/arch/x86/lib/csum-partial_64.c
+++ b/arch/x86/lib/csum-partial_64.c
@@ -92,6 +92,7 @@ __wsum csum_partial(const void *buff, int len, __wsum sum)
 		buff += 8;
 	}
 	if (len & 7) {
+#ifdef CONFIG_DCACHE_WORD_ACCESS
 		unsigned int shift = (8 - (len & 7)) * 8;
 		unsigned long trail;
 
@@ -101,6 +102,31 @@ __wsum csum_partial(const void *buff, int len, __wsum sum)
 		    "adcq $0,%[res]"
 			: [res] "+r" (temp64)
 			: [trail] "r" (trail));
+#else
+		if (len & 4) {
+			asm("addq %[val],%[res]\n\t"
+			    "adcq $0,%[res]"
+				: [res] "+r" (temp64)
+				: [val] "r" ((u64)*(u32 *)buff)
+				: "memory");
+			buff += 4;
+		}
+		if (len & 2) {
+			asm("addq %[val],%[res]\n\t"
+			    "adcq $0,%[res]"
+				: [res] "+r" (temp64)
+				: [val] "r" ((u64)*(u16 *)buff)
+				: "memory");
+			buff += 2;
+		}
+		if (len & 1) {
+			asm("addq %[val],%[res]\n\t"
+			    "adcq $0,%[res]"
+				: [res] "+r" (temp64)
+				: [val] "r" ((u64)*(u8 *)buff)
+				: "memory");
+		}
+#endif
 	}
 	result = add32_with_carry(temp64 >> 32, temp64 & 0xffffffff);
 	if (unlikely(odd)) { 
-- 
2.34.0.rc1.387.gb447b232ab-goog


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] x86/csum: fix compilation error for UM
  2021-11-18 17:52 [PATCH] x86/csum: fix compilation error for UM Eric Dumazet
@ 2021-11-18 18:22 ` Peter Zijlstra
  2021-11-23  8:53 ` [tip: x86/core] x86/csum: Fix " tip-bot2 for Eric Dumazet
  1 sibling, 0 replies; 3+ messages in thread
From: Peter Zijlstra @ 2021-11-18 18:22 UTC (permalink / raw)
  To: Eric Dumazet
  Cc: linux-kernel, Eric Dumazet, Alexander Duyck, Johannes Berg,
	kernel test robot

On Thu, Nov 18, 2021 at 09:52:39AM -0800, Eric Dumazet wrote:
> From: Eric Dumazet <edumazet@google.com>
> 
> load_unaligned_zeropad() is not yet universal.
> 
> ARCH=um SUBARCH=x86_64 builds do not have it.
> 
> When CONFIG_DCACHE_WORD_ACCESS is not set, simply continue
> the bisection with 4, 2 and 1 byte steps.
> 
> Fixes: df4554cebdaa ("x86/csum: Rewrite/optimize csum_partial()")
> Signed-off-by: Eric Dumazet <edumazet@google.com>
> Cc: Peter Zijlstra (Intel) <peterz@infradead.org>
> Cc: Alexander Duyck <alexanderduyck@fb.com>
> Cc: Johannes Berg <johannes.berg@intel.com>
> Reported-by: kernel test robot <lkp@intel.com>
> ---

Yeah, that's much nicer. I'll go feed that to the robots I suppose :-)

>  arch/x86/lib/csum-partial_64.c | 26 ++++++++++++++++++++++++++
>  1 file changed, 26 insertions(+)
> 
> diff --git a/arch/x86/lib/csum-partial_64.c b/arch/x86/lib/csum-partial_64.c
> index 5ec35626945b6db2f7f41c6d46d5e422810eac46..1eb8f2d11f7c785be624eba315fe9ca7989fd56d 100644
> --- a/arch/x86/lib/csum-partial_64.c
> +++ b/arch/x86/lib/csum-partial_64.c
> @@ -92,6 +92,7 @@ __wsum csum_partial(const void *buff, int len, __wsum sum)
>  		buff += 8;
>  	}
>  	if (len & 7) {
> +#ifdef CONFIG_DCACHE_WORD_ACCESS
>  		unsigned int shift = (8 - (len & 7)) * 8;
>  		unsigned long trail;
>  
> @@ -101,6 +102,31 @@ __wsum csum_partial(const void *buff, int len, __wsum sum)
>  		    "adcq $0,%[res]"
>  			: [res] "+r" (temp64)
>  			: [trail] "r" (trail));
> +#else
> +		if (len & 4) {
> +			asm("addq %[val],%[res]\n\t"
> +			    "adcq $0,%[res]"
> +				: [res] "+r" (temp64)
> +				: [val] "r" ((u64)*(u32 *)buff)
> +				: "memory");
> +			buff += 4;
> +		}
> +		if (len & 2) {
> +			asm("addq %[val],%[res]\n\t"
> +			    "adcq $0,%[res]"
> +				: [res] "+r" (temp64)
> +				: [val] "r" ((u64)*(u16 *)buff)
> +				: "memory");
> +			buff += 2;
> +		}
> +		if (len & 1) {
> +			asm("addq %[val],%[res]\n\t"
> +			    "adcq $0,%[res]"
> +				: [res] "+r" (temp64)
> +				: [val] "r" ((u64)*(u8 *)buff)
> +				: "memory");
> +		}
> +#endif
>  	}
>  	result = add32_with_carry(temp64 >> 32, temp64 & 0xffffffff);
>  	if (unlikely(odd)) { 
> -- 
> 2.34.0.rc1.387.gb447b232ab-goog
> 

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [tip: x86/core] x86/csum: Fix compilation error for UM
  2021-11-18 17:52 [PATCH] x86/csum: fix compilation error for UM Eric Dumazet
  2021-11-18 18:22 ` Peter Zijlstra
@ 2021-11-23  8:53 ` tip-bot2 for Eric Dumazet
  1 sibling, 0 replies; 3+ messages in thread
From: tip-bot2 for Eric Dumazet @ 2021-11-23  8:53 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: kernel test robot, Eric Dumazet, Peter Zijlstra (Intel),
	x86, linux-kernel

The following commit has been merged into the x86/core branch of tip:

Commit-ID:     6b2ecb61bb106d3688b315178831ff40d1008591
Gitweb:        https://git.kernel.org/tip/6b2ecb61bb106d3688b315178831ff40d1008591
Author:        Eric Dumazet <edumazet@google.com>
AuthorDate:    Thu, 18 Nov 2021 09:52:39 -08:00
Committer:     Peter Zijlstra <peterz@infradead.org>
CommitterDate: Tue, 23 Nov 2021 09:45:32 +01:00

x86/csum: Fix compilation error for UM

load_unaligned_zeropad() is not yet universal.

ARCH=um SUBARCH=x86_64 builds do not have it.

When CONFIG_DCACHE_WORD_ACCESS is not set, simply continue
the bisection with 4, 2 and 1 byte steps.

Fixes: df4554cebdaa ("x86/csum: Rewrite/optimize csum_partial()")
Reported-by: kernel test robot <lkp@intel.com>
Signed-off-by: Eric Dumazet <edumazet@google.com>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Link: https://lkml.kernel.org/r/20211118175239.1525650-1-eric.dumazet@gmail.com
---
 arch/x86/lib/csum-partial_64.c | 26 ++++++++++++++++++++++++++
 1 file changed, 26 insertions(+)

diff --git a/arch/x86/lib/csum-partial_64.c b/arch/x86/lib/csum-partial_64.c
index 5ec3562..1eb8f2d 100644
--- a/arch/x86/lib/csum-partial_64.c
+++ b/arch/x86/lib/csum-partial_64.c
@@ -92,6 +92,7 @@ __wsum csum_partial(const void *buff, int len, __wsum sum)
 		buff += 8;
 	}
 	if (len & 7) {
+#ifdef CONFIG_DCACHE_WORD_ACCESS
 		unsigned int shift = (8 - (len & 7)) * 8;
 		unsigned long trail;
 
@@ -101,6 +102,31 @@ __wsum csum_partial(const void *buff, int len, __wsum sum)
 		    "adcq $0,%[res]"
 			: [res] "+r" (temp64)
 			: [trail] "r" (trail));
+#else
+		if (len & 4) {
+			asm("addq %[val],%[res]\n\t"
+			    "adcq $0,%[res]"
+				: [res] "+r" (temp64)
+				: [val] "r" ((u64)*(u32 *)buff)
+				: "memory");
+			buff += 4;
+		}
+		if (len & 2) {
+			asm("addq %[val],%[res]\n\t"
+			    "adcq $0,%[res]"
+				: [res] "+r" (temp64)
+				: [val] "r" ((u64)*(u16 *)buff)
+				: "memory");
+			buff += 2;
+		}
+		if (len & 1) {
+			asm("addq %[val],%[res]\n\t"
+			    "adcq $0,%[res]"
+				: [res] "+r" (temp64)
+				: [val] "r" ((u64)*(u8 *)buff)
+				: "memory");
+		}
+#endif
 	}
 	result = add32_with_carry(temp64 >> 32, temp64 & 0xffffffff);
 	if (unlikely(odd)) { 

^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2021-11-23  8:54 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-11-18 17:52 [PATCH] x86/csum: fix compilation error for UM Eric Dumazet
2021-11-18 18:22 ` Peter Zijlstra
2021-11-23  8:53 ` [tip: x86/core] x86/csum: Fix " tip-bot2 for Eric Dumazet

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).