DPDK patches and discussions
 help / color / mirror / Atom feed
From: Thomas Monjalon <thomas@monjalon.net>
To: "'Singh, Jasvinder'" <jasvinder.singh@intel.com>
Cc: "'Dumitrescu, Cristian'" <cristian.dumitrescu@intel.com>,
	"'alangordondewar@gmail.com'" <alangordondewar@gmail.com>,
	dev@dpdk.org, 'Alan Dewar' <alan.dewar@att.com>,
	"Dewar, Alan" <alan.dewar@intl.att.com>
Subject: Re: [dpdk-dev] [PATCH] sched: fix port time rounding error
Date: Thu, 25 Jun 2020 00:50:00 +0200	[thread overview]
Message-ID: <2265604.5qLSFAYZse@thomas> (raw)
In-Reply-To: <80847da6f3b44c49a3884da76818302e@intl.att.com>

Jasvinder, what is the conclusion of this patch?

21/04/2020 10:21, Dewar, Alan:
> From: Singh, Jasvinder <jasvinder.singh@intel.com> 
> > > > From: Alan Dewar <alan.dewar@att.com>
> > > >
> > > > The QoS scheduler works off port time that is computed from the 
> > > > number of CPU cycles that have elapsed since the last time the port was
> > > > polled.   It divides the number of elapsed cycles to calculate how
> > > > many bytes can be sent, however this division can generate rounding 
> > > > errors, where some fraction of a byte sent may be lost.
> > > >
> > > > Lose enough of these fractional bytes and the QoS scheduler 
> > > > underperforms.  The problem is worse with low bandwidths.
> > > >
> > > > To compensate for this rounding error this fix doesn't advance the 
> > > > port's time_cpu_cycles by the number of cycles that have elapsed, 
> > > > but by multiplying the computed number of bytes that can be sent 
> > > > (which has been rounded down) by number of cycles per byte.
> > > > This will mean that port's time_cpu_cycles will lag behind the CPU 
> > > > cycles momentarily.  At the next poll, the lag will be taken into 
> > > > account.
> > > >
> > > > Fixes: de3cfa2c98 ("sched: initial import")
> > > >
> > > > Signed-off-by: Alan Dewar <alan.dewar@att.com>
> > > > ---
> > > >  lib/librte_sched/rte_sched.c | 12 ++++++++++--
> > > >  1 file changed, 10 insertions(+), 2 deletions(-)
> > > >
> > > > diff --git a/lib/librte_sched/rte_sched.c 
> > > > b/lib/librte_sched/rte_sched.c index c0983ddda..c656dba2d 100644
> > > > --- a/lib/librte_sched/rte_sched.c
> > > > +++ b/lib/librte_sched/rte_sched.c
> > > > @@ -222,6 +222,7 @@ struct rte_sched_port {
> > > >  	uint64_t time_cpu_bytes;      /* Current CPU time measured in bytes
> > > > */
> > > >  	uint64_t time;                /* Current NIC TX time measured in bytes */
> > > >  	struct rte_reciprocal inv_cycles_per_byte; /* CPU cycles per byte 
> > > > */
> > > > +	uint64_t cycles_per_byte;
> > > >
> > > >  	/* Grinders */
> > > >  	struct rte_mbuf **pkts_out;
> > > > @@ -852,6 +853,7 @@ rte_sched_port_config(struct
> > > rte_sched_port_params
> > > > *params)
> > > >  	cycles_per_byte = (rte_get_tsc_hz() << RTE_SCHED_TIME_SHIFT)
> > > >  		/ params->rate;
> > > >  	port->inv_cycles_per_byte = rte_reciprocal_value(cycles_per_byte);
> > > > +	port->cycles_per_byte = cycles_per_byte;
> > > >
> > > >  	/* Grinders */
> > > >  	port->pkts_out = NULL;
> > > > @@ -2673,20 +2675,26 @@ static inline void 
> > > > rte_sched_port_time_resync(struct rte_sched_port *port)  {
> > > >  	uint64_t cycles = rte_get_tsc_cycles();
> > > > -	uint64_t cycles_diff = cycles - port->time_cpu_cycles;
> > > > +	uint64_t cycles_diff;
> > > >  	uint64_t bytes_diff;
> > > >  	uint32_t i;
> > > >
> > > > +	if (cycles < port->time_cpu_cycles)
> > > > +		goto end;
> > 
> > Above check seems redundant as port->time_cpu_cycles will always be less than the current cycles due to roundoff in previous iteration.
> > 
> 
> This was to catch the condition where the cycles wraps back to zero (after 100+ years?? depending on clock speed).  
> Rather than just going to end: the conditional should at least reset port->time_cpu_cycles back to zero.
> So there would be a very temporary glitch in accuracy once every 100+ years. 




  reply	other threads:[~2020-06-24 22:50 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-04-16  8:48 alangordondewar
2020-04-17 21:19 ` Dumitrescu, Cristian
2020-04-20 11:23   ` Singh, Jasvinder
2020-04-21  8:21     ` Dewar, Alan
2020-06-24 22:50       ` Thomas Monjalon [this message]
2020-06-25  8:32         ` Singh, Jasvinder
2020-06-25  8:40           ` Alan Dewar
2020-06-25  9:59 ` [dpdk-dev] [PATCH v2] " alangordondewar
2020-07-05 20:41   ` Thomas Monjalon
2020-07-06 21:20     ` Singh, Jasvinder
2020-07-06 23:01       ` Thomas Monjalon
2020-08-20 14:32   ` Kevin Traynor
2020-08-21 15:28     ` Kinsella, Ray
2020-09-07 10:09       ` Kevin Traynor

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=2265604.5qLSFAYZse@thomas \
    --to=thomas@monjalon.net \
    --cc=alan.dewar@att.com \
    --cc=alan.dewar@intl.att.com \
    --cc=alangordondewar@gmail.com \
    --cc=cristian.dumitrescu@intel.com \
    --cc=dev@dpdk.org \
    --cc=jasvinder.singh@intel.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).