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 CCC5942DC5; Mon, 3 Jul 2023 20:55:57 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id A487140ED5; Mon, 3 Jul 2023 20:55:57 +0200 (CEST) Received: from mail-pf1-f172.google.com (mail-pf1-f172.google.com [209.85.210.172]) by mails.dpdk.org (Postfix) with ESMTP id 1D27E400EF for ; Mon, 3 Jul 2023 20:55:56 +0200 (CEST) Received: by mail-pf1-f172.google.com with SMTP id d2e1a72fcca58-6686708c986so3931418b3a.0 for ; Mon, 03 Jul 2023 11:55:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20221208.gappssmtp.com; s=20221208; t=1688410555; x=1691002555; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=x6aL7/0lscri0tIGUDwBYL6qDHpI69HcThY1E67LYcg=; b=Lzx8ZMjdhmapgwY21FGM83TSTCUGcU68KaUVGAzk922opaxDh4akzAarqyD8WnjIjp rpZJqBaVeUTfnTL/RJDH66XRwV83xcpLksFLehh3ZpNtFPunsvpRjqQoRDXcRh/U5iew CBC1/9E3LcgypGvUAlQfJYmSapsy3oXF0uICofB7aE5C4jR16rMpjx64DbwCZWjlUGyg C3cIrgFdBNzpIgeCPPxElKShxUaR+2zKGXzIVYVGpoXpdAQOsbAEekObtk22FaYypjsD dyJflm4cue1bepwB4KmJkeCw7v5Jk2yrsh1JaRRd95/MXqwO0scTSwHlz8Ai3xvHh1gy wKHQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1688410555; x=1691002555; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=x6aL7/0lscri0tIGUDwBYL6qDHpI69HcThY1E67LYcg=; b=JmSykd6CT8AA6wTcUmQxTelmzQsFRxYsD4s1Y0SqZGu3b+v+bIdGSROtZBT4Cz3C2c SlfZR0+qkQQlBSIVQqMbC/HjyrBdeWCS2zIYndg9SHD8F+4U+vnUicrdxNq5Vi1EVYFf LUTst7jRKMxNMMx6n8Y26jL1v6sWvheIW8O6v1R21qDxF5oQzqHOZxD8GvovpVsLQ91+ AtqHwgAspxvqQ3gr/uGm0fJ/gfAibBb56wfaWETr7JRG8fbYdEhe0/VRNFMou+8zZ2EM IBUqN/OA11wzZytjyCEqJ5FHOCmVcMf+ESxV8rgfVUpJRjJx4yJ7GEMpk4keG+jipU5Z SJDQ== X-Gm-Message-State: ABy/qLbhndOQw507A0FcExKvHCOMyJFgtbaUlc9yY9DU18tjLAjoHIlu PyFvMflTjlvpMVKKbtwGKz9vbJhtMXajBQV4aMM= X-Google-Smtp-Source: APBJJlGg1Rgg+V8i+gmlxUqxIQBBZEKwpIpUHeenVZSRM5Oryy/WlGEHRm7I2fB7r4vpnxCIBlp/dw== X-Received: by 2002:a62:7b07:0:b0:668:7292:b2c4 with SMTP id w7-20020a627b07000000b006687292b2c4mr13155036pfc.4.1688410554955; Mon, 03 Jul 2023 11:55:54 -0700 (PDT) Received: from hermes.local (204-195-120-218.wavecable.com. [204.195.120.218]) by smtp.gmail.com with ESMTPSA id t15-20020a62ea0f000000b00659b8313d08sm2587509pfh.78.2023.07.03.11.55.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 03 Jul 2023 11:55:54 -0700 (PDT) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger , pbhagavatula@marvell.com, Keith Wiles Subject: [PATCH] eal: avoid issues in macro expansion of alignment Date: Mon, 3 Jul 2023 11:55:51 -0700 Message-Id: <20230703185551.57908-1-stephen@networkplumber.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20210510194008.403-1-pbhagavatula@marvell.com> References: <20210510194008.403-1-pbhagavatula@marvell.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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 RTE_ALIGN_MUL_NEAR is a macro so the cycle arguement 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 --- 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