Namespace RING_BUFFER_ALIGN macros
authorMichael Jeanson <mjeanson@efficios.com>
Tue, 23 Mar 2021 20:56:21 +0000 (16:56 -0400)
committerMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Mon, 29 Mar 2021 17:58:42 +0000 (13:58 -0400)
Also add comments to clarify why efficient memory access impacts the
layout of the ringbuffer.

Change-Id: I752f8b6dec6b00b8222500194cd53428db7d0da5
Signed-off-by: Michael Jeanson <mjeanson@efficios.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
include/lttng/ringbuffer-context.h
include/lttng/ust-tracer.h

index 1b200f7c7f458a422c8abf3966f19ea2f34d6b85..0092a0f19d122390f3e23f41dce62b47422129cc 100644 (file)
@@ -101,18 +101,20 @@ void lib_ring_buffer_ctx_init(struct lttng_ust_lib_ring_buffer_ctx *ctx,
 }
 
 /*
- * We need to define RING_BUFFER_ALIGN_ATTR so it is known early at
+ * We need to define LTTNG_UST_RING_BUFFER_ALIGN_ATTR so it is known early at
  * compile-time. We have to duplicate the "config->align" information and the
  * definition here because config->align is used both in the slow and fast
- * paths, but RING_BUFFER_ALIGN_ATTR is only available for the client code.
+ * paths, but LTTNG_UST_RING_BUFFER_ALIGN_ATTR is only available for the client
+ * code.
  */
-#ifdef RING_BUFFER_ALIGN
+#ifdef LTTNG_UST_RING_BUFFER_NATURAL_ALIGN
 
-# define RING_BUFFER_ALIGN_ATTR                /* Default arch alignment */
+# define LTTNG_UST_RING_BUFFER_ALIGN_ATTR      /* Default arch alignment */
 
 /*
- * Calculate the offset needed to align the type.
- * size_of_type must be non-zero.
+ * lib_ring_buffer_align - Calculate the offset needed to align the type.
+ * @align_drift:  object offset from an "alignment"-aligned address.
+ * @size_of_type: Must be non-zero, power of 2.
  */
 static inline lttng_ust_notrace
 unsigned int lib_ring_buffer_align(size_t align_drift, size_t size_of_type);
@@ -124,17 +126,22 @@ unsigned int lib_ring_buffer_align(size_t align_drift, size_t size_of_type)
 
 #else
 
-# define RING_BUFFER_ALIGN_ATTR __attribute__((packed))
+# define LTTNG_UST_RING_BUFFER_ALIGN_ATTR __attribute__((packed))
 
 /*
- * Calculate the offset needed to align the type.
- * size_of_type must be non-zero.
+ * lib_ring_buffer_align - Calculate the offset needed to align the type.
+ * @align_drift:  object offset from an "alignment"-aligned address.
+ * @size_of_type: Must be non-zero, power of 2.
  */
 static inline lttng_ust_notrace
 unsigned int lib_ring_buffer_align(size_t align_drift, size_t size_of_type);
 static inline
 unsigned int lib_ring_buffer_align(size_t align_drift, size_t size_of_type)
 {
+       /*
+        * On architectures with efficient unaligned memory access, the content
+        * of the ringbuffer is packed and so the offset is always zero.
+        */
        return 0;
 }
 
index b451eae626f427058cd0e77dc686b2a31795a705..3a771e9b135c48aec798a18082d1203779580ec9 100644 (file)
 
 #include <lttng/ust-arch.h>
 #include <lttng/ust-compiler.h>
-#include <lttng/ust-config.h>
 #include <lttng/ust-utils.h>
 #include <lttng/ust-version.h>
 
+/*
+ * Default to having the content of the ringbuffer respect the natural
+ * alignment of the system. Only pack its content on architectures we know
+ * have efficient unaligned memory access.
+ */
 #ifndef LTTNG_UST_ARCH_HAS_EFFICIENT_UNALIGNED_ACCESS
-/* Align data on its natural alignment */
-#define RING_BUFFER_ALIGN
+#define LTTNG_UST_RING_BUFFER_NATURAL_ALIGN
 #endif
 
-#ifdef RING_BUFFER_ALIGN
+#ifdef LTTNG_UST_RING_BUFFER_NATURAL_ALIGN
 #define lttng_alignof(type)    __alignof__(type)
 #else
 #define lttng_alignof(type)    1
This page took 0.028812 seconds and 4 git commands to generate.