DPDK patches and discussions
 help / color / mirror / Atom feed
From: "Van Haaren, Harry" <harry.van.haaren@intel.com>
To: "Gaëtan Rivet" <gaetan.rivet@6wind.com>
Cc: "dev@dpdk.org" <dev@dpdk.org>
Subject: Re: [dpdk-dev] [PATCH] service: fix shifts to operate on 64 bit integers
Date: Mon, 31 Jul 2017 16:20:31 +0000	[thread overview]
Message-ID: <E923DB57A917B54B9182A2E928D00FA640C43333@IRSMSX102.ger.corp.intel.com> (raw)
In-Reply-To: <20170731161754.GN11154@bidouze.vm.6wind.com>

> From: Gaëtan Rivet [mailto:gaetan.rivet@6wind.com]
> Sent: Monday, July 31, 2017 5:18 PM
> To: Van Haaren, Harry <harry.van.haaren@intel.com>
> Cc: dev@dpdk.org
> Subject: Re: [dpdk-dev] [PATCH] service: fix shifts to operate on 64 bit integers
> 
> Hi Harry,
> 
> On Mon, Jul 31, 2017 at 04:58:27PM +0100, Harry van Haaren wrote:
> > This commit fixes shifts to an integer (1 << shift) which
> > is assumed to be a 32-bit integer. In this case, the shift is
> > variable and expected to be valid for 64-bit integers. Given that
> > the expectation to work with 64 bits exists, we must ensure that
> > the (1 << shift) one in that formula is actually a uin64_t.
> >
> > Simply defining a const uint64_t and using it ensures the compiler
> > is aware of the intention. The issue would only manifest if there
> > were greater than 31 services registered.
> >
> > Fixes: 21698354c832 ("service: introduce service cores concept")
> >
> > Signed-off-by: Harry van Haaren <harry.van.haaren@intel.com>
> > ---
> >  lib/librte_eal/common/rte_service.c | 16 ++++++++++------
> >  1 file changed, 10 insertions(+), 6 deletions(-)
> >
> > diff --git a/lib/librte_eal/common/rte_service.c b/lib/librte_eal/common/rte_service.c
> > index e82b9ad..8c1cffa 100644
> > --- a/lib/librte_eal/common/rte_service.c
> > +++ b/lib/librte_eal/common/rte_service.c
> > @@ -285,8 +285,9 @@ rte_service_unregister(struct rte_service_spec *spec)
> >
> >  	s->internal_flags &= ~(SERVICE_F_REGISTERED);
> >
> > +	const uint64_t one = 1;
> >  	for (i = 0; i < RTE_MAX_LCORE; i++)
> > -		lcore_states[i].service_mask &= ~(1 << service_id);
> > +		lcore_states[i].service_mask &= ~(one << service_id);
> 
> Why not use UINT64_C(1)?

Mostly because I've never heard of it before :) Thanks for review, still learnin' every day! Sending v2's every other day...

  reply	other threads:[~2017-07-31 16:20 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-07-31 15:58 Harry van Haaren
2017-07-31 16:17 ` Gaëtan Rivet
2017-07-31 16:20   ` Van Haaren, Harry [this message]
2017-07-31 16:38 ` [dpdk-dev] [PATCH v2] " Harry van Haaren
2017-07-31 20:12   ` 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=E923DB57A917B54B9182A2E928D00FA640C43333@IRSMSX102.ger.corp.intel.com \
    --to=harry.van.haaren@intel.com \
    --cc=dev@dpdk.org \
    --cc=gaetan.rivet@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).