From da0fc6d4532085d94ddea3c693d9308d6e4d8726 Mon Sep 17 00:00:00 2001 From: Francesco Nigro Date: Tue, 29 Oct 2019 17:12:20 +0100 Subject: [PATCH] ARTEMIS-2533 Support multiple architecture for ASYNCIO kernel by-pass --- src/main/c/CMakeLists.txt | 4 ++-- ...e_activemq_artemis_nativo_jlibaio_LibaioContext.c | 12 ++++-------- src/main/docker/Dockerfile-centos | 2 +- 3 files changed, 7 insertions(+), 11 deletions(-) diff --git a/src/main/c/CMakeLists.txt b/src/main/c/CMakeLists.txt index d457235..d89e5e9 100644 --- a/src/main/c/CMakeLists.txt +++ b/src/main/c/CMakeLists.txt @@ -32,8 +32,8 @@ endif() # harder. Nonetheless, it can still be added by passing CMAKE_USER_C_FLAGS # Also note that define the C99 as the minimum supported standard so the code can be compiled with older GCC versions # (circa 4.4) -set(CMAKE_C_FLAGS_DEBUG "-Wall -std=c99 -z execstack -fdump-tree-all -Wall -pg -g ${CMAKE_USER_C_FLAGS}") -set(CMAKE_C_FLAGS "-O3 -std=c99 -Wall ${CMAKE_USER_C_FLAGS}") +set(CMAKE_C_FLAGS_DEBUG "-Wall -std=gnu11 -z execstack -fdump-tree-all -Wall -pg -g ${CMAKE_USER_C_FLAGS}") +set(CMAKE_C_FLAGS "-O3 -std=gnu11 -Wall ${CMAKE_USER_C_FLAGS}") set(ARTEMIS_LIB_NAME artemis-native-64) diff --git a/src/main/c/org_apache_activemq_artemis_nativo_jlibaio_LibaioContext.c b/src/main/c/org_apache_activemq_artemis_nativo_jlibaio_LibaioContext.c index d495eb4..113e128 100644 --- a/src/main/c/org_apache_activemq_artemis_nativo_jlibaio_LibaioContext.c +++ b/src/main/c/org_apache_activemq_artemis_nativo_jlibaio_LibaioContext.c @@ -32,15 +32,11 @@ #include #include #include +#include #include #include "org_apache_activemq_artemis_nativo_jlibaio_LibaioContext.h" #include "exception_helper.h" -//x86 has a strong memory model and there is no need of HW fences if just Write-Back (WB) memory is used -#define mem_barrier() __asm__ __volatile__ ("":::"memory") -#define read_barrier() __asm__ __volatile__("":::"memory") -#define store_barrier() __asm__ __volatile__("":::"memory") - struct io_control { io_context_t ioContext; struct io_event * events; @@ -135,7 +131,7 @@ static int ringio_get_events(io_context_t aio_ctx, long min_nr, long max, const unsigned ring_nr = ring->nr; // We're assuming to be the exclusive writer to head, so we just need a compiler barrier unsigned head = ring->head; - mem_barrier(); + atomic_thread_fence(memory_order_acquire); const unsigned tail = ring->tail; int available = tail - head; if (available < 0) { @@ -169,7 +165,7 @@ static int ringio_get_events(io_context_t aio_ctx, long min_nr, long max, //the kernel has written ring->tail from an interrupt: //we need to load acquire the completed events here - read_barrier(); + atomic_thread_fence(memory_order_acquire); const int available_nr = available < max? available : max; //if isn't needed to wrap we can avoid % operations that are quite expansive const int needMod = ((head + available_nr) >= ring_nr) ? 1 : 0; @@ -183,7 +179,7 @@ static int ringio_get_events(io_context_t aio_ctx, long min_nr, long max, } //it allow the kernel to build its own view of the ring buffer size //and push new events if there are any - store_barrier(); + atomic_thread_fence(memory_order_release); ring->head = head; #ifdef DEBUG fprintf(stdout, "consumed non sys-call = %d\n", available_nr); diff --git a/src/main/docker/Dockerfile-centos b/src/main/docker/Dockerfile-centos index 9084ebb..bce6113 100644 --- a/src/main/docker/Dockerfile-centos +++ b/src/main/docker/Dockerfile-centos @@ -17,7 +17,7 @@ # ActiveMQ Artemis -FROM centos:7 as builder-env +FROM centos:stream8 as builder-env LABEL maintainer="Apache ActiveMQ Team"