[RFC,lttng-modules,02/10] Define max nesting count constant

Message ID 1490966239-21284-3-git-send-email-mathieu.desnoyers@efficios.com
State RFC
Headers show
Series
  • Callstack context for kernel tracer
Related show

Commit Message

Mathieu Desnoyers March 31, 2017, 1:17 p.m. UTC
From: Francis Giraldeau <francis.giraldeau at gmail.com>

Extract the constant within the code as #define. The define is added to
frontend.h in order to be included in other source files.

Signed-off-by: Francis Giraldeau <francis.giraldeau at gmail.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers at efficios.com>
---
 lib/ringbuffer/frontend.h     | 3 +++
 lib/ringbuffer/frontend_api.h | 2 +-
 2 files changed, 4 insertions(+), 1 deletion(-)

Patch

diff --git a/lib/ringbuffer/frontend.h b/lib/ringbuffer/frontend.h
index 6ff1545..4b9b011 100644
--- a/lib/ringbuffer/frontend.h
+++ b/lib/ringbuffer/frontend.h
@@ -51,6 +51,9 @@ 
 /* Internal helpers */
 #include <wrapper/ringbuffer/frontend_internal.h>
 
+/* Max ring buffer nesting count, see lib_ring_buffer_get_cpu(). */
+#define RING_BUFFER_MAX_NESTING 4
+
 /* Buffer creation/removal and setup operations */
 
 /*
diff --git a/lib/ringbuffer/frontend_api.h b/lib/ringbuffer/frontend_api.h
index a6f2c6f..85943b9 100644
--- a/lib/ringbuffer/frontend_api.h
+++ b/lib/ringbuffer/frontend_api.h
@@ -58,7 +58,7 @@  int lib_ring_buffer_get_cpu(const struct lib_ring_buffer_config *config)
 	nesting = ++per_cpu(lib_ring_buffer_nesting, cpu);
 	barrier();
 
-	if (unlikely(nesting > 4)) {
+	if (unlikely(nesting > RING_BUFFER_MAX_NESTING)) {
 		WARN_ON_ONCE(1);
 		per_cpu(lib_ring_buffer_nesting, cpu)--;
 		rcu_read_unlock_sched_notrace();