[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAL+tcoB=HYB-EnyYTK=HzpgsosbOwo2VxMw-_mzbkSYnEWAVqw@mail.gmail.com>
Date: Fri, 16 May 2025 10:32:30 +0800
From: Jason Xing <kerneljasonxing@...il.com>
To: Masami Hiramatsu <mhiramat@...nel.org>
Cc: axboe@...nel.dk, rostedt@...dmis.org, mathieu.desnoyers@...icios.com,
akpm@...ux-foundation.org, linux-kernel@...r.kernel.org,
linux-block@...r.kernel.org, linux-trace-kernel@...r.kernel.org,
Jason Xing <kernelxing@...cent.com>, Yushan Zhou <katrinzhou@...cent.com>
Subject: Re: [PATCH v2 2/4] relayfs: introduce dump of relayfs statistics function
On Fri, May 16, 2025 at 10:08 AM Masami Hiramatsu <mhiramat@...nel.org> wrote:
>
> On Thu, 15 May 2025 14:16:41 +0800
> Jason Xing <kerneljasonxing@...il.com> wrote:
>
> > From: Jason Xing <kernelxing@...cent.com>
> >
> > In this version, only support dumping the counter for buffer full and
> > implement the framework of how it works.
> >
> > Users can pass certain flag to fetch what field/statistics they expect
> > to know. Each time it only returns one result. So do not pass multiple
> > flags.
> >
> > Reviewed-by: Yushan Zhou <katrinzhou@...cent.com>
> > Signed-off-by: Jason Xing <kernelxing@...cent.com>
> > ---
> > v2
> > 1. refactor relay_dump() and make it only return a pure size_t result
> > of the value that users specifies.
> > 2. revise the commit log.
> > ---
> > include/linux/relay.h | 7 +++++++
> > kernel/relay.c | 31 +++++++++++++++++++++++++++++++
> > 2 files changed, 38 insertions(+)
> >
> > diff --git a/include/linux/relay.h b/include/linux/relay.h
> > index ce7a1b396872..3fb285716e34 100644
> > --- a/include/linux/relay.h
> > +++ b/include/linux/relay.h
> > @@ -31,6 +31,12 @@
> > /*
> > * Relay buffer statistics dump
> > */
> > +enum {
> > + RELAY_DUMP_BUF_FULL = (1 << 0),
> > +
> > + RELAY_DUMP_LAST = RELAY_DUMP_BUF_FULL,
> > +};
> > +
> > struct rchan_buf_stats
> > {
> > unsigned int full_count; /* counter for buffer full */
> > @@ -167,6 +173,7 @@ struct rchan *relay_open(const char *base_filename,
> > void *private_data);
> > extern void relay_close(struct rchan *chan);
> > extern void relay_flush(struct rchan *chan);
> > +extern size_t relay_dump(struct rchan *chan, int flags);
> > extern void relay_subbufs_consumed(struct rchan *chan,
> > unsigned int cpu,
> > size_t consumed);
> > diff --git a/kernel/relay.c b/kernel/relay.c
> > index eb3f630f3896..f47fc750e559 100644
> > --- a/kernel/relay.c
> > +++ b/kernel/relay.c
> > @@ -701,6 +701,37 @@ void relay_flush(struct rchan *chan)
> > }
> > EXPORT_SYMBOL_GPL(relay_flush);
> >
> > +/**
> > + * relay_dump - dump channel buffer statistics
>
> nit: relay_dump() can mislead to dump relay channel contents.
> Can you rename it to relay_stats() or relay_get_stats()?
Sure, both are good names. I would choose relay_stats().
Thanks,
Jason
>
> Thanks,
>
> > + * @chan: the channel
> > + * @flags: select particular information to dump
> > + *
> > + * Returns the count of certain field that caller specifies.
> > + */
> > +size_t relay_dump(struct rchan *chan, int flags)
> > +{
> > + unsigned int i, count = 0;
> > + struct rchan_buf *rbuf;
> > +
> > + if (!chan || flags > RELAY_DUMP_LAST)
> > + return 0;
> > +
> > + if (chan->is_global) {
> > + rbuf = *per_cpu_ptr(chan->buf, 0);
> > + if (flags & RELAY_DUMP_BUF_FULL)
> > + count = rbuf->stats.full_count;
> > + } else {
> > + for_each_online_cpu(i) {
> > + if ((rbuf = *per_cpu_ptr(chan->buf, i)))
> > + if (flags & RELAY_DUMP_BUF_FULL)
> > + count += rbuf->stats.full_count;
> > + }
> > + }
> > +
> > + return count;
> > +}
> > +EXPORT_SYMBOL_GPL(relay_dump);
> > +
> > /**
> > * relay_file_open - open file op for relay files
> > * @inode: the inode
> > --
> > 2.43.5
> >
>
>
> --
> Masami Hiramatsu (Google) <mhiramat@...nel.org>
Powered by blists - more mailing lists