From: Eric Dumazet <eric.dumazet@gmail.com>
To: Stephen Hemminger <shemminger@vyatta.com>
Cc: Jesper Dangaard Brouer <jdb@comx.dk>,
Robert Olsson <robert@herjulf.net>,
netdev@vger.kernel.org, "David S. Miller" <davem@davemloft.net>
Subject: [PATCH] pktgen: Fix delay handling
Date: Thu, 01 Oct 2009 11:47:34 +0200 [thread overview]
Message-ID: <4AC47AB6.9000501@gmail.com> (raw)
In-Reply-To: <20090930172532.2c2d1d42@s6510>
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>
---
net/core/pktgen.c | 6 ++++--
1 files changed, 4 insertions(+), 2 deletions(-)
diff --git a/net/core/pktgen.c b/net/core/pktgen.c
index 0bcecbf..1a0682e 100644
--- a/net/core/pktgen.c
+++ b/net/core/pktgen.c
@@ -2106,15 +2106,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;
- 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 = ktime_now();
if (remaining < 100)
next prev parent reply other threads:[~2009-10-01 9:47 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-09-23 5:49 pktgen: tricks Stephen Hemminger
2009-09-24 0:41 ` Stephen Hemminger
2009-09-24 1:05 ` Rick Jones
2009-09-24 10:10 ` Denys Fedoryschenko
2009-09-24 10:32 ` Eric Dumazet
2009-09-30 23:03 ` [PATCH] pktgen: Avoid dirtying skb->users when txq is full Eric Dumazet
2009-10-01 0:25 ` Stephen Hemminger
2009-10-01 9:47 ` Eric Dumazet [this message]
2009-10-01 10:04 ` [PATCH] pktgen: Fix delay handling Eric Dumazet
2009-10-01 16:29 ` David Miller
2009-10-01 16:32 ` Eric Dumazet
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4AC47AB6.9000501@gmail.com \
--to=eric.dumazet@gmail.com \
--cc=davem@davemloft.net \
--cc=jdb@comx.dk \
--cc=netdev@vger.kernel.org \
--cc=robert@herjulf.net \
--cc=shemminger@vyatta.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).