# urcu - check that URCU lib is at least version 0.6
AC_CHECK_LIB([urcu-bp], [call_rcu_bp], [], [AC_MSG_ERROR([liburcu 0.6 or newer is needed, please update your version or use [LDFLAGS]=-Ldir to specify the right location.])])
+# numa - check that numa lib is available
+AC_CHECK_LIB([numa], [numa_available], [], [AC_MSG_ERROR([libnuma is required, please install it (e.g. libnuma-dev) or use [LDFLAGS]=-Ldir to specify the right location.])])
+
# optional linux/perf_event.h
AC_CHECK_HEADERS([linux/perf_event.h], [have_perf_event=yes], [])
libringbuffer_la_LIBADD = \
-lpthread \
- -lrt
+ -lrt \
+ -lnuma
libringbuffer_la_CFLAGS = -DUST_COMPONENT="libringbuffer" $(AM_CFLAGS)
struct shm_object *shmobj;
shmobj = shm_object_table_alloc(handle->table, shmsize,
- SHM_OBJECT_SHM, stream_fds[i]);
+ SHM_OBJECT_SHM, stream_fds[i], i);
if (!shmobj)
goto end;
align_shm(shmobj, __alignof__(struct lttng_ust_lib_ring_buffer));
struct lttng_ust_lib_ring_buffer *buf;
shmobj = shm_object_table_alloc(handle->table, shmsize,
- SHM_OBJECT_SHM, stream_fds[0]);
+ SHM_OBJECT_SHM, stream_fds[0], -1);
if (!shmobj)
goto end;
align_shm(shmobj, __alignof__(struct lttng_ust_lib_ring_buffer));
/* Allocate normal memory for channel (not shared) */
shmobj = shm_object_table_alloc(handle->table, shmsize, SHM_OBJECT_MEM,
- -1);
+ -1, -1);
if (!shmobj)
goto error_append;
/* struct channel is at object 0, offset 0 (hardcoded) */
#include <dirent.h>
#include <lttng/align.h>
#include <limits.h>
+#include <numa.h>
#include <helper.h>
#include <ust-fd.h>
struct shm_object *shm_object_table_alloc(struct shm_object_table *table,
size_t memory_map_size,
enum shm_object_type type,
- int stream_fd)
+ int stream_fd,
+ int cpu)
{
+ int oldnode, node;
+ struct shm_object *shm_object;
+
+ oldnode = numa_preferred();
+ if (cpu >= 0) {
+ node = numa_node_of_cpu(cpu);
+ if (node >= 0)
+ numa_set_preferred(node);
+ }
+ if (cpu < 0 || node < 0)
+ numa_set_localalloc();
switch (type) {
case SHM_OBJECT_SHM:
- return _shm_object_table_alloc_shm(table, memory_map_size,
+ shm_object = _shm_object_table_alloc_shm(table, memory_map_size,
stream_fd);
+ break;
case SHM_OBJECT_MEM:
- return _shm_object_table_alloc_mem(table, memory_map_size);
+ shm_object = _shm_object_table_alloc_mem(table, memory_map_size);
+ break;
default:
assert(0);
}
- return NULL;
+ numa_set_preferred(oldnode);
+ return shm_object;
}
struct shm_object *shm_object_table_append_shm(struct shm_object_table *table,
struct shm_object *shm_object_table_alloc(struct shm_object_table *table,
size_t memory_map_size,
enum shm_object_type type,
- const int stream_fd);
+ const int stream_fd,
+ int cpu);
struct shm_object *shm_object_table_append_shm(struct shm_object_table *table,
int shm_fd, int wakeup_fd, uint32_t stream_nr,
size_t memory_map_size);