lkml.org 
[lkml]   [2020]   [Jan]   [17]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH] net: optimize cmpxchg in ip_idents_reserve
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.

\
 
 \ /
  Last update: 2020-01-17 13:34    [W:0.070 / U:0.712 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site