Re: [RFC][PATCH 03/12 v3] tracing: Create seq_buf layer in trace_seq

Steven Rostedt
2014-11-07T19:10:45Z

On Fri, 07 Nov 2014 10:59:27 -0800
Joe Perches <joe@perches.com> wrote:

> > Create a seq_buf layer that trace_seq sits on. The seq_buf will not
> > be limited to page size. This will allow other usages of seq_buf
> > instead of a hard set PAGE_SIZE one that trace_seq has.
> >
> > Link: http://lkml.kernel.org/r/20141104160221.864997179@goodmis.org
> []
> > diff --git a/include/linux/seq_buf.h b/include/linux/seq_buf.h
> []
> > +extern __printf(2, 3)
> > +int seq_buf_printf(struct seq_buf *s, const char *fmt, ...);
> > +extern __printf(2, 0)
> > +int seq_buf_vprintf(struct seq_buf *s, const char *fmt, va_list args);
> > +extern int
> > +seq_buf_bprintf(struct seq_buf *s, const char *fmt, const u32 *binary);
> > +extern int seq_buf_print_seq(struct seq_file *m, struct seq_buf *s);
> > +extern int seq_buf_to_user(struct seq_buf *s, char __user *ubuf,
> > + int cnt);
> > +extern int seq_buf_puts(struct seq_buf *s, const char *str);
> > +extern int seq_buf_putc(struct seq_buf *s, unsigned char c);
> > +extern int seq_buf_putmem(struct seq_buf *s, const void *mem, unsigned int len);
> > +extern int seq_buf_putmem_hex(struct seq_buf *s, const void *mem,
> > + unsigned int len);
> > +extern int seq_buf_path(struct seq_buf *s, const struct path *path);
> > +
> > +extern int seq_buf_bitmask(struct seq_buf *s, const unsigned long *maskp,
> > + int nmaskbits);
>
> Maybe remove the extern bits from the function definitions?

Yeah, probably should have done that. Not sure why I kept them. Cut and
paste?

> And maybe the unsigned int len/cnt could be size_t

The struct does get changed later to match seq_file.

>
> > diff --git a/include/linux/trace_seq.h b/include/linux/trace_seq.h
> []
> > @@ -12,16 +12,14 @@
> >
> > struct trace_seq {
> > unsigned char buffer[PAGE_SIZE];
> > - unsigned int len;
> > - unsigned int readpos;
> > + struct seq_buf seq;
> > int full;
> > };
> >
> > static inline void
> > trace_seq_init(struct trace_seq *s)
> > {
> > - s->len = 0;
> > - s->readpos = 0;
> > + seq_buf_init(&s->seq, s->buffer, PAGE_SIZE);
>
> Maybe the PAGE_SIZE uses could be ARRAY_SIZE(s->buffer)
>
> > diff --git a/kernel/trace/trace_seq.c b/kernel/trace/trace_seq.c
> []
> > /* How much buffer is written? */
> > -#define TRACE_SEQ_BUF_USED(s) min((s)->len, (unsigned int)(PAGE_SIZE - 1))
> > +#define TRACE_SEQ_BUF_USED(s) min((s)->seq.len, (unsigned int)(PAGE_SIZE - 1))
>
> min_t?
> maybe this should be FIELD_SIZEOF(struct trace_seq, buffer) - 1

These can be done at a later time. This patch set is focusing on
creation of seq_buf, not cleaning up trace_seq.

-- Steve