netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Paolo Abeni <pabeni@redhat.com>
To: Kevin Hao <haokexin@gmail.com>,
	"David S. Miller" <davem@davemloft.net>,
	Eric Dumazet <edumazet@google.com>,
	Jakub Kicinski <kuba@kernel.org>
Cc: netdev@vger.kernel.org, "Rafael J. Wysocki" <rafael@kernel.org>,
	Pavel Machek <pavel@ucw.cz>
Subject: Re: [PATCH net-next] net: pktgen: Use wait_event_freezable_timeout() for freezable kthread
Date: Tue, 19 Dec 2023 13:37:23 +0100	[thread overview]
Message-ID: <38f6b7856f8060f9770ec0ea2a163c5960d9eed9.camel@redhat.com> (raw)
In-Reply-To: <20231216112632.2255398-1-haokexin@gmail.com>

On Sat, 2023-12-16 at 19:26 +0800, Kevin Hao wrote:
> A freezable kernel thread can enter frozen state during freezing by
> either calling try_to_freeze() or using wait_event_freezable() and its
> variants. So for the following snippet of code in a kernel thread loop:
>   wait_event_interruptible_timeout();
>   try_to_freeze();
> 
> We can change it to a simple wait_event_freezable_timeout() and then
> eliminate a function call.
> 
> Signed-off-by: Kevin Hao <haokexin@gmail.com>
> ---
>  net/core/pktgen.c | 6 ++----
>  1 file changed, 2 insertions(+), 4 deletions(-)
> 
> diff --git a/net/core/pktgen.c b/net/core/pktgen.c
> index 57cea67b7562..2b59fc66fe26 100644
> --- a/net/core/pktgen.c
> +++ b/net/core/pktgen.c
> @@ -3669,10 +3669,8 @@ static int pktgen_thread_worker(void *arg)
>  		if (unlikely(!pkt_dev && t->control == 0)) {
>  			if (t->net->pktgen_exiting)
>  				break;
> -			wait_event_interruptible_timeout(t->queue,
> -							 t->control != 0,
> -							 HZ/10);
> -			try_to_freeze();
> +			wait_event_freezable_timeout(t->queue,
> +						     t->control != 0, HZ/10);

The patch looks functionally correct to me, so I'm sorry to nit-pick. 

Since you touch the last line just for a 'cosmetic' change, please make
checkpatch happy, too:  please replace 'HZ/10' with 'HZ / 10'.

Thanks!

Paolo


  reply	other threads:[~2023-12-19 12:37 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-12-16 11:26 [PATCH net-next] net: pktgen: Use wait_event_freezable_timeout() for freezable kthread Kevin Hao
2023-12-19 12:37 ` Paolo Abeni [this message]
2023-12-19 23:24   ` Kevin Hao

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=38f6b7856f8060f9770ec0ea2a163c5960d9eed9.camel@redhat.com \
    --to=pabeni@redhat.com \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=haokexin@gmail.com \
    --cc=kuba@kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pavel@ucw.cz \
    --cc=rafael@kernel.org \
    /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).