]> www.infradead.org Git - users/dwmw2/linux.git/commitdiff
net: pktgen: Use wait_event_freezable_timeout() for freezable kthread
authorKevin Hao <haokexin@gmail.com>
Tue, 19 Dec 2023 23:37:57 +0000 (07:37 +0800)
committerDavid S. Miller <davem@davemloft.net>
Wed, 27 Dec 2023 14:34:52 +0000 (14:34 +0000)
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>
Signed-off-by: David S. Miller <davem@davemloft.net>
net/core/pktgen.c

index 57cea67b75624696dd521904fb6eb36864c1e7eb..ea55a758a475ab0ee22d9ac91f0ac9f0a6975e1f 100644 (file)
@@ -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;
                }