Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp787216iog; Wed, 15 Jun 2022 12:18:10 -0700 (PDT) X-Google-Smtp-Source: AGRyM1vrTMdq/4ogha6H/um0eZvZ/hph5bMzfE37eVoeZ8MKQDYv99J+rbG1STD7zvmRzPL/dB3l X-Received: by 2002:a17:90b:180b:b0:1e3:25f6:6475 with SMTP id lw11-20020a17090b180b00b001e325f66475mr11949112pjb.208.1655320690584; Wed, 15 Jun 2022 12:18:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1655320690; cv=none; d=google.com; s=arc-20160816; b=nPZtmBXWPvIgikfZ7atH8wHWsDgTW6p6BAwWupdukFHoIBEPQxSzv92YyiGSzvzG3v jGb3I2isNESnehhwqmPSp8PQ6zUxDciiN2dajMo61ce8+mJOKofJRBM8Fn0Z1xZERZ8l Z9p+fzMlOMoeGsyuNVS0nUWMorxv4QHwUXpeXhKyES/fLEtgYrAyhqSFaW/VFJdigbzs PS+FkHARnJiwhv/7T7UaxzltCTzlNciDfDgtvkc6eWutjW8tF1eop5u9+tFUnxknNoIA 49Ds5xDHerBeNYz5p0bFU4/TLqeDHyyFdU2eW6gliNI0Q+c7UgGwgR0K3MsNIg+YTWNU ioNg== 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=F+DGM8o8Zn45hSbzSY35HzK/vbjQGnTANH1Bt8EkX5w=; b=arYNwlhCDfU4LKlVQ+fLKUqLuW3YYHP8nXKwoSVIVjMSDstRoofBbuj+LXKr0zVbN4 KWbm7+ZycEwduB0Y6TsOvfLPrB+Lie/9sQtEZvUp3+KlI4yLp23Mj8S9CzHZCvYhZPSN LBHo2T3jQIBf2XbBo34T5lZZo52inVY/hK3RfFdWpa03EKZZ63OsVxIp3R87xqTdROVF QfxpyFsB/t6oMtmoeAaOoucJ2QvQIJHp8yGeVZQ2WFQmViNJQBc/rRErtAwEuMaqDKuH S20n+4ZUwa4RCLj0eLMb7SshdiAghMQ/O3uHWuGUePTpxH9ePwsoMzxjeHFIKdCZkbYQ OzVw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=JEZN7GvN; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id h2-20020a170902f54200b0016645f83ef1si21491583plf.213.2022.06.15.12.17.54; Wed, 15 Jun 2022 12:18:10 -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=@gmail.com header.s=20210112 header.b=JEZN7GvN; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1348905AbiFOSof (ORCPT + 99 others); Wed, 15 Jun 2022 14:44:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52656 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231737AbiFOSoe (ORCPT ); Wed, 15 Jun 2022 14:44:34 -0400 Received: from mail-qk1-x732.google.com (mail-qk1-x732.google.com [IPv6:2607:f8b0:4864:20::732]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 55D6C340F4 for ; Wed, 15 Jun 2022 11:44:33 -0700 (PDT) Received: by mail-qk1-x732.google.com with SMTP id p63so9391276qkd.10 for ; Wed, 15 Jun 2022 11:44:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=message-id:date:mime-version:user-agent:subject:content-language:to :cc:references:from:in-reply-to:content-transfer-encoding; bh=F+DGM8o8Zn45hSbzSY35HzK/vbjQGnTANH1Bt8EkX5w=; b=JEZN7GvNEzufQhnj5M+09pKzIE1oQV4hsoD9Q8IZAl54fxgEVjh1hp0CfGrjF3DVR3 8kqcANUupPT/K9orIaIv8uo6J4MqQairMRK1KNpeNik7if/ULSDeW2Fir8lhPWA2Zqli Lce3nMmDV+cng9OOHfrObILhRAE6H21/hHx0R90Kr3ibi+v340MK1A9HXFM9XzKnH8lW lURmYabQWMg707cDfSjfMuw7WeWDYFyLJ3jUGhlr0l5sPNj3xtqCB/8jW6a57VjlxMm9 mOBA/vI+9iKIGbJfSJroSixFrV5PRm8wDHAfZYn+AKHibVyz3MZ1uqhdRZ7jadRSy2TI YztQ== 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=F+DGM8o8Zn45hSbzSY35HzK/vbjQGnTANH1Bt8EkX5w=; b=lxYngk5VBQIyVXPsuB66nwpUfBtPYiC6Wpd0kE8nQYI8A8TQIP7PU0wLNYvcnNoLyF q2QHp9VlJdLQ84hmCThiSkLQ7O9QZI4jDpds37+rUdbSj8L0kNd5DiJeWzc8IBJyKuM5 H76m4w4HHeKgy7ZAm44Jv6dvUmXgoc9T+YE2tcanISHSt3aT9qeThCx3QQwHdvmVKw7m zSNRdKazcJ/NjXIJiNoSsyjjfVxsDwaiXxl1Ly7mhTkwIJE24FBU06w3+Uw3P6NlItPM 5F6EaFpOP7peYdaTtWmiajyC8bSr1kdbgFeSQJYamrBAPsRUOtfsADtAs+IhGj+rlXFS +gxg== X-Gm-Message-State: AJIora/fQx1tHPeDPrcfIC0bp9yfw41hJh6oFc7q1soJeHGkpvJwt7J8 9jJObr5QjR1K2iRGY1ON8vGPQ2nIsTSH2Ug= X-Received: by 2002:a37:454:0:b0:6a7:7eb1:7c65 with SMTP id 81-20020a370454000000b006a77eb17c65mr899777qke.474.1655318671155; Wed, 15 Jun 2022 11:44:31 -0700 (PDT) Received: from [192.168.1.210] (c-73-219-103-14.hsd1.vt.comcast.net. [73.219.103.14]) by smtp.gmail.com with ESMTPSA id u16-20020a05620a455000b006a6ce613c7csm13676842qkp.89.2022.06.15.11.44.30 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 15 Jun 2022 11:44:30 -0700 (PDT) Message-ID: Date: Wed, 15 Jun 2022 14:44:29 -0400 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.10.0 Subject: Re: [PATCH v3 03/33] vsprintf: Convert to printbuf Content-Language: en-US To: Rasmus Villemoes , 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: Kent Overstreet In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed 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,FREEMAIL_FROM,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 6/15/22 05:09, Rasmus Villemoes wrote: > 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? Apologies for the oversight. > 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. If we care that much about sprintf performance we must have some benchmarks somewhere - could you point me at them? >> --- >> 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. kernel.h is indeed a dumping ground that needs to be reorganized, but this patch series is about printbufs, not reorganizing header files (and my doctor tells me I need to be taking my blood pressure meds more regularly before taking something like that on). For now, prt_printf() goes with the other printf() functions.