From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 189ACC433EF for ; Fri, 22 Apr 2022 22:20:58 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 7B18E6B0073; Fri, 22 Apr 2022 18:20:57 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 738DC6B0074; Fri, 22 Apr 2022 18:20:57 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 5D9B36B0075; Fri, 22 Apr 2022 18:20:57 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (relay.a.hostedemail.com [64.99.140.24]) by kanga.kvack.org (Postfix) with ESMTP id 4BA136B0073 for ; Fri, 22 Apr 2022 18:20:57 -0400 (EDT) Received: from smtpin24.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 191B220F79 for ; Fri, 22 Apr 2022 22:20:57 +0000 (UTC) X-FDA: 79385936154.24.7938450 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf02.hostedemail.com (Postfix) with ESMTP id F35E28001F for ; Fri, 22 Apr 2022 22:20:54 +0000 (UTC) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id B8EDE61FE0; Fri, 22 Apr 2022 22:20:55 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 16240C385AA; Fri, 22 Apr 2022 22:20:53 +0000 (UTC) Date: Fri, 22 Apr 2022 18:20:52 -0400 From: Steven Rostedt To: Kent Overstreet Cc: Christoph Hellwig , linux-kernel@vger.kernel.org, linux-mm@kvack.org, linux-fsdevel@vger.kernel.org, hannes@cmpxchg.org, akpm@linux-foundation.org, linux-clk@vger.kernel.org, linux-tegra@vger.kernel.org, linux-input@vger.kernel.org, roman.gushchin@linux.dev Subject: Re: [PATCH v2 1/8] lib/printbuf: New data structure for heap-allocated strings Message-ID: <20220422182052.4994525d@gandalf.local.home> In-Reply-To: <20220422215146.i663tn6zzn6blzo3@moria.home.lan> References: <20220421234837.3629927-7-kent.overstreet@gmail.com> <20220422042017.GA9946@lst.de> <20220422052208.GA10745@lst.de> <20220422113736.460058cc@gandalf.local.home> <20220422193015.2rs2wvqwdlczreh3@moria.home.lan> <20220422153916.7ebf20c3@gandalf.local.home> <20220422203057.iscsmurtrmwkpwnq@moria.home.lan> <20220422164744.6500ca06@gandalf.local.home> <20220422215146.i663tn6zzn6blzo3@moria.home.lan> X-Mailer: Claws Mail 3.17.8 (GTK+ 2.24.33; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Rspamd-Server: rspam10 X-Rspamd-Queue-Id: F35E28001F Authentication-Results: imf02.hostedemail.com; dkim=none; spf=pass (imf02.hostedemail.com: domain of "SRS0=ohlw=VA=goodmis.org=rostedt@kernel.org" designates 139.178.84.217 as permitted sender) smtp.mailfrom="SRS0=ohlw=VA=goodmis.org=rostedt@kernel.org"; dmarc=none X-Rspam-User: X-Stat-Signature: bwhuztgaw96fzcoqcbro86x5qam8x5sk X-HE-Tag: 1650666054-781812 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On Fri, 22 Apr 2022 17:51:46 -0400 Kent Overstreet 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