Received: by 2002:a05:6a10:413:0:0:0:0 with SMTP id 19csp2219688pxp; Mon, 21 Mar 2022 14:10:46 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy0EN+YtoY1OUV0AAEJBmmt1mAnQoiXpT59/FF086awo1Yc5vFfNPv+hT3mNsGS8yG2mBxO X-Received: by 2002:a17:90a:8e85:b0:1bc:429b:513d with SMTP id f5-20020a17090a8e8500b001bc429b513dmr1099740pjo.11.1647897046719; Mon, 21 Mar 2022 14:10:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1647897046; cv=none; d=google.com; s=arc-20160816; b=UQV/GIGjrJx7kSHHUUOk6OIqezQQwzime4NngpqOuoQGBpLbbIrx/n222E0LNsetCY ArgI1xTe6jDm3NurV9yOIzJ1ix156yOJGXy72jvsOBoZUmeD8DY6eLzJBAMXP/mpczBl OCCqv5s2ynyyhmeILKHErUjbsmXA398FdsxfgfXNpLBXxFpMU1AT1idtU0GNL/a9So2r ycUmYkcsYrjm78MK56heJ3MFUKKtPIuFbbWHxnQF2MVBYbGKI+6dbQElfI6LLI+XG/c1 Hhfyh4GFgBizNoBcZpNVsdMAe3nA2rPQQJj8Lc598AHmJ2eVPXkINRi4phLMX8JPCOAX aKFg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=NJ7rJ9a1MkPoaCF3v1N1Mm2BXlsL1if5z9Q1yyTlgQc=; b=JLhQ7I09pe/Z8LKVpN5VJdadcPs9TcDWA22FL1ikfSGdVKQJF6HwaZ+xKbe5GguF/v JlMTuObBEcLcrdRNoOvIQHN2CqZsX4GEpHe9xaMOE2DCdX1U4rWq9MKqhgn7HI7YqEfE CiUVRXkMDHeez8fYRZA3fAcnW/rsfZhsJL9vqXYqgQ1Rr3uMS2ciItHkmFJT8lT58lPw wlBfZi7dc513vYxamCWx5jFIjR6MJjs7D4FIk0w5Z71SX2zSkcpnCB3sAWcyhkO+DSxf IvHlNBSO0f/j/DxlKLfs6OgzSModNx03jSa+fpoZ0lRsjDKmPWGourAB86/4afNsC4Q2 xrYQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.com header.s=susede1 header.b=Muo3o4Zg; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=suse.com Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id ba4-20020a170902720400b00153b2d16561si11061218plb.361.2022.03.21.14.10.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 21 Mar 2022 14:10:46 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@suse.com header.s=susede1 header.b=Muo3o4Zg; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=suse.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 4533B101E; Mon, 21 Mar 2022 14:02:58 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237306AbiCRQHV (ORCPT + 99 others); Fri, 18 Mar 2022 12:07:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60406 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238533AbiCRQHK (ORCPT ); Fri, 18 Mar 2022 12:07:10 -0400 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 694F52DF3C0; Fri, 18 Mar 2022 09:04:51 -0700 (PDT) Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out1.suse.de (Postfix) with ESMTP id B154621101; Fri, 18 Mar 2022 16:04:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1647619489; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=NJ7rJ9a1MkPoaCF3v1N1Mm2BXlsL1if5z9Q1yyTlgQc=; b=Muo3o4Zg5mXCsjft5ZqW+yfRZ/1bGpADvnHiFhfcVtp0VpxbBDk3x4rL+bw3lo6zsiCl+F Mz46/+y2/rsHKOUnqU5Bw84dNFfrM/RxdSs1eAwg4pZawQo9mUAexd0IjrCOe7BGdb/aWM ucAHHvd02HMAoEnWfVTUf1pwaPIbHdE= Received: from suse.cz (unknown [10.100.224.162]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by relay2.suse.de (Postfix) with ESMTPS id 40E27A3B8A; Fri, 18 Mar 2022 16:04:49 +0000 (UTC) Date: Fri, 18 Mar 2022 17:04:45 +0100 From: Petr Mladek To: Andy Shevchenko Cc: Miguel Ojeda , Linus Torvalds , Greg Kroah-Hartman , rust-for-linux@vger.kernel.org, linux-kernel@vger.kernel.org, Gary Guo , Alex Gaynor , Wedson Almeida Filho , Steven Rostedt , Sergey Senozhatsky , Rasmus Villemoes Subject: Re: [PATCH v5 12/20] vsprintf: add new `%pA` format specifier Message-ID: References: <20220317181032.15436-1-ojeda@kernel.org> <20220317181032.15436-13-ojeda@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no 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 Fri 2022-03-18 16:07:31, Andy Shevchenko wrote: > On Thu, Mar 17, 2022 at 07:10:00PM +0100, Miguel Ojeda wrote: > > From: Gary Guo > > > > This patch adds a format specifier `%pA` to `vsprintf` which formats > > a pointer as `core::fmt::Arguments`. Doing so allows us to directly > > format to the internal buffer of `printf`, so we do not have to use > > a temporary buffer on the stack to pre-assemble the message on > > the Rust side. > > > > This specifier is intended only to be used from Rust and not for C, so > > `checkpatch.pl` is intentionally unchanged to catch any misuse. > > ... > > > + case 'A': > > + if (!IS_ENABLED(CONFIG_RUST)) { > > + WARN_ONCE(1, "Please remove %%pA from non-Rust code\n"); > > + return error_string(buf, end, "(%pA?)", spec); > > + } > > I'm wondering if the Big Scary Banner as trace_printk() does would be better > (in case we can tell that %pA is used in the code when RUST=n). Good question! The advantage of WARN_ONCE() is that it shows the stack so that it is easier to locate the caller. On the other hand, WARN_ONCE() is a bit misused here. It should be used only in situations that might be potentially fatal. It might even cause panic() with "panic_on_warn" kernel parameter. Well, I am not sure if it is worth huge effort. WARN_ONCE() is practical in this case because of the backtrace. We could always create something better if people hit it more frequently and it causes real life problems. Best Regards, Petr