From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 9E5A442DAB; Tue, 4 Jul 2023 18:01:01 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 43BB440E03; Tue, 4 Jul 2023 18:01:01 +0200 (CEST) Received: from mail-pg1-f178.google.com (mail-pg1-f178.google.com [209.85.215.178]) by mails.dpdk.org (Postfix) with ESMTP id D5DC640042 for ; Tue, 4 Jul 2023 18:00:59 +0200 (CEST) Received: by mail-pg1-f178.google.com with SMTP id 41be03b00d2f7-553b2979fceso2150268a12.3 for ; Tue, 04 Jul 2023 09:00:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20221208.gappssmtp.com; s=20221208; t=1688486459; x=1691078459; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:subject:cc:to:from:date:from:to:cc:subject:date :message-id:reply-to; bh=His5yEsriBN0xeYTa5PfkGhB4b7ZSPXYQAlXAajcWCc=; b=0ViBkCAxQNEdXeKar/tjYUE5QuleiKy+m8K7ynnGaUqiCSnlgBjnSrDKL9z2h1EcOX nUTjWnqL5up74ALGS4DsE8nHzO06AOVKTRt+hQOn/GTnzueeOtK4yzxYsRCYtn4WxKq/ M0uZVJAIPawC8mwHlbp7+CaP1fhUoOd+zHycdiDKI+rwXBEcklW7Lj7xNEiPn7/zsOC3 7ryFENm1zGvIZM5dx2sh/karOS8hHeVjCDp07IDH1a3sZ2NUOzaCpJLpz6+Po+LnjI4O l6A+6ukfGBsZZ923U2H+JyLUg/fVUlfi8t6qEzrPjQDL1c53RPdRerPgP7ROm0ouDE3r VGhQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1688486459; x=1691078459; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:subject:cc:to:from:date:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=His5yEsriBN0xeYTa5PfkGhB4b7ZSPXYQAlXAajcWCc=; b=YYbPsUOUccBs9QIb2BGmPVMcnOiYqO0TQHH95FGgeJ2fDV06xQq7zdELYxMfx8BRLE Wd65UFHwtEDU4TrDw1iqxbQkQViezpdXVu4z2oxk+btXRwvtGNcxKUPxDs5957fTlJKe /vb4Bc43PJo4uPlHrjpN7Tn+8p1vHi1iEHAxwRdesaO2VGlHOcHEG0w4T8g2PdUFJRbV c/su+/LpYo3oHMx1Tj+7TgGyl1QoBcknz+6WnDnhJbSnpkgS5iEBlL+zI2FVVI7a/E4R tctAMe1F07r9HoyQoi3gX9rhNOFNB8BrLlmJAPUMi0hHNqyKwr2lYKAVd9f1iieIxBxJ L7iA== X-Gm-Message-State: AC+VfDwCV60RbiUaOUMWw2BMWA0AWouuVyoBiNx3SdBOyy7sawxspT2R xuy7pamh4cn0fFlnTrOdiU5A/Q== X-Google-Smtp-Source: ACHHUZ77kyRCGUpoHXxgkxbn0QjmBgIssyfiQzLlqN7NwBIZjyULNdMe7NCM5J/vDU9Dc6xnWlrAeg== X-Received: by 2002:a05:6a20:918d:b0:110:f65a:13db with SMTP id v13-20020a056a20918d00b00110f65a13dbmr14232148pzd.15.1688486458858; Tue, 04 Jul 2023 09:00:58 -0700 (PDT) Received: from hermes.local (204-195-120-218.wavecable.com. [204.195.120.218]) by smtp.gmail.com with ESMTPSA id p10-20020a170902b08a00b001b882880550sm6099071plr.282.2023.07.04.09.00.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 04 Jul 2023 09:00:58 -0700 (PDT) Date: Tue, 4 Jul 2023 09:00:56 -0700 From: Stephen Hemminger To: Morten =?UTF-8?B?QnLDuHJ1cA==?= Cc: , Subject: Re: [PATCH v2] eal: avoid issues in macro expansion of alignment Message-ID: <20230704090056.086363d9@hermes.local> In-Reply-To: <98CBD80474FA8B44BF855DF32C47DC35D87A5D@smartserver.smartshare.dk> References: <20230703185551.57908-1-stephen@networkplumber.org> <20230703232357.122084-1-stephen@networkplumber.org> <98CBD80474FA8B44BF855DF32C47DC35D87A5D@smartserver.smartshare.dk> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org On Tue, 4 Jul 2023 10:43:40 +0200 Morten Br=C3=B8rup wrote: > > From: Stephen Hemminger [mailto:stephen@networkplumber.org] > > Sent: Tuesday, 4 July 2023 01.24 > >=20 > > RTE_ALIGN_MUL_NEAR is a macro so the cycle argument could > > get evaluated twice causing some potential skew. Fix by > > computing value once. > >=20 > > Suggested by patch to fix side effects. > >=20 > > Fixes: 5cbd14b3e5f9 ("eal: roundup TSC frequency when estimating") > > Cc: pbhagavatula@marvell.com > > Signed-off-by: Stephen Hemminger > > --- > > v2 - fix spelling error in commit message > >=20 > > lib/eal/common/eal_common_timer.c | 8 ++++++-- > > 1 file changed, 6 insertions(+), 2 deletions(-) > >=20 > > 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 =3D rte_rdtsc(); > > + uint64_t start, elapsed; > > + > > + start =3D rte_rdtsc(); > > rte_delay_us_sleep(US_PER_S); > > + elapsed =3D 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); > > } > >=20 > > void > > -- > > 2.39.2 =20 >=20 > Please fix the RTE_ALIGN_MUL_NEAR() macro instead. It already uses tempor= ary variables with typeof() anyway. >=20 > Other macros might have similar behavior of using their parameters more t= han once, and could be improved too. >=20 It is already fixed, so this patch can be dropped.