Re: [net-next v2 2/3] selftests/net: Test PACKET_STATISTICS drops

Willem de Bruijn
2026-04-06T21:20:33Z

Joe Damato wrote:
> On Sat, Apr 04, 2026 at 11:08:15AM -0400, Willem de Bruijn wrote:
> > Joe Damato wrote:
>
> [...]
>
> > > @@ -396,6 +424,11 @@ static void run_test(void)
> > >
> > > total_len = do_tx();
> > >
> > > + if (cfg_drop) {
> > > + check_packet_stats(fds);
> > > + goto out;
> > > + }
> >
> > Sashiko pointed out
>
> In the future, please link to the AI report.
>
> > that there may be a race here between rx
> > processing in the softirq and check_packet_stats. Seems plausible.
>
> Can you elaborate why this is true?
>
> I could be wrong, but I scanned the code and __local_bh_enable_ip seems to run
> softirq synchronously in this case, so I think the code is correct.

You mean that after the return to user in sendmsg, the packets are
guaranteed to have been queued to the sd->input_pkt_queue, the napi
schedule was run by enqueue_to_backlog and napi was run on this
cpu as a result of reenabling BH. At the end of dev_queue_xmit? I
recall that there may be a common one on syscall return too, but the
details elude me right now.

Either way, makes sense. I had not fully appreciated that the
softirq schedule is this deterministic.