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 454CB45A6D; Tue, 1 Oct 2024 00:12:53 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id BF9A14064F; Tue, 1 Oct 2024 00:12:50 +0200 (CEST) Received: from mail-ed1-f52.google.com (mail-ed1-f52.google.com [209.85.208.52]) by mails.dpdk.org (Postfix) with ESMTP id A3B8040150 for ; Tue, 1 Oct 2024 00:12:48 +0200 (CEST) Received: by mail-ed1-f52.google.com with SMTP id 4fb4d7f45d1cf-5c8967dd2c7so1993295a12.1 for ; Mon, 30 Sep 2024 15:12:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1727734367; x=1728339167; darn=dpdk.org; 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=+0K76rnZ+KrBgumF9RqOLmkfx1skdiYVV6zlY2WHogQ=; b=M/kHfjsti0w7fdV/2Qe5psHuRMMZtj7tB8T7LrtvIFRIvnsn+G7s21a2Y4EMBdf9Ta Pmli+1H8KoxlhttQ3yrNAGihmxMELMw/VJQdfLUYgfB2cRfYujel+STFy6YJGW0Vniid UXTMJufa2WTXJKv2toFRypCXdEu3c8Mn+HZIJbOmPWwwVi7vr/lkIXj+BCl/ZwdSDp4t 9e3v6UpPEMYnWxJ7Ro4ChBuzlArW3Wy3s+PlhRbEbBOIG6iojl3xrZg/YME6yv8Vmit/ uw5Jfw5ANg94DkDViqWambanw2gxhcm0SL7YNxRSCddWpJ/uVXeKMa8mEw098v3ZqIxU B7Mg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1727734367; x=1728339167; 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=+0K76rnZ+KrBgumF9RqOLmkfx1skdiYVV6zlY2WHogQ=; b=BaFvs0S8HFb4qi865aLT2kb8mIpASV0fQK3HmHaBIuZpOF7lr4lRuRAFs7piwG6Z+y HMOfTMHHlC/C6PIWNLwh+qM24dc9Q5aicUiwKQN0ca12JZPE/vUrb357t5SmuepAVIOf 4UtouCLJUOR6et/DF9qPhYF8q//uw+SbkvH/qQchtGSMyOj6GxcDda8zbI4uhfqw6+la 8kJEltBvDOgKrnBNL8MIivUvd1UkI8dNbNrevSAbkoFAVqpFF5kdjt01s7aEtB+A6xC3 FEqdNb/eTDxzcHr1tueOnsr/gQrU9AcYGIhJapXNJAlbPgysfXv4bYbKWqcKL/Pgt/u8 Hp/g== X-Gm-Message-State: AOJu0Yy32x9pXkmVs7+bYV6InHL62FCbqQt3N7IBsCpv6gRhJdPwkucr P3j/uvxGjcEC+HG03tBESogdXPuBIGGgFWZm+lrNopA6Nwbi8plzPp1vNl+9 X-Google-Smtp-Source: AGHT+IH4jbLlj3h1AyOWC3vQIRDiTJwnpz/CYSf8l6kvFE8QHtio/+aFALRMJ7EIHLjxtF5mt9tdWQ== X-Received: by 2002:a05:6402:90b:b0:5c8:8381:c308 with SMTP id 4fb4d7f45d1cf-5c88381c36fmr12765516a12.5.1727734367315; Mon, 30 Sep 2024 15:12:47 -0700 (PDT) Received: from localhost.localdomain ([176.12.188.220]) by smtp.googlemail.com with ESMTPSA id 4fb4d7f45d1cf-5c88240a341sm5247561a12.24.2024.09.30.15.12.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 30 Sep 2024 15:12:46 -0700 (PDT) From: Isaac Boukris To: dev@dpdk.org Cc: stephen@networkplumber.org, bruce.richardson@intel.com, roretzla@linux.microsoft.com, dmitry.kozliuk@gmail.com, david.marchand@redhat.com, Isaac Boukris Subject: [PATCH v2 1/2] timer/linux: lower rounding of tsc estimation to 100KHz Date: Tue, 1 Oct 2024 01:08:31 +0300 Message-ID: <20240930221153.268251-2-iboukris@gmail.com> X-Mailer: git-send-email 2.45.0 In-Reply-To: <20240930221153.268251-1-iboukris@gmail.com> References: <20240921140022.107239-1-iboukris@gmail.com> <20240930221153.268251-1-iboukris@gmail.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 In practice, the estimation result is just a couple of KHz away from the kernel's tsc_khz value, so it should suffice. Rounding to 10MHz can cause a significant drift from real time, up to a second per 10 minutes. See also bugzilla: 959 Signed-off-by: Isaac Boukris --- lib/eal/linux/eal_timer.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/eal/linux/eal_timer.c b/lib/eal/linux/eal_timer.c index 1cb1e92193..f56a7ae15b 100644 --- a/lib/eal/linux/eal_timer.c +++ b/lib/eal/linux/eal_timer.c @@ -192,7 +192,7 @@ get_tsc_freq(void) { #ifdef CLOCK_MONOTONIC_RAW #define NS_PER_SEC 1E9 -#define CYC_PER_10MHZ 1E7 +#define CYC_PER_100KHZ 1E5 struct timespec sleeptime = {.tv_nsec = NS_PER_SEC / 10 }; /* 1/10 second */ @@ -209,8 +209,8 @@ get_tsc_freq(void) double secs = (double)ns/NS_PER_SEC; tsc_hz = (uint64_t)((end - start)/secs); - /* Round up to 10Mhz. 1E7 ~ 10Mhz */ - return RTE_ALIGN_MUL_NEAR(tsc_hz, CYC_PER_10MHZ); + /* Round up to 100Khz. 1E5 ~ 100Khz */ + return RTE_ALIGN_MUL_NEAR(tsc_hz, CYC_PER_100KHZ); } #endif return 0; -- 2.45.0