diff mbox

pktgen: Fix delay handling

Message ID 4AC47EB9.6070809@gmail.com
State Accepted, archived
Delegated to: David Miller
Headers show

Commit Message

Eric Dumazet Oct. 1, 2009, 10:04 a.m. UTC
Eric Dumazet a écrit :
> After last pktgen changes, delay handling is wrong.
> 
> pktgen actually sends packets at full line speed.
> 
> Fix is to update pkt_dev->next_tx even if spin() returns early,
> so that next spin() calls have a chance to see a positive delay.
> 
> Signed-off-by: Eric Dumazet <eric.dumazet@gmail.com>

Oh well, I hit this bug on linux-2.6 git tree, but I did the patch on net-next-2.6

But it appears net/core/pktgen.c is different on net-next-2.6

Stephen, David, I am a bit lost here, something went wrong in a merge process ?

In any case, here is the patch against Linus tree, where bug is present.

Thanks

[PATCH] pktgen: Fix delay handling

After last pktgen changes, delay handling is wrong.

pktgen actually sends packets at full line speed.

Fix is to update pkt_dev->next_tx even if spin() returns early,
so that next spin() calls have a chance to see a positive delay.

Signed-off-by: Eric Dumazet <eric.dumazet@gmail.com>
---
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Comments

David Miller Oct. 1, 2009, 4:29 p.m. UTC | #1
From: Eric Dumazet <eric.dumazet@gmail.com>
Date: Thu, 01 Oct 2009 12:04:41 +0200

> But it appears net/core/pktgen.c is different on net-next-2.6
> 
> Stephen, David, I am a bit lost here, something went wrong in a merge process ?
> 

net-next-2.6 is just a stale old tree, there is no new networking
work in there and it is simply Linus's tree as of a few weeks
ago.

It's only there so Stephen Rothwell has something to do a 'nop'
pull from into his linux-next tree.

I'll apply your fix, thanks!
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Eric Dumazet Oct. 1, 2009, 4:32 p.m. UTC | #2
David Miller a écrit :
> net-next-2.6 is just a stale old tree, there is no new networking
> work in there and it is simply Linus's tree as of a few weeks
> ago.
> 
> It's only there so Stephen Rothwell has something to do a 'nop'
> pull from into his linux-next tree.
> 
> I'll apply your fix, thanks!

Thanks for the explanation David.
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/net/core/pktgen.c b/net/core/pktgen.c
index 4d11c28..b694552 100644
--- a/net/core/pktgen.c
+++ b/net/core/pktgen.c
@@ -2105,15 +2105,17 @@  static void pktgen_setup_inject(struct pktgen_dev *pkt_dev)
 static void spin(struct pktgen_dev *pkt_dev, ktime_t spin_until)
 {
 	ktime_t start_time, end_time;
-	s32 remaining;
+	s64 remaining;
 	struct hrtimer_sleeper t;
 
 	hrtimer_init_on_stack(&t.timer, CLOCK_MONOTONIC, HRTIMER_MODE_ABS);
 	hrtimer_set_expires(&t.timer, spin_until);
 
 	remaining = ktime_to_us(hrtimer_expires_remaining(&t.timer));
-	if (remaining <= 0)
+	if (remaining <= 0) {
+		pkt_dev->next_tx = ktime_add_ns(spin_until, pkt_dev->delay);
 		return;
+	}
 
 	start_time = ktime_now();
 	if (remaining < 100)