Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1345523 > unrolled thread
| Started by | Christophe Leroy <christophe.leroy@c-s.fr> |
|---|---|
| First post | 2016-02-29 08:30 +0100 |
| Last post | 2016-02-29 08:30 +0100 |
| Articles | 1 — 1 participant |
Back to article view | Back to linux.kernel
This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by
below is the oldest one visible, not the original post.
Re: [PATCH 8/9] powerpc: simplify csum_add(a, b) in case a or b is constant 0 Christophe Leroy <christophe.leroy@c-s.fr> - 2016-02-29 08:30 +0100
| From | Christophe Leroy <christophe.leroy@c-s.fr> |
|---|---|
| Date | 2016-02-29 08:30 +0100 |
| Subject | Re: [PATCH 8/9] powerpc: simplify csum_add(a, b) in case a or b is constant 0 |
| Message-ID | <r7qrg-8lp-9@gated-at.bofh.it> |
Le 23/10/2015 05:33, Scott Wood a écrit :
> On Tue, 2015-09-22 at 16:34 +0200, Christophe Leroy wrote:
>> Simplify csum_add(a, b) in case a or b is constant 0
>>
>> Signed-off-by: Christophe Leroy <christophe.leroy@c-s.fr>
>> ---
>> arch/powerpc/include/asm/checksum.h | 6 ++++++
>> 1 file changed, 6 insertions(+)
>>
>> diff --git a/arch/powerpc/include/asm/checksum.h
>> b/arch/powerpc/include/asm/checksum.h
>> index 56deea8..f8a9704 100644
>> --- a/arch/powerpc/include/asm/checksum.h
>> +++ b/arch/powerpc/include/asm/checksum.h
>> @@ -119,7 +119,13 @@ static inline __wsum csum_add(__wsum csum, __wsum
>> addend)
>> {
>> #ifdef __powerpc64__
>> u64 res = (__force u64)csum;
>> +#endif
>> + if (__builtin_constant_p(csum) && csum == 0)
>> + return addend;
>> + if (__builtin_constant_p(addend) && addend == 0)
>> + return csum;
>>
>> +#ifdef __powerpc64__
>> res += (__force u64)addend;
>> return (__force __wsum)((u32)res + (res >> 32));
>> #else
> How often does this happen?
>
>
In the following patch (9/9), csum_add() is used to implement
csum_partial() for small blocks.
In several places in the networking code, csum_partial() is called with
0 as initial sum.
Christophe
Back to top | Article view | linux.kernel
csiph-web