diff options
author | Eric Dumazet <eric.dumazet@gmail.com> | 2011-10-20 17:00:21 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2011-10-20 17:00:21 -0400 |
commit | 33136d12be00596a8320d4fe88f95c44f67afbdb (patch) | |
tree | b12e136753a269684794308df59183329ed553a8 /net/core/pktgen.c | |
parent | e9266a02b7e6542355431955075b4e688962fc0a (diff) | |
download | op-kernel-dev-33136d12be00596a8320d4fe88f95c44f67afbdb.zip op-kernel-dev-33136d12be00596a8320d4fe88f95c44f67afbdb.tar.gz |
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: Daniel Turull <daniel.turull@gmail.com>
Signed-off-by: Eric Dumazet <eric.dumazet@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/core/pktgen.c')
-rw-r--r-- | net/core/pktgen.c | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/net/core/pktgen.c b/net/core/pktgen.c index 6bbf008..0001c24 100644 --- a/net/core/pktgen.c +++ b/net/core/pktgen.c @@ -2145,9 +2145,12 @@ static void spin(struct pktgen_dev *pkt_dev, ktime_t spin_until) } start_time = ktime_now(); - if (remaining < 100000) - ndelay(remaining); /* really small just spin */ - else { + if (remaining < 100000) { + /* for small delays (<100us), just loop until limit is reached */ + do { + end_time = ktime_now(); + } while (ktime_lt(end_time, spin_until)); + } else { /* see do_nanosleep */ hrtimer_init_sleeper(&t, current); do { @@ -2162,8 +2165,8 @@ static void spin(struct pktgen_dev *pkt_dev, ktime_t spin_until) hrtimer_cancel(&t.timer); } while (t.task && pkt_dev->running && !signal_pending(current)); __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->next_tx = ktime_add_ns(spin_until, pkt_dev->delay); |