Commit 33136d12 authored by Eric Dumazet's avatar Eric Dumazet Committed by David S. Miller

pktgen: remove ndelay() call

Daniel Turull reported inaccuracies in pktgen when using low packet
rates, because we call ndelay(val) with values bigger than 20000.

Instead of calling ndelay() for delays < 100us, we can instead loop
calling ktime_now() only.
Reported-by: default avatarDaniel Turull <daniel.turull@gmail.com>
Signed-off-by: default avatarEric Dumazet <eric.dumazet@gmail.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent e9266a02
...@@ -2145,9 +2145,12 @@ static void spin(struct pktgen_dev *pkt_dev, ktime_t spin_until) ...@@ -2145,9 +2145,12 @@ static void spin(struct pktgen_dev *pkt_dev, ktime_t spin_until)
} }
start_time = ktime_now(); start_time = ktime_now();
if (remaining < 100000) if (remaining < 100000) {
ndelay(remaining); /* really small just spin */ /* for small delays (<100us), just loop until limit is reached */
else { do {
end_time = ktime_now();
} while (ktime_lt(end_time, spin_until));
} else {
/* see do_nanosleep */ /* see do_nanosleep */
hrtimer_init_sleeper(&t, current); hrtimer_init_sleeper(&t, current);
do { do {
...@@ -2162,8 +2165,8 @@ static void spin(struct pktgen_dev *pkt_dev, ktime_t spin_until) ...@@ -2162,8 +2165,8 @@ static void spin(struct pktgen_dev *pkt_dev, ktime_t spin_until)
hrtimer_cancel(&t.timer); hrtimer_cancel(&t.timer);
} while (t.task && pkt_dev->running && !signal_pending(current)); } while (t.task && pkt_dev->running && !signal_pending(current));
__set_current_state(TASK_RUNNING); __set_current_state(TASK_RUNNING);
end_time = ktime_now();
} }
end_time = ktime_now();
pkt_dev->idle_acc += ktime_to_ns(ktime_sub(end_time, start_time)); pkt_dev->idle_acc += ktime_to_ns(ktime_sub(end_time, start_time));
pkt_dev->next_tx = ktime_add_ns(spin_until, pkt_dev->delay); pkt_dev->next_tx = ktime_add_ns(spin_until, pkt_dev->delay);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment