From mboxrd@z Thu Jan 1 00:00:00 1970 From: Thomas Monjalon Subject: Re: [PATCH v9 2/3] Move common functions in eal_timer.c Date: Mon, 27 Jul 2015 01:40:26 +0200 Message-ID: <18444292.n7c28FrYlF@xps13> References: <1437852868-6031-1-git-send-email-rkerur@gmail.com> <1437852990-6096-1-git-send-email-rkerur@gmail.com> <1437852990-6096-2-git-send-email-rkerur@gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7Bit Cc: dev@dpdk.org To: Ravi Kerur Return-path: Received: from mail-wi0-f176.google.com (mail-wi0-f176.google.com [209.85.212.176]) by dpdk.org (Postfix) with ESMTP id 66C0EC466 for ; Mon, 27 Jul 2015 01:41:42 +0200 (CEST) Received: by wibud3 with SMTP id ud3so93688250wib.0 for ; Sun, 26 Jul 2015 16:41:42 -0700 (PDT) In-Reply-To: <1437852990-6096-2-git-send-email-rkerur@gmail.com> List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" 2015-07-25 12:36, Ravi Kerur > static int > set_tsc_freq_from_sysctl(void) > { > size_t sz; > int tmp; > + uint64_t tsc_hz; > > sz = sizeof(tmp); > tmp = 0; > @@ -94,42 +77,23 @@ set_tsc_freq_from_sysctl(void) > else if (tmp != 1) > RTE_LOG(WARNING, EAL, "TSC is not invariant\n"); > > - sz = sizeof(eal_tsc_resolution_hz); > - if (sysctlbyname("machdep.tsc_freq", &eal_tsc_resolution_hz, &sz, NULL, 0)) { > + sz = sizeof(tsc_hz); > + if (sysctlbyname("machdep.tsc_freq", &tsc_hz, &sz, NULL, 0)) { > RTE_LOG(WARNING, EAL, "%s\n", strerror(errno)); > return -1; > } > + rte_set_tsc_hz(tsc_hz); > > return 0; > } [...] > --- /dev/null > +++ b/lib/librte_eal/common/eal_common_timer.c > +void > +rte_set_tsc_hz(uint64_t tsc_hz) > +{ > + eal_tsc_resolution_hz = tsc_hz; > +} [...] > +void > +set_tsc_freq(void) > +{ > + if (set_tsc_freq_from_clock() < 0) > + set_tsc_freq_fallback(); It would be simpler to get value from return of these functions and store it in eal_tsc_resolution_hz here.