From: Dmitry Kozlyuk <dmitry.kozliuk@gmail.com>
To: Fady Bader <fady@mellanox.com>
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
Subject: Re: [dpdk-dev] [PATCH v2 2/2] timer: support EAL functions on Windows
Date: Mon, 27 Apr 2020 22:34:00 +0300 [thread overview]
Message-ID: <20200427223400.70f5bbe7@Sovereign> (raw)
In-Reply-To: <20200427122047.16780-3-fady@mellanox.com>
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
prev parent reply other threads:[~2020-04-27 19:34 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-04-27 12:20 [dpdk-dev] [PATCH v2 0/2] eal timer split and implementation for Windows Fady Bader
2020-04-27 12:20 ` [dpdk-dev] [PATCH v2 1/2] timer: move from common to Unix directory Fady Bader
2020-04-27 12:20 ` [dpdk-dev] [PATCH v2 2/2] timer: support EAL functions on Windows Fady Bader
2020-04-27 19:34 ` Dmitry Kozlyuk [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20200427223400.70f5bbe7@Sovereign \
--to=dmitry.kozliuk@gmail.com \
--cc=anand.rawat@intel.com \
--cc=dev@dpdk.org \
--cc=dmitry.koziuk@gmail.com \
--cc=fady@mellanox.com \
--cc=harini.ramakrishnan@microsoft.com \
--cc=ocardona@microsoft.com \
--cc=ranjit.menon@intel.com \
--cc=talshn@mellanox.com \
--cc=thomas@monjalon.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.