Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754856AbdCGIRC (ORCPT ); Tue, 7 Mar 2017 03:17:02 -0500 Received: from mail.kernel.org ([198.145.29.136]:55332 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754044AbdCGIQx (ORCPT ); Tue, 7 Mar 2017 03:16:53 -0500 Date: Tue, 7 Mar 2017 09:16:45 +0100 From: Masami Hiramatsu To: Nicholas Mc Guire Cc: Thomas Gleixner , Ingo Molnar , "H. Peter Anvin" , x86@kernel.org, Masami Hiramatsu , Adrian Hunter , Arnaldo Carvalho de Melo , Josh Poimboeuf , linux-kernel@vger.kernel.org Subject: Re: [PATCH] objtool: drop redundant flags generation Message-Id: <20170307091645.88a9c9511361a39dc5dad191@kernel.org> In-Reply-To: <1488819625-27395-1-git-send-email-der.herr@hofr.at> References: <1488819625-27395-1-git-send-email-der.herr@hofr.at> X-Mailer: Sylpheed 3.5.0 (GTK+ 2.24.30; x86_64-pc-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 3484 Lines: 100 On Mon, 6 Mar 2017 18:00:25 +0100 Nicholas Mc Guire wrote: > The generator was emitting quite a few duplicate flags which was making > doublebitand.cocci nervous. This awk hack resolves the duplicate issue. Yes, I know that. I don't think that the duplicating those flags in "automatic generated" source code is not so harmful. I personally prefer to keep awk code simpler... Thanks, > > Signed-off-by: Nicholas Mc Guire > --- > > The coccinelle complaints emitted was about 230 findings total: > ./arch/x86/lib/inat-tables.c:214:10-20: duplicated argument to & or | > ./arch/x86/lib/inat-tables.c:214:23-33: duplicated argument to & or | > ./arch/x86/lib/inat-tables.c:218:10-20: duplicated argument to & or | > ./arch/x86/lib/inat-tables.c:218:23-33: duplicated argument to & or | > .... > ./tools/objtool/arch/x86/insn/inat-tables.c:214:10-20: duplicated argument to & or | > ./tools/objtool/arch/x86/insn/inat-tables.c:214:23-33: duplicated argument to & or | > ./tools/objtool/arch/x86/insn/inat-tables.c:218:10-20: duplicated argument to & or | > ./tools/objtool/arch/x86/insn/inat-tables.c:218:23-33: duplicated argument to & or | > ... > spatch --sp-file scripts/coccinelle/tests/doublebitand.cocci inat-tables.c -D report > will give you the full list - all are caused by duplicates in the generated > output by the add_flags function in the two instances of gen-insn-attr-x86.awk. > > Q: The two copies of gen-insn-attr-x86.awk are identical and its not actually clear > why this duplication is needed ? Further the maintainers list emitted for the > two files differ. > > Patch was checked by manual review of the diff between the initial file and the > regenerated file after the below patch was applied. > Second verification was by make tools/objtool and comparing the generated binaries > in tools/objtool/arch/x86/decode.o with diff. > > Patch is against 4.11-rc1 (localversion-next is next-20170306) > > arch/x86/tools/gen-insn-attr-x86.awk | 12 ++++++++++-- > tools/objtool/arch/x86/insn/gen-insn-attr-x86.awk | 12 ++++++++++-- > 2 files changed, 20 insertions(+), 4 deletions(-) > > diff --git a/arch/x86/tools/gen-insn-attr-x86.awk b/arch/x86/tools/gen-insn-attr-x86.awk > index a3d2c62..9cdeefe 100644 > --- a/arch/x86/tools/gen-insn-attr-x86.awk > +++ b/arch/x86/tools/gen-insn-attr-x86.awk > @@ -226,8 +226,16 @@ function print_table(tbl,name,fmt,n) > } > > function add_flags(old,new) { > - if (old && new) > - return old " | " new > + if (old == new) > + return old > + if (old && new) { > + if(match(old,new)) > + return old > + else if(match(new,old)) > + return new > + else > + return old " | " new > + } > else if (old) > return old > else > diff --git a/tools/objtool/arch/x86/insn/gen-insn-attr-x86.awk b/tools/objtool/arch/x86/insn/gen-insn-attr-x86.awk > index a3d2c62..9cdeefe 100644 > --- a/tools/objtool/arch/x86/insn/gen-insn-attr-x86.awk > +++ b/tools/objtool/arch/x86/insn/gen-insn-attr-x86.awk > @@ -226,8 +226,16 @@ function print_table(tbl,name,fmt,n) > } > > function add_flags(old,new) { > - if (old && new) > - return old " | " new > + if (old == new) > + return old > + if (old && new) { > + if(match(old,new)) > + return old > + else if(match(new,old)) > + return new > + else > + return old " | " new > + } > else if (old) > return old > else > -- > 2.1.4 > -- Masami Hiramatsu