From: Willem de Bruijn <willemdebruijn.kernel@gmail.com>
To: Xin Zhao <jackzxcui1989@163.com>,
willemdebruijn.kernel@gmail.com, edumazet@google.com,
ferenc@fejes.dev
Cc: davem@davemloft.net, kuba@kernel.org, pabeni@redhat.com,
horms@kernel.org, netdev@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH net-next v7] net: af_packet: Use hrtimer to do the retire operation
Date: Tue, 26 Aug 2025 12:05:38 -0400 [thread overview]
Message-ID: <willemdebruijn.kernel.2d7599ee951fd@gmail.com> (raw)
In-Reply-To: <20250826145347.1309654-1-jackzxcui1989@163.com>
Xin Zhao wrote:
> On Tue, 2025-08-25 at 20:54 +0800, Willem wrote:
>
> > > I understand that the additional in_scheduled variable is meant to prevent
> > > multiple calls to hrtimer_start. However, based on the current logic
> > > implementation, the only scenario that would cancel the hrtimer is after calling
> > > prb_shutdown_retire_blk_timer. Therefore, once we have called hrtimer_start in
> > > prb_setup_retire_blk_timer, we don't need to worry about the hrtimer stopping,
> > > and we don't need to execute hrtimer_start again or check if the hrtimer is in
> > > an active state. We can simply update the timeout in the callback.
> >
> > The hrtimer is also canceled when the callback returns
> > HRTIMER_NORESTART.
>
> In prb_retire_rx_blk_timer_expired function, the only way to return HRTIMER_NORESTART
> is that the pkc->delete_blk_timer is NOT 0.
> The delete_blk_timer is only set to 1 in prb_shutdown_retire_blk_timer which is called
> by packet_set_ring.
> In my understanding, once packet_set_ring is called and prb_shutdown_retire_blk_timer
> is executed, the only way to make this af_packet work again is to call packet_set_ring
> again to execute prb_setup_retire_blk_timer. At that point, hrtimer_start will be
> called again. Therefore, I feel that there is no need to perform the check in
> _prb_refresh_rx_retire_blk_timer. Only let prb_setup_retire_blk_timer to hrtimer_start,
> is that right?
Good point.
Let's clean up the control flow a bit more to make that more clear.
For one, no need for delete_blk_timer. hrtimer_cancel will cancel the
timer if it is queued. And the callback spends the vast majority of
its time after the check. So the odds of delete_blk_timer having any
effect is minimal.
And if the callback just restarts itself unconditionally, no need for
the special refresh_timer and out labels. Or the somewhat complex
calling flow between _prb_refresh_rx_retire_blk_timer, prb_open_block
and prb_retire_rx_blk_timer_expired. They all just schedule the next
timer the fixed computed jiffies/ms from now. The only special case
is when prb_open_block is called from tpacket_rcv. That would set
the timeout further into the future than the already queued timer.
I don't think that an earlier timeout is problematic. No need to
add complexity to avoid that.
next prev parent reply other threads:[~2025-08-26 16:05 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-08-26 14:53 [PATCH net-next v7] net: af_packet: Use hrtimer to do the retire operation Xin Zhao
2025-08-26 16:05 ` Willem de Bruijn [this message]
-- strict thread matches above, loose matches on Subject: below --
2025-08-26 3:03 Xin Zhao
2025-08-26 12:54 ` Willem de Bruijn
2025-08-22 13:20 Xin Zhao
2025-08-24 18:08 ` Willem de Bruijn
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=willemdebruijn.kernel.2d7599ee951fd@gmail.com \
--to=willemdebruijn.kernel@gmail.com \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=ferenc@fejes.dev \
--cc=horms@kernel.org \
--cc=jackzxcui1989@163.com \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).