The asm code in csum_tcpudp_nofold() is performance critical, I am sorry for the poorly considered implementation about the performance influence with GCC in the commit 198688edbf77 ("MIPS: Fix inline asm input/output type mismatch in checksum.h used with Clang"). Using __clang__ instead of CC_IS_CLANG as check condition, because it still occurs build error under CC_IS_GCC when make M=samples/bpf which used with Clang compiler. With this patch, we can build successfully by both GCC and Clang, at the same time, the logic is much clear to avoid the potential performance influence with GCC. Here are some test data, the config file is loongson3_defconfig, the gcc version is 10.2.1, we can see that the size has no differences between (1) and (3). (1) linux-5.12-rc5.nopatch: without commit 198688edbf77 ("MIPS: Fix inline asm input/output type mismatch in checksum.h used with Clang"). (2) linux-5.12-rc5: with commit 198688edbf77 ("MIPS: Fix inline asm input/output type mismatch in checksum.h used with Clang"). (3) linux-5.12-rc5.newpatch: with this patch based on linux-5.12-rc5. loongson@linux:~$ size --format=GNU linux-5.12-rc5.nopatch/vmlinux text data bss total filename 10273312 3489518 17865568 31628398 linux-5.12-rc5.nopatch/vmlinux loongson@linux:~$ size --format=GNU linux-5.12-rc5/vmlinux text data bss total filename 10273536 3489550 17865568 31628654 linux-5.12-rc5/vmlinux loongson@linux:~$ size --format=GNU linux-5.12-rc5.newpatch/vmlinux text data bss total filename 10273312 3489518 17865568 31628398 linux-5.12-rc5.newpatch/vmlinux As far as I can tell, the differences between (1) and (2) is due to the following affected objects: loongson@linux:~$ size --format=GNU linux-5.12-rc5.nopatch/net/ipv4/tcp_ipv4.o text data bss total filename 20684 2268 576 23528 linux-5.12-rc5.nopatch/net/ipv4/tcp_ipv4.o loongson@linux:~$ size --format=GNU linux-5.12-rc5/net/ipv4/tcp_ipv4.o text data bss total filename 20700 2268 576 23544 linux-5.12-rc5/net/ipv4/tcp_ipv4.o loongson@linux:~$ size --format=GNU linux-5.12-rc5.nopatch/net/ipv4/tcp_offload.o text data bss total filename 3584 167 0 3751 linux-5.12-rc5.nopatch/net/ipv4/tcp_offload.o loongson@linux:~$ size --format=GNU linux-5.12-rc5/net/ipv4/tcp_offload.o text data bss total filename 3600 167 0 3767 linux-5.12-rc5/net/ipv4/tcp_offload.o loongson@linux:~$ size --format=GNU linux-5.12-rc5.nopatch/net/ipv4/udp.o text data bss total filename 30068 3018 32 33118 linux-5.12-rc5.nopatch/net/ipv4/udp.o loongson@linux:~$ size --format=GNU linux-5.12-rc5/net/ipv4/udp.o text data bss total filename 30100 3018 32 33150 linux-5.12-rc5/net/ipv4/udp.o loongson@linux:~$ size --format=GNU linux-5.12-rc5.nopatch/net/ipv4/udp_offload.o text data bss total filename 6624 311 0 6935 linux-5.12-rc5.nopatch/net/ipv4/udp_offload.o loongson@linux:~$ size --format=GNU linux-5.12-rc5/net/ipv4/udp_offload.o text data bss total filename 6640 311 0 6951 linux-5.12-rc5/net/ipv4/udp_offload.o loongson@linux:~$ size --format=GNU linux-5.12-rc5.nopatch/net/netfilter/nf_nat.o text data bss total filename 20804 2102 4112 27018 linux-5.12-rc5.nopatch/net/netfilter/nf_nat.o loongson@linux:~$ size --format=GNU linux-5.12-rc5/net/netfilter/nf_nat.o text data bss total filename 20820 2102 4112 27034 linux-5.12-rc5/net/netfilter/nf_nat.o loongson@linux:~$ size --format=GNU linux-5.12-rc5.nopatch/net/netfilter/nf_nat_proto.o text data bss total filename 7392 770 0 8162 linux-5.12-rc5.nopatch/net/netfilter/nf_nat_proto.o loongson@linux:~$ size --format=GNU linux-5.12-rc5/net/netfilter/nf_nat_proto.o text data bss total filename 7408 770 0 8178 linux-5.12-rc5/net/netfilter/nf_nat_proto.o loongson@linux:~$ size --format=GNU linux-5.12-rc5.nopatch/net/ipv4/netfilter/nf_reject_ipv4.o text data bss total filename 3776 429 0 4205 linux-5.12-rc5.nopatch/net/ipv4/netfilter/nf_reject_ipv4.o loongson@linux:~$ size --format=GNU linux-5.12-rc5/net/ipv4/netfilter/nf_reject_ipv4.o text data bss total filename 3792 429 0 4221 linux-5.12-rc5/net/ipv4/netfilter/nf_reject_ipv4.o Signed-off-by: Tiezhu Yang <yangtiezhu@xxxxxxxxxxx> --- arch/mips/include/asm/checksum.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/arch/mips/include/asm/checksum.h b/arch/mips/include/asm/checksum.h index 1e6c135..e1f80407 100644 --- a/arch/mips/include/asm/checksum.h +++ b/arch/mips/include/asm/checksum.h @@ -130,7 +130,11 @@ static inline __wsum csum_tcpudp_nofold(__be32 saddr, __be32 daddr, __u32 len, __u8 proto, __wsum sum) { +#ifdef __clang__ unsigned long tmp = (__force unsigned long)sum; +#else + __wsum tmp = sum; +#endif __asm__( " .set push # csum_tcpudp_nofold\n" -- 2.1.0