From: Masami Hiramatsu (Google) <mhiramat@kernel.org>
To: Jason Xing <kerneljasonxing@gmail.com>
Cc: axboe@kernel.dk, rostedt@goodmis.org,
mathieu.desnoyers@efficios.com, akpm@linux-foundation.org,
linux-kernel@vger.kernel.org, linux-block@vger.kernel.org,
linux-trace-kernel@vger.kernel.org,
Jason Xing <kernelxing@tencent.com>,
Yushan Zhou <katrinzhou@tencent.com>
Subject: Re: [PATCH v1 2/5] relayfs: introduce dump of relayfs statistics function
Date: Wed, 14 May 2025 10:29:08 +0900 [thread overview]
Message-ID: <20250514102908.6a431966ef5b0f5f197bdb48@kernel.org> (raw)
In-Reply-To: <CAL+tcoAGCdowY14QL7HEqbW3ewAJi0OXpWNVkbqq9cM6xRmLkg@mail.gmail.com>
On Tue, 13 May 2025 21:46:25 +0800
Jason Xing <kerneljasonxing@gmail.com> wrote:
> > > > > +
> > > > > + if (flags & RELAY_DUMP_BUF_FULL)
> > > > > + offset += snprintf(buf, sizeof(unsigned int), "%u", full_counter);
> > > > > +
> > > > > + snprintf(buf + offset, 1, "\n");
> > > >
> > > > Is there any reason to return the value as string?
> > > > If it returns a digit value and the caller makes it a string,
> > > > it could be more flexible for other use cases.
> > >
> > > Thanks for the feedback.
> > >
> > > I will remove the above one as you pointed out in the next revision.
> > > And it seems unnecessary to add '\0' at the end of the buffer like
> > > "*buf = '\0';"?
> >
> > Sorry, I think you missed my point. I meant it should be
> >
> > /* Return the number of fullfilled buffer in the channel */
> > size_t relay_full(struct rchan *chan);
> >
> > And keep the snprintf() in the blk_dropped_read() because that function
> > is responsible for formatting the output.
>
> Oh, sorry, it's not what I want because (please see patch [4/5] [1])
> relay_dump() works to print various statistics of the buffer. In this
> patch, 'full' counter is the first one.
>
> [1]: https://lore.kernel.org/all/20250512024935.64704-5-kerneljasonxing@gmail.com/
Yes, that's why I asked you to make it just returning raw value.
The string formatting of those values is blk_dropped_read()s business
(because it is a 'read' callback), not for relayfs.
For example, other relayfs user wants to summarize the values or
calculate the percentage form that value. Also, we don't need to
bother to check the buffer size etc, because blk_dropped_read()
knows that.
>
> >
> > static ssize_t blk_dropped_read(struct file *filp, char __user *buffer,
> > size_t count, loff_t *ppos)
> > {
> > struct blk_trace *bt = filp->private_data;
> > char buf[16];
> >
> > snprintf(buf, sizeof(buf), "%zu\n", relay_full(bt->rchan));
> >
> > return simple_read_from_buffer(buffer, count, ppos, buf, strlen(buf));
> > }
> >
> > But the question is that what blk_subbuf_start_callback() counts
> > is really equal to what the relay_full() counts, because it seems
> > relay_full() just returns the current status of the channel, but
> > bt->dropped is the accumlated number of dropping events.
> >
> > This means that if the client (reader) reads the subbufs the
> > number of full subbufs will be decreased, but the number of
> > dropped event does not change.
>
> At least in this series, I didn't give the 'full' counter any chance
> to decrement, which means it's compatible with blktrace, unless
> __relay_reset() is triggered :)
Ah, OK. I missed what [1/5] does. I agree that this does the
same thing.
>
> While discussing with you on this point, I suddenly recalled that in
> some network drivers, they implemented 'wake' and 'stop' as a pair to
> know what the current status of a certain queue is. I think I can add
> a similar thing to the buffer about 1) how many times are the buffer
> full, 2) how many times does the buffer get rid of being full.
Sounds nice.
Thank you,
>
> Thanks,
> Jason
>
> >
> > Can you recheck it?
> >
> > Thank you,
> >
> > >
> > > While at it, I'm thinking if I can change the return value of
> > > relay_dump() to "how many bytes do we actually write into the buffer"?
> > > Does it sound better?
> > >
> > > Thanks,
> > > Jason
> > >
> > > >
> > > > Thank you,
> > > >
> > > > > +}
> > > > > +EXPORT_SYMBOL_GPL(relay_dump);
> > > > > +
> > > > > /**
> > > > > * relay_file_open - open file op for relay files
> > > > > * @inode: the inode
> > > > > --
> > > > > 2.43.5
> > > > >
> > > >
> > > >
> > > > --
> > > > Masami Hiramatsu (Google) <mhiramat@kernel.org>
> >
> >
> > --
> > Masami Hiramatsu (Google) <mhiramat@kernel.org>
--
Masami Hiramatsu (Google) <mhiramat@kernel.org>
next prev parent reply other threads:[~2025-05-14 1:29 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-05-12 2:49 [PATCH v1 0/5] relayfs: misc changes Jason Xing
2025-05-12 2:49 ` [PATCH v1 1/5] relayfs: support a counter tracking if per-cpu buffers is full Jason Xing
2025-05-13 0:51 ` Andrew Morton
2025-05-13 1:37 ` Jason Xing
2025-05-12 2:49 ` [PATCH v1 2/5] relayfs: introduce dump of relayfs statistics function Jason Xing
2025-05-13 0:51 ` Andrew Morton
2025-05-13 1:48 ` Jason Xing
2025-05-13 2:04 ` Andrew Morton
2025-05-13 2:26 ` Jason Xing
2025-05-13 3:41 ` Andrew Morton
2025-05-13 3:48 ` Jason Xing
2025-05-13 9:58 ` Masami Hiramatsu
2025-05-13 10:32 ` Jason Xing
2025-05-13 13:22 ` Masami Hiramatsu
2025-05-13 13:46 ` Jason Xing
2025-05-14 1:29 ` Masami Hiramatsu [this message]
2025-05-14 2:06 ` Jason Xing
2025-05-12 2:49 ` [PATCH v1 3/5] blktrace: use rbuf->stats.full as a drop indicator in relayfs Jason Xing
2025-05-12 2:49 ` [PATCH v1 4/5] relayfs: support a counter tracking if data is too big to write Jason Xing
2025-05-12 2:49 ` [PATCH v1 5/5] relayfs: uniformally use possible cpu iteration Jason Xing
2025-05-13 0:52 ` Andrew Morton
2025-05-13 2:03 ` Jason Xing
2025-05-13 3:21 ` Andrew Morton
2025-05-13 3:25 ` Jason Xing
2025-05-13 5:52 ` Jason Xing
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20250514102908.6a431966ef5b0f5f197bdb48@kernel.org \
--to=mhiramat@kernel.org \
--cc=akpm@linux-foundation.org \
--cc=axboe@kernel.dk \
--cc=katrinzhou@tencent.com \
--cc=kerneljasonxing@gmail.com \
--cc=kernelxing@tencent.com \
--cc=linux-block@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-trace-kernel@vger.kernel.org \
--cc=mathieu.desnoyers@efficios.com \
--cc=rostedt@goodmis.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.