summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDamien Millescamps <damien.millescamps@6wind.com>2012-09-21 13:36:40 +0200
committerThomas Monjalon <thomas.monjalon@6wind.com>2013-07-25 16:08:01 +0200
commit2c056f91a60bbc62f5a5754613895a013cdc542f (patch)
treeb8f9e2be8a3eb862dd24fa8cfa3043b01052619f
parent54d60229a1c35c2a008f9d1b0513002f874dc42a (diff)
downloaddpdk-2c056f91a60bbc62f5a5754613895a013cdc542f.zip
dpdk-2c056f91a60bbc62f5a5754613895a013cdc542f.tar.gz
dpdk-2c056f91a60bbc62f5a5754613895a013cdc542f.tar.xz
timer: option --vmware-tsc-map for VMware guest
The VMware TSC mapping uses a hook to RDPMC to read the physical TSC in the case of VMware ESXi. Introduce new option --vmware-tsc-map, ignored if CONFIG_RTE_LIBRTE_EAL_VMWARE_TSC_MAP_SUPPORT is not set. Default is CONFIG_RTE_LIBRTE_EAL_VMWARE_TSC_MAP_SUPPORT=y. if CONFIG_RTE_LIBRTE_EAL_VMWARE_TSC_MAP_SUPPORT is set: rte_rdtsc() selects at runtime between Vmware mapping of TSC or native TSC else rte_rdtsc() always uses native rdtsc. When running DPDK on VMware guest, enable --vmware-tsc-map to read the physical TSC. Caution: ESXi should pass monitor_control.pseudo_perfctr = TRUE otherwise it results in general protection fault. Signed-off-by: Damien Millescamps <damien.millescamps@6wind.com> Signed-off-by: Jean-Mickael Guerin <jean-mickael.guerin@6wind.com> Acked-by: Olivier Matz <olivier.matz@6wind.com> Acked-by: Vincent Jardin <vincent.jardin@6wind.com> Acked-by: Thomas Monjalon <thomas.monjalon@6wind.com>
-rw-r--r--config/defconfig_i686-default-linuxapp-gcc5
-rw-r--r--config/defconfig_i686-default-linuxapp-icc5
-rw-r--r--config/defconfig_x86_64-default-linuxapp-gcc5
-rw-r--r--config/defconfig_x86_64-default-linuxapp-icc5
-rw-r--r--lib/librte_eal/common/include/rte_cycles.h19
-rw-r--r--lib/librte_eal/linuxapp/eal/eal.c23
-rw-r--r--lib/librte_eal/linuxapp/eal/include/eal_internal_cfg.h1
7 files changed, 63 insertions, 0 deletions
diff --git a/config/defconfig_i686-default-linuxapp-gcc b/config/defconfig_i686-default-linuxapp-gcc
index b1f22f1..756f1cd 100644
--- a/config/defconfig_i686-default-linuxapp-gcc
+++ b/config/defconfig_i686-default-linuxapp-gcc
@@ -121,6 +121,11 @@ CONFIG_RTE_LIBRTE_EAL_LINUXAPP=y
CONFIG_RTE_LIBRTE_EAL_BAREMETAL=n
#
+# Compile Environment Abstraction Layer to support VMware TSC map
+#
+CONFIG_RTE_LIBRTE_EAL_VMWARE_TSC_MAP_SUPPORT=y
+
+#
# Compile generic ethernet library
#
CONFIG_RTE_LIBRTE_ETHER=y
diff --git a/config/defconfig_i686-default-linuxapp-icc b/config/defconfig_i686-default-linuxapp-icc
index 1b4c653..e2d268b 100644
--- a/config/defconfig_i686-default-linuxapp-icc
+++ b/config/defconfig_i686-default-linuxapp-icc
@@ -121,6 +121,11 @@ CONFIG_RTE_LIBRTE_EAL_LINUXAPP=y
CONFIG_RTE_LIBRTE_EAL_BAREMETAL=n
#
+# Compile Environment Abstraction Layer to support VMware TSC map
+#
+CONFIG_RTE_LIBRTE_EAL_VMWARE_TSC_MAP_SUPPORT=y
+
+#
# Compile generic ethernet library
#
CONFIG_RTE_LIBRTE_ETHER=y
diff --git a/config/defconfig_x86_64-default-linuxapp-gcc b/config/defconfig_x86_64-default-linuxapp-gcc
index 5a69b70..cacadb2 100644
--- a/config/defconfig_x86_64-default-linuxapp-gcc
+++ b/config/defconfig_x86_64-default-linuxapp-gcc
@@ -121,6 +121,11 @@ CONFIG_RTE_LIBRTE_EAL_LINUXAPP=y
CONFIG_RTE_LIBRTE_EAL_BAREMETAL=n
#
+# Compile Environment Abstraction Layer to support VMware TSC map
+#
+CONFIG_RTE_LIBRTE_EAL_VMWARE_TSC_MAP_SUPPORT=y
+
+#
# Compile generic ethernet library
#
CONFIG_RTE_LIBRTE_ETHER=y
diff --git a/config/defconfig_x86_64-default-linuxapp-icc b/config/defconfig_x86_64-default-linuxapp-icc
index c546989..39e722f 100644
--- a/config/defconfig_x86_64-default-linuxapp-icc
+++ b/config/defconfig_x86_64-default-linuxapp-icc
@@ -121,6 +121,11 @@ CONFIG_RTE_LIBRTE_EAL_LINUXAPP=y
CONFIG_RTE_LIBRTE_EAL_BAREMETAL=n
#
+# Compile Environment Abstraction Layer to support VMware TSC map
+#
+CONFIG_RTE_LIBRTE_EAL_VMWARE_TSC_MAP_SUPPORT=y
+
+#
# Compile generic ethernet library
#
CONFIG_RTE_LIBRTE_ETHER=y
diff --git a/lib/librte_eal/common/include/rte_cycles.h b/lib/librte_eal/common/include/rte_cycles.h
index ed6b2e6..42c350e 100644
--- a/lib/librte_eal/common/include/rte_cycles.h
+++ b/lib/librte_eal/common/include/rte_cycles.h
@@ -2,6 +2,7 @@
* BSD LICENSE
*
* Copyright(c) 2010-2013 Intel Corporation. All rights reserved.
+ * Copyright(c) 2012-2013 6WIND S.A.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -47,6 +48,13 @@ extern "C" {
#include <stdint.h>
+#ifdef RTE_LIBRTE_EAL_VMWARE_TSC_MAP_SUPPORT
+/** Global switch to use VMware mapping of TSC instead of RDTSC */
+extern int rte_cycles_vmware_tsc_map;
+#include <rte_branch_prediction.h>
+#endif
+
+
/**
* Read the TSC register.
*
@@ -64,9 +72,20 @@ rte_rdtsc(void)
};
} tsc;
+#ifdef RTE_LIBRTE_EAL_VMWARE_TSC_MAP_SUPPORT
+ if (unlikely(rte_cycles_vmware_tsc_map)) {
+ /* ecx = 0x10000 corresponds to the Physical TSC for VMware */
+ asm volatile("rdpmc" :
+ "=a" (tsc.lo_32),
+ "=d" (tsc.hi_32) :
+ "c"(0x10000));
+ return tsc.tsc_64;
+ }
+#endif
asm volatile("rdtsc" :
"=a" (tsc.lo_32),
"=d" (tsc.hi_32));
+
return tsc.tsc_64;
}
diff --git a/lib/librte_eal/linuxapp/eal/eal.c b/lib/librte_eal/linuxapp/eal/eal.c
index 4dc1475..d94c6bb 100644
--- a/lib/librte_eal/linuxapp/eal/eal.c
+++ b/lib/librte_eal/linuxapp/eal/eal.c
@@ -84,6 +84,7 @@
#define OPT_PROC_TYPE "proc-type"
#define OPT_NO_SHCONF "no-shconf"
#define OPT_NO_HPET "no-hpet"
+#define OPT_VMWARE_TSC_MAP "vmware-tsc-map"
#define OPT_NO_PCI "no-pci"
#define OPT_NO_HUGE "no-huge"
#define OPT_FILE_PREFIX "file-prefix"
@@ -149,6 +150,9 @@ struct lcore_config lcore_config[RTE_MAX_LCORE];
/* internal configuration */
struct internal_config internal_config;
+/* used by rte_rdtsc() */
+int rte_cycles_vmware_tsc_map;
+
/* Return a pointer to the configuration structure */
struct rte_config *
rte_eal_get_configuration(void)
@@ -344,6 +348,7 @@ eal_usage(const char *prgname)
" --"OPT_HUGE_DIR" : directory where hugetlbfs is mounted\n"
" --"OPT_PROC_TYPE" : type of this process\n"
" --"OPT_FILE_PREFIX": prefix for hugepage filenames\n"
+ " --"OPT_VMWARE_TSC_MAP" : use VMware TSC map instead of native RDTSC\n\n"
"\nEAL options for DEBUG use only:\n"
" --"OPT_NO_HUGE" : use malloc instead of hugetlbfs\n"
" --"OPT_NO_PCI" : disable pci\n"
@@ -550,6 +555,7 @@ eal_parse_args(int argc, char **argv)
{OPT_NO_HUGE, 0, 0, 0},
{OPT_NO_PCI, 0, 0, 0},
{OPT_NO_HPET, 0, 0, 0},
+ {OPT_VMWARE_TSC_MAP, 0, 0, 0},
{OPT_HUGE_DIR, 1, 0, 0},
{OPT_NO_SHCONF, 0, 0, 0},
{OPT_PROC_TYPE, 1, 0, 0},
@@ -582,6 +588,8 @@ eal_parse_args(int argc, char **argv)
for (i = 0; i < MAX_HUGEPAGE_SIZES; i++)
internal_config.hugepage_info[i].lock_descriptor = 0;
+ internal_config.vmware_tsc_map = 0;
+
while ((opt = getopt_long(argc, argvopt, "b:c:d:m:n:r:v",
lgopts, &option_index)) != EOF) {
@@ -659,6 +667,9 @@ eal_parse_args(int argc, char **argv)
else if (!strcmp(lgopts[option_index].name, OPT_NO_HPET)) {
internal_config.no_hpet = 1;
}
+ else if (!strcmp(lgopts[option_index].name, OPT_VMWARE_TSC_MAP)) {
+ internal_config.vmware_tsc_map = 1;
+ }
else if (!strcmp(lgopts[option_index].name, OPT_NO_SHCONF)) {
internal_config.no_shconf = 1;
}
@@ -822,6 +833,18 @@ rte_eal_init(int argc, char **argv)
internal_config.memory = eal_get_hugepage_mem_size();
}
+ if (internal_config.vmware_tsc_map == 1) {
+#ifdef RTE_LIBRTE_EAL_VMWARE_TSC_MAP_SUPPORT
+ rte_cycles_vmware_tsc_map = 1;
+ RTE_LOG (DEBUG, EAL, "Using VMware TSC map, "
+ "you must have monitor_control.pseudo_perfctr = TRUE\n");
+#else
+ RTE_LOG (WARNING, EAL, "Ignoring --vmware-tsc-map because "
+ "RTE_LIBRTE_EAL_VMWARE_TSC_MAP_SUPPORT is not set\n");
+#endif
+ } else {
+ RTE_LOG (DEBUG, EAL, "Using native RDTSC\n");
+ }
rte_srand(rte_rdtsc());
rte_config_init();
diff --git a/lib/librte_eal/linuxapp/eal/include/eal_internal_cfg.h b/lib/librte_eal/linuxapp/eal/include/eal_internal_cfg.h
index 4da4e91..7f91855 100644
--- a/lib/librte_eal/linuxapp/eal/include/eal_internal_cfg.h
+++ b/lib/librte_eal/linuxapp/eal/include/eal_internal_cfg.h
@@ -66,6 +66,7 @@ struct internal_config {
volatile unsigned no_hugetlbfs; /**< true to disable hugetlbfs */
volatile unsigned no_pci; /**< true to disable PCI */
volatile unsigned no_hpet; /**< true to disable HPET */
+ volatile unsigned vmware_tsc_map; /**< true to use VMware TSC mapping instead of native TSC */
volatile unsigned no_shconf; /**< true if there is no shared config */
volatile int syslog_facility; /**< facility passed to openlog() */
volatile enum rte_proc_type_t process_type; /* multi-process proc type */