From: Stephen Hemminger <stephen@networkplumber.org>
To: "Morten Brørup" <mb@smartsharesystems.com>
Cc: <dev@dpdk.org>, <pbhagavatula@marvell.com>
Subject: Re: [PATCH v2] eal: avoid issues in macro expansion of alignment
Date: Tue, 4 Jul 2023 09:00:56 -0700 [thread overview]
Message-ID: <20230704090056.086363d9@hermes.local> (raw)
In-Reply-To: <98CBD80474FA8B44BF855DF32C47DC35D87A5D@smartserver.smartshare.dk>
On Tue, 4 Jul 2023 10:43:40 +0200
Morten Brørup <mb@smartsharesystems.com> wrote:
> > From: Stephen Hemminger [mailto:stephen@networkplumber.org]
> > Sent: Tuesday, 4 July 2023 01.24
> >
> > RTE_ALIGN_MUL_NEAR is a macro so the cycle argument could
> > get evaluated twice causing some potential skew. Fix by
> > computing value once.
> >
> > Suggested by patch to fix side effects.
> >
> > Fixes: 5cbd14b3e5f9 ("eal: roundup TSC frequency when estimating")
> > Cc: pbhagavatula@marvell.com
> > Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
> > ---
> > v2 - fix spelling error in commit message
> >
> > lib/eal/common/eal_common_timer.c | 8 ++++++--
> > 1 file changed, 6 insertions(+), 2 deletions(-)
> >
> > diff --git a/lib/eal/common/eal_common_timer.c
> > b/lib/eal/common/eal_common_timer.c
> > index 5686a5102b66..05614b0503cf 100644
> > --- a/lib/eal/common/eal_common_timer.c
> > +++ b/lib/eal/common/eal_common_timer.c
> > @@ -42,10 +42,14 @@ estimate_tsc_freq(void)
> > RTE_LOG(WARNING, EAL, "WARNING: TSC frequency estimated roughly"
> > " - clock timings may be less accurate.\n");
> > /* assume that the rte_delay_us_sleep() will sleep for 1 second */
> > - uint64_t start = rte_rdtsc();
> > + uint64_t start, elapsed;
> > +
> > + start = rte_rdtsc();
> > rte_delay_us_sleep(US_PER_S);
> > + elapsed = rte_rdtsc() - start;
> > +
> > /* Round up to 10Mhz. 1E7 ~ 10Mhz */
> > - return RTE_ALIGN_MUL_NEAR(rte_rdtsc() - start, CYC_PER_10MHZ);
> > + return RTE_ALIGN_MUL_NEAR(elapsed, CYC_PER_10MHZ);
> > }
> >
> > void
> > --
> > 2.39.2
>
> Please fix the RTE_ALIGN_MUL_NEAR() macro instead. It already uses temporary variables with typeof() anyway.
>
> Other macros might have similar behavior of using their parameters more than once, and could be improved too.
>
It is already fixed, so this patch can be dropped.
next prev parent reply other threads:[~2023-07-04 16:01 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-05-09 17:18 [dpdk-dev] [PATCH 1/2] eal: fix side effects in align mul macros pbhagavatula
2021-05-09 17:18 ` [dpdk-dev] [PATCH 2/2] eal: fix side effects in ptr align macros pbhagavatula
2021-05-09 19:39 ` Stephen Hemminger
2021-05-10 9:50 ` [dpdk-dev] [EXT] " Pavan Nikhilesh Bhagavatula
2021-05-10 13:34 ` David Marchand
2021-05-10 14:02 ` [dpdk-dev] [PATCH v2 1/2] eal: fix side effects in align mul macros pbhagavatula
2021-05-10 14:02 ` [dpdk-dev] [PATCH v2 2/2] eal: fix side effects in ptr align macros pbhagavatula
2021-05-10 19:40 ` [dpdk-dev] [PATCH v3 1/2] eal: fix side effects in align mul macros pbhagavatula
2021-05-10 19:40 ` [dpdk-dev] [PATCH v3 2/2] eal: fix side effects in ptr align macros pbhagavatula
2021-05-11 2:12 ` Wang, Haiyue
2021-05-11 8:44 ` Pavan Nikhilesh Bhagavatula
2021-05-12 1:13 ` Wang, Haiyue
2023-07-03 18:55 ` [PATCH] eal: avoid issues in macro expansion of alignment Stephen Hemminger
2023-07-03 23:23 ` [PATCH v2] " Stephen Hemminger
2023-07-04 8:43 ` Morten Brørup
2023-07-04 16:00 ` Stephen Hemminger [this message]
2023-07-04 22:16 ` Morten Brørup
2023-07-14 16:37 ` Stephen Hemminger
2023-07-04 16:01 ` [dpdk-dev] [PATCH v3 1/2] eal: fix side effects in align mul macros Stephen Hemminger
2023-07-14 21:11 [PATCH v2] eal: avoid issues in macro expansion of alignment Morten Brørup
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=20230704090056.086363d9@hermes.local \
--to=stephen@networkplumber.org \
--cc=dev@dpdk.org \
--cc=mb@smartsharesystems.com \
--cc=pbhagavatula@marvell.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).