net: pktgen: Use wait_event_freezable_timeout() for freezable kthread
Subsystems (2)
PATCH v2 1/1 net: pktgen: Use wait_event_freezable_timeout() for freezable kthread
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.
---
v2: Replace 'HZ/10' with 'HZ / 10' to fix the complaint from checkpatch.
net/core/pktgen.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)
net/core/pktgen.c +2 -4
@@ -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 ; }
Signature · 1 line
2.39.2
This patch was applied to netdev/net-next.git (main) by David S. Miller <[email protected]>:
Hello:
This patch was applied to netdev/net-next.git (main) by David S. Miller <[email protected]>:
Quoted 10 lines · On Wed, 20 Dec 2023 07:37:57 +0800 you wrote:
A freezable kernel thread can enter frozen state during freezing by either calling
try_to_freeze()or usingwait_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.[...]
Here is the summary with links:
- [v2,net-next] net: pktgen: Use wait_event_freezable_timeout() for freezable kthread
https://git.kernel.org/netdev/net-next/c/3fb65f6bc7dc
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html