Received: by 2002:a25:f815:0:0:0:0:0 with SMTP id u21csp1144595ybd; Sun, 23 Jun 2019 01:03:07 -0700 (PDT) X-Google-Smtp-Source: APXvYqxwVK+w0/xG5OfPXMcOqg76LcjEUmScQfaIN7mYbbZ0a8DCVtMestoFaDxb09zQ41K7X95C X-Received: by 2002:a63:6b0a:: with SMTP id g10mr13365006pgc.295.1561276987457; Sun, 23 Jun 2019 01:03:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1561276987; cv=none; d=google.com; s=arc-20160816; b=ZKqQBxNxfrvAYjwldhyQyM/XHP+mFlP66y5AkrkmyJ+gLIE+DrZnNvOWh3s+OQxvl1 9dEeyirgxTYjC+xwCl5HD7wXmR3UV1NS8WmjSacG0zaQEo+8fR9MoFfSjvgi8hspzTkU V+QjPS7pLkr3SHeT31d3Hpv9r47/+s/bY3fQG1VZPYFHTeeImlXkej9+J3uZesGQYtIV +89Kg9/K2nhcjkXUIG7BgjAy82nlSWVF8/24hc4YBljF2HtKLUMt4yC6lYRcR6W9uJfP L1tcnFVj7rxyaRtNEZYrxkvB7L5vOYgL0ew0zHI3xinMcJPqH6fhEg0zy+0t5x/fI7uS LfRQ== 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=jznGr2mPiS9OCpx7c85xS82ahDBzgpIHo9m5yFOoXqI=; b=hV1twSpdASxH8PIbHdVkDkgZEhT+DCo9dsc47gK8H/0nRaijD5U+0GyLjoDTGhYMDG 6vVhLT1W9HQ3F9B5LRnZAWw7GHmr7Uvefc+gk0MsA2+SxzLWu78OxWfB7SvaL63CHY0F DVupOnJc6mQDBj5PEHVCgcy0jcsjXdMCTniHiq0m+c/ZlKRONI6sm13hHo38c07QQ4Kd P4xFGE3msIVQSXycZIGskbmyTG9dsXHa3hjeitRAFwlYgWKN9Jzu6b4a9qBN9uNLbY9D WWDlO9rnlTAh8by0e1j/zH5JB/5kLE2JMkgoYE09Rgw0cYzUAP72aUisxtf1bamfO01n sVrQ== 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 p10si6209381pgj.534.2019.06.23.01.02.52; Sun, 23 Jun 2019 01:03:07 -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 S1726485AbfFWIBz (ORCPT + 99 others); Sun, 23 Jun 2019 04:01:55 -0400 Received: from mail2-relais-roc.national.inria.fr ([192.134.164.83]:56663 "EHLO mail2-relais-roc.national.inria.fr" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725268AbfFWIBz (ORCPT ); Sun, 23 Jun 2019 04:01:55 -0400 X-IronPort-AV: E=Sophos;i="5.63,407,1557180000"; d="scan'208";a="388663729" Received: from abo-12-105-68.mrs.modulonet.fr (HELO hadrien) ([85.68.105.12]) by mail2-relais-roc.national.inria.fr with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 23 Jun 2019 10:01:53 +0200 Date: Sun, 23 Jun 2019 10:01:52 +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. > > Cc: Julia Lawall > Cc: Logan Gunthorpe > Cc: Sebastian Andrzej Siewior > Cc: Bjorn Helgaas > Signed-off-by: Kirill Smelkov Acked-by: Julia Lawall > --- > 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 >