From mboxrd@z Thu Jan 1 00:00:00 1970 From: Joe Perches Subject: Re: [PATCH 1/3] checkpatch.pl: add missing memory barriers Date: Mon, 04 Jan 2016 08:07:40 -0800 Message-ID: <1451923660.4334.83.camel@perches.com> References: <1451907395-15978-1-git-send-email-mst@redhat.com> <1451907395-15978-2-git-send-email-mst@redhat.com> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: QUOTED-PRINTABLE Return-path: In-Reply-To: <1451907395-15978-2-git-send-email-mst@redhat.com> Sender: linux-kernel-owner@vger.kernel.org To: "Michael S. Tsirkin" , linux-kernel@vger.kernel.org Cc: "Cc : Andy Whitcroft" , Peter Zijlstra , Arnd Bergmann , linux-arch@vger.kernel.org, Andrew Cooper , virtualization@lists.linux-foundation.org, Stefano Stabellini , Thomas Gleixner , Ingo Molnar , "H. Peter Anvin" , David Miller , linux-ia64@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-s390@vger.kernel.org, sparclinux@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-metag@vger.kernel.org, linux-mips@linux-mips.org, x86@kernel.org, user-mode-linux-devel@lists.sourceforge.net, adi-buildroot-devel@lists.sourceforge.net, linux-sh@vger.kernel.org, linux-xtensa@linux-xtensa.org, xen-devel@lists.xenproject.org, Ingo Molnar , Tony Lindgren List-Id: linux-arch.vger.kernel.org On Mon, 2016-01-04 at 13:36 +0200, Michael S. Tsirkin wrote: > SMP-only barriers were missing in checkpatch.pl >=20 > Refactor code slightly to make adding more variants easier. >=20 > Signed-off-by: Michael S. Tsirkin > --- > =A0scripts/checkpatch.pl | 9 ++++++++- > =A01 file changed, 8 insertions(+), 1 deletion(-) >=20 > diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl > index 2b3c228..0245bbe 100755 > --- a/scripts/checkpatch.pl > +++ b/scripts/checkpatch.pl > @@ -5116,7 +5116,14 @@ sub process { > =A0 } > =A0 } > =A0# check for memory barriers without a comment. > - if ($line =3D~ /\b(mb|rmb|wmb|read_barrier_depends|smp_mb|smp_rmb|= smp_wmb|smp_read_barrier_depends)\(/) { > + > + my @barriers =3D ('mb', 'rmb', 'wmb', 'read_barrier_depends'); > + my @smp_barriers =3D ('smp_store_release', 'smp_load_acquire', 'sm= p_store_mb'); > + > + @smp_barriers =3D (@smp_barriers, map {"smp_" . $_} @barriers); I think using map, which so far checkpatch doesn't use, makes smp_barriers harder to understand and it'd be better to enumerate them. > + my $all_barriers =3D join('|', (@barriers, @smp_barriers)); > + > + if ($line =3D~ /\b($all_barriers)\(/) { It would be better to use /\b$all_barriers\s*\(/ as there's no reason for the capture and there could be a space between the function and the open parenthesis. > =A0 if (!ctx_has_comment($first_line, $linenr)) { > =A0 WARN("MEMORY_BARRIER", > =A0 =A0=A0=A0=A0=A0"memory barrier without comment\n" . $herecurr)= ; From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtprelay0170.hostedemail.com ([216.40.44.170]:51094 "EHLO smtprelay.hostedemail.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751581AbcADQHu (ORCPT ); Mon, 4 Jan 2016 11:07:50 -0500 Message-ID: <1451923660.4334.83.camel@perches.com> Subject: Re: [PATCH 1/3] checkpatch.pl: add missing memory barriers From: Joe Perches Date: Mon, 04 Jan 2016 08:07:40 -0800 In-Reply-To: <1451907395-15978-2-git-send-email-mst@redhat.com> References: <1451907395-15978-1-git-send-email-mst@redhat.com> <1451907395-15978-2-git-send-email-mst@redhat.com> Content-Type: text/plain; charset="ISO-8859-1" Mime-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-arch-owner@vger.kernel.org List-ID: To: "Michael S. Tsirkin" , linux-kernel@vger.kernel.org Cc: "Cc : Andy Whitcroft" , Peter Zijlstra , Arnd Bergmann , linux-arch@vger.kernel.org, Andrew Cooper , virtualization@lists.linux-foundation.org, Stefano Stabellini , Thomas Gleixner , Ingo Molnar , "H. Peter Anvin" , David Miller , linux-ia64@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-s390@vger.kernel.org, sparclinux@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-metag@vger.kernel.org, linux-mips@linux-mips.org, x86@kernel.org, user-mode-linux-devel@lists.sourceforge.net, adi-buildroot-devel@lists.sourceforge.net, linux-sh@vger.kernel.org, linux-xtensa@linux-xtensa.org, xen-devel@lists.xenproject.org, Ingo Molnar , Tony Lindgren , Andrey Konovalov , Russell King - ARM Linux Message-ID: <20160104160740.5cZGa_Q0nOb7gn-qHeBfUnWFen40PiNLBNUuindOUhA@z> On Mon, 2016-01-04 at 13:36 +0200, Michael S. Tsirkin wrote: > SMP-only barriers were missing in checkpatch.pl > > Refactor code slightly to make adding more variants easier. > > Signed-off-by: Michael S. Tsirkin > --- >  scripts/checkpatch.pl | 9 ++++++++- >  1 file changed, 8 insertions(+), 1 deletion(-) > > diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl > index 2b3c228..0245bbe 100755 > --- a/scripts/checkpatch.pl > +++ b/scripts/checkpatch.pl > @@ -5116,7 +5116,14 @@ sub process { >   } >   } >  # check for memory barriers without a comment. > - if ($line =~ /\b(mb|rmb|wmb|read_barrier_depends|smp_mb|smp_rmb|smp_wmb|smp_read_barrier_depends)\(/) { > + > + my @barriers = ('mb', 'rmb', 'wmb', 'read_barrier_depends'); > + my @smp_barriers = ('smp_store_release', 'smp_load_acquire', 'smp_store_mb'); > + > + @smp_barriers = (@smp_barriers, map {"smp_" . $_} @barriers); I think using map, which so far checkpatch doesn't use, makes smp_barriers harder to understand and it'd be better to enumerate them. > + my $all_barriers = join('|', (@barriers, @smp_barriers)); > + > + if ($line =~ /\b($all_barriers)\(/) { It would be better to use /\b$all_barriers\s*\(/ as there's no reason for the capture and there could be a space between the function and the open parenthesis. >   if (!ctx_has_comment($first_line, $linenr)) { >   WARN("MEMORY_BARRIER", >        "memory barrier without comment\n" . $herecurr); From mboxrd@z Thu Jan 1 00:00:00 1970 From: Joe Perches Date: Mon, 04 Jan 2016 16:07:40 +0000 Subject: Re: [PATCH 1/3] checkpatch.pl: add missing memory barriers Message-Id: <1451923660.4334.83.camel@perches.com> List-Id: References: <1451907395-15978-1-git-send-email-mst@redhat.com> <1451907395-15978-2-git-send-email-mst@redhat.com> In-Reply-To: <1451907395-15978-2-git-send-email-mst@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable To: "Michael S. Tsirkin" , linux-kernel@vger.kernel.org Cc: "Cc : Andy Whitcroft" , Peter Zijlstra , Arnd Bergmann , linux-arch@vger.kernel.org, Andrew Cooper , virtualization@lists.linux-foundation.org, Stefano Stabellini , Thomas Gleixner , Ingo Molnar , "H. Peter Anvin" , David Miller , linux-ia64@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-s390@vger.kernel.org, sparclinux@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-metag@vger.kernel.org, linux-mips@linux-mips.org, x86@kernel.org, user-mode-linux-devel@lists.sourceforge.net, adi-buildroot-devel@lists.sourceforge.net, linux-sh@vger.kernel.org, linux-xtensa@linux-xtensa.org, xen-devel@lists.xenproject.org, Ingo Molnar , Tony Lindgren On Mon, 2016-01-04 at 13:36 +0200, Michael S. Tsirkin wrote: > SMP-only barriers were missing in checkpatch.pl >=20 > Refactor code slightly to make adding more variants easier. >=20 > Signed-off-by: Michael S. Tsirkin > --- > =A0scripts/checkpatch.pl | 9 ++++++++- > =A01 file changed, 8 insertions(+), 1 deletion(-) >=20 > diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl > index 2b3c228..0245bbe 100755 > --- a/scripts/checkpatch.pl > +++ b/scripts/checkpatch.pl > @@ -5116,7 +5116,14 @@ sub process { > =A0 } > =A0 } > =A0# check for memory barriers without a comment. > - if ($line =3D~ /\b(mb|rmb|wmb|read_barrier_depends|smp_mb|smp_rmb|smp_= wmb|smp_read_barrier_depends)\(/) { > + > + my @barriers =3D ('mb', 'rmb', 'wmb', 'read_barrier_depends'); > + my @smp_barriers =3D ('smp_store_release', 'smp_load_acquire', 'smp_st= ore_mb'); > + > + @smp_barriers =3D (@smp_barriers, map {"smp_" . $_} @barriers); I think using map, which so far checkpatch doesn't use, makes smp_barriers harder to understand and it'd be better to enumerate them. > + my $all_barriers =3D join('|', (@barriers, @smp_barriers)); > + > + if ($line =3D~ /\b($all_barriers)\(/) { It would be better to use /\b$all_barriers\s*\(/ as there's no reason for the capture and there could be a space between the function and the open parenthesis. > =A0 if (!ctx_has_comment($first_line, $linenr)) { > =A0 WARN("MEMORY_BARRIER", > =A0 =A0=A0=A0=A0=A0"memory barrier without comment\n" . $herecurr); From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Message-ID: <1451923660.4334.83.camel@perches.com> From: Joe Perches Date: Mon, 04 Jan 2016 08:07:40 -0800 In-Reply-To: <1451907395-15978-2-git-send-email-mst@redhat.com> References: <1451907395-15978-1-git-send-email-mst@redhat.com> <1451907395-15978-2-git-send-email-mst@redhat.com> Content-Type: text/plain; charset=ISO-8859-1 Mime-Version: 1.0 Content-Transfer-Encoding: QUOTED-PRINTABLE Sender: linux-kernel-owner@vger.kernel.org Subject: Re: [PATCH 1/3] checkpatch.pl: add missing memory barriers To: "Michael S. Tsirkin" , linux-kernel@vger.kernel.org Cc: "Cc : Andy Whitcroft" , Peter Zijlstra , Arnd Bergmann , linux-arch@vger.kernel.org, Andrew Cooper , virtualization@lists.linux-foundation.org, Stefano Stabellini , Thomas Gleixner , Ingo Molnar , "H. Peter Anvin" , David Miller , linux-ia64@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-s390@vger.kernel.org, sparclinux@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-metag@vger.kernel.org, linux-mips@linux-mips.org, x86@kernel.org, user-mode-linux-devel@lists.sourceforge.net, adi-buildroot-devel@lists.sourceforge.net, linux-sh@vger.kernel.org, linux-xtensa@linux-xtensa.org, xen-devel@lists.xenproject.org, Ingo Molnar , Tony Lindgren , Andrey Konovalov , Russell King - ARM Linux List-ID: On Mon, 2016-01-04 at 13:36 +0200, Michael S. Tsirkin wrote: > SMP-only barriers were missing in checkpatch.pl >=20 > Refactor code slightly to make adding more variants easier. >=20 > Signed-off-by: Michael S. Tsirkin > --- > =A0scripts/checkpatch.pl | 9 ++++++++- > =A01 file changed, 8 insertions(+), 1 deletion(-) >=20 > diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl > index 2b3c228..0245bbe 100755 > --- a/scripts/checkpatch.pl > +++ b/scripts/checkpatch.pl > @@ -5116,7 +5116,14 @@ sub process { > =A0 } > =A0 } > =A0# check for memory barriers without a comment. > - if ($line =3D~ /\b(mb|rmb|wmb|read_barrier_depends|smp_mb|smp_rmb|= smp_wmb|smp_read_barrier_depends)\(/) { > + > + my @barriers =3D ('mb', 'rmb', 'wmb', 'read_barrier_depends'); > + my @smp_barriers =3D ('smp_store_release', 'smp_load_acquire', 'sm= p_store_mb'); > + > + @smp_barriers =3D (@smp_barriers, map {"smp_" . $_} @barriers); I think using map, which so far checkpatch doesn't use, makes smp_barriers harder to understand and it'd be better to enumerate them. > + my $all_barriers =3D join('|', (@barriers, @smp_barriers)); > + > + if ($line =3D~ /\b($all_barriers)\(/) { It would be better to use /\b$all_barriers\s*\(/ as there's no reason for the capture and there could be a space between the function and the open parenthesis. > =A0 if (!ctx_has_comment($first_line, $linenr)) { > =A0 WARN("MEMORY_BARRIER", > =A0 =A0=A0=A0=A0=A0"memory barrier without comment\n" . $herecurr)= ; -- To unsubscribe from this list: send the line "unsubscribe linux-kernel"= in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/ From mboxrd@z Thu Jan 1 00:00:00 1970 From: joe@perches.com (Joe Perches) Date: Mon, 04 Jan 2016 08:07:40 -0800 Subject: [PATCH 1/3] checkpatch.pl: add missing memory barriers In-Reply-To: <1451907395-15978-2-git-send-email-mst@redhat.com> References: <1451907395-15978-1-git-send-email-mst@redhat.com> <1451907395-15978-2-git-send-email-mst@redhat.com> Message-ID: <1451923660.4334.83.camel@perches.com> To: linux-arm-kernel@lists.infradead.org List-Id: linux-arm-kernel.lists.infradead.org On Mon, 2016-01-04 at 13:36 +0200, Michael S. Tsirkin wrote: > SMP-only barriers were missing in checkpatch.pl > > Refactor code slightly to make adding more variants easier. > > Signed-off-by: Michael S. Tsirkin > --- > ?scripts/checkpatch.pl | 9 ++++++++- > ?1 file changed, 8 insertions(+), 1 deletion(-) > > diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl > index 2b3c228..0245bbe 100755 > --- a/scripts/checkpatch.pl > +++ b/scripts/checkpatch.pl > @@ -5116,7 +5116,14 @@ sub process { > ? } > ? } > ?# check for memory barriers without a comment. > - if ($line =~ /\b(mb|rmb|wmb|read_barrier_depends|smp_mb|smp_rmb|smp_wmb|smp_read_barrier_depends)\(/) { > + > + my @barriers = ('mb', 'rmb', 'wmb', 'read_barrier_depends'); > + my @smp_barriers = ('smp_store_release', 'smp_load_acquire', 'smp_store_mb'); > + > + @smp_barriers = (@smp_barriers, map {"smp_" . $_} @barriers); I think using map, which so far checkpatch doesn't use, makes smp_barriers harder to understand and it'd be better to enumerate them. > + my $all_barriers = join('|', (@barriers, @smp_barriers)); > + > + if ($line =~ /\b($all_barriers)\(/) { It would be better to use /\b$all_barriers\s*\(/ as there's no reason for the capture and there could be a space between the function and the open parenthesis. > ? if (!ctx_has_comment($first_line, $linenr)) { > ? WARN("MEMORY_BARRIER", > ? ?????"memory barrier without comment\n" . $herecurr);