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 5965B459ED; Sat, 21 Sep 2024 16:00:31 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 2A23C40041; Sat, 21 Sep 2024 16:00:31 +0200 (CEST) Received: from mail-wr1-f47.google.com (mail-wr1-f47.google.com [209.85.221.47]) by mails.dpdk.org (Postfix) with ESMTP id 3A8C24003C for ; Sat, 21 Sep 2024 16:00:30 +0200 (CEST) Received: by mail-wr1-f47.google.com with SMTP id ffacd0b85a97d-378c16a4d3eso3075122f8f.1 for ; Sat, 21 Sep 2024 07:00:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1726927229; x=1727532029; darn=dpdk.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=+SO3FmhGuSLPaRc6C0BVWxTkpkU5YtB+Ao6P70KllzY=; b=ilzW40wZ7UPTh5vx3bV5sgLt417G6fSsM8MeYZjmuxvsq86BBne2A2XzoULzO7AMkt RWd3VLa0omDsmnJPlzzScaHaEFphiL7XozKgjQG09WdSo1lUncy5796MMkDQPqdkjhTZ j/wODdJuemX12yciMJWO8c8CN6rV2Vuv1R+HYpLBu0CtdMuLBPeC4ocBKC0ngErT5BWW j0V9I+lrnIb/DWxgwUyOvJYcQyHndozr1s5pjMVMekpkgw5urq56FH3yev5Ujw+dopuA h0sliWmmScQ6ZT8yycA3n6dNlYYaRbXV4HCSJNXijVVsqsR4bqVq30HrsmjnDE7jarCg gtVA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1726927229; x=1727532029; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=+SO3FmhGuSLPaRc6C0BVWxTkpkU5YtB+Ao6P70KllzY=; b=kK0OHW/jK72bQW1anMs3kfGdUouVUUBoqxYX6VE12kMTC74AF1WhcMw5+a9A0WijDc cAJfARIKc+BBp4/68cXaGNSxlEAdXtFq3onjH6LtSsGCstHGGXb49hfW3BfFfwVkSMW2 foy/unkvGnMp1k/qh+ji/S2vHmn7oc0lKnYvrd1lgEsZ3KFwSG3uXygc3CQ5bd1wd1Bk 5OmAfdj8afKc6gxjpQXi6xGUKwSQTp+1nV3llwnedUe08DNy1F5a94CO0c6fHg4JH85D K/JxBlnwQjX9j7iT6P7Dy4XKPEi4gfFKBi7N4/F1ZCE4hS0PHDyEjEk8UYdxIvzK0pjt rPVw== X-Gm-Message-State: AOJu0YyWJH/K1hN7DWHGBQWP7Re5XXi8THplgMYDQkQKyyHYnxbaeTiM 3fmSF139BugBli9LzDYxQPwdttFV0JZDQtHKE0sdDP6ZCIUKZM3lbjpgdQ== X-Google-Smtp-Source: AGHT+IGt0m3HNGSmo0SO8wZwiqeqSmdj7w6ZS8bjG6z8f7tlM6hcG+blRmh7qcAAZ8Lt7eSlEt66Xg== X-Received: by 2002:adf:fc52:0:b0:374:b363:2dea with SMTP id ffacd0b85a97d-37a422532femr5676876f8f.10.1726927228737; Sat, 21 Sep 2024 07:00:28 -0700 (PDT) Received: from localhost.localdomain ([176.13.142.196]) by smtp.googlemail.com with ESMTPSA id a640c23a62f3a-a90612df5cfsm993153766b.146.2024.09.21.07.00.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 21 Sep 2024 07:00:28 -0700 (PDT) From: Isaac Boukris To: dev@dpdk.org Cc: stephen@networkplumber.org, Isaac Boukris Subject: [PATCH 1/2] timer/linux: lower rounding of tsc estimation to 10KHz Date: Sat, 21 Sep 2024 17:00:21 +0300 Message-ID: <20240921140022.107239-1-iboukris@gmail.com> X-Mailer: git-send-email 2.45.0 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. Roundin 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..241b20d416 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_10KHZ 1E4 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 10Khz. 1E4 ~ 10Khz */ + return RTE_ALIGN_MUL_NEAR(tsc_hz, CYC_PER_10KHZ); } #endif return 0; -- 2.45.0