Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp1176661pxf; Fri, 2 Apr 2021 03:28:22 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwxrBw91Mu2Uutt59QMPTgwFt2bO/88ZhuE2HBcTU7ijZFtyzcYh1cuhBZpMYkf+/MIVq0f X-Received: by 2002:a17:906:7194:: with SMTP id h20mr13303473ejk.154.1617359302588; Fri, 02 Apr 2021 03:28:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1617359302; cv=none; d=google.com; s=arc-20160816; b=t/9hDsALlsz8PLKsMeM7ZXZZnmNi9Ckvgh64eCDsEPNnxyfJbiQWiCyiyvVIAwfyGh 8nlrS07l+caMqoA+n1cuKpzaBC3M4yN4C4c4EK2F2oxev/ry9+DK49/AXcoyVRvmOZtC KVQeySpuCLM+LQ66WEQej7wBEuet6PmPKLjE+Ou+6rG6NzvlFbRPS81eAyWOW3ESaEUr jn3YbObSmX4ApRNwPgSSVWVDRaE3XTGoDEUx7NHR3PvUJPB+Oqn+kaj7XeEO6AXSkVfm jR6R1wX1ya0dHk9KYmGWVh3ZEMHNVafs4vkdUyC4EpkPSDDUgrE6FGiLXVOFdMG7s+Gi F1ug== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:message-id:date:subject:cc:to:from; bh=OfnzDP34MyK8FCJadgMShjg1tTGfvpwrM1Js/KdEybw=; b=DzZhwEnGRGeu3Okqe4gzLVNVXCJocjfur8MF9H7E67O90cZuuBg1DW9qs/i53w7wKp ORYyHm9CRV06JwWxgIHmpv6uF45dQcToJoNJLQH0NpQhGKZGmSPaWh8xMBvCBEvBGy5R 9OAXv1AHTvSZUyKOIJr8fC9+NfkjGlLv6j2XMAxpyngz+oziu4bMbjgC1AeI4rWSIAev h9TpTTP88bfh1Vl0t2bB8cReAoHoMhBH/39zjwwF9/4KvP0jd2om91FOyey8hQVKQXYk iLrkXl65noVkiHxmI/slqweqt8z0a59WwPLKc+UaovfHJ0viM6XzvmBFpd9Qyw0QX6Ys HH5g== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id a3si6205112ejv.34.2021.04.02.03.27.59; Fri, 02 Apr 2021 03:28:22 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234548AbhDBK1Z (ORCPT + 99 others); Fri, 2 Apr 2021 06:27:25 -0400 Received: from mail.loongson.cn ([114.242.206.163]:49634 "EHLO loongson.cn" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S229605AbhDBK1Z (ORCPT ); Fri, 2 Apr 2021 06:27:25 -0400 Received: from linux.localdomain (unknown [113.200.148.30]) by mail.loongson.cn (Coremail) with SMTP id AQAAf9CxycmI8WZgY6cDAA--.7636S2; Fri, 02 Apr 2021 18:27:21 +0800 (CST) From: Tiezhu Yang To: Thomas Bogendoerfer Cc: linux-mips@vger.kernel.org, linux-kernel@vger.kernel.org, "Maciej W. Rozycki" , Xuefeng Li Subject: [PATCH v3] MIPS: Check __clang__ to avoid performance influence with GCC in csum_tcpudp_nofold() Date: Fri, 2 Apr 2021 18:27:20 +0800 Message-Id: <1617359240-16609-1-git-send-email-yangtiezhu@loongson.cn> X-Mailer: git-send-email 2.1.0 X-CM-TRANSID: AQAAf9CxycmI8WZgY6cDAA--.7636S2 X-Coremail-Antispam: 1UD129KBjvJXoWxKF4UJr17ZFW3Kr15Jr4rAFb_yoW7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org 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 --- 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