From: Stephen Hemminger <stephen@networkplumber.org>
To: "Mattias Rönnblom" <mattias.ronnblom@ericsson.com>
Cc: Thomas Monjalon <thomas@monjalon.net>,
David Marchand <david.marchand@redhat.com>,
"dev@dpdk.org" <dev@dpdk.org>,
Onar Olsen <onar.olsen@ericsson.com>,
"Honnappa.Nagarahalli@arm.com" <Honnappa.Nagarahalli@arm.com>,
"nd@arm.com" <nd@arm.com>,
"konstantin.ananyev@intel.com" <konstantin.ananyev@intel.com>,
"mb@smartsharesystems.com" <mb@smartsharesystems.com>,
"hofors@lysator.liu.se" <hofors@lysator.liu.se>,
Chengwen Feng <fengchengwen@huawei.com>,
Ola Liljedahl <ola.liljedahl@arm.com>
Subject: Re: [PATCH v9] eal: add seqlock
Date: Wed, 1 Jun 2022 09:15:43 -0700 [thread overview]
Message-ID: <20220601091543.08e3e83b@hermes.local> (raw)
In-Reply-To: <60dd49ad-c323-4286-749e-79e174accabc@ericsson.com>
On Wed, 1 Jun 2022 08:19:54 +0000
Mattias Rönnblom <mattias.ronnblom@ericsson.com> wrote:
> On 2022-06-01 00:45, Stephen Hemminger wrote:
> > On Mon, 23 May 2022 16:23:46 +0200
> > Mattias Rönnblom <mattias.ronnblom@ericsson.com> wrote:
> >
> >> +/**
> >> + * The RTE seqcount type.
> >> + */
> >> +typedef struct {
> >> + uint32_t sn; /**< A sequence number for the protected data. */
> >> +} rte_seqcount_t;
> >
> > Don't need structure for only one element.
> >
>
> The struct adds a degree of type safety, with no run-time cost.
Makes sense.
>
> > typedef uint32_t rte_seqcount_t;
> >
> > + if (unlikely(begin_sn != end_sn))
> > + return true;
> > +
> > + return false;
> >
> > Prefer to avoid conditional if possible (compiler will optimize it as):
> >
> > return begin_sn == end_sn;
>
> Is this a readability argument, or a performance one?
>
> The compiler might use the unlikely hint to do something useful, like
> avoiding a branch in the common case.
It is a matter of taste. I always prefer writing the smallest (within reason)
amount of code as possible. And my preference is to do things with declarative
and data statements rather than conditionals.
next prev parent reply other threads:[~2022-06-01 16:15 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20220513103820.3e34fcb9@hermes.local>
2022-05-15 12:24 ` [PATCH v7] " Mattias Rönnblom
2022-05-15 12:39 ` Mattias Rönnblom
2022-05-15 15:19 ` Morten Brørup
2022-05-15 17:54 ` Mattias Rönnblom
2022-05-16 8:30 ` Morten Brørup
2022-05-15 15:23 ` Morten Brørup
2022-05-20 6:02 ` Mattias Rönnblom
2022-05-23 11:31 ` [PATCH v8] " Mattias Rönnblom
2022-05-23 14:23 ` [PATCH v9] " Mattias Rönnblom
2022-05-31 11:52 ` David Marchand
2022-06-01 9:01 ` Mattias Rönnblom
2022-06-01 9:10 ` Morten Brørup
2022-05-31 22:45 ` Stephen Hemminger
2022-06-01 6:07 ` Morten Brørup
2022-06-01 8:19 ` Mattias Rönnblom
2022-06-01 16:15 ` Stephen Hemminger [this message]
2022-06-01 19:33 ` Mattias Rönnblom
2022-05-31 22:49 ` Stephen Hemminger
2022-05-31 22:57 ` Honnappa Nagarahalli
2022-06-07 9:25 ` David Marchand
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=20220601091543.08e3e83b@hermes.local \
--to=stephen@networkplumber.org \
--cc=Honnappa.Nagarahalli@arm.com \
--cc=david.marchand@redhat.com \
--cc=dev@dpdk.org \
--cc=fengchengwen@huawei.com \
--cc=hofors@lysator.liu.se \
--cc=konstantin.ananyev@intel.com \
--cc=mattias.ronnblom@ericsson.com \
--cc=mb@smartsharesystems.com \
--cc=nd@arm.com \
--cc=ola.liljedahl@arm.com \
--cc=onar.olsen@ericsson.com \
--cc=thomas@monjalon.net \
/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).