[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CANn89iKTYMT8T5tOPmk0j4emHt2gCbJD9Dpjf=5LR88zC1tu4A@mail.gmail.com>
Date: Sun, 26 Jan 2020 10:38:41 -0800
From: Eric Dumazet <edumazet@...gle.com>
To: Pavel Machek <pavel@...x.de>
Cc: Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
LKML <linux-kernel@...r.kernel.org>, stable@...r.kernel.org,
Willem de Bruijn <willemb@...gle.com>,
"David S. Miller" <davem@...emloft.net>,
Sasha Levin <sashal@...nel.org>
Subject: Re: [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@...x.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.
Powered by blists - more mailing lists