Thread (13 messages) 13 messages, 3 authors, 2026-02-27

Re: [PATCH net-next v2 8/8] bng_en: implement ndo_get_stats64

From: Bhargava Chenna Marreddy <hidden>
Date: 2026-02-27 19:04:59
Also in: lkml

On Fri, Feb 27, 2026 at 6:52 AM Jakub Kicinski [off-list ref] wrote:
On Thu, 26 Feb 2026 23:51:33 +0530 Bhargava Marreddy wrote:
quoted
+     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

Attachments

  • smime.p7s [application/pkcs7-signature] 5496 bytes
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help