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 EE82842DC6; Tue, 4 Jul 2023 01:24:03 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 87D3340F18; Tue, 4 Jul 2023 01:24:03 +0200 (CEST) Received: from mail-pf1-f169.google.com (mail-pf1-f169.google.com [209.85.210.169]) by mails.dpdk.org (Postfix) with ESMTP id DEDFA40E03 for ; Tue, 4 Jul 2023 01:24:01 +0200 (CEST) Received: by mail-pf1-f169.google.com with SMTP id d2e1a72fcca58-666e3b15370so2747587b3a.0 for ; Mon, 03 Jul 2023 16:24:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20221208.gappssmtp.com; s=20221208; t=1688426641; x=1691018641; 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=Zrr4Rrbd4hDba1TxTezLvp3omGySgcYE4kNiuoW+Qp4=; b=W3BIc+XQ0mbBQCd32bfJ/uctWh0GW4qkiFGPyyZMd78MXivB9Ef50BuPfTD9neL+r7 eJguGHRRqWjQdMQFgFZIdnKtCzphIqUkckQsG/T+vr2rbJ7jM4EIocAg+ySG30YlbelC 0UfZzmKSo4e4NmHeX+rhy/z2gifLmpQTI7OdIKIYbSgcjSYteDFmYW9WEiEo4ih0djaR UwHGRzqDcm5LxNnWlZfwKaQ5RQtBUxA5+rOgvm/PWBofnBXieCVBCoFi0+fGs8aVq95p y1/uQnIXf8hWFQkP8AIY6Aq3/IszaNiq77xwA07gWCsnzfWIGe3T+SWf0TXCvZOfAE1M DmhQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1688426641; x=1691018641; 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=Zrr4Rrbd4hDba1TxTezLvp3omGySgcYE4kNiuoW+Qp4=; b=EiKk1bXEdZPLrLZ85xHd1w6+nDwy50CXvTv/hyqHFzO/w6G7n40SlA9ul7Dc/8m/sn 8+dSkweaoYqkblPT4Qc0wvDRiuQx+oWJTLPZZ9RHm/H+2mUi82BBFP1wEKXcbyxaWRV1 mBAh3rdk2fn+lRSqZpA/2rA75ISCbAEpxKj7hwTyPMtJqmfO0h1rgKc4C4jJXgJkZNFw D7r8rd2dH+sIocIDf48kvG0eQ0U43AAZVfcbYO/qrkmuupxPOfNUpJvq0Q9dgy884Nh0 0Z1xAU0zHWamtD1ZmhZaV0xjxAVTxHzDF1xhKYiEMpy57VV1psmoGUC3XxQOgDKPF7CO aZxg== X-Gm-Message-State: ABy/qLadnuGRXLKHmrjweBml0ZDpz8NbL7be0sJCLAgz2vORsExxIMWN MV9ZHJO/Y+ugvZz2I//zHm4kJXtoK5G/SObJU9k= X-Google-Smtp-Source: APBJJlGIJeT4TnnaYjjMfZ90rilJDmEErS3rlQVhck4L/m3Fe0+VdO44AlV0y2wysNiuE9vj//sGsA== X-Received: by 2002:a05:6a00:1803:b0:66a:4a45:e017 with SMTP id y3-20020a056a00180300b0066a4a45e017mr12853420pfa.20.1688426640802; Mon, 03 Jul 2023 16:24:00 -0700 (PDT) Received: from hermes.local (204-195-120-218.wavecable.com. [204.195.120.218]) by smtp.gmail.com with ESMTPSA id t26-20020aa7939a000000b006702c433741sm13415351pfe.3.2023.07.03.16.24.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 03 Jul 2023 16:24:00 -0700 (PDT) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger , pbhagavatula@marvell.com Subject: [PATCH v2] eal: avoid issues in macro expansion of alignment Date: Mon, 3 Jul 2023 16:23:57 -0700 Message-Id: <20230703232357.122084-1-stephen@networkplumber.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230703185551.57908-1-stephen@networkplumber.org> References: <20230703185551.57908-1-stephen@networkplumber.org> 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 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 --- 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