Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751767AbdCIUP3 (ORCPT ); Thu, 9 Mar 2017 15:15:29 -0500 Received: from mail3-relais-sop.national.inria.fr ([192.134.164.104]:62193 "EHLO mail3-relais-sop.national.inria.fr" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751300AbdCIUP2 (ORCPT ); Thu, 9 Mar 2017 15:15:28 -0500 X-IronPort-AV: E=Sophos;i="5.36,137,1486422000"; d="scan'208";a="216212364" Date: Thu, 9 Mar 2017 21:15:21 +0100 (CET) From: Julia Lawall X-X-Sender: jll@hadrien To: Julia Cartwright cc: Gilles Muller , Nicolas Palix , Michal Marek , linux-kernel@vger.kernel.org, Thomas Gleixner , Sebastian Andrzej Siewior , Linus Walleij , cocci@systeme.lip6.fr Subject: Re: [PATCH 01/19] Coccinelle: locks: identify callers of spin_lock{,_irq,_irqsave}() in irqchip implementations In-Reply-To: <23190c912611c5d1d36529488e46706cdc3e4d87.1489015238.git.julia@ni.com> Message-ID: References: <23190c912611c5d1d36529488e46706cdc3e4d87.1489015238.git.julia@ni.com> User-Agent: Alpine 2.20 (DEB 67 2015-01-07) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1525 Lines: 63 > +@match2 depends on match@ > +identifier match.__irq_mask; > +identifier data; > +identifier x; > +identifier l; > +type T; > +position j0; > +expression flags; > +@@ > + static void __irq_mask(struct irq_data *data) > + { > + ... > + T *x; > + ... > +( > + spin_lock_irqsave(&x->l@j0, flags); > +| > + spin_lock_irq(&x->l@j0); > +| > + spin_lock(&x->l@j0); > +) > + ... > + } I guess that here you want a match if there is a lock anywhere in the function? Currently, the rule requires that the lock appear on every control-flow path. If you put exists after depends on match in the rule header, it will match if there exists a control-flow patch that contains a local call. Also, ... matches the shortest path between the pattern before the ... and the pattern after. Thus, x would have to be the first variable in the function of pointer type. To eliminate this constraint, put when any on each of the ...s. This will additionally allow more than one lock call in the function. All in all, I would suggest the following for this rule: @match2 depends on match exists@ identifier match.__irq_mask; identifier data; identifier x; identifier l; type T; position j0; expression flags; @@ static void __irq_mask(struct irq_data *data) { ... when any T *x; ... when any ( spin_lock_irqsave(&x->l@j0, flags); | spin_lock_irq(&x->l@j0); | spin_lock(&x->l@j0); ) ... when any } julia