From patchwork Thu Oct 1 09:47:34 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Dumazet X-Patchwork-Id: 34663 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.176.167]) by ozlabs.org (Postfix) with ESMTP id C2C71B7BCA for ; Thu, 1 Oct 2009 19:47:44 +1000 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756024AbZJAJrf (ORCPT ); Thu, 1 Oct 2009 05:47:35 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1755954AbZJAJrf (ORCPT ); Thu, 1 Oct 2009 05:47:35 -0400 Received: from gw1.cosmosbay.com ([212.99.114.194]:48757 "EHLO gw1.cosmosbay.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755005AbZJAJre (ORCPT ); Thu, 1 Oct 2009 05:47:34 -0400 Received: from [127.0.0.1] (localhost [127.0.0.1]) by gw1.cosmosbay.com (8.13.7/8.13.7) with ESMTP id n919lYVB031383; Thu, 1 Oct 2009 11:47:34 +0200 Message-ID: <4AC47AB6.9000501@gmail.com> Date: Thu, 01 Oct 2009 11:47:34 +0200 From: Eric Dumazet User-Agent: Thunderbird 2.0.0.23 (Windows/20090812) MIME-Version: 1.0 To: Stephen Hemminger CC: Jesper Dangaard Brouer , Robert Olsson , netdev@vger.kernel.org, "David S. Miller" Subject: [PATCH] pktgen: Fix delay handling References: <20090922224902.17ed6cc4@nehalam> <20090923174141.1d350103@s6510> <4AC3E3C5.1090108@gmail.com> <20090930172532.2c2d1d42@s6510> In-Reply-To: <20090930172532.2c2d1d42@s6510> X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-1.6 (gw1.cosmosbay.com [0.0.0.0]); Thu, 01 Oct 2009 11:47:35 +0200 (CEST) Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org 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 --- net/core/pktgen.c | 6 ++++-- 1 files changed, 4 insertions(+), 2 deletions(-) -- 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 --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)