From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 59EA1A034E; Wed, 6 May 2020 21:43:56 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 2C3CA1DA54; Wed, 6 May 2020 21:43:56 +0200 (CEST) Received: from mail-lj1-f193.google.com (mail-lj1-f193.google.com [209.85.208.193]) by dpdk.org (Postfix) with ESMTP id AF2701D9FD for ; Wed, 6 May 2020 21:43:54 +0200 (CEST) Received: by mail-lj1-f193.google.com with SMTP id e25so3711630ljg.5 for ; Wed, 06 May 2020 12:43:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Ij/ftD19BQmNzbyegfmXFADRcDpZrvwDQ/3ii54GTgk=; b=fFSMtp6zj0p/XnQWSFnFE5FFaneIZYp97ua7XOChCixMvaE+RU9a9MrKH7L8ow3uB8 5l2v1FqCXrLm63B4l/Ni0hQGZWOhmmMW+cK7ZtS/Ei+XMcIi1425J0xA9022lJ1nQLXH /0vonwFcEQej1TYPkkUZakMxqd/SceHudJdpEjdIXJKTiIHTEmsImANVVOJQYTLFCG7H VnU8siRTaZBCs658OGGbSuk/H5UFQ4XrTsvWGC2mK7P16ExX9rp53JCc4w4gQ8W7xzlm AKXOCCUWSpnGfB893+PX4auKYmxih2RIYbFs5QvArSA57FZH8vzFEGlyD64dizk0ROdB 4CAw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Ij/ftD19BQmNzbyegfmXFADRcDpZrvwDQ/3ii54GTgk=; b=C0wsuZjl9IFkvnS9w/ReQ/XNqGtJWAMt/I7jzEC/dqGuIFbsxeDEtCrnoo6FgB9Sit 0CCQfEKBbmEp4QKP7TUtbL7+GB2WZXroM4Yp0K7XO0Hu14RClycZg9AVoyBX6+XgTi3P mS4M0xrayeycYkL2puVnFPxhMZ2ooGE0vvkMKVzwZZtTKOPYIqCj9crgPnFLnlKJP+1Z TAubdelUCFu7z4J5QdSxY6StPGP+Sk+Ej0xtGzwAfHVl6EY9kP8Q40P1CWhC5s851spH 0eBBDHNGXsGDAp0M5aBH8zXCdcraqQkX5saQNDNUEh+O7PdzYDdp3ep+K2Akt9bODrIV kOUg== X-Gm-Message-State: AGi0PubbD+c/pPbNb2oGMmVpiD4q6VlWFCpvmlrFRE2XrRRezG8N4ZZZ jd39xXrTkI5jKXzUz2XuJpE= X-Google-Smtp-Source: APiQypLWdWzMeqBwa4yejlspta6U05PhQpOUoHiNwK/K5ZtZTuRsD+cxz6ZnRTYAycffx2toBiTldw== X-Received: by 2002:a2e:9a4a:: with SMTP id k10mr6035378ljj.115.1588794234173; Wed, 06 May 2020 12:43:54 -0700 (PDT) Received: from Sovereign (broadband-37-110-65-23.ip.moscow.rt.ru. [37.110.65.23]) by smtp.gmail.com with ESMTPSA id o27sm2472387lfi.27.2020.05.06.12.43.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 May 2020 12:43:53 -0700 (PDT) Date: Wed, 6 May 2020 22:43:52 +0300 From: Dmitry Kozlyuk To: Fady Bader Cc: dev@dpdk.org, thomas@monjalon.net, talshn@mellanox.com, dmitry.koziuk@gmail.com, harini.ramakrishnan@microsoft.com, ocardona@microsoft.com, anand.rawat@intel.com, ranjit.menon@intel.com, yohadt@mellanox.com Message-ID: <20200506224352.38910815@Sovereign> In-Reply-To: <20200506120109.9856-3-fady@mellanox.com> References: <20200506120109.9856-1-fady@mellanox.com> <20200506120109.9856-3-fady@mellanox.com> X-Mailer: Claws Mail 3.17.5 (GTK+ 2.24.32; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Subject: Re: [dpdk-dev] [PATCH v4 2/2] timer: support EAL functions on Windows X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" Getting extremely volatile results from get_tsc_hz(). Here's what I get from 10 successive calls: freq=3D2660000000 freq=3D3220000000 freq=3D3740000000 freq=3D3870000000 freq=3D3830000000 freq=3D4060000000 freq=3D3370000000 freq=3D3820000000 freq=3D7370000000 freq=3D4970000000 Please see the last comment for the reason (and other comments inline). On 2020-05-06 15:01 GMT+0300 Fady Bader wrote: > Implemented the needed Windows eal timer functions. >=20 > Signed-off-by: Fady Bader > --- [snip] > diff --git a/lib/librte_eal/windows/eal_timer.c b/lib/librte_eal/windows/= eal_timer.c > new file mode 100644 > index 000000000..108f66b54 > --- /dev/null > +++ b/lib/librte_eal/windows/eal_timer.c > @@ -0,0 +1,96 @@ > +/* SPDX-License-Identifier: BSD-3-Clause > + * Copyright 2020 Mellanox Technologies, Ltd > + */ > +#include > +#include > + > +#include > +#include > +#include > +#include > +#include > +#include #include "eal_private.h", without it: ../../../lib/librte_eal/windows/eal_timer.c: In function =E2=80=98rte_eal_t= imer_init=E2=80=99: ../../../lib/librte_eal/windows/eal_timer.c:108:2: warning: implicit declar= ation of function =E2=80=98set_tsc_freq=E2=80=99; did you mean =E2=80=98get= _tsc_freq=E2=80=99? [-Wimplicit-function-declaration] 108 | set_tsc_freq(); > + > +#define US_PER_SEC 1E6 > +#define CYC_PER_10MHZ 1E7 > + > +/* The frequency of the RDTSC timer resolution */ > +static uint64_t eal_tsc_resolution_hz; > + At top level: ../../../lib/librte_eal/windows/eal_timer.c:20:17: warning: =E2=80=98eal_ts= c_resolution_hz=E2=80=99 defined but not used [-Wunused-variable] 20 | static uint64_t eal_tsc_resolution_hz; Note: set_tsc_freq() already caches frequency you calculate here. > + due_time.QuadPart =3D -(us * 10); > + if (!SetWaitableTimer(timer, &due_time, 0, NULL, NULL, FALSE)) { > + CloseHandle(timer); > + RTE_LOG_WIN32_ERR("SetWaitableTimer()"); RTE_LOG_WIN32_ERR() uses GetLastError(), the value of which may be overridd= en by a successful call to CloseHandle(). > + rte_errno =3D EINVAL; > + return; > + } > + /* start wait for timer for us microseconds */ > + WaitForSingleObject(timer, INFINITE); > + CloseHandle(timer); > +} > + > +uint64_t > +get_tsc_freq(void) > +{ > + LARGE_INTEGER t_start, t_end, elapsed_us; > + LARGE_INTEGER frequency; > + uint64_t tsc_hz; > + > + if (QueryPerformanceFrequency(&frequency) =3D=3D 0) { > + RTE_LOG_WIN32_ERR("QueryPerformanceFrequency()"); > + return 0; > + } > + > + if (QueryPerformanceCounter(&t_start) !=3D 0) { Per MSDN, QueryPerformanceFrequency() and QueryPerformanceCounter() always succeed on all supported Windows versions. > + uint64_t end, start =3D rte_get_tsc_cycles(); > + > + rte_delay_us(US_PER_SEC / 10); /* 1/10 second */ Did you mean rte_delay_us_sleep()? rte_delay_us() assumes TSC frequency is already available. With this fix, results become stable. --=20 Dmitry Kozlyuk