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 EDE0BA0C42 for ; Wed, 23 Jun 2021 22:57:06 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id D75AD41149; Wed, 23 Jun 2021 22:57:06 +0200 (CEST) Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by mails.dpdk.org (Postfix) with ESMTP id 7190D4003C; Wed, 23 Jun 2021 22:57:04 +0200 (CEST) Received: by linux.microsoft.com (Postfix, from userid 1061) id C917F20B7188; Wed, 23 Jun 2021 13:57:03 -0700 (PDT) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com C917F20B7188 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1624481823; bh=uuW44N7WBsCaJHQvgef2kayUbSVMUqVwm9LW5+tu0og=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=S5zH4jOkuf/xkYURIGRo2eqwlZNdFAp3smdCm/VIK78pc68insiDMv/9u4hfsZ2N3 gy6x+O03Ng1fJIpdkF6Hlx7V/utOK1MR5LY1Tuy12w6+UOCOy0KVvwC/SLx3334CjL ffwPl2eUaa5JezlRlbbP26WO8cLzt12eMplZJM0E= Date: Wed, 23 Jun 2021 13:57:03 -0700 From: Jie Zhou To: Dmitry Kozlyuk Cc: dev@dpdk.org, xiaoyun.li@intel.com, roretzla@microsoft.com, talshn@nvidia.com, pallavi.kadam@intel.com, thomas@monjalon.net, bruce.richardson@intel.com, ferruh.yigit@intel.com, konstantin.ananyev@intel.com, stable@dpdk.org Message-ID: <20210623205703.GB20289@linuxonhyperv3.guj3yctzbm1etfxqx2vob5hsef.xx.internal.cloudapp.net> References: <1620236174-10676-1-git-send-email-jizh@linux.microsoft.com> <1620241931-28435-1-git-send-email-jizh@linux.microsoft.com> <1620241931-28435-5-git-send-email-jizh@linux.microsoft.com> <20210621023036.61f982ca@sovereign> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210621023036.61f982ca@sovereign> User-Agent: Mutt/1.5.21 (2010-09-15) Subject: Re: [dpdk-stable] [PATCH v13 04/10] eal/Windows: add clock_gettime on Windows X-BeenThere: stable@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: patches for DPDK stable branches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: stable-bounces@dpdk.org Sender: "stable" On Mon, Jun 21, 2021 at 02:30:36AM +0300, Dmitry Kozlyuk wrote: > 2021-05-05 12:12 (UTC-0700), Jie Zhou: > > Add clock_gettime on Windows in rte_os_shim.h > > > > Signed-off-by: Jie Zhou > > Signed-off-by: Jie Zhou > > --- > > lib/eal/windows/include/rte_os_shim.h | 38 +++++++++++++++++++++++++++ > > 1 file changed, 38 insertions(+) > > > > diff --git a/lib/eal/windows/include/rte_os_shim.h b/lib/eal/windows/include/rte_os_shim.h > > index 3763cae62..cd1f53dfa 100644 > > --- a/lib/eal/windows/include/rte_os_shim.h > > +++ b/lib/eal/windows/include/rte_os_shim.h > > @@ -77,4 +77,42 @@ rte_timespec_get(struct timespec *now, int base) > > > > #endif /* RTE_TOOLCHAIN_GCC */ > > > > +/* Identifier for system-wide realtime clock. */ > > +#define CLOCK_REALTIME 0 > > +/* Monotonic system-wide clock. */ > > +#define CLOCK_MONOTONIC 1 > > +/* High-resolution timer from the CPU. */ > > +#define CLOCK_PROCESS_CPUTIME_ID 2 > > +/* Thread-specific CPU-time clock. */ > > +#define CLOCK_THREAD_CPUTIME_ID 3 > > Are the last two constants needed? Will remove these two unnecessary ones in V14. > > > + > > +#define NS_PER_SEC 1E9 > > NS_PER_SEC isn't provided by any interface that we shim, > but it can be defined by applications (like testpmd does), > so it's better to make this constant private to rte_clock_gettime(). Sure, will move into rte_clock_gettime() > IMO, we should provide such constants with RTE_ prefix someday. > rte_time.h provides NSEC_PER_SEC without RTE_ prefix already. > > > + > > +typedef int clockid_t; > > + > > +static inline int > > +rte_clock_gettime(clockid_t clock_id, struct timespec *tp) > > +{ > > + LARGE_INTEGER pf, pc; > > + LONGLONG nsec; > > + switch (clock_id) { > > + case CLOCK_REALTIME: > > + if (timespec_get(tp, TIME_UTC) != TIME_UTC) > > + return -1; > > + return 0; > > + case CLOCK_MONOTONIC: > > + if (QueryPerformanceFrequency(&pf) == 0) > > + return -1; > > + if (QueryPerformanceCounter(&pc) == 0) > > + return -1; > > These calls never fail on any supported Windows version. Agree, these two zero check is redundant as per ms document, systems run Windows XP or later will always succeed and will never return zero. Will remove the check.