aboutsummaryrefslogtreecommitdiffstats
path: root/examples/performance-thread/common
diff options
context:
space:
mode:
Diffstat (limited to 'examples/performance-thread/common')
-rw-r--r--examples/performance-thread/common/arch/x86/ctx.h8
-rw-r--r--examples/performance-thread/common/common.mk20
-rw-r--r--examples/performance-thread/common/lthread.h8
-rw-r--r--examples/performance-thread/common/lthread_api.h8
-rw-r--r--examples/performance-thread/common/lthread_cond.h8
-rw-r--r--examples/performance-thread/common/lthread_diag.h9
-rw-r--r--examples/performance-thread/common/lthread_diag_api.h8
-rw-r--r--examples/performance-thread/common/lthread_int.h8
-rw-r--r--examples/performance-thread/common/lthread_mutex.h8
-rw-r--r--examples/performance-thread/common/lthread_objcache.h7
-rw-r--r--examples/performance-thread/common/lthread_pool.h7
-rw-r--r--examples/performance-thread/common/lthread_queue.h7
-rw-r--r--examples/performance-thread/common/lthread_sched.h7
-rw-r--r--examples/performance-thread/common/lthread_timer.h24
-rw-r--r--examples/performance-thread/common/lthread_tls.c1
-rw-r--r--examples/performance-thread/common/lthread_tls.h7
16 files changed, 132 insertions, 13 deletions
diff --git a/examples/performance-thread/common/arch/x86/ctx.h b/examples/performance-thread/common/arch/x86/ctx.h
index 03860508..a41ce05a 100644
--- a/examples/performance-thread/common/arch/x86/ctx.h
+++ b/examples/performance-thread/common/arch/x86/ctx.h
@@ -35,6 +35,10 @@
#ifndef CTX_H
#define CTX_H
+#ifdef __cplusplus
+extern "C" {
+#endif
+
/*
* CPU context registers
*/
@@ -54,4 +58,8 @@ void
ctx_switch(struct ctx *new_ctx, struct ctx *curr_ctx);
+#ifdef __cplusplus
+}
+#endif
+
#endif /* RTE_CTX_H_ */
diff --git a/examples/performance-thread/common/common.mk b/examples/performance-thread/common/common.mk
index d3de5fc6..f6cab771 100644
--- a/examples/performance-thread/common/common.mk
+++ b/examples/performance-thread/common/common.mk
@@ -30,13 +30,15 @@
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-# list the C files belonhing to the lthread subsystem, these are common to all lthread apps
-SRCS-y += ../common/lthread.c \
- ../common/lthread_sched.c \
- ../common/lthread_cond.c \
- ../common/lthread_tls.c \
- ../common/lthread_mutex.c \
- ../common/lthread_diag.c \
- ../common/arch/x86/ctx.c
+# list the C files belonging to the lthread subsystem, these are common to all
+# lthread apps. Any makefile including this should set VPATH to include this
+# directory path
+#
+
+MKFILE_PATH=$(abspath $(dir $(lastword $(MAKEFILE_LIST))))
+
+VPATH := $(MKFILE_PATH) $(MKFILE_PATH)/arch/x86
+
+SRCS-y += lthread.c lthread_sched.c lthread_cond.c lthread_tls.c lthread_mutex.c lthread_diag.c ctx.c
-INCLUDES += -I$(RTE_SDK)/examples/performance-thread/common/ -I$(RTE_SDK)/examples/performance-thread/common/arch/x86/
+INCLUDES += -I$(MKFILE_PATH) -I$(MKFILE_PATH)/arch/x86/
diff --git a/examples/performance-thread/common/lthread.h b/examples/performance-thread/common/lthread.h
index 8c77af82..5c2c1a5f 100644
--- a/examples/performance-thread/common/lthread.h
+++ b/examples/performance-thread/common/lthread.h
@@ -62,6 +62,10 @@
#ifndef LTHREAD_H_
#define LTHREAD_H_
+#ifdef __cplusplus
+extern "C" {
+#endif
+
#include <rte_per_lcore.h>
#include "lthread_api.h"
@@ -96,4 +100,8 @@ _lthread_init(struct lthread *lt,
void _lthread_set_stack(struct lthread *lt, void *stack, size_t stack_size);
+#ifdef __cplusplus
+}
+#endif
+
#endif /* LTHREAD_H_ */
diff --git a/examples/performance-thread/common/lthread_api.h b/examples/performance-thread/common/lthread_api.h
index ec976103..ff245a08 100644
--- a/examples/performance-thread/common/lthread_api.h
+++ b/examples/performance-thread/common/lthread_api.h
@@ -124,6 +124,10 @@
#ifndef LTHREAD_H
#define LTHREAD_H
+#ifdef __cplusplus
+extern "C" {
+#endif
+
#include <stdint.h>
#include <sys/socket.h>
#include <fcntl.h>
@@ -829,4 +833,8 @@ int lthread_cond_signal(struct lthread_cond *c);
*/
int lthread_cond_broadcast(struct lthread_cond *c);
+#ifdef __cplusplus
+}
+#endif
+
#endif /* LTHREAD_H */
diff --git a/examples/performance-thread/common/lthread_cond.h b/examples/performance-thread/common/lthread_cond.h
index 5bd02a7d..5e5f14be 100644
--- a/examples/performance-thread/common/lthread_cond.h
+++ b/examples/performance-thread/common/lthread_cond.h
@@ -62,6 +62,10 @@
#ifndef LTHREAD_COND_H_
#define LTHREAD_COND_H_
+#ifdef __cplusplus
+extern "C" {
+#endif
+
#include "lthread_queue.h"
#define MAX_COND_NAME_SIZE 64
@@ -74,4 +78,8 @@ struct lthread_cond {
uint64_t diag_ref; /* optional ref to user diag data */
} __rte_cache_aligned;
+#ifdef __cplusplus
+}
+#endif
+
#endif /* LTHREAD_COND_H_ */
diff --git a/examples/performance-thread/common/lthread_diag.h b/examples/performance-thread/common/lthread_diag.h
index 2877d311..3dce8e0e 100644
--- a/examples/performance-thread/common/lthread_diag.h
+++ b/examples/performance-thread/common/lthread_diag.h
@@ -34,6 +34,10 @@
#ifndef LTHREAD_DIAG_H_
#define LTHREAD_DIAG_H_
+#ifdef __cplusplus
+extern "C" {
+#endif
+
#include <stdint.h>
#include <inttypes.h>
@@ -129,4 +133,9 @@ extern uint64_t diag_mask;
#define DIAG_USED __rte_unused
#endif /* LTHREAD_DIAG */
+
+#ifdef __cplusplus
+}
+#endif
+
#endif /* LTHREAD_DIAG_H_ */
diff --git a/examples/performance-thread/common/lthread_diag_api.h b/examples/performance-thread/common/lthread_diag_api.h
index 7ee514f8..2fda0951 100644
--- a/examples/performance-thread/common/lthread_diag_api.h
+++ b/examples/performance-thread/common/lthread_diag_api.h
@@ -33,6 +33,10 @@
#ifndef LTHREAD_DIAG_API_H_
#define LTHREAD_DIAG_API_H_
+#ifdef __cplusplus
+extern "C" {
+#endif
+
#include <stdint.h>
#include <inttypes.h>
@@ -322,4 +326,8 @@ lthread_cond_diag_ref(struct lthread_cond *c);
uint64_t
lthread_mutex_diag_ref(struct lthread_mutex *m);
+#ifdef __cplusplus
+}
+#endif
+
#endif /* LTHREAD_DIAG_API_H_ */
diff --git a/examples/performance-thread/common/lthread_int.h b/examples/performance-thread/common/lthread_int.h
index 031d8afc..3f7fb92d 100644
--- a/examples/performance-thread/common/lthread_int.h
+++ b/examples/performance-thread/common/lthread_int.h
@@ -62,6 +62,10 @@
#include <lthread_api.h>
#define LTHREAD_INT_H
+#ifdef __cplusplus
+extern "C" {
+#endif
+
#include <stdint.h>
#include <sys/time.h>
#include <sys/types.h>
@@ -197,4 +201,8 @@ struct lthread {
uint64_t diag_ref; /* ref to user diag data */
} __rte_cache_aligned;
+#ifdef __cplusplus
+}
+#endif
+
#endif /* LTHREAD_INT_H */
diff --git a/examples/performance-thread/common/lthread_mutex.h b/examples/performance-thread/common/lthread_mutex.h
index 4d30b2e7..e78db91d 100644
--- a/examples/performance-thread/common/lthread_mutex.h
+++ b/examples/performance-thread/common/lthread_mutex.h
@@ -35,6 +35,10 @@
#ifndef LTHREAD_MUTEX_H_
#define LTHREAD_MUTEX_H_
+#ifdef __cplusplus
+extern "C" {
+#endif
+
#include "lthread_queue.h"
@@ -49,4 +53,8 @@ struct lthread_mutex {
uint64_t diag_ref; /* optional ref to user diag data */
} __rte_cache_aligned;
+#ifdef __cplusplus
+}
+#endif
+
#endif /* LTHREAD_MUTEX_H_ */
diff --git a/examples/performance-thread/common/lthread_objcache.h b/examples/performance-thread/common/lthread_objcache.h
index d7e35825..6e5195ba 100644
--- a/examples/performance-thread/common/lthread_objcache.h
+++ b/examples/performance-thread/common/lthread_objcache.h
@@ -33,6 +33,10 @@
#ifndef LTHREAD_OBJCACHE_H_
#define LTHREAD_OBJCACHE_H_
+#ifdef __cplusplus
+extern "C" {
+#endif
+
#include <string.h>
#include <rte_per_lcore.h>
@@ -154,5 +158,8 @@ _lthread_objcache_free(struct lthread_objcache *c, void *obj)
}
+#ifdef __cplusplus
+}
+#endif
#endif /* LTHREAD_OBJCACHE_H_ */
diff --git a/examples/performance-thread/common/lthread_pool.h b/examples/performance-thread/common/lthread_pool.h
index 27680eab..fb0c578b 100644
--- a/examples/performance-thread/common/lthread_pool.h
+++ b/examples/performance-thread/common/lthread_pool.h
@@ -69,6 +69,10 @@
#ifndef LTHREAD_POOL_H_
#define LTHREAD_POOL_H_
+#ifdef __cplusplus
+extern "C" {
+#endif
+
#include <rte_malloc.h>
#include <rte_per_lcore.h>
#include <rte_log.h>
@@ -328,5 +332,8 @@ _qnode_pool_destroy(struct qnode_pool *p)
return 0;
}
+#ifdef __cplusplus
+}
+#endif
#endif /* LTHREAD_POOL_H_ */
diff --git a/examples/performance-thread/common/lthread_queue.h b/examples/performance-thread/common/lthread_queue.h
index 2c55fcec..4fc2074e 100644
--- a/examples/performance-thread/common/lthread_queue.h
+++ b/examples/performance-thread/common/lthread_queue.h
@@ -69,6 +69,10 @@
#ifndef LTHREAD_QUEUE_H_
#define LTHREAD_QUEUE_H_
+#ifdef __cplusplus
+extern "C" {
+#endif
+
#include <string.h>
#include <rte_prefetch.h>
@@ -298,5 +302,8 @@ _lthread_queue_remove(struct lthread_queue *q)
return NULL;
}
+#ifdef __cplusplus
+}
+#endif
#endif /* LTHREAD_QUEUE_H_ */
diff --git a/examples/performance-thread/common/lthread_sched.h b/examples/performance-thread/common/lthread_sched.h
index 4ce56c27..7cddda9c 100644
--- a/examples/performance-thread/common/lthread_sched.h
+++ b/examples/performance-thread/common/lthread_sched.h
@@ -62,6 +62,10 @@
#ifndef LTHREAD_SCHED_H_
#define LTHREAD_SCHED_H_
+#ifdef __cplusplus
+extern "C" {
+#endif
+
#include "lthread_int.h"
#include "lthread_queue.h"
#include "lthread_objcache.h"
@@ -148,5 +152,8 @@ extern struct lthread_sched *schedcore[];
void _sched_timer_cb(struct rte_timer *tim, void *arg);
void _sched_shutdown(__rte_unused void *arg);
+#ifdef __cplusplus
+}
+#endif
#endif /* LTHREAD_SCHED_H_ */
diff --git a/examples/performance-thread/common/lthread_timer.h b/examples/performance-thread/common/lthread_timer.h
index b5e6fb0e..7c03d673 100644
--- a/examples/performance-thread/common/lthread_timer.h
+++ b/examples/performance-thread/common/lthread_timer.h
@@ -35,6 +35,10 @@
#ifndef LTHREAD_TIMER_H_
#define LTHREAD_TIMER_H_
+#ifdef __cplusplus
+extern "C" {
+#endif
+
#include "lthread_int.h"
#include "lthread_sched.h"
@@ -42,11 +46,22 @@
static inline uint64_t
_ns_to_clks(uint64_t ns)
{
- unsigned __int128 clkns = rte_get_tsc_hz();
+ /*
+ * clkns needs to be divided by 1E9 to get ns clocks. However,
+ * dividing by this first would lose a lot of accuracy.
+ * Dividing after a multiply by ns, could cause overflow of
+ * uint64_t if ns is about 5 seconds [if we assume a max tsc
+ * rate of 4GHz]. Therefore we first divide by 1E4, then
+ * multiply and finally divide by 1E5. This allows ns to be
+ * values many hours long, without overflow, while still keeping
+ * reasonable accuracy.
+ */
+ uint64_t clkns = rte_get_tsc_hz() / 1e4;
clkns *= ns;
- clkns /= 1000000000;
- return (uint64_t) clkns;
+ clkns /= 1e5;
+
+ return clkns;
}
@@ -75,5 +90,8 @@ _timer_stop(struct lthread *lt)
}
}
+#ifdef __cplusplus
+}
+#endif
#endif /* LTHREAD_TIMER_H_ */
diff --git a/examples/performance-thread/common/lthread_tls.c b/examples/performance-thread/common/lthread_tls.c
index 6876f831..47505f2d 100644
--- a/examples/performance-thread/common/lthread_tls.c
+++ b/examples/performance-thread/common/lthread_tls.c
@@ -42,7 +42,6 @@
#include <fcntl.h>
#include <sys/time.h>
#include <sys/mman.h>
-#include <execinfo.h>
#include <sched.h>
#include <rte_malloc.h>
diff --git a/examples/performance-thread/common/lthread_tls.h b/examples/performance-thread/common/lthread_tls.h
index 86cbfadc..fff3c0db 100644
--- a/examples/performance-thread/common/lthread_tls.h
+++ b/examples/performance-thread/common/lthread_tls.h
@@ -34,6 +34,10 @@
#ifndef LTHREAD_TLS_H_
#define LTHREAD_TLS_H_
+#ifdef __cplusplus
+extern "C" {
+#endif
+
#include "lthread_api.h"
#define RTE_PER_LTHREAD_SECTION_SIZE \
@@ -53,5 +57,8 @@ void _lthread_tls_destroy(struct lthread *lt);
void _lthread_key_pool_init(void);
void _lthread_tls_alloc(struct lthread *lt);
+#ifdef __cplusplus
+}
+#endif
#endif /* LTHREAD_TLS_H_ */