Thread (6 messages) 6 messages, 2 authors, 2024-01-04

Re: [PATCH v9 1/2] ring-buffer: Introducing ring-buffer mapping functions

From: Steven Rostedt <rostedt@goodmis.org>
Date: 2024-01-04 18:27:45
Also in: lkml

On Thu, 21 Dec 2023 12:58:13 -0500
Steven Rostedt [off-list ref] wrote:
On Thu, 21 Dec 2023 17:35:22 +0000
Vincent Donnefort [off-list ref] wrote:
quoted
@@ -5999,6 +6078,307 @@ int ring_buffer_subbuf_order_set(struct trace_buffer *buffer, int order)
 }
 EXPORT_SYMBOL_GPL(ring_buffer_subbuf_order_set);
   
The kernel developers have agreed to allow loop variables to be declared in
loops. This will simplify these macros:


quoted
+#define subbuf_page(off, start) \
+	virt_to_page((void *)(start + (off << PAGE_SHIFT)))
+
+#define foreach_subbuf_page(off, sub_order, start, page)	\
+	for (off = 0, page = subbuf_page(0, start);		\
+	     off < (1 << sub_order);				\
+	     off++, page = subbuf_page(off, start))  
#define foreach_subbuf_page(sub_order, start, page)		\
	for (int __off = 0, page = subbuf_page(0, (start));	\
	     __off < (1 << (sub_order));			\
	     __off++, page = subbuf_page(__off, (start)))
So it seems that you can't declare "int __off" with page there, but we
could have:

#define foreach_subbuf_page(sub_order, start, page)		\
	page = subbuf_page(0, (start));				\
	for (int __off = 0; __off < (1 << (sub_order));		\
	     __off++, page = subbuf_page(__off, (start)))


And that would work.

-- Steve
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help