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 E15A745A72; Tue, 1 Oct 2024 02:26:02 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id D225B40611; Tue, 1 Oct 2024 02:26:02 +0200 (CEST) Received: from mail-lj1-f176.google.com (mail-lj1-f176.google.com [209.85.208.176]) by mails.dpdk.org (Postfix) with ESMTP id D3834402CB for ; Tue, 1 Oct 2024 02:26:00 +0200 (CEST) Received: by mail-lj1-f176.google.com with SMTP id 38308e7fff4ca-2facf48157dso18005021fa.2 for ; Mon, 30 Sep 2024 17:26:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1727742360; x=1728347160; 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=a5zsMllqNTHYtp1M4/q3q+XMN42r6zFQb45APOAm9hNa5yhQJbeSN9c4coIsCMmAqq 0Lt+nAdxmD2+kU8wiaHvqLxfEFoILeGvvwJS7IrMKCfxSthNCps6irw0g4rRfAhsq4B2 ftfmTpV+6nkmIBZAoR0RkDMkA213H7aP4mavw8H6zAdchOIPGG5bqOIOLYCULcrEQygJ RrwvKEM+U+lFO4jpmO31HSlbAy/AZoVgr8z8FsDsKhGcPHbmGgg6WZGxUk8BuczQFv9l 4+VhdvQVOmnHL54Cnqd5iLR3n48hxIjXJhxlC1TK/rsKt1tK2scSZqKsxiWk723FZres 6PLg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1727742360; x=1728347160; 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=ecvthmg0oz8L/jEyKeN+PtVcLlizwWHVtZjqkW0Cyy4LeAxMgRvhurxy/NJrWwxXPT ORTzA75mTpz4y+lxq60bxIEtYN0EApxh5/8f4Bd9wKhn1MbBd2FwRYBzCFGt8Yp9j7Lv jUsXLlRF9e+PN+3naH1p6679f//luSdetYCJJ+XJkx7uf69GNB9Dvw0gnoNba4GIR1Cb zwgbiH3o0Bao98eyO/SgYg0rOnxu4+56T3gh3JX7LhgMLBm8noVYsjtI+XL1w1qpTTQp kGWqSVO9klr1DCVW5+m9vCqVnQkuRvJn0vK4tCvzPHMECEo8j/vmjpJ6ItOKDzmQ9GmL Vp0g== X-Gm-Message-State: AOJu0YxSfESCM0FrC7XDyD+Ga86ECabfgJ0EThaArS6psLZtavgc6KIo im2k399Dnh2Sq0jF8AGEEC8A57suyZYvSKgSHGR/jFtWBROVZhd7ra8j9J0L X-Google-Smtp-Source: AGHT+IEQeit9TIUcxjd8m1S6WWsx6PyNUfiQz/HIAaVB58uFIJVyBY0CZPBVN2nd6T7wqmJaBkKAQQ== X-Received: by 2002:a2e:d09:0:b0:2f9:d4f8:6048 with SMTP id 38308e7fff4ca-2f9d4f861demr55178461fa.42.1727742359434; Mon, 30 Sep 2024 17:25:59 -0700 (PDT) Received: from localhost.localdomain ([176.12.188.220]) by smtp.googlemail.com with ESMTPSA id 4fb4d7f45d1cf-5c8824056adsm5179335a12.17.2024.09.30.17.25.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 30 Sep 2024 17:25:59 -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 v3 1/2] timer/linux: lower rounding of tsc estimation to 100KHz Date: Tue, 1 Oct 2024 03:22:50 +0300 Message-ID: <20241001002527.277838-2-iboukris@gmail.com> X-Mailer: git-send-email 2.45.0 In-Reply-To: <20241001002527.277838-1-iboukris@gmail.com> References: <20240921140022.107239-1-iboukris@gmail.com> <20241001002527.277838-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