Received: by 2002:a25:f815:0:0:0:0:0 with SMTP id u21csp1128535ybd; Sun, 23 Jun 2019 00:37:06 -0700 (PDT) X-Google-Smtp-Source: APXvYqy2uglYVuVDTiiYY3tGWtYtv9SZkEM4WJcqskiWNhd1V6JDcmt+qpnzMqBtVwHhTXBTf8q8 X-Received: by 2002:a17:90a:b30a:: with SMTP id d10mr17490634pjr.8.1561275426541; Sun, 23 Jun 2019 00:37:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1561275426; cv=none; d=google.com; s=arc-20160816; b=kr90Qi1vKY5KyLNIbvZaiJn+7YR7kWvwNzyp7Gvr6qrgkie4j7rRxcRZxRKTvWfYIl yqk4A0vU7/hUj+gxVaa4vMO/pf3Ad05ck3CPRTqgNtyzAGspJDOzw1zvW2fpIMVZk/jB vAU1aTD/bwp721phOgMy3dblQFiKvnvvH5y/f000w4I/yYcB16TSq2o+RAN43KeQhs9l 63zOSTELt/d/8KqVUDiVffNfLQtD3QkMz+5Xpi/aJXpj9/RiOfZ0Jl2Y9+L8xhMcjDWG 9hHC4rKttD0sjDvstLFB2QqvCkQiw0xF7EavR+JqWZi4IRQFkrDDOnqnGlXYIr711hDX Tq3Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :message-id:in-reply-to:subject:cc:to:from:date; bh=rZ3DdhKYjoHHn6Mzk9kwQ1jFL4aRTbS2haSDq72cswM=; b=Mhe/d/TUjrAluuESMAa4L7EQzeAQiL+rckNvVTtNBuHub6dTAK57IukIEwlakgIG5R BtxA2+X4Bmner2ESjc8PPE5gZ/3Jrpo1t/yhCZiv7wVt24YkTb6CS4ZhmJRnFroQRO4J hMXspbyxOQs3dwbpOB1tmf4RbHvlyvqdf6EMFi3OhaYAHxwSuvA9G9Df4BU6eo1U7owY 2y8JCoRoanp+UvGhaMyRzKAj/hUCkdeV07bOo0IR6rFBM86vMbUQKc0pNExNKBYWg0Nz eV7dXLqVVL9JPhS3JlZygzsep8iB8bFbJ8aslR2DhaPEOBvrlKvICwBzXeJZkzT+9RlQ RLig== ARC-Authentication-Results: i=1; mx.google.com; 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 c21si6739937plo.308.2019.06.23.00.36.21; Sun, 23 Jun 2019 00:37:06 -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; 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 S1726417AbfFWHfU (ORCPT + 99 others); Sun, 23 Jun 2019 03:35:20 -0400 Received: from mail3-relais-sop.national.inria.fr ([192.134.164.104]:57991 "EHLO mail3-relais-sop.national.inria.fr" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726362AbfFWHfU (ORCPT ); Sun, 23 Jun 2019 03:35:20 -0400 X-IronPort-AV: E=Sophos;i="5.63,407,1557180000"; d="scan'208";a="311103180" Received: from abo-12-105-68.mrs.modulonet.fr (HELO hadrien) ([85.68.105.12]) by mail3-relais-sop.national.inria.fr with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 23 Jun 2019 09:35:18 +0200 Date: Sun, 23 Jun 2019 09:35:17 +0200 (CEST) From: Julia Lawall X-X-Sender: jll@hadrien To: Kirill Smelkov cc: cocci@systeme.lip6.fr, linux-kernel@vger.kernel.org, Julia Lawall , Logan Gunthorpe , Sebastian Andrzej Siewior , Bjorn Helgaas Subject: Re: [PATCH 1/2] coccinelle: api/stream_open: treat all wait_.*() calls as blocking In-Reply-To: <20190623072838.31234-1-kirr@nexedi.com> Message-ID: References: <20190623072838.31234-1-kirr@nexedi.com> User-Agent: Alpine 2.21 (DEB 202 2017-01-01) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sun, 23 Jun 2019, Kirill Smelkov wrote: > Previously steam_open.cocci was treating only wait_event_.* - e.g. > wait_event_interruptible - as a blocking operation. However e.g. > wait_for_completion_interruptible is also blocking, and so from this > point of view it would be more logical to treat all wait_.* as a > blocking point. > > The logic of this change actually came up for real when > drivers/pci/switch/switchtec.c changed from using > wait_event_interruptible to wait_for_completion_interruptible: > > https://lore.kernel.org/linux-pci/20190413170056.GA11293@deco.navytux.spb.ru/ > https://lore.kernel.org/linux-pci/20190415145456.GA15280@deco.navytux.spb.ru/ > https://lore.kernel.org/linux-pci/20190415154102.GB17661@deco.navytux.spb.ru/ > > For a driver that uses nonseekable_open with read/write having stream > semantic and read also calling e.g. wait_for_completion_interruptible, > running stream_open.cocci before this patch would produce: > > WARNING: _fops: .read() and .write() have stream semantic; safe to change nonseekable_open -> stream_open. > > while after this patch it will report: > > ERROR: _fops: .read() can deadlock .write(); change nonseekable_open -> stream_open to fix. Are you really sure that every word that starts with wait_ in the Linux kernel has the property you want? How many of them are there? Would it be reasonable to put the names in the semantic patch explicitly? julia > > Cc: Julia Lawall > Cc: Logan Gunthorpe > Cc: Sebastian Andrzej Siewior > Cc: Bjorn Helgaas > Signed-off-by: Kirill Smelkov > --- > scripts/coccinelle/api/stream_open.cocci | 8 ++++---- > 1 file changed, 4 insertions(+), 4 deletions(-) > > diff --git a/scripts/coccinelle/api/stream_open.cocci b/scripts/coccinelle/api/stream_open.cocci > index 350145da7669..12ce18fa6b74 100644 > --- a/scripts/coccinelle/api/stream_open.cocci > +++ b/scripts/coccinelle/api/stream_open.cocci > @@ -35,11 +35,11 @@ type loff_t; > // a function that blocks > @ blocks @ > identifier block_f; > -identifier wait_event =~ "^wait_event_.*"; > +identifier wait =~ "^wait_.*"; > @@ > block_f(...) { > ... when exists > - wait_event(...) > + wait(...) > ... when exists > } > > @@ -49,12 +49,12 @@ identifier wait_event =~ "^wait_event_.*"; > // XXX currently reader_blocks supports only direct and 1-level indirect cases. > @ reader_blocks_direct @ > identifier stream_reader.readstream; > -identifier wait_event =~ "^wait_event_.*"; > +identifier wait =~ "^wait_.*"; > @@ > readstream(...) > { > ... when exists > - wait_event(...) > + wait(...) > ... when exists > } > > -- > 2.20.1 >