[tip: timers/core] net: pktgen: Use accessor for hrtimer_sleeper ->task field
From: tip-bot2 for Paul E. McKenney
Date: Tue Sep 29 2026 - 15:06:09 EST
The following commit has been merged into the timers/core branch of tip:
Commit-ID: 3990d196954a06cf9fb1bb4efd142d57c30a8e21
Gitweb: https://git.kernel.org/tip/3990d196954a06cf9fb1bb4efd142d57c30a8e21
Author: Paul E. McKenney <paulmck@xxxxxxxxxx>
AuthorDate: Fri, 18 Sep 2026 17:14:23 -07:00
Committer: Thomas Gleixner <tglx@xxxxxxxxxx>
CommitterDate: Tue, 29 Sep 2026 21:02:52 +02:00
net: pktgen: Use accessor for hrtimer_sleeper ->task field
The hrtimer_sleeper structure's ->task field is used as a flag to indicate
that the associated hrtimer has expired. This means that the hrtimer
handler can be storing to this field while other code is loading from it
to check for expiry. Note that additional races appear for hrtimers that
can be restarted, which could be argued to be a user error. However, that
is no reason to let the compiler introduce additional confusion, and to
this end, the hrtimer_sleeper_task_get() was introduced, use of which also
has the benefit of avoiding open-code access to hrtimer_sleeper innards.
Therefore, apply this accessor to the pktgen spin() function.
KCSAN located this issue.
Signed-off-by: Paul E. McKenney <paulmck@xxxxxxxxxx>
Signed-off-by: Thomas Gleixner <tglx@xxxxxxxxxx>
Link: https://patch.msgid.link/20260919001428.3133388-7-paulmck@xxxxxxxxxx
---
net/core/pktgen.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/net/core/pktgen.c b/net/core/pktgen.c
index 7f81aed..784d839 100644
--- a/net/core/pktgen.c
+++ b/net/core/pktgen.c
@@ -2346,11 +2346,11 @@ static void spin(struct pktgen_dev *pkt_dev, ktime_t spin_until)
set_current_state(TASK_INTERRUPTIBLE);
hrtimer_sleeper_start_expires(&t, HRTIMER_MODE_ABS);
- if (likely(t.task))
+ if (likely(hrtimer_sleeper_task_get(&t)))
schedule();
hrtimer_cancel(&t.timer);
- } while (t.task && pkt_dev->running && !signal_pending(current));
+ } while (hrtimer_sleeper_task_get(&t) && pkt_dev->running && !signal_pending(current));
__set_current_state(TASK_RUNNING);
end_time = ktime_get();
}