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 43ACEC433EF for ; Tue, 21 Jun 2022 03:11:04 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id C209C6B0072; Mon, 20 Jun 2022 23:11:03 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id BD15B8E0001; Mon, 20 Jun 2022 23:11:03 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id A730A6B0074; Mon, 20 Jun 2022 23:11:03 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id 999EE6B0072 for ; Mon, 20 Jun 2022 23:11:03 -0400 (EDT) Received: from smtpin05.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 69CDA20637 for ; Tue, 21 Jun 2022 03:11:03 +0000 (UTC) X-FDA: 79600766406.05.4162154 Received: from mail-qk1-f177.google.com (mail-qk1-f177.google.com [209.85.222.177]) by imf14.hostedemail.com (Postfix) with ESMTP id 23003100089 for ; Tue, 21 Jun 2022 03:11:03 +0000 (UTC) Received: by mail-qk1-f177.google.com with SMTP id g15so9146324qke.4 for ; Mon, 20 Jun 2022 20:11:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=VwtrkCyUs94Mby5M4DxsvnJMAG0rgaBoGLdHEt+Fwzo=; b=IT7i6qpkzPP+/B8tR3+2O0f/z5jek6NcrA1b8mQf14+DJksUQjM32sIi6dVwNFOpMw 9cuKnA/jlIqlFcda0c72VqV5MJXOVPPflMokzlYZQD1bMNpjDWpr05TVOkOKZ/l0WB03 ea+Hl16MM3s+Bg4l7AMwnTbci7t+tzE5ftuu75m4Vc0xFR6pTCYiPsbUt+QupQTSOrHb 0HZLrKryjd1McRzKDcFKU8eQsO2Vkur3hlWvxNy33L2Fovzv2MnggsozuUnXaO6xE1cc Pb0VqyffkjSNGPT/sbysr1Ks9z5mxZTLe0Z2lYQw67Mg871s3zWiCHcNfFKFBepxaZff 2Avw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=VwtrkCyUs94Mby5M4DxsvnJMAG0rgaBoGLdHEt+Fwzo=; b=SRdqr2z/Vlp9p68ltwb2cHtUDQ3i9hi9FbX11YuHj3O1xGWMAV3/1Cmfvk81SadQmJ ApcHILG6v4TbHK/SF8lUyZEBOuFVKuff7YojmWdyN6co57YZzcWpHaeR3l0lR7oDm+JP koiRxpDsOFxkm1B5Nz4XwE/m7lXaxYUcDekrxYF3C+/uUX1kLVXyFm7d/3TMH92gfzTK FWP07n3qFjgrDYNMWKir6ZT+l83MGNKnqqbG4e0w5Oyvcy+W/3u0aBzn1yPOprU4W7wV /XHASWD4MYAyB2K4QhliEedi7uNEyl4I0CBO93BGe0Ov6WzdZakO7ZhYAl3xuKZG0LZd h7sA== X-Gm-Message-State: AJIora8Jr239GH1TFhNFQ79PtFvqx9ESsXJJjAiheZrK4ZdXAw1C1MrJ gvZnn4OTbZt4tO0McooSYQ== X-Google-Smtp-Source: AGRyM1u6rlI+7jxlDfwReGjJwiNc3ZmlhiTHDLDcH9/FMxzHU+kQWUvCmtXlItRTLwc/8HvCK17Igg== X-Received: by 2002:a05:620a:1336:b0:6a6:b5fe:44cf with SMTP id p22-20020a05620a133600b006a6b5fe44cfmr17941191qkj.525.1655781062424; Mon, 20 Jun 2022 20:11:02 -0700 (PDT) Received: from localhost (c-73-219-103-14.hsd1.vt.comcast.net. [73.219.103.14]) by smtp.gmail.com with ESMTPSA id t9-20020a37ea09000000b006a6be577535sm13767332qkj.85.2022.06.20.20.11.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 20 Jun 2022 20:11:01 -0700 (PDT) Date: Mon, 20 Jun 2022 23:11:01 -0400 From: Kent Overstreet To: David Laight Cc: "linux-kernel@vger.kernel.org" , "linux-mm@kvack.org" , "pmladek@suse.com" , "rostedt@goodmis.org" , "enozhatsky@chromium.org" , "linux@rasmusvillemoes.dk" , "willy@infradead.org" Subject: Re: [PATCH v4 00/34] Printbufs - new data structure for building strings Message-ID: <20220621031101.ex3qwbyywwyy5ctk@moria.home.lan> References: <20220620004233.3805-1-kent.overstreet@gmail.com> <0a5901f8460f452a89c9b0cda32fb833@AcuMS.aculab.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <0a5901f8460f452a89c9b0cda32fb833@AcuMS.aculab.com> ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1655781063; a=rsa-sha256; cv=none; b=ZkFkEZdhN8kgqIn/C9mP3AR4nOHxgYdln75g3+kPjzAPqauMk0xaAWkItmOWvnWHUHldu3 RNQ4FTZOINMIJAkISCtRe7o4MwkI9sCkt35dtEY+tIXIWNU3Bh4U4HfYyEkjn1K1hzqjN1 WeziXpFKgf0KNcmw75j4/rQ/wA9/vQo= ARC-Authentication-Results: i=1; imf14.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=IT7i6qpk; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf14.hostedemail.com: domain of kent.overstreet@gmail.com designates 209.85.222.177 as permitted sender) smtp.mailfrom=kent.overstreet@gmail.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1655781063; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=VwtrkCyUs94Mby5M4DxsvnJMAG0rgaBoGLdHEt+Fwzo=; b=QUYdzi8DI0J4UMutkPmwMBUlNirAnDBB91JNOGrytDvk5ILyR7kUdOPl2oPce0EiNETN1u cBTQpSl5XJ4iSU3WE+U2xBWmFNIYTghmlhCLqw+IY1/9OURnIaezISkgvEKxZnccEVgS8Y VcRgltJ7gvcutjUGnaL0tc6YbY8I8EA= Authentication-Results: imf14.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=IT7i6qpk; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf14.hostedemail.com: domain of kent.overstreet@gmail.com designates 209.85.222.177 as permitted sender) smtp.mailfrom=kent.overstreet@gmail.com X-Stat-Signature: afgxubdcdktgpu3murnn7otjexabzk5r X-Rspamd-Queue-Id: 23003100089 X-Rspam-User: X-Rspamd-Server: rspam03 X-HE-Tag: 1655781062-105191 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000023, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On Mon, Jun 20, 2022 at 04:19:31AM +0000, David Laight wrote: > I really think that is a bad idea. > printk() already uses a lot of stack, anything doing a recursive > call is just making that worse. > Especially since these calls can often be in error paths > which are not often tested and can already be on deep stacks. So it seems this is something you never actually checked, and I naively assumed that you might actually know what you were talking about - an understandable mistake, I think, because vsprintf.c is _a fucking mess_ and high stack usage would be believable. But the main part we're concerned with here, snprint() or prt_printf(), has no such stack usage problems. On v5.18, the frame size is under 64 bytes. On my branch, it's 72 bytes - higher because we do need to save arguments on the stack for the pretty-printer invocation, and there's no way around that without dropping to asm - although I'm allowing up to 8 arguments (besides the printbuf itself), which is probably excessive. So I'm not seeing what you're talking about. In the leaf functions, the individual pretty-printers/%p extensions, those are doing completely ridiculous things and I have fixed them all except symbol_string() on my branch, and I'll get to that one. Having a proper string library with useful helpers really makes things easier, it turns out. As for recursive %pf() invocations blowing the stack? I seriously fucking doubt it, once you're in a pretty-printer where you've already got a printbuf you can output to there's not much reason to be doing recursive calls to prt_printf() passing it yet another pretty printer - that's not where %pf() is convenient, what it makes convenient is using pretty printers when you're calling printk() directly. In a pretty printer fuction, if you want to do recursive pretty-printer calls you'd just call it directly! prt_printf(out, "%pf(%p)"), foo_to_text, foo) is silly when you can just call foo_to_text(out, foo). Now, I ask both of you please take your bureaucratic nitpicky nonsense and, kindly, pretty please with sugar on top - stuff it. I much prefer to work with people who don't waste my time, and who have actual _taste_.