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 4E704C433EF for ; Fri, 10 Jun 2022 12:44:36 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id AFE468D009B; Fri, 10 Jun 2022 08:44:35 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id A85CA8D0090; Fri, 10 Jun 2022 08:44:35 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 94E118D009B; Fri, 10 Jun 2022 08:44:35 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id 84F618D0090 for ; Fri, 10 Jun 2022 08:44:35 -0400 (EDT) Received: from smtpin19.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 556CC35978 for ; Fri, 10 Jun 2022 12:44:35 +0000 (UTC) X-FDA: 79562294910.19.50BDA7F Received: from relay5.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by imf27.hostedemail.com (Postfix) with ESMTP id B962740079 for ; Fri, 10 Jun 2022 12:44:34 +0000 (UTC) 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: quoted-printable User-Agent: Evolution 3.44.1-0ubuntu1 MIME-Version: 1.0 X-Session-Marker: 6A6F6540706572636865732E636F6D X-Session-ID: U2FsdGVkX19T013fSZHIO4BR28mlFWzRzi2PPI2hbJs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1654865074; 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:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=OAJCn8/36BAdonHF+RP2oAXrts99hS6adlJgc7N31Hs=; b=gM+KR/nT1EgG1jFPLr3mvJN9PShYXqxk6bqrulvoJVIYTNd2iCT8KAT9+ee1ZUl58LlHKk yxdMWPxYJBW0k2KV+9WZv/Uy88umpdtrhNUAu80MHCli4MqMCyuBhRSlavmHv3r9joC6TX MM85DYafa80pBUctOPAnDJ6fhd1dVfM= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1654865074; a=rsa-sha256; cv=none; b=njPpe/Hb4TifhDPqVAlneY76WvQW2/BxbIr3wR2dpLr+ibuJd29xjv21EOvOb/O+czNbmt lZ13q2aDYYFUHUOPU0VHSCnxktPv/MMy1yO5vSl+PmVc5PBVIpuNBzcLTYc6JgZkf2uaFX B27J3UDvpv45OwjAJ/0e1mYUkbQWTMg= ARC-Authentication-Results: i=1; imf27.hostedemail.com; dkim=none; dmarc=none; spf=none (imf27.hostedemail.com: domain of joe@perches.com has no SPF policy when checking 216.40.44.11) smtp.mailfrom=joe@perches.com X-Rspamd-Server: rspam11 X-Rspam-User: X-HE-Tag-Orig: 1654865058-93434 Authentication-Results: imf27.hostedemail.com; dkim=none; dmarc=none; spf=none (imf27.hostedemail.com: domain of joe@perches.com has no SPF policy when checking 216.40.44.11) smtp.mailfrom=joe@perches.com X-Stat-Signature: ssp5x31cs14qioc8sedsshk9go8wy4xd X-Rspamd-Queue-Id: B962740079 X-HE-Tag: 1654865074-930014 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: 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: > > > > >=20 > > > > > > This patch set fixes some clang warnings when -Wformat is enabl= ed. > > > > >=20 > > > > > tldr: > > > > >=20 > > > > > - printk(msg); > > > > > + printk("%s", msg); > > > > >=20 > > > > > 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 > > >=20 > > > - printk(msg); > > > + puts(msg); > >=20 > > That might be a nice compromise. Andrew, what do you think? >=20 > 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|c= ont|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|d= ebug|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|d= ebug|dbg|cont)|printk)\s*\(\s*"%s(?:\\n)?"\s*,\s*(?:".*"|\w+)\s*\)\s*;' | w= c -l 305 unless I screwed up my greps (which of course is quite possible)