From: Alexander Duyck <alexander.duyck@gmail.com>
To: Harry van Haaren <harry.van.haaren@intel.com>, dev@dpdk.org
Subject: Re: [PATCH 1/2] ixgbe: fix VF statistic wraparound handling macro
Date: Mon, 12 Oct 2015 08:41:34 -0700 [thread overview]
Message-ID: <561BD4AE.4010704@gmail.com> (raw)
In-Reply-To: <1444656823-717-2-git-send-email-harry.van.haaren@intel.com>
On 10/12/2015 06:33 AM, Harry van Haaren wrote:
> Fix a misinterpretation of VF stats in ixgbe
>
> Signed-off-by: Harry van Haaren <harry.van.haaren@intel.com>
> ---
> drivers/net/ixgbe/ixgbe_ethdev.c | 8 ++++++--
> 1 file changed, 6 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/net/ixgbe/ixgbe_ethdev.c b/drivers/net/ixgbe/ixgbe_ethdev.c
> index ec2918c..d226e8d 100644
> --- a/drivers/net/ixgbe/ixgbe_ethdev.c
> +++ b/drivers/net/ixgbe/ixgbe_ethdev.c
> @@ -329,10 +329,14 @@ static int ixgbe_timesync_read_tx_timestamp(struct rte_eth_dev *dev,
> /*
> * Define VF Stats MACRO for Non "cleared on read" register
> */
> -#define UPDATE_VF_STAT(reg, last, cur) \
> +#define UPDATE_VF_STAT(reg, last, cur) \
> { \
> uint32_t latest = IXGBE_READ_REG(hw, reg); \
> - cur += latest - last; \
> + if(likely(latest > last)) { \
> + cur += latest - last; \
> + } else { \
> + cur += (UINT_MAX - last) + latest; \
> + } \
> last = latest; \
> }
>
From what I can tell your math is adding an off by one error. You
should probably be using UINT_MAX as a mask for the result, not as a
part of the calculation itself.
So the correct way to compute this would be "cur += (latest - last) &
UINT_MAX". Also the mask approach should be faster as it avoids any
conditional jumps.
- Alex
next prev parent reply other threads:[~2015-10-12 15:41 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-10-12 13:33 [PATCH 0/2] fix vf statistic wraparound handling in macro Harry van Haaren
2015-10-12 13:33 ` [PATCH 1/2] ixgbe: fix VF statistic wraparound handling macro Harry van Haaren
2015-10-12 14:45 ` Roger B. Melton
2015-10-12 15:41 ` Alexander Duyck [this message]
2015-10-12 16:45 ` [PATCH 0/2] fix vf statistic wraparound handling in macro Harry van Haaren
2015-10-12 16:45 ` [PATCH 1/2] ixgbe: fix VF statistic wraparound handling macro Harry van Haaren
2015-10-13 19:43 ` Roger B. Melton
2015-10-14 10:15 ` Roger B. Melton
2015-10-28 13:37 ` Thomas Monjalon
2015-10-12 16:45 ` [PATCH 2/2] igb: " Harry van Haaren
2015-10-13 19:44 ` Roger B. Melton
2015-10-14 10:16 ` Roger B. Melton
2015-10-28 13:40 ` [PATCH 0/2] fix vf statistic wraparound handling in macro Thomas Monjalon
2015-10-13 19:43 ` [PATCH 1/2] ixgbe: fix VF statistic wraparound handling macro Roger B. Melton
2015-10-12 13:33 ` [PATCH 2/2] igb: " Harry van Haaren
2015-10-12 15:02 ` Roger B. Melton
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=561BD4AE.4010704@gmail.com \
--to=alexander.duyck@gmail.com \
--cc=dev@dpdk.org \
--cc=harry.van.haaren@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.