From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <nhorman@tuxdriver.com>
Received: from smtp.tuxdriver.com (charlotte.tuxdriver.com [70.61.120.58])
 by dpdk.org (Postfix) with ESMTP id 33F187E7B
 for <dev@dpdk.org>; Tue, 21 Oct 2014 15:29:31 +0200 (CEST)
Received: from [2001:470:8:a08:a03f:1c79:d585:4dec] (helo=localhost)
 by smtp.tuxdriver.com with esmtpsa (TLSv1:AES128-SHA:128) (Exim 4.63)
 (envelope-from <nhorman@tuxdriver.com>)
 id 1XgZd5-0006cv-Jo; Tue, 21 Oct 2014 09:37:45 -0400
Date: Tue, 21 Oct 2014 09:37:38 -0400
From: Neil Horman <nhorman@tuxdriver.com>
To: "Richardson, Bruce" <bruce.richardson@intel.com>
Message-ID: <20141021133738.GC12795@hmsreliant.think-freely.org>
References: <1408947174-11323-1-git-send-email-cunming.liang@intel.com>
 <1412944201-30703-1-git-send-email-cunming.liang@intel.com>
 <1412944201-30703-2-git-send-email-cunming.liang@intel.com>
 <20141010175226.GG19499@hmsreliant.think-freely.org>
 <D0158A423229094DA7ABF71CF2FA0DA31183E8F0@shsmsx102.ccr.corp.intel.com>
 <20141021103315.GB12795@hmsreliant.think-freely.org>
 <59AF69C657FD0841A61C55336867B5B0344212BF@IRSMSX103.ger.corp.intel.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
In-Reply-To: <59AF69C657FD0841A61C55336867B5B0344212BF@IRSMSX103.ger.corp.intel.com>
User-Agent: Mutt/1.5.23 (2014-03-12)
X-Spam-Score: -2.9 (--)
X-Spam-Status: No
Cc: "dev@dpdk.org" <dev@dpdk.org>
Subject: Re: [dpdk-dev] [PATCH v2 1/4] app/test: unit test for rx and tx
 cycles/packet
X-BeenThere: dev@dpdk.org
X-Mailman-Version: 2.1.15
Precedence: list
List-Id: patches and discussions about DPDK <dev.dpdk.org>
List-Unsubscribe: <http://dpdk.org/ml/options/dev>,
 <mailto:dev-request@dpdk.org?subject=unsubscribe>
List-Archive: <http://dpdk.org/ml/archives/dev/>
List-Post: <mailto:dev@dpdk.org>
List-Help: <mailto:dev-request@dpdk.org?subject=help>
List-Subscribe: <http://dpdk.org/ml/listinfo/dev>,
 <mailto:dev-request@dpdk.org?subject=subscribe>
X-List-Received-Date: Tue, 21 Oct 2014 13:29:31 -0000

On Tue, Oct 21, 2014 at 10:43:03AM +0000, Richardson, Bruce wrote:
> 
> 
> > -----Original Message-----
> > From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Neil Horman
> > Sent: Tuesday, October 21, 2014 11:33 AM
> > To: Liang, Cunming
> > Cc: dev@dpdk.org
> > Subject: Re: [dpdk-dev] [PATCH v2 1/4] app/test: unit test for rx and tx
> > cycles/packet
> > 
> > > >
> > > > > +	if (count == 0)
> > > > > +		return -1;
> > > > > +
> > > > > +	printf("%lu packet, %lu drop, %lu idle\n", count, drop, idle);
> > > > > +	printf("Result: %ld cycles per packet\n", (cur_tsc - prev_tsc) / count);
> > > > > +
> > > > Bad math here.  Theres no guarantee that the tsc hasn't wrapped (potentially
> > > > more than once) depending on your test length.  you need to check the tsc
> > before
> > > > and after each burst and record an average of deltas instead, accounting in
> > each
> > > > instance for the possibility of wrap.
> > > [Liang, Cunming] I'm not sure catch your point correctly.
> > > I think both cur_tsc and prev_tsc are 64 bits width.
> > > For 3GHz, I think it won't wrapped so quick.
> > > As it's uint64_t, so even get wrapped, the delta should still be correct.
> > But theres no guarantee that the tsc starts at zero when you begin your test.
> > The system may have been up for a long time and near wrapping already.
> > Regardless, you need to account for the possibility that cur_tsc is smaller
> > than prev_tsc, or this breaks.
> > 
> 
> The tsc. is 64-bit and so only wraps around every couple of hundred years or so on a 2GHz machine, so I don't think it's necessary to handle that case. 
> 
But that presumes that no one has written the TSC via IA32_TIME_STAMP_COUNTER.
Assuming that something will never wrap just seems like bad practice here.  We
should have a general purpose macro to handle wrapping counters like this, if
not for this case specficially, then in general.

Neil

> /Bruce
>