From patchwork Fri Oct 16 02:48:53 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Morton X-Patchwork-Id: 11840755 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id B989415E6 for ; Fri, 16 Oct 2020 02:48:57 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 70E5C2074D for ; Fri, 16 Oct 2020 02:48:57 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=kernel.org header.i=@kernel.org header.b="fXeaFRRx" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 70E5C2074D Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=linux-foundation.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 6914C940063; Thu, 15 Oct 2020 22:48:56 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 61B6F940034; Thu, 15 Oct 2020 22:48:56 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 50B0D940063; Thu, 15 Oct 2020 22:48:56 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0136.hostedemail.com [216.40.44.136]) by kanga.kvack.org (Postfix) with ESMTP id 1F9DE940034 for ; Thu, 15 Oct 2020 22:48:56 -0400 (EDT) Received: from smtpin06.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id B18523623 for ; Fri, 16 Oct 2020 02:48:55 +0000 (UTC) X-FDA: 77376256230.06.beam73_1214a1127219 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin06.hostedemail.com (Postfix) with ESMTP id 925551024B142 for ; Fri, 16 Oct 2020 02:48:55 +0000 (UTC) X-Spam-Summary: 1,0,0,c8226619eadd2e78,d41d8cd98f00b204,akpm@linux-foundation.org,,RULES_HIT:41:355:379:800:960:967:973:982:988:989:1260:1345:1359:1381:1431:1437:1534:1541:1711:1730:1747:1777:1792:1801:2194:2197:2199:2200:2393:2525:2559:2563:2682:2685:2693:2859:2902:2933:2937:2939:2942:2945:2947:2951:2954:3022:3138:3139:3140:3141:3142:3353:3653:3865:3866:3867:3868:3870:3871:3872:3874:3934:3936:3938:3941:3944:3947:3950:3953:3956:3959:4250:4321:4605:5007:6119:6261:6653:7576:7809:7903:9025:9149:9545:10004:11658:11914:12043:12048:12296:12297:12438:12517:12519:12555:12679:12986:13069:13311:13357:14181:14384:14721:21067:21080:21212:21221:21433:21451:21627:21939:30012:30034:30054:30062:30070,0,RBL:198.145.29.99:@linux-foundation.org:.lbl8.mailshell.net-62.2.0.100 64.100.201.201;04yfdwk73g7z6da6jtabzzfshf8psycupr9ykd59ficsuc6drndjxj7dqkzwcmq.5zdo9jfpxk6i6xdeznwefu69esfnnxf7gps1xnh1jhj77jyqs1wfob4676edqb1.q-lbl8.mailshell.net-223.238.255.100,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck: none,Dom X-HE-Tag: beam73_1214a1127219 X-Filterd-Recvd-Size: 3289 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by imf11.hostedemail.com (Postfix) with ESMTP for ; Fri, 16 Oct 2020 02:48:55 +0000 (UTC) Received: from localhost.localdomain (c-73-231-172-41.hsd1.ca.comcast.net [73.231.172.41]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id EE8C120897; Fri, 16 Oct 2020 02:48:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1602816534; bh=rLlJSTd/jaZP9BY5EqjGjcK1DFidff+fwX7ncfrLHRg=; h=Date:From:To:Subject:In-Reply-To:From; b=fXeaFRRx8zhLrFdqW3dBFDtIBaChMulWCAo4gZK2xeh7JBC+inwxv4Ts4nCWxypsE 0OMGstwxKQT+VhfQsLLkR6+MQiZNhVDjvDlYr6zlBOeKYC7oft57FRD166+NDskLjC a10sCvFrQTdccRyb5/fBlt8nAsN5dQCMgnD97nyM= Date: Thu, 15 Oct 2020 19:48:53 -0700 From: Andrew Morton To: akpm@linux-foundation.org, drinkcat@chromium.org, joe@perches.com, linux-mm@kvack.org, mm-commits@vger.kernel.org, rostedt@goodmis.org, torvalds@linux-foundation.org Subject: [patch 125/156] checkpatch: warn if trace_printk and friends are called Message-ID: <20201016024853.NXTjAZOIJ%akpm@linux-foundation.org> In-Reply-To: <20201015192732.f448da14e9854c7cb7299956@linux-foundation.org> User-Agent: s-nail v14.8.16 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: From: Nicolas Boichat Subject: checkpatch: warn if trace_printk and friends are called trace_printk is meant as a debugging tool, and should not be compiled into production code without specific debug Kconfig options enabled, or source code changes, as indicated by the warning that shows up on boot if any trace_printk is called: ** NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE ** ** ** ** trace_printk() being used. Allocating extra memory. ** ** ** ** This means that this is a DEBUG kernel and it is ** ** unsafe for production use. ** Let's warn developers when they try to submit such a change. Link: https://lkml.kernel.org/r/20200825193600.v2.1.I723c43c155f02f726c97501be77984f1e6bb740a@changeid Signed-off-by: Nicolas Boichat Cc: Steven Rostedt Cc: Joe Perches Signed-off-by: Andrew Morton --- scripts/checkpatch.pl | 6 ++++++ 1 file changed, 6 insertions(+) --- a/scripts/checkpatch.pl~checkpatch-warn-if-trace_printk-and-friends-are-called +++ a/scripts/checkpatch.pl @@ -4274,6 +4274,12 @@ sub process { "Prefer dev_$level(... to dev_printk(KERN_$orig, ...\n" . $herecurr); } +# trace_printk should not be used in production code. + if ($line =~ /\b(trace_printk|trace_puts|ftrace_vprintk)\s*\(/) { + WARN("TRACE_PRINTK", + "Do not use $1() in production code (this can be ignored if built only with a debug config option)\n" . $herecurr); + } + # ENOSYS means "bad syscall nr" and nothing else. This will have a small # number of false positives, but assembly files are not checked, so at # least the arch entry code will not trigger this warning.