lkml.org 
[lkml]   [2020]   [Jan]   [26]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
Date
SubjectRe: [PATCH 4.19 625/639] packet: fix data-race in fanout_flow_is_huge()
On Sun, Jan 26, 2020 at 10:29 AM Pavel Machek <pavel@denx.de> wrote:
>
>
> > - po->rollover->history[prandom_u32() % ROLLOVER_HLEN] = rxhash;
> > + victim = prandom_u32() % ROLLOVER_HLEN;
> > +
> > + /* Avoid dirtying the cache line if possible */
> > + if (READ_ONCE(history[victim]) != rxhash)
> > + WRITE_ONCE(history[victim], rxhash);
> > +
>
> Replacing simple asignment with if() is ... not nice and with all the
> "volatile" magic in _ONCE macros may not be win for
> everyone. [Actually, I don't think this is win here. This is not
> exactly hot path, is it?


This is a critical hot path, eg under DDOS attack.

>
> If this is going to get more common, should we get
> WRITE_ONCE_NONDIRTY() macro hiding the uglyness?
>

Sure, but we do not add macros for stable patches, usually.

Honestly, WRITE_ONCE_NONDIRTY() looks ugly to me.

Note that the KCSAN race might be solved in another way when
data_race() is available.

\
 
 \ /
  Last update: 2020-01-26 19:39    [W:0.139 / U:0.332 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site