[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20250214141011.501910f3@kernel.org>
Date: Fri, 14 Feb 2025 14:10:11 -0800
From: Jakub Kicinski <kuba@...nel.org>
To: Breno Leitao <leitao@...ian.org>
Cc: Frederic Weisbecker <frederic@...nel.org>, LKML
<linux-kernel@...r.kernel.org>, Peter Zijlstra <peterz@...radead.org>, Ingo
Molnar <mingo@...hat.com>, Will Deacon <will@...nel.org>, Boqun Feng
<boqun.feng@...il.com>, Waiman Long <longman@...hat.com>, "David S. Miller"
<davem@...emloft.net>, Eric Dumazet <edumazet@...gle.com>, Paolo Abeni
<pabeni@...hat.com>, Simon Horman <horms@...nel.org>, Hayes Wang
<hayeswang@...ltek.com>, linux-usb@...r.kernel.org, netdev@...r.kernel.org
Subject: Re: [PATCH 1/2] net: Assert proper context while calling
napi_schedule()
On Fri, 14 Feb 2025 08:43:28 -0800 Breno Leitao wrote:
> diff --git a/drivers/net/netdevsim/netdev.c b/drivers/net/netdevsim/netdev.c
> index 42f247cbdceec..cd56904a39049 100644
> --- a/drivers/net/netdevsim/netdev.c
> +++ b/drivers/net/netdevsim/netdev.c
> @@ -87,7 +87,7 @@ static netdev_tx_t nsim_start_xmit(struct sk_buff *skb, struct net_device *dev)
> if (unlikely(nsim_forward_skb(peer_dev, skb, rq) == NET_RX_DROP))
> goto out_drop_cnt;
>
> - napi_schedule(&rq->napi);
> + hrtimer_start(&rq->napi_timer, ns_to_ktime(5), HRTIMER_MODE_REL);
ns -> us
We want to leave the timer be in case it's already scheduled.
Otherwise we'll keep postponing forever under load.
Double check that hrtime_start() does not reset the time if already
pending. Maybe hrtimer_start_range_ns(..., 0, us_to_ktime(5), ...)
would work?
> rcu_read_unlock();
> u64_stats_update_begin(&ns->syncp);
> @@ -426,6 +426,25 @@ static int nsim_init_napi(struct netdevsim *ns)
> return err;
> }
>
> +static enum hrtimer_restart nsim_napi_schedule(struct hrtimer *timer)
> +{
> + struct nsim_rq *rq;
> +
> + rq = container_of(timer, struct nsim_rq, napi_timer);
> + napi_schedule(&rq->napi);
> + /* TODO: Should HRTIMER_RESTART be returned if napi_schedule returns
> + * false?
> + */
I think not, ignore the return value
> + return HRTIMER_NORESTART;
> +}
Powered by blists - more mailing lists