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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6BFB0C433EF for ; Fri, 10 Jun 2022 12:44:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233309AbiFJMoj convert rfc822-to-8bit (ORCPT ); Fri, 10 Jun 2022 08:44:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47276 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229608AbiFJMoi (ORCPT ); Fri, 10 Jun 2022 08:44:38 -0400 Received: from relay5.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D4E5D18E; Fri, 10 Jun 2022 05:44:35 -0700 (PDT) Received: from omf09.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay12.hostedemail.com (Postfix) with ESMTP id 06E07121083; Fri, 10 Jun 2022 12:44:30 +0000 (UTC) Received: from [HIDDEN] (Authenticated sender: joe@perches.com) by omf09.hostedemail.com (Postfix) with ESMTPA id 08E1F2002A; Fri, 10 Jun 2022 12:44:18 +0000 (UTC) Message-ID: Subject: Re: [PATCH 00/12] Clang -Wformat warning fixes From: Joe Perches To: Greg Kroah-Hartman , Bill Wendling Cc: Jan Engelhardt , Andrew Morton , Bill Wendling , Tony Luck , Borislav Petkov , Thomas Gleixner , Ingo Molnar , Dave Hansen , "maintainer:X86 ARCHITECTURE (32-BIT AND 64-BIT)" , "H. Peter Anvin" , Phillip Potter , Arnd Bergmann , "Rafael J. Wysocki" , Jan Kara , Pablo Neira Ayuso , Jozsef Kadlecsik , Florian Westphal , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Jaroslav Kysela , Takashi Iwai , Nathan Chancellor , Nick Desaulniers , Tom Rix , Ross Philipson , Daniel Kiper , linux-edac@vger.kernel.org, LKML , ACPI Devel Maling List , linux-mm@kvack.org, netfilter-devel@vger.kernel.org, coreteam@netfilter.org, Networking , alsa-devel@alsa-project.org, clang-built-linux Date: Fri, 10 Jun 2022 05:44:18 -0700 In-Reply-To: References: <20220609221702.347522-1-morbo@google.com> <20220609152527.4ad7862d4126e276e6f76315@linux-foundation.org> Content-Type: text/plain; charset="ISO-8859-1" Content-Transfer-Encoding: 8BIT User-Agent: Evolution 3.44.1-0ubuntu1 MIME-Version: 1.0 X-Rspamd-Server: rspamout05 X-Rspamd-Queue-Id: 08E1F2002A X-Stat-Signature: r8ecgxf89uwg9qffzdumnqfsj56kpo1p X-Session-Marker: 6A6F6540706572636865732E636F6D X-Session-ID: U2FsdGVkX19T013fSZHIO4BR28mlFWzRzi2PPI2hbJs= X-HE-Tag: 1654865058-93434 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org On Fri, 2022-06-10 at 07:20 +0200, Greg Kroah-Hartman wrote: > On Thu, Jun 09, 2022 at 04:16:16PM -0700, Bill Wendling wrote: > > On Thu, Jun 9, 2022 at 4:03 PM Jan Engelhardt wrote: > > > On Friday 2022-06-10 00:49, Bill Wendling wrote: > > > > On Thu, Jun 9, 2022 at 3:25 PM Andrew Morton wrote: > > > > > On Thu, 9 Jun 2022 22:16:19 +0000 Bill Wendling wrote: > > > > > > > > > > > This patch set fixes some clang warnings when -Wformat is enabled. > > > > > > > > > > tldr: > > > > > > > > > > - printk(msg); > > > > > + printk("%s", msg); > > > > > > > > > > Otherwise these changes are a > > > > > useless consumer of runtime resources. > > > > Calling a "printf" style function is already insanely expensive. I expect the printk code itself dominates, not the % scan cost. > > > Perhaps you can split vprintk_store in the middle (after the call to > > > vsnprintf), and offer the second half as a function of its own (e.g. > > > "puts"). Then the tldr could be > > > > > > - printk(msg); > > > + puts(msg); > > > > That might be a nice compromise. Andrew, what do you think? > > You would need to do that for all of the dev_printk() variants, so I > doubt that would ever be all that useful as almost no one should be > using a "raw" printk() these days. True. The kernel has ~20K variants like that. $ git grep -P '\b(?:(?:\w+_){1,3}(?:alert|emerg|crit|err|warn|notice|info|cont|debug|dbg)|printk)\s*\(".*"\s*\)\s*;' | wc -l 21160 That doesn't include the ~3K uses like #define foo "bar" printk(foo); $ git grep -P '\b(?:(?:\w+_){1,3}(?:alert|emerg|crit|err|warn|info|notice|debug|dbg|cont)|printk)\s*\((?:\s*\w+){1,3}\s*\)\s*;'|wc -l 2922 There are apparently only a few hundred uses of variants like: printk("%s", foo) $ git grep -P '\b(?:(?:\w+_){1,3}(?:alert|emerg|crit|err|warn|info|notice|debug|dbg|cont)|printk)\s*\(\s*"%s(?:\\n)?"\s*,\s*(?:".*"|\w+)\s*\)\s*;' | wc -l 305 unless I screwed up my greps (which of course is quite possible)