[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <5fd55696-e46c-4269-c106-79782efb0dd8@hisilicon.com>
Date: Sun, 19 Jan 2020 11:46:23 +0800
From: Shaokun Zhang <zhangshaokun@...ilicon.com>
To: Peter Zijlstra <peterz@...radead.org>
CC: Eric Dumazet <eric.dumazet@...il.com>,
David Miller <davem@...emloft.net>, <netdev@...r.kernel.org>,
<linux-kernel@...r.kernel.org>, <jinyuqi@...wei.com>,
<kuznet@....inr.ac.ru>, <yoshfuji@...ux-ipv6.org>,
<edumazet@...gle.com>, <guoyang2@...wei.com>,
Will Deacon <will@...nel.org>
Subject: Re: [PATCH] net: optimize cmpxchg in ip_idents_reserve
Hi Peter,
On 2020/1/17 20:32, Peter Zijlstra wrote:
> On Fri, Jan 17, 2020 at 02:54:03PM +0800, Shaokun Zhang wrote:
>> So how about this? ;-)
>>
>> delta = prandom_u32_max(now - old);
>>
>> +#ifdef CONFIG_UBSAN
>> /* Do not use atomic_add_return() as it makes UBSAN unhappy */
>> + old = (u32)atomic_read(p_id);
>> do {
>> - old = (u32)atomic_read(p_id);
>> new = old + delta + segs;
>> - } while (atomic_cmpxchg(p_id, old, new) != old);
>> + } while (!atomic_try_cmpxchg(p_id, &old, new));
>> +#else
>> + new = atomic_add_return(segs + delta, p_id);
>> +#endif
>
> That's crazy, just accept that UBSAN is taking bonghits and ignore it.
> Use atomic_add_return() unconditionally.
We have used the atomic_add_return[1], but it makes the UBSAN unhappy followed
by the comment.
It seems that Eric also agreed to do it if some comments are added. I will do
it later.
Thanks,
Shaokun
[1] https://lkml.org/lkml/2019/7/26/217
>
> .
>
Powered by blists - more mailing lists