* [PATCH net-next] net: pktgen: Use wait_event_freezable_timeout() for freezable kthread
@ 2023-12-16 11:26 Kevin Hao
2023-12-19 12:37 ` Paolo Abeni
0 siblings, 1 reply; 3+ messages in thread
From: Kevin Hao @ 2023-12-16 11:26 UTC (permalink / raw)
To: David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni
Cc: netdev, Rafael J. Wysocki, Pavel Machek
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);
continue;
}
--
2.39.2
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH net-next] net: pktgen: Use wait_event_freezable_timeout() for freezable kthread
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
2023-12-19 23:24 ` Kevin Hao
0 siblings, 1 reply; 3+ messages in thread
From: Paolo Abeni @ 2023-12-19 12:37 UTC (permalink / raw)
To: Kevin Hao, David S. Miller, Eric Dumazet, Jakub Kicinski
Cc: netdev, Rafael J. Wysocki, Pavel Machek
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
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH net-next] net: pktgen: Use wait_event_freezable_timeout() for freezable kthread
2023-12-19 12:37 ` Paolo Abeni
@ 2023-12-19 23:24 ` Kevin Hao
0 siblings, 0 replies; 3+ messages in thread
From: Kevin Hao @ 2023-12-19 23:24 UTC (permalink / raw)
To: Paolo Abeni
Cc: David S. Miller, Eric Dumazet, Jakub Kicinski, netdev,
Rafael J. Wysocki, Pavel Machek
[-- Attachment #1: Type: text/plain, Size: 1654 bytes --]
On Tue, Dec 19, 2023 at 01:37:23PM +0100, Paolo Abeni wrote:
> 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'.
Yes, I saw the complaint from checkpatch before sending this patch, but I
thought I should keep it as it is. :-)
Anyway, v2 is coming.
Thanks,
Kevin
>
> Thanks!
>
> Paolo
>
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2023-12-19 23:25 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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
2023-12-19 23:24 ` Kevin Hao
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).