Received: by 2002:ac0:a594:0:0:0:0:0 with SMTP id m20-v6csp1655920imm; Tue, 22 May 2018 07:24:35 -0700 (PDT) X-Google-Smtp-Source: AB8JxZqkHPNTH2uglb/EJqyG0n/roseDOAraObvHGyjjX3xu/fmEBKSw8Fg+uzaBfi4TWl2VYkOy X-Received: by 2002:a17:902:26a:: with SMTP id 97-v6mr25095407plc.367.1526999075336; Tue, 22 May 2018 07:24:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1526999075; cv=none; d=google.com; s=arc-20160816; b=AFDO9PDEkt/OwEKULxd8F7i3j4em6Sf7yzbdYqWpsi7de8CdO5nR0HcmhYbuxIr+Un nAEhJW6pL254K0RYXFXAD1GBbKtxGsCmczYCm95cd98glO6TN3LUetp32Le7IB7Lyut/ goCGVf2UnvQP7d1HKqecnNy/UZeq45Bq3PoKTUan1IahWDYxEkr7gHFtjRB4rltzQEXh ckG/BRpoWqBXQnjp8Apf5ltnkXFkHSMQD+k52jYgckO6FAWoEBrRRjJklgkOYl7ydq36 AExxo6jsUEIonTya3O4e0dE3cTssTBl/0EtVVj4fAp2NspA3iSxaO6omNs/AgaY1Br6r JDVg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :references:in-reply-to:mime-version:dkim-signature:dkim-filter :arc-authentication-results; bh=zISSr9WJjKyqKesaJk6jl2ovAYIDlFo9FY4IJd2H/CA=; b=m20oYldjdvcMmi0e2A+h5ffsL7fF6mN5iuBAtDnntHdjjQevIyHXgENxEkntvp5gEi qWT1yV7FiyLNhaqUcnd4oLh+wyv2GA2B7O5HwjBHAnmJ5ELxrHQ28pjiEzGFyLJecWkr Dh5rR3WNXjQHJcX7UgJzfR8EIDKSj7g4T10inzKKEc7nbARXsiJq4Xzw7VKpTh4Mde/f F0PUnvOYYs8nRQRkoqpTymZIGjJPv7zVzvSVK90sn6q/MK3WVTpT9uVSbgFam7qr7Lr0 5YJxICRwOMIssUh550Ek+c1C7rbPjyjUqcQN8P6xEzIrDkgJxJ9kOXYVR9mpdHHq9Drr 1eig== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@nifty.com header.s=dec2015msa header.b=mOciMajd; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id v6-v6si17146602plp.60.2018.05.22.07.24.12; Tue, 22 May 2018 07:24:35 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@nifty.com header.s=dec2015msa header.b=mOciMajd; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751434AbeEVOX5 (ORCPT + 99 others); Tue, 22 May 2018 10:23:57 -0400 Received: from conssluserg-01.nifty.com ([210.131.2.80]:23277 "EHLO conssluserg-01.nifty.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751411AbeEVOX4 (ORCPT ); Tue, 22 May 2018 10:23:56 -0400 Received: from mail-vk0-f50.google.com (mail-vk0-f50.google.com [209.85.213.50]) (authenticated) by conssluserg-01.nifty.com with ESMTP id w4MENpY1020891; Tue, 22 May 2018 23:23:52 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conssluserg-01.nifty.com w4MENpY1020891 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1526999032; bh=zISSr9WJjKyqKesaJk6jl2ovAYIDlFo9FY4IJd2H/CA=; h=In-Reply-To:References:From:Date:Subject:To:Cc:From; b=mOciMajdqCM90kQfdu+iD3ZXMpoBQqJC4bqBOyVSdgqfG0wtZz+2ckrOSDHKfrxkf asw76wzHy/iQZhObeYVJb4k6+OuhvrHkQ+TOIWmUqUjwxL2EREXag83QowXw1E+6dw f+A7xCVi0wSaaPrBo9E0rGvKyXtPB5fCAShimEaEgrBlRB/u2yEHfUHWR2iBKrnWtj YddQ8/p6OkhS1C0c1q0W833XArtbcXxjLlCT4jMVODmu86p11DrOPk8UKoyLAx2ppA OJ7y/GW2SahNUpNCMZByIlB+DC1G+hAaPTEduZOdycxU1aeSL/CTdBlbS3mXF2vspt tT3ZH+CoOTjRw== X-Nifty-SrcIP: [209.85.213.50] Received: by mail-vk0-f50.google.com with SMTP id g83-v6so11008415vkc.6; Tue, 22 May 2018 07:23:52 -0700 (PDT) X-Gm-Message-State: ALKqPwcGAFsosW5ZDQxkd2j+20IIO69Urz2ri9Mwqczsjj0C+mcDubCJ mXWGit+3Lko/jUqEk6UWK8jOTChcE0xPNa65Vno= X-Received: by 2002:a1f:cc85:: with SMTP id c127-v6mr6585881vkg.166.1526999031345; Tue, 22 May 2018 07:23:51 -0700 (PDT) MIME-Version: 1.0 Received: by 2002:ab0:55d8:0:0:0:0:0 with HTTP; Tue, 22 May 2018 07:23:10 -0700 (PDT) In-Reply-To: <1526885939-1741-1-git-send-email-Julia.Lawall@lip6.fr> References: <1526885939-1741-1-git-send-email-Julia.Lawall@lip6.fr> From: Masahiro Yamada Date: Tue, 22 May 2018 23:23:10 +0900 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH] coccinelle: deref_null: improve performance To: Julia Lawall Cc: kernel-janitors@vger.kernel.org, Gilles Muller , Nicolas Palix , Michal Marek , cocci@systeme.lip6.fr, Linux Kernel Mailing List Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 2018-05-21 15:58 GMT+09:00 Julia Lawall : > Move rules looking for some special cases of safe dereferences before > the collection of NULL-tested values. The special cases are fairly > rare, but somewhat costly to find, because isomorphisms create many > variants of the rules. There is thus no need to search for them over > and over for each NULL tested expression. Collecting them just once > is sufficient and more efficient. > > Signed-off-by: Julia Lawall > > --- > scripts/coccinelle/null/deref_null.cocci | 40 +++++++++++++++---------------- > 1 file changed, 20 insertions(+), 20 deletions(-) Applied to linux-kbuild. Thanks! > diff --git a/scripts/coccinelle/null/deref_null.cocci b/scripts/coccinelle/null/deref_null.cocci > index b16ccb7..cbc6184 100644 > --- a/scripts/coccinelle/null/deref_null.cocci > +++ b/scripts/coccinelle/null/deref_null.cocci > @@ -14,18 +14,10 @@ virtual context > virtual org > virtual report > > -@ifm@ > -expression *E; > -statement S1,S2; > -position p1; > -@@ > - > -if@p1 ((E == NULL && ...) || ...) S1 else S2 > - > // The following two rules are separate, because both can match a single > // expression in different ways > @pr1 expression@ > -expression *ifm.E; > +expression E; > identifier f; > position p1; > @@ > @@ -33,7 +25,7 @@ position p1; > (E != NULL && ...) ? <+...E->f@p1...+> : ... > > @pr2 expression@ > -expression *ifm.E; > +expression E; > identifier f; > position p2; > @@ > @@ -46,6 +38,14 @@ position p2; > sizeof(<+...E->f@p2...+>) > ) > > +@ifm@ > +expression *E; > +statement S1,S2; > +position p1; > +@@ > + > +if@p1 ((E == NULL && ...) || ...) S1 else S2 > + > // For org and report modes > > @r depends on !context && (org || report) exists@ > @@ -212,16 +212,8 @@ else S3 > // The following three rules are duplicates of ifm, pr1 and pr2 respectively. > // It is need because the previous rule as already made a "change". > > -@ifm1 depends on context && !org && !report@ > -expression *E; > -statement S1,S2; > -position p1; > -@@ > - > -if@p1 ((E == NULL && ...) || ...) S1 else S2 > - > @pr11 depends on context && !org && !report expression@ > -expression *ifm1.E; > +expression E; > identifier f; > position p1; > @@ > @@ -229,7 +221,7 @@ position p1; > (E != NULL && ...) ? <+...E->f@p1...+> : ... > > @pr12 depends on context && !org && !report expression@ > -expression *ifm1.E; > +expression E; > identifier f; > position p2; > @@ > @@ -242,6 +234,14 @@ position p2; > sizeof(<+...E->f@p2...+>) > ) > > +@ifm1 depends on context && !org && !report@ > +expression *E; > +statement S1,S2; > +position p1; > +@@ > + > +if@p1 ((E == NULL && ...) || ...) S1 else S2 > + > @depends on context && !org && !report exists@ > expression subE <= ifm1.E; > expression *ifm1.E; > -- Best Regards Masahiro Yamada