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 AA8CBA2F6B for ; Tue, 8 Oct 2019 00:33:12 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id A09271C035; Tue, 8 Oct 2019 00:33:11 +0200 (CEST) Received: from mga04.intel.com (mga04.intel.com [192.55.52.120]) by dpdk.org (Postfix) with ESMTP id B3C601BF8C for ; Tue, 8 Oct 2019 00:33:09 +0200 (CEST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga005.jf.intel.com ([10.7.209.41]) by fmsmga104.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 07 Oct 2019 15:33:08 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.67,269,1566889200"; d="scan'208";a="368253548" Received: from jrharri1-skx.ch.intel.com (HELO [127.0.1.1]) ([143.182.137.73]) by orsmga005.jf.intel.com with ESMTP; 07 Oct 2019 15:33:08 -0700 From: Jim Harris To: dev@dpdk.org, bruce.richardson@intel.com, anatoly.burakov@intel.com Date: Mon, 07 Oct 2019 08:28:21 -0700 Message-ID: <157046210105.10142.15291330038149009146.stgit@jrharri1-skx> In-Reply-To: <156646334762.14099.13593080473257757748.stgit@jrharri1-skx> References: <156646334762.14099.13593080473257757748.stgit@jrharri1-skx> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Subject: [dpdk-dev] [PATCH v6 RESEND] eal: add tsc_hz to rte_mem_config 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" This ensures secondary processes never have to calculate the TSC rate themselves, which can be noticeable in VMs that don't have access to arch-specific detection mechanism (such as CPUID leaf 0x15 or MSR 0xCE on x86). Since rte_mem_config is now internal to the rte_eal library, we can add tsc_hz without ABI breakage concerns. Reduces rte_eal_init() execution time in a secondary process from 165ms to 66ms on my test system. Signed-off-by: Jim Harris --- lib/librte_eal/common/eal_common_timer.c | 15 +++++++++++++++ lib/librte_eal/common/eal_memcfg.h | 3 +++ 2 files changed, 18 insertions(+) diff --git a/lib/librte_eal/common/eal_common_timer.c b/lib/librte_eal/common/eal_common_timer.c index 145543de7..fa9ee1b22 100644 --- a/lib/librte_eal/common/eal_common_timer.c +++ b/lib/librte_eal/common/eal_common_timer.c @@ -15,8 +15,10 @@ #include #include #include +#include #include "eal_private.h" +#include "eal_memcfg.h" /* The frequency of the RDTSC timer resolution */ static uint64_t eal_tsc_resolution_hz; @@ -77,8 +79,20 @@ estimate_tsc_freq(void) void set_tsc_freq(void) { + struct rte_mem_config *mcfg = rte_eal_get_configuration()->mem_config; uint64_t freq; + if (rte_eal_process_type() == RTE_PROC_SECONDARY) { + /* + * Just use the primary process calculated TSC rate in any + * secondary process. It avoids any unnecessary overhead on + * systems where arch-specific frequency detection is not + * available. + */ + eal_tsc_resolution_hz = mcfg->tsc_hz; + return; + } + freq = get_tsc_freq_arch(); if (!freq) freq = get_tsc_freq(); @@ -87,6 +101,7 @@ set_tsc_freq(void) RTE_LOG(DEBUG, EAL, "TSC frequency is ~%" PRIu64 " KHz\n", freq / 1000); eal_tsc_resolution_hz = freq; + mcfg->tsc_hz = freq; } void rte_delay_us_callback_register(void (*userfunc)(unsigned int)) diff --git a/lib/librte_eal/common/eal_memcfg.h b/lib/librte_eal/common/eal_memcfg.h index 359beb216..73be6fbae 100644 --- a/lib/librte_eal/common/eal_memcfg.h +++ b/lib/librte_eal/common/eal_memcfg.h @@ -70,6 +70,9 @@ struct rte_mem_config { uint32_t single_file_segments; /**< stored single file segments parameter. */ + uint64_t tsc_hz; + /**< TSC rate */ + uint8_t dma_maskbits; /**< Keeps the more restricted dma mask. */ };