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 A278445A84; Tue, 1 Oct 2024 22:01:38 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 3EE4940268; Tue, 1 Oct 2024 22:01:38 +0200 (CEST) Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.12]) by mails.dpdk.org (Postfix) with ESMTP id DEE8A40267 for ; Tue, 1 Oct 2024 22:01:35 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1727812896; x=1759348896; h=date:from:to:cc:subject:message-id:references: in-reply-to:mime-version; bh=UuM/k2H873wHs5SDVkduH7sxwaDnyF/xhFsGTgowOtI=; b=Lwgj/UD9bUeqIdm39eeUI4t8vKRebjN1SlSKliZFTVmzNr6LmwY5bQkx APS5MR7zbTjip37/qpfQNTMXGxPxRc4DhTCZ5lJPnxzkv3nYiytZ+Iiem g7pv0M7yIClkwcxXbpQPKLNdL6AcZnJ9yxyZb6tAE2mvjFW89X9+c2R3a t4m6F3awzp4OfaHROxfS2E+OJFqYYj4g9h4G6plyyOaTH4yeRGydo25/f 45lJbcGqDr3izYx3uk60HRALwvfeCPUyiAKTNxCuAdxaOdMsLNtN3mzLs jQ3tKqcJ5aZCdtkPr+lJzsO9yiWN0olfayqPMXWSTNZDDzblwZYPCOY7Y A==; X-CSE-ConnectionGUID: FjDCPFt+RiSpEGr0yBQnhQ== X-CSE-MsgGUID: afozprD0QW62QFf2rAsFTg== X-IronPort-AV: E=McAfee;i="6700,10204,11212"; a="38353116" X-IronPort-AV: E=Sophos;i="6.11,169,1725346800"; d="scan'208";a="38353116" Received: from fmviesa008.fm.intel.com ([10.60.135.148]) by orvoesa104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Oct 2024 13:01:22 -0700 X-CSE-ConnectionGUID: d2kv3Z0QSeK27JxPo+ucZA== X-CSE-MsgGUID: W+Xx1t+1Q9WwZEXiR8yPAQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.11,169,1725346800"; d="scan'208";a="73899878" Received: from fmsmsx602.amr.corp.intel.com ([10.18.126.82]) by fmviesa008.fm.intel.com with ESMTP/TLS/AES256-GCM-SHA384; 01 Oct 2024 13:01:21 -0700 Received: from fmsmsx611.amr.corp.intel.com (10.18.126.91) by fmsmsx602.amr.corp.intel.com (10.18.126.82) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Tue, 1 Oct 2024 13:01:21 -0700 Received: from fmsmsx601.amr.corp.intel.com (10.18.126.81) by fmsmsx611.amr.corp.intel.com (10.18.126.91) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Tue, 1 Oct 2024 13:01:21 -0700 Received: from fmsedg601.ED.cps.intel.com (10.1.192.135) by fmsmsx601.amr.corp.intel.com (10.18.126.81) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39 via Frontend Transport; Tue, 1 Oct 2024 13:01:21 -0700 Received: from NAM10-DM6-obe.outbound.protection.outlook.com (104.47.58.100) by edgegateway.intel.com (192.55.55.70) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2507.39; Tue, 1 Oct 2024 13:01:20 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=fF/brcMsV1ZoJokxjG6c0UoNQ7XoZgfJh0Ot+NlTRx1Kb4IGqS7kgnzMjXVnqIsCLBMj0f/2AengugiHevnRGtykbdXXNaf+9UuankNbMZu4ReE52gEhpWjhsW+kBKqHOaqE06rhyFlgvViQvqmw1Gcf3OTwN6+cOghan0SDm6FenYm/GEo4YXrQa8PGakqI99XcVz++0yKyvSS83BgF4yCVV9nsw5PS9cfa8C/uf3AVsu9bTxtFgI/SKks2tpR7krsB2FmQ7qKafTivFB35rP66Aten5ey2u8e5QA+Jkr7DeUOKmseIbCmpIjT1vdhIB6XS5ab8KaOdKud8LHyOIw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=OKuPFzIbeQOOBhA6OiuDMSpRct+pANvxMmPqStSjDLk=; b=wckCgdmRrSCzuJiXAkpwOQJqSTvqbIsaIkgIWbru25bNLcnBGTv3G0EPAktx/3TGVbBaifA0PPaL1/vJa6ZdudNicmelWh9Zj0graEi1OU1lLNSs1Wty917hTNzpe6dGKbmHgBl2fSNXDEHjFEvNTITq7axka0wcYIySqAcyhK7+BfgRkQiF/GUzKKH47/OU6zqWrKUbazfB4PcKnQqDNOoliGuFAJkzoCNrR8SpvxDKrNgxmgbMC1Ke4C5zvmjOVok38TaXUTYoHbACVAkArNEFGnwJBofdcxe704HdcQI1rdb4+9j1WL/IpbhXmrh3bjOUtCYk5GZ9Dgn6+QdW8Q== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=intel.com; dmarc=pass action=none header.from=intel.com; dkim=pass header.d=intel.com; arc=none Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=intel.com; Received: from DS0PR11MB7309.namprd11.prod.outlook.com (2603:10b6:8:13e::17) by SA2PR11MB4826.namprd11.prod.outlook.com (2603:10b6:806:11c::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8005.27; Tue, 1 Oct 2024 20:01:17 +0000 Received: from DS0PR11MB7309.namprd11.prod.outlook.com ([fe80::f120:cc1f:d78d:ae9b]) by DS0PR11MB7309.namprd11.prod.outlook.com ([fe80::f120:cc1f:d78d:ae9b%4]) with mapi id 15.20.8026.014; Tue, 1 Oct 2024 20:01:17 +0000 Date: Tue, 1 Oct 2024 21:01:12 +0100 From: Bruce Richardson To: Isaac Boukris CC: , , , , Subject: Re: [PATCH v3 2/2] timer/linux/x86: override TSC freq if no tsc_known_freq Message-ID: References: <20240921140022.107239-1-iboukris@gmail.com> <20241001002527.277838-1-iboukris@gmail.com> <20241001002527.277838-3-iboukris@gmail.com> Content-Type: text/plain; charset="us-ascii" Content-Disposition: inline In-Reply-To: <20241001002527.277838-3-iboukris@gmail.com> X-ClientProxiedBy: DU2PR04CA0180.eurprd04.prod.outlook.com (2603:10a6:10:2b0::35) To DS0PR11MB7309.namprd11.prod.outlook.com (2603:10b6:8:13e::17) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DS0PR11MB7309:EE_|SA2PR11MB4826:EE_ X-MS-Office365-Filtering-Correlation-Id: b2a142bb-2bdc-4e02-9f41-08dce253cf5e X-LD-Processed: 46c98d88-e344-4ed4-8496-4ed7712e255d,ExtAddr X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|366016|376014|1800799024; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?Li24GuBbDKhxUNhamle/PtBD6+03LbsS1Fvxfz7X6FF8mbaAM62UVr0SNp/T?= =?us-ascii?Q?BKwxaOjHdrZwk7i516TLm1J21B3MspgRh5dTa7x1rMuAO8t75K1Euzq7sKV3?= =?us-ascii?Q?9L3r9cJ720hBBdhsE3/w6DYcqRu/ZgyB4m54AT34Uya4eIzj/B4WA/sThXU1?= =?us-ascii?Q?kJRQnfkIxWRhr17FROts/SQTjO+FnL9Pxxy4VY3KoNhJ5synTP2OB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+4tue6/sRDe1y54l6UvUroPRbNqoudWr07Gic0?= =?us-ascii?Q?phcZQLnSHRQHppJBCh6035jvT4ok19g+6WZtozMsAg8JQrtJ7tWKyqHeu54P?= =?us-ascii?Q?pRDM2mfIxObUhudl0DTysAvdtLfPQvCQKCSj1Cac1VYvv3dmaaMH3K3dg+QK?= =?us-ascii?Q?qccAEMzhYmtNNIYImmZvjpybrTFV203CTZVPy4i5Ew=3D=3D?= X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:DS0PR11MB7309.namprd11.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230040)(366016)(376014)(1800799024); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?i9B3FHJ7eRXcJoJdd9yK57MIJO0HHXHQPvBHpgKbq9slLpmeivdF90qvtb8d?= =?us-ascii?Q?lZ5FxTilJLD20mWjzo5Js56u7JdjCGDlzQ1z5UCHE92TIyF2e0L4kwpXXHgz?= =?us-ascii?Q?oC+zjwq/kBAj9VrcPjCaD9uC877USfth9FXGJFa4V/YA2+Z1Qf8JtZ4ZCTQy?= =?us-ascii?Q?lHzbP+Dbv0pupJwY/yKwwzAG5EFwoPadj3/LOu/UQ/pTCZJgFXYCDP3TIvzd?= =?us-ascii?Q?xXEa1IXK3J+f66KL51RMvN0KTTjZwSWjZ6JyDv4kHSweL+1ynOkLUoT8SPdn?= =?us-ascii?Q?40ZPOgoLusbIIfQzKB1TIALy8NtxVWCQwvku5oRFEkO95W4hs66UqPKLsQ1N?= =?us-ascii?Q?3SqEF21c/IhDckFaeEhFXtmNMVdR1YeFufSuvn6HcU/U1q/BKmSJCETBXEES?= =?us-ascii?Q?SqFYfyu+OUjwxJzfip1ivsUGxAyac/qORn4vVUGA+T9rZk8aCjbZPP5GFzba?= =?us-ascii?Q?PQTHi7NKQOGrS/YcS6o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IUHVxu?= =?us-ascii?Q?g2mHOVBnADtbr9onfaNljkgIwfuM8/F0aZZAG18vh5p6930pBXUWr2y6inGn?= =?us-ascii?Q?whCL3WytQmQUH31sYvV388dCRgXrcavduQntT9E4psr8jAtmex3fHdw3byEm?= =?us-ascii?Q?r0KO1+ZIhgz4eSGRcKpSnJaB0DjxGZ9cVnG0oCe8HxJeX7rwmdA4Y/Q/cd9w?= =?us-ascii?Q?qYRL+azEjnISeN8tSkjZ8lgo+OXKHkiWX8o+htjLQHJETXXSZK4pKINaTioX?= =?us-ascii?Q?Tg=3D=3D?= X-MS-Exchange-CrossTenant-Network-Message-Id: b2a142bb-2bdc-4e02-9f41-08dce253cf5e X-MS-Exchange-CrossTenant-AuthSource: DS0PR11MB7309.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 01 Oct 2024 20:01:17.1415 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 46c98d88-e344-4ed4-8496-4ed7712e255d X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: vO0K255P3XOxXjsywdCKmg7nQRjC8wpelNzBnjNrqu4TG2qAidXFOJ00uZ8GG2GKDvzn5dHLwRyP/TRyTxsFJgLyP4AyF5dqoSQH45fyh7s= X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA2PR11MB4826 X-OriginatorOrg: intel.com 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 On Tue, Oct 01, 2024 at 03:22:51AM +0300, Isaac Boukris wrote: > If the tsc_known_freq cpu flag is missing, it means the kernel doesn't > trust it and calculates its own. We should do the same to avoid drift. > > Signed-off-by: Isaac Boukris > --- > lib/eal/common/eal_common_timer.c | 3 +- > lib/eal/common/eal_private.h | 2 +- > lib/eal/freebsd/eal_timer.c | 5 ++- > lib/eal/linux/eal_timer.c | 53 +++++++++++++++++++++++++++++-- > lib/eal/windows/eal_timer.c | 5 ++- > 5 files changed, 60 insertions(+), 8 deletions(-) > > diff --git a/lib/eal/common/eal_common_timer.c b/lib/eal/common/eal_common_timer.c > index c5c4703f15..e00be0a5c8 100644 > --- a/lib/eal/common/eal_common_timer.c > +++ b/lib/eal/common/eal_common_timer.c > @@ -66,8 +66,7 @@ set_tsc_freq(void) > } > > freq = get_tsc_freq_arch(); > - if (!freq) > - freq = get_tsc_freq(); > + freq = get_tsc_freq(freq); > if (!freq) > freq = estimate_tsc_freq(); > > diff --git a/lib/eal/common/eal_private.h b/lib/eal/common/eal_private.h > index af09620426..bb315dab04 100644 > --- a/lib/eal/common/eal_private.h > +++ b/lib/eal/common/eal_private.h > @@ -374,7 +374,7 @@ void set_tsc_freq(void); > * > * This function is private to the EAL. > */ > -uint64_t get_tsc_freq(void); > +uint64_t get_tsc_freq(uint64_t arch_hz); > > /** > * Get TSC frequency if the architecture supports. > diff --git a/lib/eal/freebsd/eal_timer.c b/lib/eal/freebsd/eal_timer.c > index 3dd70e24ba..5a8aea03e1 100644 > --- a/lib/eal/freebsd/eal_timer.c > +++ b/lib/eal/freebsd/eal_timer.c > @@ -26,12 +26,15 @@ > enum timer_source eal_timer_source = EAL_TIMER_TSC; > > uint64_t > -get_tsc_freq(void) > +get_tsc_freq(uint64_t arch_hz) > { > size_t sz; > int tmp; > uint64_t tsc_hz; > > + if (arch_hz) > + return arch_hz; > + > sz = sizeof(tmp); > tmp = 0; > On FreeBSD I'm not sure this is the best behaviour. On BSD we read the TSC value from the kernel, which, one assumes, has measured it accurately. Therefore I'd tend toward just using the kernel value in all cases, maybe check the arch value (if non-zero) against that and warning if they have significant divergence. WDYT? /Bruce