DPDK patches and discussions
 help / color / mirror / Atom feed
From: Ferruh Yigit <ferruh.yigit@intel.com>
To: Vivien Didelot <vivien.didelot@gmail.com>,
	Stephen Hemminger <stephen@networkplumber.org>
Cc: dev@dpdk.org, patrick.keroulas@radio-canada.ca, thomas@monjalon.net
Subject: Re: [dpdk-dev] [PATCH v2] net/pcap: support software Tx nanosecond timestamps
Date: Wed, 10 Jun 2020 13:17:14 +0100	[thread overview]
Message-ID: <a19b9448-1df6-f8cc-f21d-e0412ff032a5@intel.com> (raw)
In-Reply-To: <20200609155753.GB111880@t480s.localdomain>

On 6/9/2020 8:57 PM, Vivien Didelot wrote:
> Hi Stephen,
> 
> On Tue, 9 Jun 2020 12:43:57 -0700, Stephen Hemminger <stephen@networkplumber.org> wrote:
>> On Tue,  9 Jun 2020 15:07:19 -0400
>> Vivien Didelot <vivien.didelot@gmail.com> wrote:
>>
>>>  
>>> +#define NSEC_PER_SEC	1000000000L
>>> +
>>>  static inline void
>>>  calculate_timestamp(struct timeval *ts) {
>>>  	uint64_t cycles;
>>> @@ -294,8 +296,14 @@ calculate_timestamp(struct timeval *ts) {
>>>  
>>>  	cycles = rte_get_timer_cycles() - start_cycles;
>>>  	cur_time.tv_sec = cycles / hz;
>>> -	cur_time.tv_usec = (cycles % hz) * 1e6 / hz;
>>> -	timeradd(&start_time, &cur_time, ts);
>>> +	cur_time.tv_usec = (cycles % hz) * NSEC_PER_SEC / hz;
>>> +
>>> +	ts->tv_sec = start_time.tv_sec + cur_time.tv_sec;
>>> +	ts->tv_usec = start_time.tv_usec + cur_time.tv_usec;
>>> +	if (ts->tv_usec >= NSEC_PER_SEC) {
>>> +		ts->tv_usec -= NSEC_PER_SEC;
>>> +		ts->tv_sec += 1;
>>> +	}
>>>  }
>>>  
>>
>> You may want to pre-compute the reciprocal here to save the expensive
>> cost of divide in the fast path. See rte_reciprocal.
> 
> Please note that I did not change the calculation logic that was previously
> used here. Thus pre-computing the reciprocal here to save the expensive cost
> of divide in the fast path seems out of the scope of this patch to me.
> 
> Can we keep this for a future patch maybe?
> 

+1 to have this as incremental improvement to this patch.

  reply	other threads:[~2020-06-10 12:17 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-06-09 19:07 Vivien Didelot
2020-06-09 19:43 ` Stephen Hemminger
2020-06-09 19:57   ` Vivien Didelot
2020-06-10 12:17     ` Ferruh Yigit [this message]
2020-06-10 13:42 ` Ferruh Yigit

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=a19b9448-1df6-f8cc-f21d-e0412ff032a5@intel.com \
    --to=ferruh.yigit@intel.com \
    --cc=dev@dpdk.org \
    --cc=patrick.keroulas@radio-canada.ca \
    --cc=stephen@networkplumber.org \
    --cc=thomas@monjalon.net \
    --cc=vivien.didelot@gmail.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).