Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1332865

[RFC][PATCH 01/10] tracing: Move some constants to ring_buffer.h

From Tom Zanussi <tom.zanussi@linux.intel.com>
Newsgroups linux.kernel
Subject [RFC][PATCH 01/10] tracing: Move some constants to ring_buffer.h
Date 2016-02-12 17:20 +0100
Message-ID <r1oBR-SL-41@gated-at.bofh.it> (permalink)
References <r1oBQ-SL-7@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


For eBPF trace event support, we need to be able to inform the eBPF
verifier about legal accesses to the event buffer, which means we need
some of the ring_buffer constants.  This moves what we need along with
related constants to the ring_buffer header file.

Signed-off-by: Tom Zanussi <tom.zanussi@linux.intel.com>
---
 include/linux/ring_buffer.h | 35 +++++++++++++++++++++++++++++++++++
 kernel/trace/ring_buffer.c  | 31 -------------------------------
 2 files changed, 35 insertions(+), 31 deletions(-)

diff --git a/include/linux/ring_buffer.h b/include/linux/ring_buffer.h
index 4acc552..6da902f 100644
--- a/include/linux/ring_buffer.h
+++ b/include/linux/ring_buffer.h
@@ -6,6 +6,8 @@
 #include <linux/seq_file.h>
 #include <linux/poll.h>
 
+#include <asm/local.h>
+
 struct ring_buffer;
 struct ring_buffer_iter;
 
@@ -198,4 +200,37 @@ enum ring_buffer_flags {
 	RB_FL_OVERWRITE		= 1 << 0,
 };
 
+/* Used for individual buffers (after the counter) */
+#define RB_BUFFER_OFF		(1 << 20)
+
+#define BUF_PAGE_HDR_SIZE offsetof(struct buffer_data_page, data)
+
+#define RB_EVNT_HDR_SIZE (offsetof(struct ring_buffer_event, array))
+#define RB_ALIGNMENT		4U
+#define RB_MAX_SMALL_DATA	(RB_ALIGNMENT * RINGBUF_TYPE_DATA_TYPE_LEN_MAX)
+#define RB_EVNT_MIN_SIZE	8U	/* two 32bit words */
+
+#ifndef CONFIG_HAVE_64BIT_ALIGNED_ACCESS
+# define RB_FORCE_8BYTE_ALIGNMENT	0
+# define RB_ARCH_ALIGNMENT		RB_ALIGNMENT
+#else
+# define RB_FORCE_8BYTE_ALIGNMENT	1
+# define RB_ARCH_ALIGNMENT		8U
+#endif
+
+#define RB_ALIGN_DATA		__aligned(RB_ARCH_ALIGNMENT)
+
+struct buffer_data_page {
+	u64		 time_stamp;	/* page time stamp */
+	local_t		 commit;	/* write committed index */
+	unsigned char	 data[] RB_ALIGN_DATA;	/* data of buffer page */
+};
+
+#define BUF_PAGE_HDR_SIZE offsetof(struct buffer_data_page, data)
+
+#define BUF_PAGE_SIZE (PAGE_SIZE - BUF_PAGE_HDR_SIZE)
+
+/* Max payload is BUF_PAGE_SIZE - header (8bytes) */
+#define BUF_MAX_DATA_SIZE (BUF_PAGE_SIZE - (sizeof(u32) * 2))
+
 #endif /* _LINUX_RING_BUFFER_H */
diff --git a/kernel/trace/ring_buffer.c b/kernel/trace/ring_buffer.c
index 9c6045a..1af61d6 100644
--- a/kernel/trace/ring_buffer.c
+++ b/kernel/trace/ring_buffer.c
@@ -115,26 +115,6 @@ int ring_buffer_print_entry_header(struct trace_seq *s)
  *
  */
 
-/* Used for individual buffers (after the counter) */
-#define RB_BUFFER_OFF		(1 << 20)
-
-#define BUF_PAGE_HDR_SIZE offsetof(struct buffer_data_page, data)
-
-#define RB_EVNT_HDR_SIZE (offsetof(struct ring_buffer_event, array))
-#define RB_ALIGNMENT		4U
-#define RB_MAX_SMALL_DATA	(RB_ALIGNMENT * RINGBUF_TYPE_DATA_TYPE_LEN_MAX)
-#define RB_EVNT_MIN_SIZE	8U	/* two 32bit words */
-
-#ifndef CONFIG_HAVE_64BIT_ALIGNED_ACCESS
-# define RB_FORCE_8BYTE_ALIGNMENT	0
-# define RB_ARCH_ALIGNMENT		RB_ALIGNMENT
-#else
-# define RB_FORCE_8BYTE_ALIGNMENT	1
-# define RB_ARCH_ALIGNMENT		8U
-#endif
-
-#define RB_ALIGN_DATA		__aligned(RB_ARCH_ALIGNMENT)
-
 /* define RINGBUF_TYPE_DATA for 'case RINGBUF_TYPE_DATA:' */
 #define RINGBUF_TYPE_DATA 0 ... RINGBUF_TYPE_DATA_TYPE_LEN_MAX
 
