DPDK patches and discussions
 help / color / mirror / Atom feed
From: "Ouyang, Changchun" <changchun.ouyang@intel.com>
To: Thomas Monjalon <thomas.monjalon@6wind.com>,
	Stephen Hemminger <stephen@networkplumber.org>
Cc: "dev@dpdk.org" <dev@dpdk.org>
Subject: Re: [dpdk-dev] [PATCH] virtio: Fix stats issue
Date: Fri, 27 Mar 2015 14:26:01 +0000	[thread overview]
Message-ID: <F52918179C57134FAEC9EA62FA2F962511A78AD9@shsmsx102.ccr.corp.intel.com> (raw)
In-Reply-To: <11509543.rOgWUoKvXr@xps13>

Hi Stephen, Thomas, David,



> -----Original Message-----
> From: Thomas Monjalon [mailto:thomas.monjalon@6wind.com]
> Sent: Monday, March 23, 2015 6:42 PM
> To: Ouyang, Changchun
> Cc: dev@dpdk.org; David Marchand
> Subject: Re: [dpdk-dev] [PATCH] virtio: Fix stats issue
> 
> 2015-03-23 16:38, Ouyang, Changchun:
> > On 3/23/2015 3:20 PM, David Marchand wrote:
> > > On Mon, Mar 23, 2015 at 7:56 AM, Ouyang Changchun
> > > <changchun.ouyang@intel.com <mailto:changchun.ouyang@intel.com>>
> wrote:
> > >
> > >     It need clear/reset the stats information before count in all
> > >     queues data.
> > >
> > >     Signed-off-by: Changchun Ouyang <changchun.ouyang@intel.com
> > >     <mailto:changchun.ouyang@intel.com>>
> > >     ---
> > >      lib/librte_pmd_virtio/virtio_ethdev.c | 8 ++++++++
> > >      1 file changed, 8 insertions(+)
> > >
> > >     diff --git a/lib/librte_pmd_virtio/virtio_ethdev.c
> > >     b/lib/librte_pmd_virtio/virtio_ethdev.c
> > >     index 603be2d..e4cb55e 100644
> > >     --- a/lib/librte_pmd_virtio/virtio_ethdev.c
> > >     +++ b/lib/librte_pmd_virtio/virtio_ethdev.c
> > >     @@ -572,6 +572,10 @@ virtio_dev_stats_get(struct rte_eth_dev *dev,
> > >     struct rte_eth_stats *stats)
> > >      {
> > >             unsigned i;
> > >
> > >     +       stats->opackets = 0;
> > >     +       stats->obytes = 0;
> > >     +       stats->oerrors = 0;
> > >
> > >
> > > stats are supposed to be zero'd in generic rte_ethdev.c before this
> > > pmd function is called, so this patch seems useless to me.
> > > Can you give some context ?
> > >
> > > Same comment for the i* part.
> > >
> > 2 reasons:
> > 1. this change could keep the stats_get has consistent behavior with
> > the one in other drivers;
> 
> If there are some useless reset in other drivers, they should be removed.
> 
> > 2. we don't rely on the assumption of caller always zero'd the stats,
> > and still can return correct value;
> 
> The caller is ethdev and it is zero'ing the structure before the call:
> 	http://dpdk.org/browse/dpdk/commit/?id=02331c16ec0
> 

I have seen this patch is rejected in patch-work,
But I'd like continue to discuss it here.
 
Do you guys see any big issues if we initialize 0 here in this function?
Well, I don't see any big issue here, just once again zero'd the stats info before get the actual value, it doesn't affect the rx and tx perf.

do you guys think it is better way to make a function behave under some assumption like here, caller must zero'd some memory?
It could work, but I think the better way is every function should make sure it has correct behavior even without any assumption.

On the other hand, I even think it is worthy to revert this patch, if you guys think the duplicated zero'd are not so nice:
http://dpdk.org/browse/dpdk/commit/?id=02331c16ec0

the background is that 
some guys want to implement another function(mostly like API in ethdev) which will call  virtio_dev_stats_get directly,
and NOT zero'd the stats before the calling, and then get the incorrect stats info as stats use '+=' to calculate the value and nowhere zero'd it before
do the '+='.  

So my opinion is we had better zero'd in virtio_dev_stats_get, instead of in rtedev,
While other pmd use '=' rather than '+=',
So they don't need explicitly zero'd the stats, but has similar effect.

Any thoughts?

Thanks
Changchun

  parent reply	other threads:[~2015-03-27 14:26 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-03-23  6:56 Ouyang Changchun
2015-03-23  7:20 ` David Marchand
2015-03-23  8:38   ` Ouyang, Changchun
2015-03-23 10:42     ` Thomas Monjalon
2015-03-23 22:53       ` Stephen Hemminger
2015-03-27 14:26       ` Ouyang, Changchun [this message]
2015-03-27 15:25         ` Thomas Monjalon

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=F52918179C57134FAEC9EA62FA2F962511A78AD9@shsmsx102.ccr.corp.intel.com \
    --to=changchun.ouyang@intel.com \
    --cc=dev@dpdk.org \
    --cc=stephen@networkplumber.org \
    --cc=thomas.monjalon@6wind.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).