diff options
author | Kent Overstreet <kent.overstreet@gmail.com> | 2022-05-20 14:26:53 -0400 |
---|---|---|
committer | Kent Overstreet <kent.overstreet@gmail.com> | 2022-08-07 21:08:02 -0400 |
commit | 39a0d5c32b0ee85af1ecefedaec659e6184ea56a (patch) | |
tree | 21658f1f995009b5898741e6e62b9ae48dbfb19d /include | |
parent | 4c144633669377b56b772fb39f0e0f412b02b906 (diff) |
tracing: Convert to printbuf
This converts the seq_bufs in dynevent_cmd and trace_seq to printbufs.
- read_pos in seq_buf doesn't exist in printbuf, so is added to
trace_seq
- seq_buf_to_user doesn't have a printbuf equivalent, so is inlined
into trace_seq_to_user
- seq_buf_putmem_hex currently swabs bytes on little endian, hardcoded
to 8 byte units. This patch switches it to prt_hex_bytes(), which
does _not_ swab.
Otherwise this is largely a direct conversion, with a few slight
refactorings and cleanups.
Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
Cc: Steven Rostedt <rostedt@goodmis.org>
Cc: Ingo Molnar <mingo@redhat.com>
Diffstat (limited to 'include')
-rw-r--r-- | include/linux/trace_events.h | 2 | ||||
-rw-r--r-- | include/linux/trace_seq.h | 17 |
2 files changed, 12 insertions, 7 deletions
diff --git a/include/linux/trace_events.h b/include/linux/trace_events.h index b18759a673c6..4cb7cacb57b1 100644 --- a/include/linux/trace_events.h +++ b/include/linux/trace_events.h @@ -496,7 +496,7 @@ struct dynevent_cmd; typedef int (*dynevent_create_fn_t)(struct dynevent_cmd *cmd); struct dynevent_cmd { - struct seq_buf seq; + struct printbuf seq; const char *event_name; unsigned int n_fields; enum dynevent_type type; diff --git a/include/linux/trace_seq.h b/include/linux/trace_seq.h index 5a2c650d9e1c..d2b51007b3b9 100644 --- a/include/linux/trace_seq.h +++ b/include/linux/trace_seq.h @@ -2,10 +2,12 @@ #ifndef _LINUX_TRACE_SEQ_H #define _LINUX_TRACE_SEQ_H -#include <linux/seq_buf.h> +#include <linux/printbuf.h> #include <asm/page.h> +struct seq_file; + /* * Trace sequences are used to allow a function to call several other functions * to create a string of data to use (up to a max of PAGE_SIZE). @@ -13,14 +15,16 @@ struct trace_seq { char buffer[PAGE_SIZE]; - struct seq_buf seq; + struct printbuf seq; + unsigned readpos; int full; }; static inline void trace_seq_init(struct trace_seq *s) { - seq_buf_init(&s->seq, s->buffer, PAGE_SIZE); + s->seq = PRINTBUF_EXTERN(s->buffer, PAGE_SIZE); + s->readpos = 0; s->full = 0; } @@ -39,7 +43,7 @@ trace_seq_init(struct trace_seq *s) */ static inline int trace_seq_used(struct trace_seq *s) { - return seq_buf_used(&s->seq); + return printbuf_written(&s->seq); } /** @@ -54,7 +58,7 @@ static inline int trace_seq_used(struct trace_seq *s) static inline char * trace_seq_buffer_ptr(struct trace_seq *s) { - return s->buffer + seq_buf_used(&s->seq); + return s->buffer + printbuf_written(&s->seq); } /** @@ -66,7 +70,7 @@ trace_seq_buffer_ptr(struct trace_seq *s) */ static inline bool trace_seq_has_overflowed(struct trace_seq *s) { - return s->full || seq_buf_has_overflowed(&s->seq); + return s->full || printbuf_overflowed(&s->seq); } /* @@ -87,6 +91,7 @@ extern void trace_seq_putc(struct trace_seq *s, unsigned char c); extern void trace_seq_putmem(struct trace_seq *s, const void *mem, unsigned int len); extern void trace_seq_putmem_hex(struct trace_seq *s, const void *mem, unsigned int len); +struct path; extern int trace_seq_path(struct trace_seq *s, const struct path *path); extern void trace_seq_bitmask(struct trace_seq *s, const unsigned long *maskp, |