Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp294074iog; Wed, 15 Jun 2022 02:22:54 -0700 (PDT) X-Google-Smtp-Source: ABdhPJySdeB2cUpma+l0lcEHVypsngt8EURM6N7pFvtEMEVJxvOc+6fcVsc61JrHmd8e4huMH6Tg X-Received: by 2002:a50:fd01:0:b0:42e:1e73:955d with SMTP id i1-20020a50fd01000000b0042e1e73955dmr11333494eds.148.1655284973998; Wed, 15 Jun 2022 02:22:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1655284973; cv=none; d=google.com; s=arc-20160816; b=Zx5dW/H+skGZvWe8plwHFX8t1KHpg02BZHOZ35+jUNsliv5nlZ5h4j50gcP3V2/JMF /5bWNnsoTfXnwUPHYI3PLtjZv8ksV85guRqIJexZlh+KaQTX894C1j/7N/xLu2z1LyWG bfUXSn9eYimDo4kdAE5fIlqQ0kauuHC4p9V6wsLqn00ayh7EV6inrbobbvQR5q62BXyR jNpHqzoNWv8VsH4GH0svGMjg/0wfFYpVv5HwglESKEU02ypGE896JuDB7A2F108Vd/A5 NqiJrWAA63W+CJwrtoPqfrshr4nB6NcjaymAryc4MXvLc4YrBA1R9EklvipuRlHBf3px 5y6w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id:dkim-signature; bh=V+kmWLFtKxHFtE7D251rkedl9qOMbdcj3b6CVnfdeSo=; b=VJI2b2J3erDUSznb0zz9mceliJ/Cvj67+3Rm0uXC1/aFC+IysWo9YekOQmsfG+KfT0 W3rkwSy12GaP+HDP7NpKKPX/Qk34oORmoEIpJvS2Cl/gXSE2vRS9Z1+bNz7N5b1LIH9M E7bGIgZGXHF1FfSefZqQ08zdYbNHwQkkF0wcP3WFT8R4eCSLuQ8dmHANxdH0VUPPHXiN wO+mHNIDPsqxk4oKOFSLRnuJpc/wTRn/dfWR00UfvNqJo8QHdRw3X73VkQ7NRfgt2ms0 hgJEGN3DJ4Ud6jqI21kRX50YO2XlVVGieFtmrlH5c2j4yYcLsOUKAz7fxJgIwK+831Mt jZ/A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@rasmusvillemoes.dk header.s=google header.b=NE+mnajr; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id i3-20020a05640242c300b0042dbcd63aabsi16203777edc.587.2022.06.15.02.22.26; Wed, 15 Jun 2022 02:22:53 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@rasmusvillemoes.dk header.s=google header.b=NE+mnajr; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241711AbiFOJJn (ORCPT + 99 others); Wed, 15 Jun 2022 05:09:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50652 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240563AbiFOJJm (ORCPT ); Wed, 15 Jun 2022 05:09:42 -0400 Received: from mail-lj1-x22c.google.com (mail-lj1-x22c.google.com [IPv6:2a00:1450:4864:20::22c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C68459597 for ; Wed, 15 Jun 2022 02:09:38 -0700 (PDT) Received: by mail-lj1-x22c.google.com with SMTP id l18so12490928lje.13 for ; Wed, 15 Jun 2022 02:09:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rasmusvillemoes.dk; s=google; h=message-id:date:mime-version:user-agent:subject:content-language:to :cc:references:from:in-reply-to:content-transfer-encoding; bh=V+kmWLFtKxHFtE7D251rkedl9qOMbdcj3b6CVnfdeSo=; b=NE+mnajrCrACb0200xvrtk/8xRh1Lg8Mt6uhlUrNjoT6kl2fc2JvqJFE6J+FrVBwPR ML8baTpu8Ccv/suOg5ZIVA7dO995FxHEpBsj/tvWgAZ+p/ZWXTaH9w8h0QFOpaOBERiu PMyKXzv5LZfS4zNVXaoect0zbgLE9X3GATL8c= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:date:mime-version:user-agent:subject :content-language:to:cc:references:from:in-reply-to :content-transfer-encoding; bh=V+kmWLFtKxHFtE7D251rkedl9qOMbdcj3b6CVnfdeSo=; b=HxuWJiLiqZtbC0jk7/L4Z8VQpglj0KvZo+WQzADOUtfhSqfqV26TWHzGDi/KnZgVkA ueifh9Re8sNy3klOVtqbckSh6fIybE1GkToDsa3vdAGBWg43wDBYgEfGzaTYMSBQbINA 98roA/oPlG6wqegDz4zsqDScH5T+gWsowddi7Sdt5aWbQb8O2R/y2X/KuFnfNURp9hGi jI8y64Up7dnlciqnpRwFZVRveEgWan3n/5ava6zPYRiV3d+ku5BfrS62GFDQZRd4wMqF f3/P1ji4ztWC9NhxHUUEOC0AvvMAJGZ7yCtytsE7k6KYuDgrIrJCaRTt4GUbE94DX0S7 VxBg== X-Gm-Message-State: AJIora9pOJLvj+qph+Xaq0hFj3vruZcopOjDl0BsJEGzk2zdeAx+vR3R 33N0LSjJjcntN3AZR5Fg1xj4s9i952DL+Gcy X-Received: by 2002:a2e:a583:0:b0:255:877b:5d2d with SMTP id m3-20020a2ea583000000b00255877b5d2dmr4687046ljp.237.1655284176899; Wed, 15 Jun 2022 02:09:36 -0700 (PDT) Received: from [172.21.3.73] ([87.54.42.112]) by smtp.gmail.com with ESMTPSA id t7-20020a2e9547000000b0024f3d1dae84sm1630283ljh.12.2022.06.15.02.09.35 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 15 Jun 2022 02:09:36 -0700 (PDT) Message-ID: Date: Wed, 15 Jun 2022 11:09:35 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.9.1 Subject: Re: [PATCH v3 03/33] vsprintf: Convert to printbuf Content-Language: en-US To: Kent Overstreet , linux-kernel@vger.kernel.org Cc: pmladek@suse.com, rostedt@goodmis.org References: <20220604193042.1674951-1-kent.overstreet@gmail.com> <20220604193042.1674951-4-kent.overstreet@gmail.com> From: Rasmus Villemoes In-Reply-To: <20220604193042.1674951-4-kent.overstreet@gmail.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-3.3 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 04/06/2022 21.30, Kent Overstreet wrote: > This converts vsnprintf() to printbufs: instead of passing around raw > char * pointers for current buf position and end of buf, we have a real > type! > > This makes the calling convention for our existing pretty printers a lot > saner and less error prone, plus printbufs add some new helpers that > make the code smaller and more readable, with a lot less crazy pointer > arithmetic. > > There are a lot more refactorings to be done: this patch tries to stick > to just converting the calling conventions, as that needs to be done all > at once in order to avoid introducing a ton of wrappers that will just > be deleted. > > Thankfully we have good unit tests for printf, and they have been run > and are all passing with this patch. So, as the primary author of those tests, a somewhat active contributor to vsprintf.c and being listed as R: for both files, why wasn't I cc'ed on this? Anyway, my main concern with this is that performance goes down the drain and the generated code will be awful. Have you done any measurements and/or looked at disassembly? Thanks to -fno-strict-aliasing (or perhaps just because we're writing through a char* pointer which IIRC may alias anything), I think the compiler will be forced to reload prt->pos and prt->size over and over and over. I may be wrong, of course, that happens often. Perhaps __restrict could help, IDK. > --- > include/linux/kernel.h | 4 + Please don't expand that dumping ground. Please, if printbufs will become a thing (whether or not vsprintf internally will be refactored to use them), add a new linux/printf.h where these things can go, and the declarations of vsprintf() and close friends can eventually be moved. Rasmus