From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754914AbbDIAOz (ORCPT ); Wed, 8 Apr 2015 20:14:55 -0400 Received: from smtprelay0195.hostedemail.com ([216.40.44.195]:60348 "EHLO smtprelay.hostedemail.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1752898AbbDIAOw (ORCPT ); Wed, 8 Apr 2015 20:14:52 -0400 X-Session-Marker: 6A6F6540706572636865732E636F6D X-Spam-Summary: 2,0,0,,d41d8cd98f00b204,joe@perches.com,:::::::,RULES_HIT:41:355:379:541:800:960:973:982:988:989:1260:1277:1311:1313:1314:1345:1359:1373:1437:1515:1516:1518:1534:1541:1593:1594:1711:1730:1747:1777:1792:2197:2199:2393:2559:2562:2828:3138:3139:3140:3141:3142:3352:3866:3867:4250:5007:6119:6261:6642:7903:10004:10400:10848:11026:11473:11658:11914:12043:12517:12519:12555:12740:13069:13311:13357:14394:21080,0,RBL:none,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:fn,MSBL:0,DNSBL:none,Custom_rules:0:0:0 X-HE-Tag: table10_476e1d400925b X-Filterd-Recvd-Size: 2156 Message-ID: <1428538489.22406.65.camel@perches.com> Subject: [PATCH] checkpatch: Add a test for const with __read_mostly uses From: Joe Perches To: Andrew Morton Cc: Andy Whitcroft , Andi Kleen , linux-kernel@vger.kernel.org Date: Wed, 08 Apr 2015 17:14:49 -0700 In-Reply-To: <20150408235239.GU2366@two.firstfloor.org> References: <1428498405-7019-1-git-send-email-andi@firstfloor.org> <1428498405-7019-2-git-send-email-andi@firstfloor.org> <20150408153554.65c87de78f1c2289483f67e8@linux-foundation.org> <20150408235239.GU2366@two.firstfloor.org> Content-Type: text/plain; charset="ISO-8859-1" X-Mailer: Evolution 3.12.10-0ubuntu1~14.10.1 Mime-Version: 1.0 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org const objects shouldn't be __read_mostly. They are read-only. Marking these objects as __read_mostly causes section conflicts with LTO linking. So add a test to try to avoid this issue. Signed-off-by: Joe Perches --- scripts/checkpatch.pl | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl index 9a8b2bd..199d81b 100755 --- a/scripts/checkpatch.pl +++ b/scripts/checkpatch.pl @@ -4777,6 +4777,16 @@ sub process { } } +# check for __read_mostly with const non-pointer (should just be const) + if ($line =~ /\b__read_mostly\b/ && + $line =~ /($Type)\s*$Ident/ && $1 !~ /\*\s*$/ && $1 =~ /\bconst\b/) { + if (ERROR("CONST_READ_MOSTLY", + "Invalid use of __read_mostly with const type\n" . $herecurr) && + $fix) { + $fixed[$fixlinenr] =~ s/\s+__read_mostly\b//; + } + } + # don't use __constant_ functions outside of include/uapi/ if ($realfile !~ m@^include/uapi/@ && $line =~ /(__constant_(?:htons|ntohs|[bl]e(?:16|32|64)_to_cpu|cpu_to_[bl]e(?:16|32|64)))\s*\(/) {