DPDK patches and discussions
 help / color / mirror / Atom feed
From: David Marchand <david.marchand@redhat.com>
To: "Mattias Rönnblom" <hofors@lysator.liu.se>
Cc: dev@dpdk.org,
	"Jack Bond-Preston" <jack.bond-preston@foss.arm.com>,
	"Morten Brørup" <mb@smartsharesystems.com>,
	"Mattias Rönnblom" <mattias.ronnblom@ericsson.com>,
	"Tyler Retzlaff" <roretzla@linux.microsoft.com>
Subject: Re: [PATCH] test/bitops: check worker lcore availability
Date: Mon, 14 Oct 2024 16:26:10 +0200	[thread overview]
Message-ID: <CAJFAV8zaOBMYjdHc26UebbSRE+GW=550oZW9m+OVAfa7vczMPw@mail.gmail.com> (raw)
In-Reply-To: <55889d87-e94c-4a94-9850-a2b3b7e8d5a4@lysator.liu.se>

On Sun, Oct 13, 2024 at 8:53 AM Mattias Rönnblom <hofors@lysator.liu.se> wrote:
>
> On 2024-10-11 17:25, David Marchand wrote:
> > Coverity is not able to understand that having 2 lcores means that
> > rte_get_next_lcore(-1, 0, 1) can't return RTE_MAX_LCORE.
> > Add an assert.
> >
> > Coverity issue: 445382, 445383, 445384, 445387, 445389, 445391
> > Fixes: 35326b61aecb ("bitops: add atomic bit operations in new API")
> >
> > Signed-off-by: David Marchand <david.marchand@redhat.com>
> > ---
> > Note:
> > - a better fix would be to check lcore id validity in the EAL launch API,
> >    but it requires inspecting all functions and it could result in some
> >    API change, so sending this as a simple fix for now,
> >
> > ---
> >   app/test/test_bitops.c | 3 +++
> >   1 file changed, 3 insertions(+)
> >
> > diff --git a/app/test/test_bitops.c b/app/test/test_bitops.c
> > index 4200073ae4..4ed54709fb 100644
> > --- a/app/test/test_bitops.c
> > +++ b/app/test/test_bitops.c
> > @@ -159,6 +159,7 @@ test_bit_atomic_parallel_assign ## size(void) \
> >               return TEST_SKIPPED; \
> >       } \
> >       worker_lcore_id = rte_get_next_lcore(-1, 1, 0); \
> > +     TEST_ASSERT(worker_lcore_id < RTE_MAX_LCORE, "Failed to find a worker lcore"); \
>
> How about:
>
> static unsigned int
> get_worker_lcore(void)
> {
>         unsigned int lcore_id;
>
>         lcore_id = rte_get_next_lcore(-1, 1, 0);
>
>         /* avoid Coverity false positives */
>         RTE_VERIFY(lcore_id < RTE_MAX_LCORE);
>
>         return lcore_id;
> }
>
> In the macros:
> worker_lcore_id = get_worker_lcore(-1, 1, 0);
>
> Makes the macros a tiny bit smaller/less redundant and gives an
> opportunity for a comment. Also, it's more appropriate to use RTE_VERIFY
> I would argue, since rte_get_next_lcore() is not the SUT.

I agree on the principle.
I will send a new one when possible.


-- 
David Marchand


      reply	other threads:[~2024-10-14 14:26 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-10-11 15:25 David Marchand
2024-10-11 15:27 ` Morten Brørup
2024-10-13  6:53 ` Mattias Rönnblom
2024-10-14 14:26   ` David Marchand [this message]

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='CAJFAV8zaOBMYjdHc26UebbSRE+GW=550oZW9m+OVAfa7vczMPw@mail.gmail.com' \
    --to=david.marchand@redhat.com \
    --cc=dev@dpdk.org \
    --cc=hofors@lysator.liu.se \
    --cc=jack.bond-preston@foss.arm.com \
    --cc=mattias.ronnblom@ericsson.com \
    --cc=mb@smartsharesystems.com \
    --cc=roretzla@linux.microsoft.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).