From: Tiezhu Yang <yangtiezhu@loongson.cn>
To: Alexander Lobakin <alobakin@pm.me>
Cc: Thomas Bogendoerfer <tsbogend@alpha.franken.de>,
"Maciej W. Rozycki" <macro@orcam.me.uk>,
linux-mips@vger.kernel.org, linux-kernel@vger.kernel.org,
Xuefeng Li <lixuefeng@loongson.cn>,
David Laight <David.Laight@ACULAB.COM>
Subject: Re: [PATCH v2] MIPS: Check __clang__ to avoid performance influence with GCC in csum_tcpudp_nofold()
Date: Mon, 15 Mar 2021 20:10:32 +0800 [thread overview]
Message-ID: <204cc2bb-cc4e-b639-e02b-1dd2dbcf7333@loongson.cn> (raw)
In-Reply-To: <20210315102346.10227-1-alobakin@pm.me>
On 03/15/2021 06:24 PM, Alexander Lobakin wrote:
> From: Tiezhu Yang <yangtiezhu@loongson.cn>
> Date: Tue, 9 Mar 2021 12:18:13 +0800
>
>> 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").
>>
>> With this patch, we can build successfully by both GCC and Clang,
>> at the same time, we can avoid the potential performance influence
>> with GCC.
>>
>> Signed-off-by: Tiezhu Yang <yangtiezhu@loongson.cn>
>> ---
>> arch/mips/include/asm/checksum.h | 12 ++++++++----
>> 1 file changed, 8 insertions(+), 4 deletions(-)
>>
>> diff --git a/arch/mips/include/asm/checksum.h b/arch/mips/include/asm/checksum.h
>> index 1e6c135..80eddd4 100644
>> --- a/arch/mips/include/asm/checksum.h
>> +++ b/arch/mips/include/asm/checksum.h
>> @@ -128,9 +128,13 @@ static inline __sum16 ip_fast_csum(const void *iph, unsigned int ihl)
>>
>> static inline __wsum csum_tcpudp_nofold(__be32 saddr, __be32 daddr,
>> __u32 len, __u8 proto,
>> - __wsum sum)
>> + __wsum sum_in)
>> {
>> - unsigned long tmp = (__force unsigned long)sum;
>> +#ifdef __clang__
> Why not rely on CONFIG_CC_IS_CLANG here?
Hi,
Thanks for your suggestion, I once considered that way:
https://lore.kernel.org/patchwork/patch/1371666/#1587127
But it still occurs build error under CC_IS_GCC when
make M=samples/bpf which used with Clang compiler,
so use __clang__ is better.
Thanks,
Tiezhu
>
>> + unsigned long sum = (__force unsigned long)sum_in;
>> +#else
>> + __wsum sum = sum_in;
>> +#endif
>>
>> __asm__(
>> " .set push # csum_tcpudp_nofold\n"
>> @@ -159,7 +163,7 @@ static inline __wsum csum_tcpudp_nofold(__be32 saddr, __be32 daddr,
>> " addu %0, $1 \n"
>> #endif
>> " .set pop"
>> - : "=r" (tmp)
>> + : "=r" (sum)
>> : "0" ((__force unsigned long)daddr),
>> "r" ((__force unsigned long)saddr),
>> #ifdef __MIPSEL__
>> @@ -169,7 +173,7 @@ static inline __wsum csum_tcpudp_nofold(__be32 saddr, __be32 daddr,
>> #endif
>> "r" ((__force unsigned long)sum));
>>
>> - return (__force __wsum)tmp;
>> + return (__force __wsum)sum;
>> }
>> #define csum_tcpudp_nofold csum_tcpudp_nofold
>>
>> --
>> 2.1.0
> Al
prev parent reply other threads:[~2021-03-15 12:11 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-03-09 4:18 Tiezhu Yang
2021-03-14 20:49 ` Maciej W. Rozycki
2021-03-15 12:26 ` Tiezhu Yang
2021-03-15 12:42 ` David Laight
2021-03-17 0:26 ` Tiezhu Yang
2021-03-17 15:35 ` Maciej W. Rozycki
2021-03-17 16:09 ` David Laight
2021-03-17 21:36 ` Maciej W. Rozycki
2021-03-15 10:24 ` Alexander Lobakin
2021-03-15 12:10 ` Tiezhu Yang [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=204cc2bb-cc4e-b639-e02b-1dd2dbcf7333@loongson.cn \
--to=yangtiezhu@loongson.cn \
--cc=David.Laight@ACULAB.COM \
--cc=alobakin@pm.me \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mips@vger.kernel.org \
--cc=lixuefeng@loongson.cn \
--cc=macro@orcam.me.uk \
--cc=tsbogend@alpha.franken.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®