Re: [PATCH net-next v2 8/8] bng_en: implement ndo_get_stats64
From: Bhargava Chenna Marreddy
Date: Fri Feb 27 2026 - 14:07:59 EST
On Fri, Feb 27, 2026 at 6:52 AM Jakub Kicinski <kuba@xxxxxxxxxx> wrote:
>
> On Thu, 26 Feb 2026 23:51:33 +0530 Bhargava Marreddy wrote:
> > + set_bit(BNGE_STATE_READ_STATS, &bn->state);
> > + /* Make sure bnge_close_core() sees that we are reading stats before
> > + * we check the BNGE_STATE_OPEN flag.
> > + */
> > + smp_mb__after_atomic();
> > + if (!test_bit(BNGE_STATE_OPEN, &bd->state)) {
> > + clear_bit(BNGE_STATE_READ_STATS, &bn->state);
> > + *stats = bn->net_stats_prev;
> > + return;
> > + }
>
> There can be multiple concurrent readers. Two enter, first one gets
> stalled second one exits clearing the bit, close frees the memory,
> second reader proceeds to hit the NULL pointers.
>
> Again, please don't try to invent synchronization primitives.
> You can probably use RCU here.
Thanks Jakub.
RCU is a good idea to handle the race.
I will switch to it in the next spin and drop the BNGE_STATE_READ_STATS bit.
Thanks,
Bhargava Marreddy
> --
> pw-bot: cr
Attachment:
smime.p7s
Description: S/MIME Cryptographic Signature