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 4C9E045A9A; Thu, 3 Oct 2024 11:31:22 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 47E7E4025E; Thu, 3 Oct 2024 11:31:21 +0200 (CEST) Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.13]) by mails.dpdk.org (Postfix) with ESMTP id 4BD4E400D7 for ; Thu, 3 Oct 2024 11:31:19 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1727947880; x=1759483880; h=date:from:to:cc:subject:message-id:references: content-transfer-encoding:in-reply-to:mime-version; bh=GXsTRLRbQoZ363izzRZY+2lbVcF/BdF61VWJEqF8BE4=; b=HfytCR3hoUxPP2JYBOODaW4CxI61OJ9J43in6sZqxiCXa9ZRyIO7OCAD zIkK0lbjFBuS5tCgQSC0fJXCn5fySN7V4YDQ21Ktq2KVExJ+18bRq+4hi iLBS88BR0NO/ZvD6p3qHAbi2hfj9ccppr/gh6bFbT5gKBrST476q1pBL+ 53xpbisB1MsjGqgwExIFM645fb0KpPbMyf66TqfJ+t2J8nkY1xu07Tni/ ld23XREwS0asIeFgG6vpvQf4FwsO9+cuNsEn5DKVTu+JzWZcPgP+zVQlH qqU58/aV2hNQhZAeMCY5IlKDomqyMMcKyoA2Ru1OgQMPw36rRJQvzWY2a Q==; X-CSE-ConnectionGUID: gyBlXou2Q4Cd3WWaLZn1yA== X-CSE-MsgGUID: 0l9FxgjQQg2rUf6voXP+7A== X-IronPort-AV: E=McAfee;i="6700,10204,11213"; a="38268326" X-IronPort-AV: E=Sophos;i="6.11,174,1725346800"; d="scan'208";a="38268326" Received: from fmviesa004.fm.intel.com ([10.60.135.144]) by orvoesa105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 03 Oct 2024 02:31:19 -0700 X-CSE-ConnectionGUID: gDYAuXLIQCiOSQYoyxQceg== X-CSE-MsgGUID: CZqyofeQSE6m/9RVb9hSVA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.11,174,1725346800"; d="scan'208";a="78842400" Received: from orsmsx601.amr.corp.intel.com ([10.22.229.14]) by fmviesa004.fm.intel.com with ESMTP/TLS/AES256-GCM-SHA384; 03 Oct 2024 02:31:18 -0700 Received: from orsmsx610.amr.corp.intel.com (10.22.229.23) by ORSMSX601.amr.corp.intel.com (10.22.229.14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Thu, 3 Oct 2024 02:31:17 -0700 Received: from orsmsx610.amr.corp.intel.com (10.22.229.23) by ORSMSX610.amr.corp.intel.com (10.22.229.23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Thu, 3 Oct 2024 02:31:17 -0700 Received: from ORSEDG601.ED.cps.intel.com (10.7.248.6) by orsmsx610.amr.corp.intel.com (10.22.229.23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39 via Frontend Transport; Thu, 3 Oct 2024 02:31:17 -0700 Received: from NAM10-MW2-obe.outbound.protection.outlook.com (104.47.55.42) by edgegateway.intel.com (134.134.137.102) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2507.39; Thu, 3 Oct 2024 02:31:17 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=UbxmOmueUmhkn0OB83XhcHE++TQ8o9UIgcH1LbIIBwpt+zUQF6yH/V/DceMZbxZjYDT8WSaNqYVEh1R+gEObbz9PjlKv7WTIuRTKfbDsQEJiZVfi83MQAYzyVxr03gLqGSQrc3UMYty92+QhnTXLGwdQib5S2eYRoXAhoQtf0T7P00TU6990D1BYY8pBSY5PqI6G4pjHvaWwOhVBagT2kS1KXkiADTfu7GMAxtp/fR0QjmtyuLJCarxPZh0+LrFAAXvOFlFmuIgHLDfV4S/nlc1eQ3tQtGsTQsvcdB1QLYrTkfLkZuo2gOuWy4qyi89B/iIpu2QJmNElhmENxOb2yA== 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=M5EV9wW65d5mYcwWl00uxPqnn5IBG2UGax66RZEAmzw=; b=KR2+x9LZB1j3KdHBZN/VQZPJbUuSTDiqmi4SNVBTomJL5ujckkfyFNb3kW0Z3o1U1+RS4AhKkjspI+C6Hy0QujsZnpkNhwbdc/BzGYHOJbcfI9ROE3bwI4Dp2Z1nmqraTphQ+eAd9sArn5mf97qi8IikVYZRl24bCdQOnNlD+W9vh1tSwkXhc7w7/yygthEuKNEemMPFo8sU6/0miWE4enxrU0I5O4RgW7kfEy32TSj8vDuJzXWWcS3PNeLKFy1HRfLr/15YMqKnGjr5kB+rwhIQX2fVwnIGCShekYxd4dUe3ufb27lUB7vLgMynSh9b6V7UwNxEBMX0gkDQv2Hmkw== 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 DM6PR11MB4532.namprd11.prod.outlook.com (2603:10b6:5:2aa::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8005.21; Thu, 3 Oct 2024 09:31:15 +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; Thu, 3 Oct 2024 09:31:15 +0000 Date: Thu, 3 Oct 2024 10:31:10 +0100 From: Bruce Richardson To: Isaac Boukris CC: , , , , Subject: Re: [PATCH v4 2/2] timer: allow platform to override cpu TSC frequency Message-ID: References: <20240921140022.107239-1-iboukris@gmail.com> <20241002165840.341116-1-iboukris@gmail.com> <20241002165840.341116-3-iboukris@gmail.com> Content-Type: text/plain; charset="utf-8" Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: X-ClientProxiedBy: DU7P189CA0030.EURP189.PROD.OUTLOOK.COM (2603:10a6:10:552::34) To DS0PR11MB7309.namprd11.prod.outlook.com (2603:10b6:8:13e::17) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DS0PR11MB7309:EE_|DM6PR11MB4532:EE_ X-MS-Office365-Filtering-Correlation-Id: 277cf9af-e9be-483a-389d-08dce38e2067 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|376014|366016|1800799024; X-Microsoft-Antispam-Message-Info: =?utf-8?B?cGpwQ2xzNGQ4dHA2aTdaYzVIUTNNRmtXY3NXZU8xcldMeTN1b09SeXBuL1FO?= =?utf-8?B?Z0RScUJZSk1uaFdFUTByNzJsY00zci9OYS8zQ2tPQUpHYjAxVkdlaVdMSXUx?= =?utf-8?B?S0EvaWhXL25KbXBFcVlXQ0Z3citqcERObjlQdzFESUNXRVFJKzNjaDAvTHFx?= =?utf-8?B?K1pCR3ByZGdTZUZDTjRId25tb2IzVHNCcEhSSlhnMllSNzBhZ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R0gwRnN0U09Da3huQjdSRVU3SW1BUFVo?= =?utf-8?B?cUw4MWRZNW82ckJneXBOc3NGTjk5YzBoT2ZIWThJTDFNbmkzbjd1bmpLT21w?= =?utf-8?B?dnA1Ym1Ta1JQSy9RMXMydnRMWXhhZ0NwdlAycXJ2RU5hRUltc2tRUTNheGVu?= =?utf-8?B?SGFrVk1KOVVESXhQU2lBYnRoczZvK2lzbDZCaUovNW1OYlRCRXVIZTU4WE1E?= =?utf-8?B?dHZyU3Z5bzhvNHF0dUJEaWN0YUtadUJRMncvMW1YUWp0N0FYYmhYRDlhT3hF?= =?utf-8?B?NlFMM1llZUR3aTNBUnBabzVia0wzc3dBR09yZWJYd1QrMnBiKzg0bzQvempZ?= =?utf-8?B?Y0w1UkpCTVorSkZ0N2lZbndBZmNkNW11SnZJK2FSSXJuM0dNQmozRk91bTVv?= =?utf-8?B?KzNtRHhyd3drank4Vjc3Vkd0Y1FZdDArUFVKZHYyZjBxdHdhRWNMMWlDNG5r?= =?utf-8?B?eVBqd0lXbStCREV2QlRzZVRnbWU0NzJzT2ZsZGNkcDRURmNaODFCY2U5S2sw?= =?utf-8?B?WEx0YktOcGVwVnNEemFySW8yeEJSMnVJelhDZXR1bHlYWXY2ajRQbmx0UGpz?= =?utf-8?B?ZkpnQ1RDbGVWVXdsS2VWelExOEJYbmdGL3k4d2NvZFlsS2FzekxOVXh3PT0=?= 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)(376014)(366016)(1800799024); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?YUw2Q1Z0a2FNWm5DYjduTDFsMmNLc04rbmI2eEw2NXEvMGJoWWNrQU5kMlQ5?= =?utf-8?B?dHVKUHhkMVhvTVNVS0pDY3o4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d1htcXdTbm9U?= =?utf-8?B?dld6U3JibkhsWGs4anpEU0NFOVdSRkV1UGduSzY4QjRIU3k0UUd6bzdIVUhI?= =?utf-8?B?WXpYV1dlejhJYkJGVVVOK2x3dzFJbU5QY0wxR2RFc2ErQkpLcWRmUlZ5RGY2?= =?utf-8?B?Q3BLdGF5UTZWcVNBOVZCYW5GN2dKR2F2TTZiMU55VCtnVjV5STJPOENoR3lG?= =?utf-8?B?bXo0NGVFOFNZOGxvd2dhT082cXZyTEgzMXpTaC9XQUJ6c0pON2tZdnVteHU0?= =?utf-8?B?elRMdXRhWHRMeENROG9rd0grVHQ2eDZ6cFhaamlqazBuWVJKM2ZpWmI4cDRY?= =?utf-8?B?YUE9PQ==?= X-MS-Exchange-CrossTenant-Network-Message-Id: 277cf9af-e9be-483a-389d-08dce38e2067 X-MS-Exchange-CrossTenant-AuthSource: DS0PR11MB7309.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Oct 2024 09:31:15.0220 (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: IqgMAfVKB0nZ67qz0xfmaKy3tXtvtwElkb9wa34EXCFtbfU1GqKTH59LP3ephRDUslkcePLkM33Rs2d1Mv26MaFTtZElc8AHfK2eMbxGuOw= X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR11MB4532 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 Wed, Oct 02, 2024 at 10:14:57PM +0300, Isaac Boukris wrote: > On Wed, Oct 2, 2024 at 8:11 PM Bruce Richardson > wrote: > > > > On Wed, Oct 02, 2024 at 07:56:36PM +0300, Isaac Boukris wrote: > > > The CPU value is often not accurate, allow overriding it based > > > on info from the host OS. > > > > > > On Linux X86, 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. > > > > > > On freebsd we have access to the kernel tsc_hz value, just use it. > > > > > > Signed-off-by: Isaac Boukris > > > --- > > > > Looks good to me. Hope to test it out soon on my systems to see how it > > goes. > > > > One comment inline below. > > > > /Bruce > > > > > lib/eal/common/eal_common_timer.c | 3 +- > > > lib/eal/common/eal_private.h | 2 +- > > > lib/eal/freebsd/eal_timer.c | 8 +++-- > > > lib/eal/linux/eal_timer.c | 53 +++++++++++++++++++++++++++++-- > > > lib/eal/windows/eal_timer.c | 5 ++- > > > 5 files changed, 62 insertions(+), 9 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..19fc9a7228 100644 > > > --- a/lib/eal/freebsd/eal_timer.c > > > +++ b/lib/eal/freebsd/eal_timer.c > > > @@ -26,7 +26,7 @@ > > > 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; > > > @@ -50,9 +50,13 @@ get_tsc_freq(void) > > > sz = sizeof(tsc_hz); > > > if (sysctlbyname("machdep.tsc_freq", &tsc_hz, &sz, NULL, 0)) { > > > EAL_LOG(WARNING, "%s", strerror(errno)); > > > - return 0; > > > + return arch_hz; > > > } > > > > > > + if (arch_hz && arch_hz - tsc_hz > arch_hz / 100) > > > > Do we not need an "abs()" call on the "arch_hz - tsc_hz" in case tsc_hz is > > the bigger value? > > As they are unsigned it will overflow and result the absolute value, I > actually did use abs() at first, and the compiler yelled at me: > warning: taking the absolute value of unsigned type ‘uint64_t’ {aka > ‘long unsigned int’} has no effect [-Wabsolute-value] Yes, the compiler is right about them being unsigned. However, without using signed arithmetic and using abs, tsc_hz being even 1Hz greater than arch_hz will lead to the condition failing, so it is actually checking for tsc_hz being within 1% only on the low side. /Bruce