@@ -280,12 +260,6 @@ EXPORT_SYMBOL_GPL(ring_buffer_event_data);
 /* Missed count stored at end */
 #define RB_MISSED_STORED	(1 << 30)
 
-struct buffer_data_page {
-	u64		 time_stamp;	/* page time stamp */
-	local_t		 commit;	/* write committed index */
-	unsigned char	 data[] RB_ALIGN_DATA;	/* data of buffer page */
-};
-
 /*
  * Note, the buffer_page list must be first. The buffer pages
  * are allocated in cache lines, which means that each buffer
@@ -355,11 +329,6 @@ static inline int test_time_stamp(u64 delta)
 	return 0;
 }
 
-#define BUF_PAGE_SIZE (PAGE_SIZE - BUF_PAGE_HDR_SIZE)
-
-/* Max payload is BUF_PAGE_SIZE - header (8bytes) */
-#define BUF_MAX_DATA_SIZE (BUF_PAGE_SIZE - (sizeof(u32) * 2))
-
 int ring_buffer_print_page_header(struct trace_seq *s)
 {
 	struct buffer_data_page field;
-- 
1.9.3

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[RFC][PATCH 00/10] Add trace event support to eBPF Tom Zanussi <tom.zanussi@linux.intel.com> - 2016-02-12 17:20 +0100
  [RFC][PATCH 02/10] eBPF: Add BPF_PROG_TYPE_TRACE_EVENT prog type Tom Zanussi <tom.zanussi@linux.intel.com> - 2016-02-12 17:20 +0100
  [RFC][PATCH 05/10] eBPF/tracing: Add eBPF trace event field access helpers Tom Zanussi <tom.zanussi@linux.intel.com> - 2016-02-12 17:20 +0100
  [RFC][PATCH 03/10] tracing: Add an 'accessor' function to ftrace_event_field Tom Zanussi <tom.zanussi@linux.intel.com> - 2016-02-12 17:20 +0100
  [RFC][PATCH 06/10] tracing: Add kprobe/uprobe support for TRACE_EVENT eBPF progs Tom Zanussi <tom.zanussi@linux.intel.com> - 2016-02-12 17:20 +0100
  [RFC][PATCH 04/10] tracing: Add trace event accessor functions Tom Zanussi <tom.zanussi@linux.intel.com> - 2016-02-12 17:20 +0100
  [RFC][PATCH 01/10] tracing: Move some constants to ring_buffer.h Tom Zanussi <tom.zanussi@linux.intel.com> - 2016-02-12 17:20 +0100
  [RFC][PATCH 10/10] samples/bpf: Add kprobe-event-fields example Tom Zanussi <tom.zanussi@linux.intel.com> - 2016-02-12 17:20 +0100
  [RFC][PATCH 07/10] tracing: Add eBPF program support to static trace events Tom Zanussi <tom.zanussi@linux.intel.com> - 2016-02-12 17:20 +0100
  Re: [RFC][PATCH 00/10] Add trace event support to eBPF Alexei Starovoitov <alexei.starovoitov@gmail.com> - 2016-02-14 01:10 +0100
    Re: [RFC][PATCH 00/10] Add trace event support to eBPF Tom Zanussi <tom.zanussi@linux.intel.com> - 2016-02-16 23:40 +0100
      Re: [RFC][PATCH 00/10] Add trace event support to eBPF Alexei Starovoitov <alexei.starovoitov@gmail.com> - 2016-02-17 06:00 +0100
        Re: [RFC][PATCH 00/10] Add trace event support to eBPF Tom Zanussi <tom.zanussi@linux.intel.com> - 2016-02-18 22:30 +0100
          Re: [RFC][PATCH 00/10] Add trace event support to eBPF Daniel Borkmann <daniel@iogearbox.net> - 2016-02-18 23:50 +0100
          Re: [RFC][PATCH 00/10] Add trace event support to eBPF Alexei Starovoitov <alexei.starovoitov@gmail.com> - 2016-02-19 05:20 +0100

csiph-web