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 9DFC4A00BE; Mon, 27 Apr 2020 21:34:05 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id AFF811D424; Mon, 27 Apr 2020 21:34:04 +0200 (CEST) Received: from mail-lj1-f196.google.com (mail-lj1-f196.google.com [209.85.208.196]) by dpdk.org (Postfix) with ESMTP id 1B2341D423 for ; Mon, 27 Apr 2020 21:34:03 +0200 (CEST) Received: by mail-lj1-f196.google.com with SMTP id g4so18916630ljl.2 for ; Mon, 27 Apr 2020 12:34:03 -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=u+csVrEg2NCC8vMPWO2AEWRm3gS7raepsu5+whvrB6E=; b=LmxEm7wIXMbtgEwMdBukLWtkpFDMiY9dmbC2KAUl6nO+2rd3zFB+h/H8vs0GIy9vie cPkUWS/3ggAyIOTBM6TP0arqiyXsQmxWd8jzKrYyTg4+YTklRmRg/vr2EgOCIYzzCi/l lkrEx4zEzMQVAeAUQ2FbGCFQMlhmkM1PrFvxPX/L6KriehGVdGwAxrGd++7/96ZNzNku iwsluTMs+SZXh2ctDpbZQlNpPsxfTCaPZWklOGssyKYVZCkbblFHY/dy/bUcv4XSyUJZ UyEObGMgn9Wkt/zZqGF5amTSTXPftF7ecvcigaEIJifZ4MgXvZgnS2QpNzYgR7pmISBN bBAw== 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=u+csVrEg2NCC8vMPWO2AEWRm3gS7raepsu5+whvrB6E=; b=QNUJdn5tmFcukViN+EO/h+xS37RmLIL3LD12ZCU42+77lUfoTYouR3aGZyVUF0ui4n MgQOfwQgZbf4eEUnL8Bc/2prRfCh00RzS4TL9cJgDjMLmellvmeeGZYd4MUaNSoUZbZ3 zvASZ4pJN/JL/7vN+zgw7Rez1cdxAUJV9R7R++d5PTeGiz2d5Bj8L/eyuxWw5Uk6NGFO P3tqHBsdGDSEdG/0xajRrxCpio11weZUHe3D38DLk09KMt1AqBo2d/8QidRs/DX9oOzn vyBSh7rPblzHlfI5RMVo7bO+MgMZdWIO4uBRzhLC2JkD7Xi3Rwd2FIhQR3z2Jvp7oH++ WA8Q== X-Gm-Message-State: AGi0Pua2lgOMI52JKMUdtZmk2dvFGlTDTy03sAJ9pQ2ClqjFHQueOwMZ mdTT8HqSU9gmiTO6Uz7GbRI= X-Google-Smtp-Source: APiQypI/OceMkfUcZENN6Tt48wBT7SKYR1NCS4ZNEoq6NeUTWggQVfWNs82TrRsxM3BMN4gS0ZxbJQ== X-Received: by 2002:a2e:b6cf:: with SMTP id m15mr14700891ljo.168.1588016042498; Mon, 27 Apr 2020 12:34:02 -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 p23sm11633803lfc.95.2020.04.27.12.34.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 27 Apr 2020 12:34:01 -0700 (PDT) Date: Mon, 27 Apr 2020 22:34:00 +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 Message-ID: <20200427223400.70f5bbe7@Sovereign> In-Reply-To: <20200427122047.16780-3-fady@mellanox.com> References: <20200427122047.16780-1-fady@mellanox.com> <20200427122047.16780-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=US-ASCII Content-Transfer-Encoding: 7bit Subject: Re: [dpdk-dev] [PATCH v2 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" On 2020-04-27 15:20 GMT+0300 Fady Bader wrote: > Implemented the needed Windows eal timer functions. [snip] > +void > +rte_delay_us_sleep(unsigned int us) > +{ > + HANDLE timer; > + LARGE_INTEGER li_due_time; Here usually comes a blank line. > + /* create waitable timer */ > + timer = CreateWaitableTimer(NULL, TRUE, NULL); > + if (!timer) { > + RTE_LOG_WIN32_ERR("CreateWaitableTimer()"); > + rte_errno = ENOMEM; > + return; > + } > + > + /* set us microseconds time for timer */ > + li_due_time.QuadPart = -(us * 10); The comment is still misleading. [snip] > +uint64_t > +get_tsc_freq(void) > +{ > + uint64_t tsc_freq; > + LARGE_INTEGER Frequency; > + > + QueryPerformanceFrequency(&Frequency); > + > + /* > + * Mulitply by 1K to obtain the true frequency of the CPU > + * it was noted in the MSDN "in many cases, QueryPerformanceFrequency > + * returns the TSC frequency divided by 1024" > + */ > + tsc_freq = ((uint64_t)Frequency.QuadPart * 1024); > + > + return tsc_freq; > +} Extended quote from MSDN: Cases might exist where QueryPerformanceFrequency doesn't return the actual frequency of the hardware tick generator. For example, in many cases, QueryPerformanceFrequency returns the TSC frequency divided by 1024; and on Hyper-V, the performance counter frequency is always 10 MHz when the guest virtual machine runs under a hypervisor that implements the hypervisor version 1.0 interface. As a result, don't assume that QueryPerformanceFrequency will return the precise TSC frequency. https://docs.microsoft.com/en-us/windows/win32/sysinfo/acquiring-high-resolution-time-stamps "In many cases" is pretty vague, we can't distinguish such cases. Here's what I observe on my QEMU guest ("ticks" is Win32 API, "tsc" is RDTSC): freq = 100000000 Hz # note: 100 MHz, not 10 MHz delta (ticks) = 100401071 # Sleep(1000) delta (secs) = 1.004011 # delta (ticks) / freq delta (tsc) = 3460948332 # roughly CPU clock frequency tsc / tick = 34.471229 I suggest measuring a real-time delay with rte_get_tsc_cycles() from arch/ as other EALs do when HPET is not available or configured. This is discouraged by MSDN, but its reasons seem irrelevant for DPDK. -- Dmitry Kozlyuk