[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20220422182052.4994525d@gandalf.local.home>
Date: Fri, 22 Apr 2022 18:20:52 -0400
From: Steven Rostedt <rostedt@...dmis.org>
To: Kent Overstreet <kent.overstreet@...il.com>
Cc: Christoph Hellwig <hch@....de>, linux-kernel@...r.kernel.org,
linux-mm@...ck.org, linux-fsdevel@...r.kernel.org,
hannes@...xchg.org, akpm@...ux-foundation.org,
linux-clk@...r.kernel.org, linux-tegra@...r.kernel.org,
linux-input@...r.kernel.org, roman.gushchin@...ux.dev
Subject: Re: [PATCH v2 1/8] lib/printbuf: New data structure for
heap-allocated strings
On Fri, 22 Apr 2022 17:51:46 -0400
Kent Overstreet <kent.overstreet@...il.com> wrote:
>
> But it's definitely not an unreasonable idea - I can try it out and see how it
> turns out. Would you have any objections to making some changes to seq_buf?
No I don't mind, and that's why I want the coupled, as enhancements or bug
fixes would happen to both.
>
> - You've got size and len as size_t, I've got them as unsigned. Given that we
> need to be checking for overflow anyways for correctens, I like having them
> as u32s.
I had it as size_t as I had planned (and still plan to) make seq_file use
seq_buf, and seq_file uses size_t. Who knows, perhaps in the future, we may
have strings that are more than 4GBs. ;-)
> - seq_buf->readpos - it looks like this is only used by seq_buf_to_user(), does
> it need to be in seq_buf?
Perhaps.
> - in printbufs, I make sure the buffer is always nul-terminated - seems
> simplest, given that we need to make sure there's always room for the
> terminating nul anyways.
I'm not against that. It was an optimization, but I never actually
benchmarked it. But I'm not sure how many fast paths it is used in to
warrant that kind of optimization over the complexity it can bring for
users.
>
> A downside of having printbuf on top of seq_buf is that now we've got two apis
> that functions can output to - vs. if we modified printbuf by adding a flag for
> "this is an external buffer, don't reallocate it". That approach would be less
> code overall, for sure.
>
> Could I get you to look over printbuf and share your thoughts on the different
> approaches?
Sure, but will have to wait till next week.
-- Steve
Powered by blists - more mailing lists