Re: [PATCH net-next v3 4/4] netdevsim: account dropped packet length in stats on queue free
From: Breno Leitao
Date: Tue Jun 17 2025 - 09:29:42 EST
On Tue, Jun 17, 2025 at 05:59:34AM -0700, Jakub Kicinski wrote:
> On Tue, 17 Jun 2025 01:19:00 -0700 Breno Leitao wrote:
> > -static void nsim_queue_free(struct nsim_rq *rq)
> > +static void nsim_queue_free(struct net_device *dev, struct nsim_rq *rq)
> > {
> > hrtimer_cancel(&rq->napi_timer);
> > + dev_dstats_rx_dropped_add(dev, rq->skb_queue.qlen);
>
> here we are in process context and debug checks complain about the use
> of this_cpu_ptr(). Let's wrap this in local_bh_disable() / enable() ?
Thanks. I was able to reproduce it. Your suggestion avoids the complain.
I suppose we should just wrap dev_dstats_rx_dropped_add(), right?
diff --git a/drivers/net/netdevsim/netdev.c b/drivers/net/netdevsim/netdev.c
index 5d0b801e81129..07171cf8b07ee 100644
--- a/drivers/net/netdevsim/netdev.c
+++ b/drivers/net/netdevsim/netdev.c
@@ -635,7 +635,9 @@ static struct nsim_rq *nsim_queue_alloc(void)
static void nsim_queue_free(struct net_device *dev, struct nsim_rq *rq)
{
hrtimer_cancel(&rq->napi_timer);
+ local_bh_disable();
dev_dstats_rx_dropped_add(dev, rq->skb_queue.qlen);
+ local_bh_enable();
skb_queue_purge_reason(&rq->skb_queue, SKB_DROP_REASON_QUEUE_PURGE);
kfree(rq);
}