Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751468AbcDQI2A (ORCPT ); Sun, 17 Apr 2016 04:28:00 -0400 Received: from smtprelay0233.hostedemail.com ([216.40.44.233]:34668 "EHLO smtprelay.hostedemail.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751207AbcDQI16 (ORCPT ); Sun, 17 Apr 2016 04:27:58 -0400 X-Session-Marker: 6A6F6540706572636865732E636F6D X-Spam-Summary: 2,0,0,,d41d8cd98f00b204,joe@perches.com,:::::::::::,RULES_HIT:41:355:379:541:599: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:2393:2553:2559:2562:2828:3138:3139:3140:3141:3142:3352:3622:3865:3866:3867:3868:3870:3871:3872:3874:4321:5007:7974:10004:10226:10400:10848:11232:11658:11783:11914:12296:12517:12519:12740:13069:13161:13229:13311:13357:13439:13894:14659:14721:21080:30054:30090:30091,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,LFtime:2,LUA_SUMMARY:none X-HE-Tag: order72_622f2166cb159 X-Filterd-Recvd-Size: 2019 Message-ID: <1460881671.19090.90.camel@perches.com> Subject: Re: [PATCH] checkpatch: Whine about ACCESS_ONCE From: Joe Perches To: Julia Lawall Cc: Andrew Morton , Andy Whitcroft , linux-kernel@vger.kernel.org, Davidlohr Bueso , Davidlohr Bueso Date: Sun, 17 Apr 2016 01:27:51 -0700 In-Reply-To: References: <1460828078-5224-1-git-send-email-dave@stgolabs.net> <1460833453.19090.79.camel@perches.com> <1460836099.19090.82.camel@perches.com> Content-Type: text/plain; charset="ISO-8859-1" X-Mailer: Evolution 3.18.5.2-0ubuntu1 Mime-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 943 Lines: 38 On Sun, 2016-04-17 at 07:43 +0200, Julia Lawall wrote: > On Sat, 16 Apr 2016, Joe Perches wrote: > > On Sat, 2016-04-16 at 12:04 -0700, Joe Perches wrote: > > > Add a test for use of ACCESS_ONCE that could be written using > > > READ_ONCE or WRITE_ONCE. > > >? > > > --fix it too if desired. > >? > > And here's a simple coccinelle script that does a > > rather better job: > >? > > $ cat access_once.cocci > > @@ > > expression e1; > > expression e2; > > @@ > >? > > -?????ACCESS_ONCE(e1) = e2 > > +?????WRITE_ONCE(e1, e2) > >? > > @@ > > expression e1; > > @@ > >? > > -?????ACCESS_ONCE(e1) > > +?????READ_ONCE(e1) > > Looks good to me.? Is this something to put in the kernel? Maybe. ?There are more than 500 of these ACCESS_ONCE uses that could be converted. The kernel cocci scripts are typically more complicated with virtual org/report/context/patch blocks. So perhaps this needs to be fleshed out more. Works for me as-is though.